(deli, do_demo, lnd_sweep, guerrilla): Saturate items at ITEM_MAX.

With variables, item increases beyond the capacity of variables
(65535) were ignored here.

This should cover all item changes not going through putvec().
This commit is contained in:
Markus Armbruster 2004-03-05 06:48:57 +00:00
parent 95ef2b139d
commit 58e93c0ea3
4 changed files with 10 additions and 4 deletions

View file

@ -101,7 +101,8 @@ deli(void)
if (!check_sect_ok(&sect))
continue;
del = thresh + dir;
thresh = min(thresh, ITEM_MAX) & ~7;
del = thresh | dir;
sect.sct_del[ich->i_vtype] = del;
putsect(&sect);
}

View file

@ -105,6 +105,8 @@ do_demo(struct natstr *natp, struct nstr_sect nstr, int number, s_char *p,
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;

View file

@ -715,7 +715,7 @@ lnd_sweep(struct emp_qelem *land_list, int verbose, int takemob,
mines--;
if (lshells < max)
++lshells;
else
else if (sshells < ITEM_MAX)
++sshells;
}
}

View file

@ -220,10 +220,9 @@ guerrilla(struct sctstr *sp)
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;
}
@ -347,6 +346,10 @@ guerrilla(struct sctstr *sp)
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;