diff --git a/include/prototypes.h b/include/prototypes.h index ade09bd0..c717185d 100644 --- a/include/prototypes.h +++ b/include/prototypes.h @@ -330,7 +330,7 @@ extern int gamehours(time_t, int *); extern int has_units(coord, coord, natid, struct lndstr *); extern int has_units_with_mob(coord, coord, natid); extern int adj_units(coord, coord, natid); -extern int is_engineer(int x, int y); +extern int has_helpful_engineer(coord x, coord y, natid cn); /* log.c */ extern void loginit(void); extern void logerror(s_char *, ...); diff --git a/src/lib/common/land.c b/src/lib/common/land.c index 627f7e6f..8ebebfd8 100644 --- a/src/lib/common/land.c +++ b/src/lib/common/land.c @@ -97,14 +97,19 @@ has_units_with_mob(coord x, coord y, natid cn) return 0; } +/* + * Is there a engineer unit at X,Y that can help nation CN? + */ int -is_engineer(int x, int y) +has_helpful_engineer(coord x, coord y, natid cn) { struct nstr_item ni; struct lndstr land; snxtitem_xy(&ni, EF_LAND, x, y); while (nxtitem(&ni, (s_char *)&land)) { + if (land.lnd_own != cn && getrel(getnatp(land.lnd_own), cn) != ALLIED) + continue; if (lchr[(int)land.lnd_type].l_flags & L_ENGINEER) return 1; } diff --git a/src/lib/subs/lndsub.c b/src/lib/subs/lndsub.c index 80f9230a..8799864c 100644 --- a/src/lib/subs/lndsub.c +++ b/src/lib/subs/lndsub.c @@ -1367,7 +1367,7 @@ lnd_fortify (struct lndstr *lp, int hard_amt) if ((lp->lnd_harden + hard_amt) > land_mob_max) hard_amt = land_mob_max - lp->lnd_harden; - eng = is_engineer(lp->lnd_x, lp->lnd_y); + eng = has_helpful_engineer(lp->lnd_x, lp->lnd_y, lp->lnd_own); if (eng) hard_amt = ((float)hard_amt * 1.5);