/*
* Empire - A multi-player, client/server Internet based war game.
- * Copyright (C) 1986-2013, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ * Copyright (C) 1986-2016, Dave Pare, Jeff Bailey, Thomas Ruschak,
* Ken Stevens, Steve McClure, Markus Armbruster
*
* Empire is free software: you can redistribute it and/or modify
* Known contributors to this file:
* Ken Stevens, 1995
* Steve McClure, 1996-2000
- * Markus Armbruster, 2003-2012
+ * Markus Armbruster, 2003-2015
*/
#include <config.h>
act[0] = 0;
for (cn = 1; cn < MAXNOC; cn++) {
act[cn] = relations_with(cn, victim) <= HOSTILE;
- emp_initque((struct emp_qelem *)&mi[cn]);
+ emp_initque(&mi[cn].queue);
}
build_mission_list(mi, act, act, x, y, MI_INTERDICT);
other_act[cn] = rel <= HOSTILE;
plane_act[cn] = mission == MI_SINTERDICT
? rel <= NEUTRAL : other_act[cn];
- emp_initque((struct emp_qelem *)&mi[cn]);
+ emp_initque(&mi[cn].queue);
}
build_mission_list(mi, other_act, plane_act, x, y, mission);
}
/*
- * Perform support missions in X,Y against VICTIM for ACTEE.
- * MISSION is either MI_OSUPPORT or MI_DSUPPORT.
+ * Perform support missions in @x,@y against @victim for @actee.
+ * @mission is either MI_OSUPPORT or MI_DSUPPORT.
* Return total damage.
*/
static int
act[0] = 0;
for (cn = 1; cn < MAXNOC; cn++) {
act[cn] = feels_like_helping(cn, actee, victim);
- emp_initque((struct emp_qelem *)&mi[cn]);
+ emp_initque(&mi[cn].queue);
}
build_mission_list(mi, act, act, x, y, MI_SUPPORT);
snxtitem_all(&ni, type);
while (nxtitem(&ni, &item)) {
- gp = (struct empobj *)&item;
+ gp = &item.gen;
if (!act[gp->own])
continue;
wu(0, sp->shp_own,
"\tEffective torpedo range is %d.0\n", range);
wu(0, sp->shp_own,
- "\tWhooosh... Hitchance = %d%%\n",
- (int)(hitchance * 100));
+ "\tWhooosh... Hitchance = %.0f%%\n", hitchance * 100);
if (!chance(hitchance)) {
wu(0, sp->shp_own, "\tMissed\n");
if (!msl_hit(&plp->plane, SECT_HARDTARGET, EF_SECTOR,
N_SCT_MISS, N_SCT_SMISS, sublaunch, victim))
CANT_REACH();
- dam2 = pln_damage(&plp->plane, 'p', 1);
+ dam2 = pln_damage(&plp->plane, 'p', "");
air_dam += dam2;
use_up_msl:
plp->plane.pln_effic = 0;
}
/*
- * Maximum distance GP can perform its mission.
+ * Maximum distance @gp can perform its mission.
* Note: this has nothing to do with the radius of the op-area.
* oprange() governs where the unit *can* strike, the op-area governs
* where the player wants it to strike.
}
/*
- * Does GP's mission op area cover X,Y?
+ * Does @gp's mission op area cover @x,@y?
*/
int
in_oparea(struct empobj *gp, coord x, coord y)
getsect(x, y, §);
a->own = sect.sct_own;
- emp_insque((struct emp_qelem *)a, airp);
+ emp_insque(&a->queue, airp);
}
/*
struct plist *plp;
struct plnstr *pp;
int newdam, dam = 0;
+ char buf[32];
int hitchance;
for (qp = bombers->q_forw; qp != bombers; qp = qp->q_forw) {
"\t%s pinbombing %s %s in %s\n",
prplane(pp), cname(victim), s, xyas(x, y, pp->pln_own));
}
- hitchance = pln_hitchance(pp, hardtarget, EF_SHIP);
+
+ buf[0] = 0;
if (nuk_on_plane(&plp->plane) >= 0)
hitchance = 100;
- else if (hardtarget != SECT_HARDTARGET)
- wu(0, pp->pln_own, "\t\t%d%% hitchance...", hitchance);
+ else {
+ hitchance = pln_hitchance(pp, hardtarget, EF_SHIP);
+ if (hardtarget != SECT_HARDTARGET)
+ snprintf(buf, sizeof(buf), "\t\t%d%% hitchance...",
+ hitchance);
+ }
if (pct_chance(hitchance)) {
- newdam = pln_damage(&plp->plane, 'p', 1);
+ newdam = pln_damage(&plp->plane, 'p', buf);
wu(0, pp->pln_own,
"\t\thit %s %s for %d damage\n",
cname(victim), s, newdam);
dam += newdam;
} else {
- newdam = pln_damage(&plp->plane, 'p', 0);
- wu(0, pp->pln_own, "missed\n");
+ newdam = pln_damage(&plp->plane, 'p', NULL);
+ wu(0, pp->pln_own, "%smissed\n", buf);
if (mission == MI_SINTERDICT) {
mpr(victim,
"RUMBLE... your sub in %s hears a depth-charge explode nearby\n",