int totpop;
int act; /* actual production */
int cost;
- int i;
- int max; /* production w/infinate materials */
+ int i, j;
+ int max; /* production w/infinite materials */
int nsect;
double take;
double mtake;
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];
+ s_char maxc[MAXPRCON][10];
+ s_char use[MAXPRCON][10];
int lcms, hcms;
int civs = 0;
int uws = 0;
* raw material limit
*/
used = 9999;
- amount = pp->p_vamt;
- endcomp = pp->p_vtype + pp->p_nv;
- for (comp = pp->p_vtype; comp < endcomp; comp++, amount++) {
- if (*amount == 0)
+ for (j = 0; j < MAXPRCON; ++j) {
+ it = pp->p_ctype[j];
+ if (!pp->p_camt[j])
continue;
- used = min(used, sect.sct_item[(int)*comp] / *amount);
- unit_work += *amount;
+ if (CANT_HAPPEN(it <= I_NONE || I_MAX < it))
+ continue;
+ used = min(used, sect.sct_item[it] / pp->p_camt[j]);
+ unit_work += pp->p_camt[j];
}
if (unit_work == 0)
unit_work = 1;
}
}
- comp = pp->p_vtype;
- amount = pp->p_vamt;
i = 0;
- while (comp < endcomp) {
- 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);
- ++comp;
- ++amount;
- ++i;
+ for (j = 0; j < MAXPRCON; ++j) {
+ it = pp->p_ctype[j];
+ if (it > I_NONE && it <= I_MAX && ichr[it].i_name != 0) {
+ if (CANT_HAPPEN(i >= 3))
+ break;
+ sprintf(use[i], " %3d%c",
+ (int)((take * (double)pp->p_camt[j]) + 0.5),
+ ichr[it].i_name[0]);
+ sprintf(maxc[i], " %3d%c",
+ (int)((mtake * (double)pp->p_camt[j]) + 0.5),
+ ichr[it].i_name[0]);
+ ++i;
+ }
}
while (i < 3) {
strcpy(use[i], " ");
struct pchrstr pchr[] = {
/* level cost nrndx nrdep nlndx nlmin nllag effic sname name */
- {0, {0}, {0},
+ {{I_NONE, I_NONE, I_NONE}, {0, 0, 0},
0, 0, 0, 0, 0, 0, 0, 0, 0,
"unused", "",},
- {2, {V_LCM, V_HCM}, {2, 1},
+ {{I_LCM, I_HCM, I_NONE}, {2, 1, 0},
V_SHELL, -1, 3, 0, 0, NAT_TLEV, 20, 10, 100,
"shells", "shells",},
- {3, {V_OIL, V_LCM, V_HCM}, {1, 5, 10},
+ {{I_OIL, I_LCM, I_HCM}, {1, 5, 10},
V_GUN, -1, 30, 0, 0, NAT_TLEV, 20, 10, 100,
"guns", "guns",},
- {1, {V_OIL}, {1},
+ {{I_OIL, I_NONE, I_NONE}, {1, 0, 0},
V_PETROL, -1, 1, 0, 0, NAT_TLEV, 20, 10, 1000,
"petrol", "petrol",},
- {0, {0}, {0},
+ {{I_NONE, I_NONE, I_NONE}, {0, 0, 0},
V_IRON, -1, 0, offsetof(struct sctstr, sct_min), 0, -1, 0, 0, 100,
"iron ore", "iron",},
- {0, {0}, {0},
+ {{I_NONE, I_NONE, I_NONE}, {0, 0, 0},
V_DUST, -1, 0, offsetof(struct sctstr, sct_gmin), 20, -1, 0, 0, 100,
"gold dust", "dust",},
- {1, {V_DUST}, {5},
+ {{I_DUST, I_NONE, I_NONE}, {5, 0, 0},
V_BAR, -1, 10, 0, 0, -1, 0, 0, 100,
"gold bars", "bars",},
- {0, {0}, {0},
+ {{I_NONE, I_NONE, I_NONE}, {0, 0, 0},
V_FOOD, -1, 0, offsetof(struct sctstr, sct_fertil), 0, NAT_TLEV, -10, 10, 900,
"food", "food",},
- {0, {0}, {0},
+ {{I_NONE, I_NONE, I_NONE}, {0, 0, 0},
V_OIL, -1, 0, offsetof(struct sctstr, sct_oil), 10, NAT_TLEV, -10, 10, 100,
"oil", "oil",},
- {1, {V_IRON}, {1},
+ {{I_IRON, I_NONE, I_NONE}, {1, 0, 0},
V_LCM, -1, 0, 0, 0, NAT_TLEV, -10, 10, 100,
"light construction materials", "lcm",},
- {1, {V_IRON}, {2},
+ {{I_IRON, I_NONE, I_NONE}, {2, 0, 0},
V_HCM, -1, 0, 0, 0, NAT_TLEV, -10, 10, 100,
"heavy construction materials", "hcm",},
- {3, {V_DUST, V_OIL, V_LCM}, {1, 5, 10},
+ {{I_DUST, I_OIL, I_LCM}, {1, 5, 10},
0, NAT_TLEV, 300, 0, 0, NAT_ELEV, 5, 10, 100,
"technological breakthroughs", "tech",},
- {3, {V_DUST, V_OIL, V_LCM}, {1, 5, 10},
+ {{I_DUST, I_OIL, I_LCM}, {1, 5, 10},
0, NAT_RLEV, 90, 0, 0, NAT_ELEV, 5, 10, 100,
"medical discoveries", "medical",},
- {1, {V_LCM}, {1},
+ {{I_LCM, I_NONE, I_NONE}, {1, 0, 0},
0, NAT_ELEV, 9, 0, 0, -1, 0, 0, 100,
"a class of graduates", "edu",},
- {1, {V_LCM}, {1},
+ {{I_LCM, I_NONE, I_NONE}, {1, 0, 0},
0, NAT_HLEV, 9, 0, 0, -1, 0, 0, 100,
"happy strollers", "happy",},
- {0, {0}, {0},
+ {{I_NONE, I_NONE, I_NONE}, {0, 0, 0},
V_RAD, -1, 2, offsetof(struct sctstr, sct_uran), 35, NAT_TLEV, 40, 10, 100,
"radioactive materials", "rad",},
- {0, {0}, {0},
+ {{I_NONE, I_NONE, I_NONE}, {0, 0, 0},
V_DUST, -1, 0, offsetof(struct sctstr, sct_gmin), 20, -1, 0, 0, 75,
"gold dust", "dust",},
- {0, {0}, {0},
+ {{I_NONE, I_NONE, I_NONE}, {0, 0, 0},
0, 0, 0, 0, 0, 0, 0, 0, 0, "", "",}
};