Use feels_like_helping() in dosupport(), lnd_support()
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.
This commit is contained in:
parent
c095ad285b
commit
89bc9c4d5b
2 changed files with 10 additions and 11 deletions
|
@ -1068,16 +1068,15 @@ lnd_mar_one_sector(struct emp_qelem *list, int dir, natid actor,
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* find all artillery units belonging
|
* Fire land unit support against VICTIM for ATTACKER, at X,Y.
|
||||||
* to the attacker or defender that can fire.
|
* If DEFENDING, this is defensive support, else offensive support.
|
||||||
* Each arty unit adds +1%/damage point
|
* Return total damage.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
lnd_support(natid victim, natid attacker, coord x, coord y, int defending)
|
lnd_support(natid victim, natid attacker, coord x, coord y, int defending)
|
||||||
{
|
{
|
||||||
struct nstr_item ni;
|
struct nstr_item ni;
|
||||||
struct lndstr land;
|
struct lndstr land;
|
||||||
int rel, rel2;
|
|
||||||
int dam, dam2;
|
int dam, dam2;
|
||||||
int dist;
|
int dist;
|
||||||
int range;
|
int range;
|
||||||
|
@ -1087,10 +1086,7 @@ lnd_support(natid victim, natid attacker, coord x, coord y, int defending)
|
||||||
while (nxtitem(&ni, &land)) {
|
while (nxtitem(&ni, &land)) {
|
||||||
if ((land.lnd_x == x) && (land.lnd_y == y))
|
if ((land.lnd_x == x) && (land.lnd_y == y))
|
||||||
continue;
|
continue;
|
||||||
rel = getrel(getnatp(land.lnd_own), attacker);
|
if (!feels_like_helping(land.lnd_own, attacker, victim))
|
||||||
rel2 = getrel(getnatp(land.lnd_own), victim);
|
|
||||||
if ((land.lnd_own != attacker) &&
|
|
||||||
((rel != ALLIED) || (rel2 != AT_WAR)))
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* are we in range? */
|
/* are we in range? */
|
||||||
|
|
|
@ -231,6 +231,11 @@ def_support(coord x, coord y, natid victim, natid actee)
|
||||||
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
|
static int
|
||||||
dosupport(coord x, coord y, natid victim, natid actee, int mission)
|
dosupport(coord x, coord y, natid victim, natid actee, int mission)
|
||||||
{
|
{
|
||||||
|
@ -243,9 +248,7 @@ dosupport(coord x, coord y, natid victim, natid actee, int mission)
|
||||||
memset(mi, 0, sizeof(mi));
|
memset(mi, 0, sizeof(mi));
|
||||||
act[0] = 0;
|
act[0] = 0;
|
||||||
for (cn = 1; cn < MAXNOC; cn++) {
|
for (cn = 1; cn < MAXNOC; cn++) {
|
||||||
act[cn] = (cn == actee
|
act[cn] = feels_like_helping(cn, actee, victim);
|
||||||
|| (getrel(getnatp(cn), actee) == ALLIED
|
|
||||||
&& getrel(getnatp(cn), victim) == AT_WAR));
|
|
||||||
emp_initque((struct emp_qelem *)&mi[cn]);
|
emp_initque((struct emp_qelem *)&mi[cn]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue