Remove option SLOW_WAR

SLOW_WAR has issues:

* The check whether the attacker old-owns the attacked sector is
  broken, because att_abort() uses sect.sct_oldown uninitialized.

  Spotted by the Clang Static Analyzer.

* Its implementation in setrel() is somewhat scary.  It's actually
  okay, because that part of setrel() only runs within decl().  Other
  callers don't reach it: update_main() because player->god != 0
  there, and the rest because they never pass a rel < HOSTILE.

* Documentation is a bit vague.

SLOW_WAR hasn't been used in a public game in years.  Fixing it is not
worth it, so remove it instead.
This commit is contained in:
Markus Armbruster 2011-01-09 19:03:38 +01:00
parent a94ae5f8c1
commit 439f111f98
23 changed files with 11 additions and 274 deletions

View file

@ -173,8 +173,7 @@ assa(void)
putland(llp->unit.land.lnd_uid, &llp->unit.land);
} else {
pr("%s was spotted", prland(&llp->unit.land));
if (rel == HOSTILE || rel == AT_WAR || rel == SITZKRIEG ||
rel == MOBILIZATION) {
if (rel <= HOSTILE) {
wu(0, def->own, "%s spy shot and killed in %s.\n",
cname(player->cnum), xyas(def->x, def->y,
def->own));

View file

@ -95,8 +95,6 @@ bomb(void)
char mission;
struct plist *plp;
struct emp_qelem *qp, *next;
int rel;
struct natstr *natp;
char buf[1024];
if (get_planes(&ni_bomb, &ni_esc, player->argp[1], player->argp[2]) < 0)
@ -160,20 +158,6 @@ bomb(void)
}
break;
case 's':
if (opt_SLOW_WAR) {
natp = getnatp(player->cnum);
if (target.sct_own) {
rel = getrel(natp, target.sct_own);
if ((rel != AT_WAR) && (player->cnum != target.sct_own)
&& (target.sct_own) &&
(target.sct_oldown != player->cnum)) {
pr("You're not at war with them!\n");
pln_put(&bomb_list);
pln_put(&esc_list);
return RET_FAIL;
}
}
}
nreport(player->cnum, N_SCT_BOMB, target.sct_own, 1);
strat_bomb(&bomb_list, &target);
break;
@ -197,8 +181,6 @@ pin_bomb(struct emp_qelem *list, struct sctstr *target)
char *p;
int nsubs;
int nunits;
struct natstr *natp;
int rel;
char buf[1024];
int i;
@ -229,18 +211,6 @@ pin_bomb(struct emp_qelem *list, struct sctstr *target)
}
switch (*p) {
case 'l':
if (opt_SLOW_WAR) {
natp = getnatp(player->cnum);
if (target->sct_own) {
rel = getrel(natp, target->sct_own);
if ((rel != AT_WAR) && (player->cnum != target->sct_own)
&& (target->sct_own) &&
(target->sct_oldown != player->cnum)) {
pr("You're not at war with them!\n");
goto retry;
}
}
}
if (nunits == 0) {
pr("no units there\n");
goto retry;
@ -248,18 +218,6 @@ pin_bomb(struct emp_qelem *list, struct sctstr *target)
land_bomb(list, target);
break;
case 'p':
if (opt_SLOW_WAR) {
natp = getnatp(player->cnum);
if (target->sct_own) {
rel = getrel(natp, target->sct_own);
if ((rel != AT_WAR) && (player->cnum != target->sct_own)
&& (target->sct_own) &&
(target->sct_oldown != player->cnum)) {
pr("You're not at war with them!\n");
goto retry;
}
}
}
if (nplanes == 0) {
pr("no planes there\n");
goto retry;
@ -281,19 +239,6 @@ pin_bomb(struct emp_qelem *list, struct sctstr *target)
ship_bomb(list, target);
break;
case 'c':
if (opt_SLOW_WAR) {
natp = getnatp(player->cnum);
if (target->sct_own) {
rel = getrel(natp, target->sct_own);
if ((rel != AT_WAR) && (player->cnum != target->sct_own)
&& (target->sct_own) &&
(target->sct_oldown != player->cnum)) {
pr("You're not at war with them!\n");
goto retry;
}
}
}
for (i = 0; i < nbomb; i++) {
if (!target->sct_item[bombcomm[i]])
continue;
@ -307,18 +252,6 @@ pin_bomb(struct emp_qelem *list, struct sctstr *target)
comm_bomb(list, target);
break;
case 'e':
if (opt_SLOW_WAR) {
natp = getnatp(player->cnum);
if (target->sct_own) {
rel = getrel(natp, target->sct_own);
if ((rel != AT_WAR) && (player->cnum != target->sct_own)
&& (target->sct_own) &&
(target->sct_oldown != player->cnum)) {
pr("You're not at war with them!\n");
goto retry;
}
}
}
eff_bomb(list, target);
break;
case 'q':

View file

@ -64,20 +64,6 @@ decl(void)
case 'h':
rel = HOSTILE;
break;
case 'm':
if (!opt_SLOW_WAR)
return RET_SYN;
if (!player->god)
return RET_SYN;
rel = MOBILIZATION;
break;
case 's':
if (!opt_SLOW_WAR)
return RET_SYN;
if (!player->god)
return RET_SYN;
rel = SITZKRIEG;
break;
case 'w':
rel = AT_WAR;
break;

View file

@ -182,8 +182,6 @@ launch_missile(struct plnstr *pp)
struct mchrstr *mcp;
struct shpstr target_ship;
struct sctstr sect;
int rel;
struct natstr *natp;
struct nukstr nuke;
char buf[1024];
@ -230,18 +228,6 @@ launch_missile(struct plnstr *pp)
if (msl_equip(pp, 's') < 0)
return RET_FAIL;
getsect(sx, sy, &sect);
if (opt_SLOW_WAR) {
natp = getnatp(player->cnum);
rel = getrel(natp, sect.sct_own);
if ((rel != AT_WAR) && (sect.sct_own != player->cnum) &&
(sect.sct_own) && (sect.sct_oldown != player->cnum)) {
pr("You are not at war with the player->owner of the target sector!\n");
pr_beep();
pr("Kaboom!!!\n");
pr("Missile monitoring officer destroys RV before detonation.\n");
return RET_OK;
}
}
if (msl_launch(pp, EF_SECTOR, "sector", sx, sy, sect.sct_own,
&sublaunch) < 0)
return RET_OK;

View file

@ -82,8 +82,6 @@ multifire(void)
struct shpstr vship;
struct sctstr vsect;
enum targ_type target;
int rel;
struct natstr *natp;
struct nstr_item nbst;
int type;
struct empobj *attgp;
@ -416,17 +414,6 @@ multifire(void)
break;
}
if (opt_SLOW_WAR) {
if (target == targ_land) {
natp = getnatp(player->cnum);
rel = getrel(natp, vict);
if ((rel != AT_WAR) && (player->cnum != vict) &&
(vict) && (vsect.sct_oldown != player->cnum)) {
pr("You're not at war with them!\n");
continue;
}
}
}
nfiring++;
switch (target) {
case targ_sub:

View file

@ -101,8 +101,6 @@ vers(void)
if (rollover_avail_max)
pr("Up to %d avail can roll over an update.\n",
rollover_avail_max);
if (opt_SLOW_WAR)
pr("Declaring war will cost you $%i\n\n", War_Cost);
pr("Happiness p.e. requires 1 happy stroller per %d civ.\n",
(int)hap_cons / etu_per_update);
pr("Education p.e. requires 1 class of graduates per %d civ.\n",