With variables, item increases beyond the capacity of variables
(65535) were ignored here.
This should cover all item changes not going through putvec().
if (!check_sect_ok(§))
continue;
- del = thresh + dir;
+ thresh = min(thresh, ITEM_MAX) & ~7;
+ del = thresh | dir;
sect.sct_del[ich->i_vtype] = del;
putsect(§);
}
continue;
} else if ((deltamil = min(mil, number)) <= 0)
continue;
+ if (deltamil > ITEM_MAX - civ)
+ deltamil = ITEM_MAX - civ;
civ += deltamil;
mil -= deltamil;
mil_demob += deltamil;
mines--;
if (lshells < max)
++lshells;
- else
+ else if (sshells < ITEM_MAX)
++sshells;
}
}
if ((tnat->nat_stat & STAT_INUSE) == 0) {
/* target nation has dissolved: che's retire. */
logerror("%d Che targeted at country %d retiring", che, target);
- civ += che;
sp->sct_che = 0;
sp->sct_che_target = 0;
- sp->sct_item[I_CIVIL] = civ;
+ sp->sct_item[I_CIVIL] = min(civ + che, ITEM_MAX);
return;
}
sp->sct_newtype = SCT_AGRI;
n = civ / 20;
civ -= n;
+ if (civ > ITEM_MAX) {
+ uw = ITEM_MAX - civ;
+ civ = ITEM_MAX;
+ }
sp->sct_item[I_CIVIL] = civ;
sp->sct_item[I_UW] = uw;
sp->sct_item[I_MILIT] = n;