(pchrstr, MAXPRCON): Simplify variable-style storage of constituents.
Store only up to MAXPRCON constituents, not MAXCHRNV; code doesn't fully support more than three anyway. Remove member p_nv, use item type I_NONE for unused slots. Rename members p_vtype, p_vamt to p_ctype, p_camt to avoid confusion with variable-style storage. (pchr): Initializers adapted. (nullify_objects, materials_cost, materials_charge, prod, show_sect_capab, grind): Adapt, simplify where possible, protect against bad item types in pchr[]. (MAXCHRNV): Unused, remove.
This commit is contained in:
parent
15d4f89951
commit
4d154753b8
8 changed files with 103 additions and 101 deletions
|
@ -68,23 +68,36 @@ grin(void)
|
|||
if (sect.sct_effic < 60 || sect.sct_own != player->cnum)
|
||||
continue;
|
||||
n = sect.sct_item[I_BAR] >= qty ? qty : sect.sct_item[I_BAR];
|
||||
avail = n * 5.0;
|
||||
/* work limit */
|
||||
avail = n * 5;
|
||||
if (avail > sect.sct_avail) {
|
||||
n = sect.sct_avail / 5;
|
||||
avail = sect.sct_avail;
|
||||
}
|
||||
for (i = 0; i < pchr[P_BAR].p_nv; i++) {
|
||||
/* space limit */
|
||||
for (i = 0; i < MAXPRCON; i++) {
|
||||
if (!pchr[P_BAR].p_camt[i])
|
||||
continue;
|
||||
if (CANT_HAPPEN(pchr[P_BAR].p_ctype[i] <= I_NONE ||
|
||||
pchr[P_BAR].p_ctype[i] > I_MAX))
|
||||
continue;
|
||||
n = min(n,
|
||||
(double)(ITEM_MAX - sect.sct_item[pchr[P_BAR].p_vtype[i]])
|
||||
/ (pchr[P_BAR].p_vamt[i] * grind_eff));
|
||||
(double)(ITEM_MAX - sect.sct_item[pchr[P_BAR].p_ctype[i]])
|
||||
/ (pchr[P_BAR].p_camt[i] * grind_eff));
|
||||
}
|
||||
|
||||
if (n > 0) {
|
||||
pr("%d bars ground up in %s\n", n,
|
||||
xyas(sect.sct_x, sect.sct_y, player->cnum));
|
||||
sect.sct_item[I_BAR] -= n;
|
||||
for (i = 0; i < pchr[P_BAR].p_nv; i++) {
|
||||
sect.sct_item[pchr[P_BAR].p_vtype[i]]
|
||||
+= n * pchr[P_BAR].p_vamt[i] * grind_eff;
|
||||
for (i = 0; i < MAXPRCON; i++) {
|
||||
if (!pchr[P_BAR].p_camt[i])
|
||||
continue;
|
||||
if (CANT_HAPPEN(pchr[P_BAR].p_ctype[i] <= I_NONE ||
|
||||
pchr[P_BAR].p_ctype[i] > I_MAX))
|
||||
continue;
|
||||
sect.sct_item[pchr[P_BAR].p_ctype[i]]
|
||||
+= n * pchr[P_BAR].p_camt[i] * grind_eff;
|
||||
}
|
||||
sect.sct_avail -= avail;
|
||||
putsect(§);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue