Clean up misuse of mpr() in pln_damage()

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.

While there, wrap long "blam" lines.  Can only happen for bomb loads
above 16.  Stock game needs a tech 406 jhb for that.

The mpr() misuse was introduced in Empire 2.
This commit is contained in:
Markus Armbruster 2010-06-06 23:05:58 +02:00
parent 47dd33698c
commit e002bf207f

View file

@ -985,12 +985,11 @@ int
pln_damage(struct plnstr *pp, char type, int noisy)
{
struct plchrstr *pcp = plchr + pp->pln_type;
int load, i;
int hitroll;
int load, i, hitroll, aim, len;
int dam = 0;
int aim;
int effective = 1;
int pinbomber = 0;
char buf[80];
if (CANT_HAPPEN(nuk_on_plane(pp) >= 0))
return 0;
@ -1018,27 +1017,34 @@ pln_damage(struct plnstr *pp, char type, int noisy)
aim = 100 - aim;
}
len = 0;
while (i--) {
dam += roll(6);
hitroll = roll(100);
if (hitroll >= 90) {
dam += 8;
if (noisy)
mpr(pp->pln_own, "BLAM");
len += sprintf(buf + len, "BLAM");
} else if (hitroll < aim) {
dam += 5;
if (noisy)
mpr(pp->pln_own, "Blam");
len += sprintf(buf + len, "Blam");
} else {
dam += 1;
if (noisy)
mpr(pp->pln_own, "blam");
len += sprintf(buf + len, "blam");
}
if (noisy) {
if (len > 75) {
mpr(pp->pln_own, "%s\n", buf);
len = 0;
}
if (i)
len += sprintf(buf + len, "-");
}
if (i && noisy)
mpr(pp->pln_own, "-");
}
if (noisy)
mpr(pp->pln_own, "\n");
if (noisy && len)
mpr(pp->pln_own, "%s\n", buf);
if (effective)
dam *= 2;
return dam;