diff --git a/include/sect.h b/include/sect.h index 3db52198..6cfcef69 100644 --- a/include/sect.h +++ b/include/sect.h @@ -188,6 +188,8 @@ extern struct dchrstr bigcity_dchr; #define CHE_MAX 255 /* maximum number of mines, must fit into struct sctstr member sct_mines */ #define MINES_MAX 65535 +/* maximum fallout, must fit into struct sctstr member sct_fallout */ +#define FALLOUT_MAX 9999 /* Each cost is per point of efficency */ struct sctintrins { diff --git a/src/lib/commands/edit.c b/src/lib/commands/edit.c index 274c0075..c5064ac8 100644 --- a/src/lib/commands/edit.c +++ b/src/lib/commands/edit.c @@ -616,7 +616,7 @@ doland(s_char op, int arg, s_char *p, struct sctstr *sect) break; case 'F': old = sect->sct_fallout; - new = errcheck(arg, 0, 9999); + new = errcheck(arg, 0, FALLOUT_MAX); pr("Fallout for sector %s changed from %d to %d\n", xyas(sect->sct_x, sect->sct_y, player->cnum), old, new); sect->sct_fallout = new; diff --git a/src/lib/subs/detonate.c b/src/lib/subs/detonate.c index 3265410d..b1b3dbac 100644 --- a/src/lib/subs/detonate.c +++ b/src/lib/subs/detonate.c @@ -112,7 +112,7 @@ detonate(struct plnstr *pp, int x, int y) fallout += damage * 30; else fallout += damage * 3; - sect.sct_fallout = fallout; + sect.sct_fallout = min(fallout, FALLOUT_MAX); } if (damage > 100) { makelost(EF_SECTOR, sect.sct_own, 0, sect.sct_x, sect.sct_y); diff --git a/src/lib/update/sect.c b/src/lib/update/sect.c index 4ae30aed..01e63c06 100644 --- a/src/lib/update/sect.c +++ b/src/lib/update/sect.c @@ -307,7 +307,7 @@ spread_fallout(struct sctstr *sp, int etus) #endif if (inc < 0) inc = 0; - ap->sct_fallout += inc; + ap->sct_fallout = min(ap->sct_fallout + inc, FALLOUT_MAX); } } @@ -327,8 +327,7 @@ decay_fallout(struct sctstr *sp, int etus) sp->sct_y, decay, sp->sct_fallout); #endif - sp->sct_fallout = - (decay < sp->sct_fallout) ? (sp->sct_fallout - decay) : 0; + sp->sct_fallout = decay < sp->sct_fallout ? sp->sct_fallout - decay : 0; } #define SHOULD_PRODUCE(sp,t) (((sp->sct_type == t) || (t == -1)) ? 1 : 0)