(prod): Simplify printing of materials used. Don't assume amount fits

into eight characters and item mnemo can't be '%'.
This commit is contained in:
Markus Armbruster 2006-03-26 12:37:22 +00:00
parent aee94ca077
commit 7b4a164d0a

View file

@ -79,7 +79,7 @@ prod(void)
int totpop; int totpop;
int act; /* actual production */ int act; /* actual production */
int cost; int cost;
int i, j; int i;
int max; /* production w/infinite materials */ int max; /* production w/infinite materials */
int nsect; int nsect;
double take; double take;
@ -90,8 +90,8 @@ prod(void)
i_type it; i_type it;
i_type vtype; i_type vtype;
unsigned char *resource; unsigned char *resource;
s_char maxc[MAXPRCON][10]; char cmnem[MAXPRCON];
s_char use[MAXPRCON][10]; int cuse[MAXPRCON], cmax[MAXPRCON];
int lcms, hcms; int lcms, hcms;
int civs = 0; int civs = 0;
int uws = 0; int uws = 0;
@ -210,14 +210,14 @@ prod(void)
* raw material limit * raw material limit
*/ */
used = 9999; used = 9999;
for (j = 0; j < MAXPRCON; ++j) { for (i = 0; i < MAXPRCON; ++i) {
it = pp->p_ctype[j]; it = pp->p_ctype[i];
if (!pp->p_camt[j]) if (!pp->p_camt[i])
continue; continue;
if (CANT_HAPPEN(it <= I_NONE || I_MAX < it)) if (CANT_HAPPEN(it <= I_NONE || I_MAX < it))
continue; continue;
used = MIN(used, sect.sct_item[it] / pp->p_camt[j]); used = MIN(used, sect.sct_item[it] / pp->p_camt[i]);
unit_work += pp->p_camt[j]; unit_work += pp->p_camt[i];
} }
if (unit_work == 0) if (unit_work == 0)
unit_work = 1; unit_work = 1;
@ -258,25 +258,16 @@ prod(void)
} }
} }
i = 0; for (i = 0; i < MAXPRCON; ++i) {
for (j = 0; j < MAXPRCON; ++j) { cmnem[i] = cuse[i] = cmax[i] = 0;
it = pp->p_ctype[j]; if (!pp->p_camt[i])
if (it > I_NONE && it <= I_MAX && ichr[it].i_mnem != 0) { continue;
if (CANT_HAPPEN(i >= 3)) it = pp->p_ctype[i];
break; if (CANT_HAPPEN(it <= I_NONE || I_MAX < it))
sprintf(use[i], "%4d%c", continue;
(int)((take * (double)pp->p_camt[j]) + 0.5), cmnem[i] = ichr[it].i_mnem;
ichr[it].i_mnem); cuse[i] = (int)(take * pp->p_camt[i] + 0.5);
sprintf(maxc[i], "%4d%c", cmax[i] = (int)(mtake * pp->p_camt[i] + 0.5);
(int)((mtake * (double)pp->p_camt[j]) + 0.5),
ichr[it].i_mnem);
++i;
}
}
while (i < 3) {
strcpy(use[i], " ");
strcpy(maxc[i], " ");
++i;
} }
is_enlist: is_enlist:
@ -343,11 +334,17 @@ prod(void)
pr(" %.2f", prodeff); pr(" %.2f", prodeff);
pr(" $%-5d", cost); pr(" $%-5d", cost);
for (i = 0; i < 3; i++) { for (i = 0; i < 3; i++) {
pr(use[i]); if (i < MAXPRCON && cmnem[i])
pr("%4d%c", cuse[i], cmnem[i]);
else
pr(" ");
} }
pr(" "); pr(" ");
for (i = 0; i < 3; i++) { for (i = 0; i < 3; i++) {
pr(maxc[i]); if (i < MAXPRCON && cmnem[i])
pr("%4d%c", cmax[i], cmnem[i]);
else
pr(" ");
} }
if (natp->nat_priorities[type] == 0) { if (natp->nat_priorities[type] == 0) {
max = 0; max = 0;