register int i;
register int pop = 0;
struct sctstr *sp;
- int vec[I_MAX+1];
+ int vec[I_MAX + 1];
for (i = 0; NULL != (sp = getsectid(i)); i++) {
- if (sp->sct_own != n)
- continue;
- if (sp->sct_oldown != n)
- continue;
- if (getvec(VT_ITEM, vec, (s_char *)sp, EF_SECTOR) <= 0)
- continue;
- pop += vec[I_CIVIL];
+ if (sp->sct_own != n)
+ continue;
+ if (sp->sct_oldown != n)
+ continue;
+ if (getvec(VT_ITEM, vec, (s_char *)sp, EF_SECTOR) <= 0)
+ continue;
+ pop += vec[I_CIVIL];
}
return pop;
}
int
prod(void)
{
- extern double obrate, uwbrate;
- extern int etu_per_update;
- struct natstr *natp;
- struct sctstr sect;
- struct nstr_sect nstr;
- struct pchrstr *pp;
- double effic;
- double maxr; /* floating version of max */
- double prodeff;
- double real; /* floating pt version of act */
- double work;
- int totpop;
- int act; /* actual production */
- int cost;
- int i;
- int max; /* production w/infinate materials */
- double maxtake;
- int nsect;
- double take;
- double mtake;
- int there;
- int totcomp; /* sum of component amounts */
- int used; /* production w/infinite workforce */
- int wforce;
- int it;
- u_short *amount; /* amount for component pointer */
- u_char *comp; /* component pointer */
- u_char *endcomp;
- u_char vtype;
- s_char *resource;
- int c;
- s_char maxc[3][10];
- s_char use[3][10];
- int items[I_MAX+1];
- int vec[I_MAX+1], lcms, hcms;
- int civs=0;
- int uws=0;
- int bwork;
- int twork;
- int type;
- int eff;
- int maxpop;
- u_char otype;
-
+ extern double obrate, uwbrate;
+ extern int etu_per_update;
+ struct natstr *natp;
+ struct sctstr sect;
+ struct nstr_sect nstr;
+ struct pchrstr *pp;
+ double effic;
+ double maxr; /* floating version of max */
+ double prodeff;
+ double real; /* floating pt version of act */
+ double work;
+ int totpop;
+ int act; /* actual production */
+ int cost;
+ int i;
+ int max; /* production w/infinate materials */
+ double maxtake;
+ int nsect;
+ double take;
+ double mtake;
+ int there;
+ int totcomp; /* sum of component amounts */
+ int used; /* production w/infinite workforce */
+ int wforce;
+ int it;
+ u_short *amount; /* amount for component pointer */
+ u_char *comp; /* component pointer */
+ u_char *endcomp;
+ u_char vtype;
+ s_char *resource;
+ int c;
+ s_char maxc[3][10];
+ s_char use[3][10];
+ int items[I_MAX + 1];
+ int vec[I_MAX + 1], lcms, hcms;
+ int civs = 0;
+ int uws = 0;
+ int bwork;
+ int twork;
+ int type;
+ int eff;
+ int maxpop;
+ u_char otype;
+
if (!snxtsct(&nstr, player->argp[1]))
return RET_SYN;
- player->simulation = 1;
- prdate();
+ player->simulation = 1;
+ prdate();
nsect = 0;
while (nxtsct(&nstr, §)) {
if (!player->owner)
continue;
getvec(VT_ITEM, items, (s_char *)§, EF_SECTOR);
-
- civs = min(9999, (int) ((obrate * (double) etu_per_update + 1.0)
- * (double) items[I_CIVIL]));
- uws = min(9999, (int) ((uwbrate * (double) etu_per_update + 1.0)
- * (double) items[I_UW]));
+
+ civs = min(9999, (int)((obrate * (double)etu_per_update + 1.0)
+ * (double)items[I_CIVIL]));
+ uws = min(9999, (int)((uwbrate * (double)etu_per_update + 1.0)
+ * (double)items[I_UW]));
if (opt_RES_POP) {
natp = getnatp(sect.sct_own);
maxpop = max_pop((float)natp->nat_level[NAT_RLEV], §);
civs = min(civs, maxpop);
uws = min(uws, maxpop);
- } else { /* now RES_POP */
- civs = min(999,civs);
- uws = min(999,uws);
- } /* end RES_POP */
-
+ } else { /* now RES_POP */
+ civs = min(999, civs);
+ uws = min(999, uws);
+ } /* end RES_POP */
+
/* This isn't quite right, since research might rise/fall */
/* during the update, but it's the best we can really do */
wforce = (int)(((double)civs * (double)sect.sct_work)
- / 100.0 + (double)uws + (double)items[I_MILIT] * 2.0 / 5.0);
- work = (double)etu_per_update * (double)wforce / 100.0;
+ / 100.0 + (double)uws +
+ (double)items[I_MILIT] * 2.0 / 5.0);
+ work = (double)etu_per_update *(double)wforce / 100.0;
bwork = (int)((double)work / 2.0);
-
+
if (sect.sct_off)
continue;
type = sect.sct_type;
eff = sect.sct_effic;
- if(sect.sct_newtype != type) {
- twork = (eff+3)/4;
- if(twork > bwork) {
+ if (sect.sct_newtype != type) {
+ twork = (eff + 3) / 4;
+ if (twork > bwork) {
twork = bwork;
}
bwork -= twork;
- eff -= twork*4;
+ eff -= twork * 4;
otype = type;
- if(eff <= 0) {
+ if (eff <= 0) {
type = sect.sct_newtype;
eff = 0;
}
dchr[type].d_pkg != UPKG) {
if (opt_RES_POP) {
natp = getnatp(sect.sct_own);
- civs = min(civs, max_pop(natp->nat_level[NAT_RLEV],0));
- uws = min(uws, max_pop(natp->nat_level[NAT_RLEV], 0));
+ civs =
+ min(civs,
+ max_pop(natp->nat_level[NAT_RLEV], 0));
+ uws =
+ min(uws,
+ max_pop(natp->nat_level[NAT_RLEV], 0));
} else {
- civs = min(9999,civs);
- uws = min(9999,uws);
+ civs = min(9999, civs);
+ uws = min(9999, uws);
}
- wforce = (int)((civs * sect.sct_work) / 100.0 + uws + items[I_MILIT] * 2 / 5.0);
+ wforce =
+ (int)((civs * sect.sct_work) / 100.0 + uws +
+ items[I_MILIT] * 2 / 5.0);
work = etu_per_update * wforce / 100.0;
- bwork = min((int)(work/2), bwork);
+ bwork = min((int)(work / 2), bwork);
}
}
twork = 100 - eff;
- if(twork > bwork) {
+ if (twork > bwork) {
twork = bwork;
}
getvec(VT_ITEM, vec, (s_char *)§, EF_SECTOR);
- if (dchr[type].d_lcms>0){
+ if (dchr[type].d_lcms > 0) {
lcms = vec[I_LCM];
lcms /= dchr[type].d_lcms;
if (twork > lcms)
twork = lcms;
}
- if (dchr[type].d_hcms>0){
+ if (dchr[type].d_hcms > 0) {
hcms = vec[I_HCM];
hcms /= dchr[type].d_hcms;
if (twork > hcms)
bwork -= twork;
eff += twork;
}
- work = work/2 + bwork;
+ work = work / 2 + bwork;
if (eff < 60 || (type != SCT_ENLIST && eff < 61))
continue;
-
- effic = eff/100.0;
+
+ effic = eff / 100.0;
if (effic > 1.0)
effic = 1.0;
-
+
if (dchr[type].d_prd == 0 && type != SCT_ENLIST)
continue;
totcomp = 0;
goto is_enlist;
if (pp->p_nrndx != 0) {
totcomp++;
- resource = ((s_char *) §) + pp->p_nrndx;
+ resource = ((s_char *)§) + pp->p_nrndx;
effic = (*resource * effic) / 100.0;
if (pp->p_nrdep > 0) {
maxtake = (*resource * 100.0) / pp->p_nrdep;
* is production limited by resources or
* workforce?
*/
- max = (int) (work * effic / (double) totcomp) + 0.5;
+ max = (int)(work * effic / (double)totcomp) + 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 * (double)prodeff;
- maxr = (double)max * (double)prodeff;
-
+ 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 *(double)prodeff;
+ maxr = (double)max *(double)prodeff;
+
if (vtype != 0) {
if (real < 0.0)
real = 0.0;
/* production backlog? */
- if ((there = getvar((int)vtype, (s_char *)§, EF_SECTOR)) >= 9999) {
+ if ((there =
+ getvar((int)vtype, (s_char *)§, EF_SECTOR)) >= 9999) {
there = 9999;
}
act = min(act, (9999 - there));
max = min(max, (9999 - there));
}
-
+
if (prodeff != 0) {
take = real / prodeff;
mtake = maxr / prodeff;
} 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) {
cost = (int)((double)cost * (double)totpop / 50000.0);
}
}
-
+
comp = pp->p_vtype;
amount = pp->p_vamt;
i = 0;
while (comp < endcomp) {
- it = unitem((int) *comp);
+ it = unitem((int)*comp);
if (it > 0 && it <= I_MAX && ichr[it].i_name != 0)
c = ichr[it].i_name[0];
else
c = ' ';
- (void) sprintf(use[i], " %3d%c", (int)((take * (double)(*amount)) + 0.5), c);
- (void) sprintf(maxc[i], " %3d%c", (int)((mtake * (double)(*amount)) + 0.5), c);
+ (void)sprintf(use[i], " %3d%c",
+ (int)((take * (double)(*amount)) + 0.5), c);
+ (void)sprintf(maxc[i], " %3d%c",
+ (int)((mtake * (double)(*amount)) + 0.5), c);
++comp;
++amount;
++i;
strcpy(maxc[i], " ");
++i;
}
-
- is_enlist:
-
+
+ is_enlist:
+
if (nsect++ == 0) {
pr("PRODUCTION SIMULATION\n");
pr(" sect des eff wkfc will make- p.e. cost use1 use2 use3 max1 max2 max3 max\n");
}
-
+
prxy("%4d,%-4d", nstr.x, nstr.y, player->cnum);
pr(" %c", dchr[type].d_mnem);
pr(" %3.0f%%", effic * 100.0);
-
+
pr(" %4d", wforce);
if (vtype != 0) {
pr(" %4d", (int)(real + 0.5));
break;
}
} else {
- int maxmil;
- int enlisted;
- int civs;
-
- civs = min(999, (int) ((obrate * (double) etu_per_update + 1.0)
- * (double) items[I_CIVIL]));
+ int maxmil;
+ int enlisted;
+ int civs;
+
+ civs = min(999, (int)((obrate * (double)etu_per_update + 1.0)
+ * (double)items[I_CIVIL]));
natp = getnatp(sect.sct_own);
maxpop = max_pop((float)natp->nat_level[NAT_RLEV], §);
civs = min(civs, maxpop);
}
if (enlisted < 0)
enlisted = 0;
- if (natp->nat_priorities[type] == 0){
+ if (natp->nat_priorities[type] == 0) {
maxmil = 0;
}
pr(" %4d mil 1.00 $%-5d%3dc",
enlisted, maxmil, maxmil);
continue;
}
-
+
pr(" %-5.5s", pp->p_sname);
prodeff = prodeff * (double)pp->p_effic * 0.01;
pr(" %.2f", prodeff);
for (i = 0; i < 3; i++) {
pr(maxc[i]);
}
- if (natp->nat_priorities[type] == 0){
+ if (natp->nat_priorities[type] == 0) {
max = 0;
maxr = 0;
}
if (vtype != 0 || pp->p_level == NAT_ELEV
|| pp->p_level == NAT_HLEV)
- pr(" %4d\n", min(999,(int)(max * prodeff + 0.05)));
+ pr(" %4d\n", min(999, (int)(max * prodeff + 0.05)));
else
pr(" %1.2f\n", maxr);
}
pr("%d sector%s\n", nsect, splur(nsect));
return RET_OK;
}
-