Clean up misuse of mpr() in shp_missile_defense()

Don't use multiple calls of mpr() to print a single line, because that
creates a separate bulletin for each part.  The read command normally
merges the bulletins, but if the bulletins are more than five seconds
apart (clock jumped somehow), we get a bulletin header in the middle
of a line.

The mpr() misuse was introduced in Empire 2.
This commit is contained in:
Markus Armbruster 2010-06-06 22:40:44 +02:00
parent 4033a3be7d
commit 47dd33698c

View file

@ -840,7 +840,7 @@ shp_missile_defense(coord dx, coord dy, natid bombown, int hardtarget)
{ {
struct nstr_item ni; struct nstr_item ni;
struct shpstr ship; struct shpstr ship;
int hitchance; int hitchance, hit;
double gun, eff, teff; double gun, eff, teff;
snxtitem_dist(&ni, EF_SHIP, dx, dy, 1); snxtitem_dist(&ni, EF_SHIP, dx, dy, 1);
@ -877,23 +877,20 @@ shp_missile_defense(coord dx, coord dy, natid bombown, int hardtarget)
hitchance = 0; hitchance = 0;
if (hitchance > 100) if (hitchance > 100)
hitchance = 100; hitchance = 100;
hit = roll(100) <= hitchance;
mpr(bombown, "%s anti-missile system activated...", mpr(bombown, "%s anti-missile system activated...%s\n",
cname(ship.shp_own)); cname(ship.shp_own),
hit ? "KABOOOM!! Missile destroyed\n"
: "SWOOSH!! anti-missile system failed!!");
mpr(ship.shp_own, "Ship #%i anti-missile system activated!\n", mpr(ship.shp_own, "Ship #%i anti-missile system activated!\n",
ship.shp_uid); ship.shp_uid);
mpr(ship.shp_own, "%d%% hitchance...", hitchance); mpr(ship.shp_own, "%d%% hitchance...%s\n", hitchance,
hit ? "KABOOOM!! Incoming missile destroyed!\n"
: "SWOOSH!! Missile evades anti-missile systems\n");
if (roll(100) <= hitchance) { if (hit)
mpr(bombown, "KABOOOM!! Missile destroyed\n\n");
mpr(ship.shp_own,
"KABOOOM!! Incoming missile destroyed!\n\n");
return 1; return 1;
} else {
mpr(bombown, "SWOOSH!! anti-missile system failed!!\n");
mpr(ship.shp_own,
"SWOOSH!! Missile evades anti-missile systems\n\n");
}
} }
return 0; /* all attempts failed */ return 0; /* all attempts failed */
} }