Fix misdirected nuclear detonation output

Output went to the owner of the nuke instead of the player.
Fortunately, they're the same in normal usage.  They can differ only
when a deity drops a foreign nuke from a foreign plane.

The fix also cleans up a misuse of mpr() in kaboom(): it used multiple
calls to print a single line, which 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.  Fortunately, that
could happen only when a deity drops a foreign nuke.  Before commit
a269cdd7 (v4.3.23), it could also happen for missions.

Broken in Empire 2.
This commit is contained in:
Markus Armbruster 2010-06-06 15:03:35 +02:00
parent 10d316660e
commit 891ea01b1f

View file

@ -51,13 +51,12 @@
#include "ship.h" #include "ship.h"
#include "xy.h" #include "xy.h"
static void kaboom(int x, int y, int rad, natid cn); static void kaboom(int x, int y, int rad);
int int
detonate(struct nukstr *np, coord x, coord y, int airburst) detonate(struct nukstr *np, coord x, coord y, int airburst)
{ {
int nuketype = np->nuk_type; int nuketype = np->nuk_type;
natid bombown = np->nuk_own;
struct nchrstr *ncp; struct nchrstr *ncp;
struct plnstr plane; struct plnstr plane;
struct sctstr sect; struct sctstr sect;
@ -76,12 +75,12 @@ detonate(struct nukstr *np, coord x, coord y, int airburst)
struct nstr_item ni; struct nstr_item ni;
int changed = 0; int changed = 0;
mpr(bombown, "Releasing RV's for %s detonation...\n", pr("Releasing RV's for %s detonation...\n",
airburst ? "airburst" : "groundburst"); airburst ? "airburst" : "groundburst");
getsect(x, y, &sect); getsect(x, y, &sect);
ncp = &nchr[nuketype]; ncp = &nchr[nuketype];
kaboom(x, y, ncp->n_blast, bombown); kaboom(x, y, ncp->n_blast);
rad = ncp->n_blast; rad = ncp->n_blast;
if (!airburst) if (!airburst)
rad = rad * 2 / 3; rad = rad * 2 / 3;
@ -97,10 +96,10 @@ detonate(struct nukstr *np, coord x, coord y, int airburst)
if ((damage = nukedamage(ncp, ns.curdist, airburst)) <= 0) if ((damage = nukedamage(ncp, ns.curdist, airburst)) <= 0)
continue; continue;
if (type == SCT_SANCT) { if (type == SCT_SANCT) {
mpr(bombown, "bounced off %s\n", xyas(ns.x, ns.y, bombown)); pr("bounced off %s\n", xyas(ns.x, ns.y, player->cnum));
mpr(own, "%s nuclear device bounced off %s\n", mpr(own, "%s nuclear device bounced off %s\n",
cname(bombown), xyas(ns.x, ns.y, own)); cname(player->cnum), xyas(ns.x, ns.y, own));
nreport(bombown, N_NUKE, own, 1); nreport(player->cnum, N_NUKE, own, 1);
continue; continue;
} }
sect_damage(&sect, damage); sect_damage(&sect, damage);
@ -135,11 +134,11 @@ detonate(struct nukstr *np, coord x, coord y, int airburst)
} }
(void)putsect(&sect); (void)putsect(&sect);
if (type != SCT_WATER) if (type != SCT_WATER)
nreport(bombown, N_NUKE, own, 1); nreport(player->cnum, N_NUKE, own, 1);
mpr(bombown, bp, xyas(ns.x, ns.y, bombown)); pr(bp, xyas(ns.x, ns.y, player->cnum));
if (own != bombown && own != 0) { if (own != player->cnum && own != 0) {
(void)sprintf(buf2, bp, xyas(ns.x, ns.y, own)); (void)sprintf(buf2, bp, xyas(ns.x, ns.y, own));
mpr(own, "%s nuclear device %s\n", cname(bombown), buf2); mpr(own, "%s nuclear device %s\n", cname(player->cnum), buf2);
} }
} }
@ -179,13 +178,13 @@ detonate(struct nukstr *np, coord x, coord y, int airburst)
} }
} }
planedamage(&plane, damage); planedamage(&plane, damage);
if (own == bombown) { if (own == player->cnum) {
mpr(bombown, "%s at %s reports %d%% damage\n", pr("%s at %s reports %d%% damage\n",
prplane(&plane), prplane(&plane),
xyas(plane.pln_x, plane.pln_y, own), damage); xyas(plane.pln_x, plane.pln_y, own), damage);
} else { } else {
mpr(own, "%s nuclear device did %d%% damage to %s at %s\n", mpr(own, "%s nuclear device did %d%% damage to %s at %s\n",
cname(bombown), damage, cname(player->cnum), damage,
prplane(&plane), xyas(plane.pln_x, plane.pln_y, own)); prplane(&plane), xyas(plane.pln_x, plane.pln_y, own));
} }
putplane(ni.cur, &plane); putplane(ni.cur, &plane);
@ -222,12 +221,12 @@ detonate(struct nukstr *np, coord x, coord y, int airburst)
} }
} }
land_damage(&land, damage); land_damage(&land, damage);
if (own == bombown) { if (own == player->cnum) {
mpr(bombown, "%s at %s reports %d%% damage\n", pr("%s at %s reports %d%% damage\n",
prland(&land), xyas(land.lnd_x, land.lnd_y, own), damage); prland(&land), xyas(land.lnd_x, land.lnd_y, own), damage);
} else { } else {
mpr(own, "%s nuclear device did %d%% damage to %s at %s\n", mpr(own, "%s nuclear device did %d%% damage to %s at %s\n",
cname(bombown), damage, cname(player->cnum), damage,
prland(&land), xyas(land.lnd_x, land.lnd_y, own)); prland(&land), xyas(land.lnd_x, land.lnd_y, own));
} }
putland(land.lnd_uid, &land); putland(land.lnd_uid, &land);
@ -258,12 +257,12 @@ detonate(struct nukstr *np, coord x, coord y, int airburst)
} }
} }
ship_damage(&ship, damage); ship_damage(&ship, damage);
if (own == bombown) { if (own == player->cnum) {
mpr(bombown, "%s at %s reports %d%% damage\n", pr("%s at %s reports %d%% damage\n",
prship(&ship), xyas(ship.shp_x, ship.shp_y, own), damage); prship(&ship), xyas(ship.shp_x, ship.shp_y, own), damage);
} else { } else {
mpr(own, "%s nuclear device did %d%% damage to %s at %s\n", mpr(own, "%s nuclear device did %d%% damage to %s at %s\n",
cname(bombown), damage, prship(&ship), cname(player->cnum), damage, prship(&ship),
xyas(ship.shp_x, ship.shp_y, own)); xyas(ship.shp_x, ship.shp_y, own));
} }
putship(ship.shp_uid, &ship); putship(ship.shp_uid, &ship);
@ -278,9 +277,9 @@ detonate(struct nukstr *np, coord x, coord y, int airburst)
if (roll(100) >= damage) if (roll(100) >= damage)
continue; continue;
nuke.nuk_effic = 0; nuke.nuk_effic = 0;
if (own == bombown) { if (own == player->cnum) {
mpr(bombown, "%s at %s destroyed\n", pr("%s at %s destroyed\n",
prnuke(&nuke), xyas(nuke.nuk_x, nuke.nuk_y, own)); prnuke(&nuke), xyas(nuke.nuk_x, nuke.nuk_y, own));
} else { } else {
mpr(own, "%s at %s destroyed\n", mpr(own, "%s at %s destroyed\n",
prnuke(&nuke), xyas(nuke.nuk_x, nuke.nuk_y, own)); prnuke(&nuke), xyas(nuke.nuk_x, nuke.nuk_y, own));
@ -296,10 +295,10 @@ detonate(struct nukstr *np, coord x, coord y, int airburst)
* silly to be sure. * silly to be sure.
*/ */
static void static void
kaboom(int x, int y, int rad, natid cn) kaboom(int x, int y, int rad)
{ {
mpr(cn, "\n\nK A B O O "); pr("\n\nK A B O O ");
while (rad-- > 1) while (rad-- > 1)
mpr(cn, "O O "); pr("O O ");
mpr(cn, "M ! in %s\n\n", xyas(x, y, cn)); pr("M ! in %s\n\n", xyas(x, y, player->cnum));
} }