- if (type == SCT_ENLIST)
- goto is_enlist;
- if (pp->p_nrndx != 0) {
- unit_work++;
- resource = ((s_char *)§) + pp->p_nrndx;
- p_e = (*resource * p_e) / 100.0;
- }
- /*
- * production effic.
- */
- if (pp->p_nlndx >= 0) {
- level_p_e = natp->nat_level[pp->p_nlndx] - pp->p_nlmin;
- if (level_p_e < 0.0) {
- level_p_e = 0.0;
- }
- level_p_e = level_p_e / (level_p_e + pp->p_nllag);
- } else {
- level_p_e = 1.0;
- }
- /*
- * raw material limit
- */
- used = 999;
- amount = pp->p_vamt;
- endcomp = pp->p_vtype + pp->p_nv;
- for (comp = pp->p_vtype; comp < endcomp; comp++, amount++) {
- if (*amount == 0)
- continue;
- used = min(used, sect.sct_item[(int)*comp] / *amount);
- unit_work += *amount;
- }
- if (unit_work == 0)
- unit_work = 1;
- /*
- * is production limited by resources or
- * workforce?
- */
- max = (int)((work * p_e / (double)unit_work) + 0.5);
- act = min(used, max);
- /*
- * some things are easier to make.. food,
- * pet, etc.
- */
- act = (int)(((double)pp->p_effic * 0.01 * (double)act) + 0.5);
- max = (int)(((double)pp->p_effic * 0.01 * (double)max) + 0.5);
-
- real = (double)act * level_p_e;
- maxr = (double)max * level_p_e;
-
- if (vtype != 0) {
- if (real < 0.0)
- real = 0.0;
- /* production backlog? */
- there = min(ITEM_MAX, sect.sct_item[vtype]);
- act = min(act, ITEM_MAX - there);
- max = min(max, ITEM_MAX - there);
- }
-
- if (level_p_e != 0) {
- take = real / level_p_e;
- mtake = maxr / level_p_e;
- } else
- mtake = take = 0.0;
-
- if (take > 999.0)
- take = 999.0;
- if (mtake > 999.0)
- mtake = 999.0;
-
- take = (double)take / ((double)pp->p_effic * 0.01);
- mtake = (double)mtake / ((double)pp->p_effic * 0.01);
-
- cost = (int)(take * (double)pp->p_cost);
- if (opt_TECH_POP) {
- if (pp->p_level == NAT_TLEV) {
- totpop = count_pop(sect.sct_own);
- if (totpop > 50000)
- cost = (int)((double)cost * (double)totpop / 50000.0);
- }
- }