feels_like_helping() case cn == foe is missing in the code it
replaces. No difference in behavior, because:
* cn == foe && cn == friend can't happen. Because you can't get into
ground combat against yourself (assault, attack and paradrop don't
let you), friend != foe for support.
* cn == foe && cn != friend behaves the same: no support.
feels_like_helping() returns 0 because of the explicit case. The
replaced code doesn't support because cn can't be at war with
itself.
- * find all artillery units belonging
- * to the attacker or defender that can fire.
- * Each arty unit adds +1%/damage point
+ * Fire land unit support against VICTIM for ATTACKER, at X,Y.
+ * If DEFENDING, this is defensive support, else offensive support.
+ * Return total damage.
*/
int
lnd_support(natid victim, natid attacker, coord x, coord y, int defending)
{
struct nstr_item ni;
struct lndstr land;
*/
int
lnd_support(natid victim, natid attacker, coord x, coord y, int defending)
{
struct nstr_item ni;
struct lndstr land;
int dam, dam2;
int dist;
int range;
int dam, dam2;
int dist;
int range;
while (nxtitem(&ni, &land)) {
if ((land.lnd_x == x) && (land.lnd_y == y))
continue;
while (nxtitem(&ni, &land)) {
if ((land.lnd_x == x) && (land.lnd_y == y))
continue;
- rel = getrel(getnatp(land.lnd_own), attacker);
- rel2 = getrel(getnatp(land.lnd_own), victim);
- if ((land.lnd_own != attacker) &&
- ((rel != ALLIED) || (rel2 != AT_WAR)))
+ if (!feels_like_helping(land.lnd_own, attacker, victim))
continue;
/* are we in range? */
continue;
/* are we in range? */
return dosupport(x, y, victim, actee, MI_DSUPPORT);
}
return dosupport(x, y, victim, actee, 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
dosupport(coord x, coord y, natid victim, natid actee, int mission)
{
static int
dosupport(coord x, coord y, natid victim, natid actee, int mission)
{
memset(mi, 0, sizeof(mi));
act[0] = 0;
for (cn = 1; cn < MAXNOC; cn++) {
memset(mi, 0, sizeof(mi));
act[0] = 0;
for (cn = 1; cn < MAXNOC; cn++) {
- act[cn] = (cn == actee
- || (getrel(getnatp(cn), actee) == ALLIED
- && getrel(getnatp(cn), victim) == AT_WAR));
+ act[cn] = feels_like_helping(cn, actee, victim);
emp_initque((struct emp_qelem *)&mi[cn]);
}
emp_initque((struct emp_qelem *)&mi[cn]);
}