subs: Change pln_damage()'s parameter noisy to string prefix

No functional change for now.  The next commit will put it to use.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
This commit is contained in:
Markus Armbruster 2015-01-11 12:59:24 +01:00
parent 9e643dad00
commit 820d755e59
8 changed files with 26 additions and 24 deletions

View file

@ -533,7 +533,7 @@ extern void pln_put1(struct plist *);
extern void plane_sweep(struct emp_qelem *, coord, coord); extern void plane_sweep(struct emp_qelem *, coord, coord);
extern int put_plane_on_land(struct plnstr *, struct lndstr *); extern int put_plane_on_land(struct plnstr *, struct lndstr *);
extern int pln_hitchance(struct plnstr *, int, int); extern int pln_hitchance(struct plnstr *, int, int);
extern int pln_damage(struct plnstr *, char, int); extern int pln_damage(struct plnstr *, char, char *);
extern int pln_identchance(struct plnstr *, int, int); extern int pln_identchance(struct plnstr *, int, int);
extern int pln_is_in_orbit(struct plnstr *); extern int pln_is_in_orbit(struct plnstr *);
extern void pln_set_tech(struct plnstr *, int); extern void pln_set_tech(struct plnstr *, int);

View file

@ -275,7 +275,7 @@ eff_bomb(struct emp_qelem *list, struct sctstr *target)
plp = (struct plist *)qp; plp = (struct plist *)qp;
if (changed_plane_aborts(plp)) if (changed_plane_aborts(plp))
continue; continue;
dam += pln_damage(&plp->plane, 'p', 1); dam += pln_damage(&plp->plane, 'p', "");
} }
getsect(target->sct_x, target->sct_y, &sect); getsect(target->sct_x, target->sct_y, &sect);
target = &sect; target = &sect;
@ -348,7 +348,7 @@ comm_bomb(struct emp_qelem *list, struct sctstr *target)
plp = (struct plist *)qp; plp = (struct plist *)qp;
if (changed_plane_aborts(plp)) if (changed_plane_aborts(plp))
continue; continue;
dam += pln_damage(&plp->plane, 'p', 1); dam += pln_damage(&plp->plane, 'p', "");
} }
getsect(target->sct_x, target->sct_y, &sect); getsect(target->sct_x, target->sct_y, &sect);
target = &sect; target = &sect;
@ -457,7 +457,7 @@ ship_bomb(struct emp_qelem *list, struct sctstr *target)
} }
if (pct_chance(hitchance)) { if (pct_chance(hitchance)) {
/* pinbombing is more accurate than normal bombing */ /* pinbombing is more accurate than normal bombing */
dam = 2 * pln_damage(&plp->plane, 'p', 1); dam = 2 * pln_damage(&plp->plane, 'p', "");
} else { } else {
pr("splash\n"); pr("splash\n");
/* Bombs that miss have to land somewhere! */ /* Bombs that miss have to land somewhere! */
@ -556,7 +556,7 @@ plane_bomb(struct emp_qelem *list, struct sctstr *target)
} }
if (pct_chance(hitchance)) { if (pct_chance(hitchance)) {
/* pinbombing is more accurate than normal bombing */ /* pinbombing is more accurate than normal bombing */
dam = 2 * pln_damage(&plp->plane, 'p', 1); dam = 2 * pln_damage(&plp->plane, 'p', "");
} else { } else {
pr("thud\n"); pr("thud\n");
/* Bombs that miss have to land somewhere! */ /* Bombs that miss have to land somewhere! */
@ -664,7 +664,7 @@ land_bomb(struct emp_qelem *list, struct sctstr *target)
pr("%d%% hitchance...", hitchance); pr("%d%% hitchance...", hitchance);
} }
if (pct_chance(hitchance)) { if (pct_chance(hitchance)) {
dam = 2 * pln_damage(&plp->plane, 'p', 1); dam = 2 * pln_damage(&plp->plane, 'p', "");
} else { } else {
pr("thud\n"); pr("thud\n");
/* Bombs that miss have to land somewhere! */ /* Bombs that miss have to land somewhere! */
@ -703,7 +703,7 @@ strat_bomb(struct emp_qelem *list, struct sctstr *target)
detonate(&nuke, target->sct_x, target->sct_y, detonate(&nuke, target->sct_x, target->sct_y,
plp->plane.pln_flags & PLN_AIRBURST); plp->plane.pln_flags & PLN_AIRBURST);
else else
dam += pln_damage(&plp->plane, 's', 1); dam += pln_damage(&plp->plane, 's', "");
} }
if (dam <= 0) if (dam <= 0)
return; return;

View file

@ -239,7 +239,7 @@ launch_missile(struct plnstr *pp)
if (getnuke(nuk_on_plane(pp), &nuke)) if (getnuke(nuk_on_plane(pp), &nuke))
detonate(&nuke, sx, sy, pp->pln_flags & PLN_AIRBURST); detonate(&nuke, sx, sy, pp->pln_flags & PLN_AIRBURST);
else { else {
dam = pln_damage(pp, 's', 1); dam = pln_damage(pp, 's', "");
pr("did %d damage in %s\n", PERCENT_DAMAGE(dam), pr("did %d damage in %s\n", PERCENT_DAMAGE(dam),
xyas(sx, sy, player->cnum)); xyas(sx, sy, player->cnum));
if (sect.sct_own != 0) { if (sect.sct_own != 0) {
@ -268,11 +268,11 @@ launch_missile(struct plnstr *pp)
N_SHP_MISS, N_SHP_SMISS, sublaunch, N_SHP_MISS, N_SHP_SMISS, sublaunch,
target_ship.shp_own)) { target_ship.shp_own)) {
pr("splash\n"); pr("splash\n");
dam = pln_damage(pp, 'p', 0); dam = pln_damage(pp, 'p', NULL);
collateral_damage(target_ship.shp_x, target_ship.shp_y, dam); collateral_damage(target_ship.shp_x, target_ship.shp_y, dam);
return RET_OK; return RET_OK;
} }
dam = pln_damage(pp, 'p', 1); dam = pln_damage(pp, 'p', "");
shipdamage(&target_ship, dam); shipdamage(&target_ship, dam);
if (target_ship.shp_effic < SHIP_MINEFF) if (target_ship.shp_effic < SHIP_MINEFF)
pr("%s sunk!\n", prship(&target_ship)); pr("%s sunk!\n", prship(&target_ship));

View file

@ -818,10 +818,10 @@ lnd_missile_interdiction(struct emp_qelem *list, coord newx, coord newy,
stopping = 1; stopping = 1;
if (msl_hit(&plp->plane, hardtarget, EF_LAND, if (msl_hit(&plp->plane, hardtarget, EF_LAND,
N_LND_MISS, N_LND_SMISS, sublaunch, victim)) { N_LND_MISS, N_LND_SMISS, sublaunch, victim)) {
newdam = pln_damage(&plp->plane, 'p', 1); newdam = pln_damage(&plp->plane, 'p', "");
dam += newdam; dam += newdam;
} else { } else {
newdam = pln_damage(&plp->plane, 'p', 0); newdam = pln_damage(&plp->plane, 'p', NULL);
collateral_damage(newx, newy, newdam); collateral_damage(newx, newy, newdam);
} }
use_up_msl: use_up_msl:

View file

@ -561,7 +561,7 @@ perform_mission_msl(int dam, struct emp_qelem *missiles, coord x, coord y,
if (!msl_hit(&plp->plane, SECT_HARDTARGET, EF_SECTOR, if (!msl_hit(&plp->plane, SECT_HARDTARGET, EF_SECTOR,
N_SCT_MISS, N_SCT_SMISS, sublaunch, victim)) N_SCT_MISS, N_SCT_SMISS, sublaunch, victim))
CANT_REACH(); CANT_REACH();
dam2 = pln_damage(&plp->plane, 'p', 1); dam2 = pln_damage(&plp->plane, 'p', "");
air_dam += dam2; air_dam += dam2;
use_up_msl: use_up_msl:
plp->plane.pln_effic = 0; plp->plane.pln_effic = 0;
@ -1066,7 +1066,7 @@ air_damage(struct emp_qelem *bombers, coord x, coord y, int mission,
else if (hardtarget != SECT_HARDTARGET) else if (hardtarget != SECT_HARDTARGET)
wu(0, pp->pln_own, "\t\t%d%% hitchance...", hitchance); wu(0, pp->pln_own, "\t\t%d%% hitchance...", hitchance);
if (pct_chance(hitchance)) { if (pct_chance(hitchance)) {
newdam = pln_damage(&plp->plane, 'p', 1); newdam = pln_damage(&plp->plane, 'p', "");
wu(0, pp->pln_own, wu(0, pp->pln_own,
"\t\thit %s %s for %d damage\n", "\t\thit %s %s for %d damage\n",
cname(victim), s, newdam); cname(victim), s, newdam);

View file

@ -114,7 +114,7 @@ msl_launch(struct plnstr *pp, int type, char *what, coord x, coord y,
struct sctstr sect; struct sctstr sect;
int dam; int dam;
dam = pln_damage(pp, 'p', 0) / 2; dam = pln_damage(pp, 'p', NULL) / 2;
if (pp->pln_ship >= 0) { if (pp->pln_ship >= 0) {
shipdamage(&ship, dam); shipdamage(&ship, dam);
putship(ship.shp_uid, &ship); putship(ship.shp_uid, &ship);

View file

@ -30,7 +30,7 @@
* Dave Pare, 1986 * Dave Pare, 1986
* Ken Stevens, 1995 * Ken Stevens, 1995
* Steve McClure, 1998-2000 * Steve McClure, 1998-2000
* Markus Armbruster, 2004-2012 * Markus Armbruster, 2004-2015
*/ */
#include <config.h> #include <config.h>
@ -1004,7 +1004,7 @@ pln_hitchance(struct plnstr *pp, int hardtarget, int type)
} }
int int
pln_damage(struct plnstr *pp, char type, int noisy) pln_damage(struct plnstr *pp, char type, char *noisy)
{ {
struct plchrstr *pcp = plchr + pp->pln_type; struct plchrstr *pcp = plchr + pp->pln_type;
int load, i, hitroll, aim, len; int load, i, hitroll, aim, len;
@ -1039,8 +1039,14 @@ pln_damage(struct plnstr *pp, char type, int noisy)
aim = 100 - aim; aim = 100 - aim;
} }
len = 0; len = snprintf(buf, sizeof(buf), "%s", noisy);
while (i--) { while (i--) {
if (noisy) {
if (len > 75) {
mpr(pp->pln_own, "%s\n", buf);
len = 0;
}
}
dam += roll(6); dam += roll(6);
hitroll = roll(100); hitroll = roll(100);
if (hitroll >= 90) { if (hitroll >= 90) {
@ -1057,10 +1063,6 @@ pln_damage(struct plnstr *pp, char type, int noisy)
len += sprintf(buf + len, "blam"); len += sprintf(buf + len, "blam");
} }
if (noisy) { if (noisy) {
if (len > 75) {
mpr(pp->pln_own, "%s\n", buf);
len = 0;
}
if (i) if (i)
len += sprintf(buf + len, "-"); len += sprintf(buf + len, "-");
} }

View file

@ -569,13 +569,13 @@ shp_missile_interdiction(struct emp_qelem *list, coord newx, coord newy,
if (msl_hit(&plp->plane, if (msl_hit(&plp->plane,
shp_hardtarget(&mvs->unit.ship), EF_SHIP, shp_hardtarget(&mvs->unit.ship), EF_SHIP,
N_SHP_MISS, N_SHP_SMISS, sublaunch, victim)) { N_SHP_MISS, N_SHP_SMISS, sublaunch, victim)) {
dam = pln_damage(&plp->plane, 'p', 1); dam = pln_damage(&plp->plane, 'p', "");
mpr(victim, mpr(victim,
"missile interdiction mission does %d damage to %s!\n", "missile interdiction mission does %d damage to %s!\n",
dam, prship(&mvs->unit.ship)); dam, prship(&mvs->unit.ship));
shp_damage_one(mvs, dam); shp_damage_one(mvs, dam);
} else { } else {
dam = pln_damage(&plp->plane, 'p', 0); dam = pln_damage(&plp->plane, 'p', NULL);
collateral_damage(newx, newy, dam); collateral_damage(newx, newy, dam);
} }
mvs = most_valuable_ship(list, newx, newy); mvs = most_valuable_ship(list, newx, newy);