(MINES_MAX): New.

(doland, mine, landmine, setsector, pln_dropoff): Use it.  With
variables, mining beyond the capacity of variables (65535) was
ignored.  Now the mines saturate at MINES_MAX.
This commit is contained in:
Markus Armbruster 2004-03-04 15:54:46 +00:00
parent 7cd66c0f70
commit 828b84d840
5 changed files with 14 additions and 9 deletions

View file

@ -184,8 +184,10 @@ extern struct dchrstr bigcity_dchr;
/* Sector flags */
#define MOVE_IN_PROGRESS bit(0) /* move in progress */
/* maximal number of che, must fit into struct sctstr member sct_che */
/* maximum number of che, must fit into struct sctstr member sct_che */
#define CHE_MAX 255
/* maximum number of mines, must fit into struct sctstr member sct_mines */
#define MINES_MAX 65535
/* Each cost is per point of efficency */
struct sctintrins {

View file

@ -627,8 +627,9 @@ doland(s_char op, int arg, s_char *p, struct sctstr *sect)
sect->sct_avail = new;
break;
case 'M':
sect->sct_mines = arg;
pr("Mines changed to %d\n", arg);
new = errcheck(arg, 0, MINES_MAX);
sect->sct_mines = new;
pr("Mines changed to %d\n", new);
break;
case 'L':
if (!sarg_xy(p, &newx, &newy))

View file

@ -59,8 +59,8 @@ mine(void)
if (!snxtitem(&ni, EF_SHIP, player->argp[1]))
return RET_SYN;
mines =
onearg(player->argp[2], "Drop how many mines from each ship? ");
mines = onearg(player->argp[2],
"Drop how many mines from each ship? ");
if (mines <= 0)
return RET_SYN;
while (nxtitem(&ni, (s_char *)&ship)) {
@ -77,7 +77,7 @@ mine(void)
pr("You can't lay mines there!!\n");
continue;
}
sect.sct_mines += mines_avail;
sect.sct_mines = min(sect.sct_mines + mines_avail, MINES_MAX);
ship.shp_item[I_SHELL] = shells - mines_avail;
putsect(&sect);
ship.shp_mission = 0;
@ -151,7 +151,7 @@ landmine(void)
shells = min(shells, land.lnd_mobil);
}
getsect(sect.sct_x, sect.sct_y, &sect);
sect.sct_mines += total_mines_laid;
sect.sct_mines = min(sect.sct_mines + total_mines_laid, MINES_MAX);
putsect(&sect);
if (total_mines_laid == mines_wanted) {
pr("%s laid a total of %d mines in %s",

View file

@ -222,6 +222,8 @@ setsector(void)
current += amt;
if (current < 0)
current = 0;
if (current > MINES_MAX)
current = MINES_MAX;
if (sect.sct_own != 0)
resnoise(&sect, 1, "Mines", sect.sct_mines, current);
sect.sct_mines = current;

View file

@ -230,7 +230,7 @@ pln_dropoff(struct emp_qelem *list, struct ichrstr *ip, coord tx, coord ty,
sectp = ptr;
if (sectp->sct_type == SCT_WATER && ip->i_vtype == V_SHELL) {
/* aerial mining */
sectp->sct_mines += amt;
sectp->sct_mines = min(sectp->sct_mines + amt, MINES_MAX);
pr("%d mines laid in %s.\n", amt,
xyas(sectp->sct_x, sectp->sct_y, player->cnum));
if (amt > 0