Don't intercept tactical and marine missiles targeting planes

Missiles attacking ground targets (sectors, ships or land units) can
be intercepted, missiles targeting planes can't.  Except msl_launch()
checked the missile's capabilities instead of its target, and thus
intercepted missiles that *could* target ground even when they
targeted planes.

This broke the missile interception code's assumption that
interceptors aren't intercepted, and crashed the server through
infinite recursion: tactical abm #1 intercepts, tactical abm #2
intercepts #1, #1 intercepts #2, ...

Same bug in msl_hit() printed "incoming missile" for missiles that
could target ground but do target planes.

Broken in Empire 2.  Bug can't bite with the stock game's planes.
This commit is contained in:
Markus Armbruster 2009-10-11 22:18:26 -04:00
parent fd894d9864
commit 22071b4edb

View file

@ -61,7 +61,6 @@ msl_launch(struct plnstr *pp, int type, char *what, coord x, coord y,
struct shpstr ship; struct shpstr ship;
struct sctstr sect; struct sctstr sect;
int sublaunch = 0; int sublaunch = 0;
struct plchrstr *pcp = plchr + pp->pln_type;
char *from; char *from;
int dam; int dam;
@ -115,16 +114,16 @@ msl_launch(struct plnstr *pp, int type, char *what, coord x, coord y,
putplane(pp->pln_uid, pp); putplane(pp->pln_uid, pp);
mpr(pp->pln_own, "\tSHWOOOOOSH! Missile launched!\n"); mpr(pp->pln_own, "\tSHWOOOOOSH! Missile launched!\n");
if (pcp->pl_flags & P_T) if (type != EF_PLANE)
mpr(victim, "Incoming %s missile sighted at %s...\n", mpr(victim, "Incoming %s missile sighted at %s...\n",
sublaunch ? "sub-launched" : cname(pp->pln_own), sublaunch ? "sub-launched" : cname(pp->pln_own),
xyas(x, y, victim)); xyas(x, y, victim));
if ((pcp->pl_flags & P_T && !(pcp->pl_flags & P_MAR))) { if (type == EF_SECTOR || type == EF_LAND) {
if (msl_abm_intercept(pp, x, y, sublaunch)) if (msl_abm_intercept(pp, x, y, sublaunch))
return -1; return -1;
} }
if (pcp->pl_flags & P_MAR) { if (type == EF_SHIP) {
if (shp_missile_defense(x, y, pp->pln_own, pln_def(pp))) { if (shp_missile_defense(x, y, pp->pln_own, pln_def(pp))) {
return -1; return -1;
} }
@ -139,7 +138,6 @@ int
msl_hit(struct plnstr *pp, int hardtarget, int type, msl_hit(struct plnstr *pp, int hardtarget, int type,
int news_item, int snews_item, int sublaunch, natid victim) int news_item, int snews_item, int sublaunch, natid victim)
{ {
struct plchrstr *pcp = plchr + pp->pln_type;
int hitchance, hit; int hitchance, hit;
if (nuk_on_plane(pp) >= 0) { if (nuk_on_plane(pp) >= 0) {
@ -152,7 +150,7 @@ msl_hit(struct plnstr *pp, int hardtarget, int type,
hit ? "HIT!" : "miss"); hit ? "HIT!" : "miss");
} }
if (pcp->pl_flags & P_T) if (type != EF_PLANE)
mpr(victim, "...Incoming %s missile %s\n", mpr(victim, "...Incoming %s missile %s\n",
sublaunch ? "" : cname(pp->pln_own), sublaunch ? "" : cname(pp->pln_own),
hit ? "HIT!\n" : "missed\n"); hit ? "HIT!\n" : "missed\n");