diff --git a/include/prototypes.h b/include/prototypes.h index 8a580c54..1d3ac26f 100644 --- a/include/prototypes.h +++ b/include/prototypes.h @@ -682,7 +682,8 @@ extern void snxtsct_dist(struct nstr_sect *, coord, coord, int); extern void resupply_all(struct lndstr *); extern void resupply_commod(struct lndstr *, i_type); extern int supply_commod(int, int, int, i_type, int); -extern int has_supply(struct lndstr *); +extern int lnd_in_supply(struct lndstr *); +extern int lnd_could_be_supplied(struct lndstr *); /* takeover.c */ extern void takeover_land(struct lndstr *, natid); extern void takeover(struct sctstr *, natid); diff --git a/src/lib/commands/load.c b/src/lib/commands/load.c index e6ff0b43..b809a08b 100644 --- a/src/lib/commands/load.c +++ b/src/lib/commands/load.c @@ -653,7 +653,7 @@ load_land_ship(struct sctstr *sectp, struct shpstr *sp, int noisy, resupply_all(&land); #endif putland(land.lnd_uid, &land); - if (!has_supply(&land)) + if (!lnd_in_supply(&land)) pr("WARNING: %s is out of supply!\n", prland(&land)); } else { sprintf(buf, "unloaded in your %s at %s", @@ -999,7 +999,7 @@ load_land_land(struct sctstr *sectp, struct lndstr *lp, int noisy, resupply_all(&land); #endif putland(land.lnd_uid, &land); - if (!has_supply(&land)) + if (!lnd_in_supply(&land)) pr("WARNING: %s is out of supply!\n", prland(&land)); } else { sprintf(buf, "unloaded in your %s at %s", diff --git a/src/lib/commands/stre.c b/src/lib/commands/stre.c index ee3c94c4..20a96083 100644 --- a/src/lib/commands/stre.c +++ b/src/lib/commands/stre.c @@ -138,7 +138,7 @@ units_in_sector(struct combat *def) if (land.lnd_ship >= 0) continue; d_unit = defense_val(&land); - if (!has_supply(&land)) + if (!lnd_could_be_supplied(&land)) d_unit /= 2.0; dtotal += d_unit; } diff --git a/src/lib/commands/supp.c b/src/lib/commands/supp.c index 90d31c0f..61f64c04 100644 --- a/src/lib/commands/supp.c +++ b/src/lib/commands/supp.c @@ -53,7 +53,7 @@ supp(void) nunits++; resupply_all(&land); putland(land.lnd_uid, &land); - if (has_supply(&land)) + if (lnd_in_supply(&land)) pr("%s has supplies\n", prland(&land)); else pr("%s is out of supply\n", prland(&land)); diff --git a/src/lib/subs/attsub.c b/src/lib/subs/attsub.c index ba877e3e..7f47f132 100644 --- a/src/lib/subs/attsub.c +++ b/src/lib/subs/attsub.c @@ -1074,7 +1074,7 @@ ask_olist(int combat_mode, struct combat *off, struct combat *def, } resupply_all(&land); putland(land.lnd_uid, &land); - if (!has_supply(&land)) { + if (!lnd_in_supply(&land)) { pr("%s is out of supply, and cannot %s\n", prland(&land), att_mode[combat_mode]); continue; @@ -1235,7 +1235,9 @@ get_dlist(struct combat *def, struct emp_qelem *list, int a_spy, } memset(llp, 0, sizeof(struct ulist)); emp_insque(&llp->queue, list); - llp->supplied = has_supply(&land); + resupply_all(&land); + putland(land.lnd_uid, &land); + llp->supplied = lnd_in_supply(&land); if (!get_land(A_DEFEND, def, land.lnd_uid, llp, 1)) continue; if (lnd_spyval(&land) > *d_spyp) @@ -1499,8 +1501,15 @@ att_reacting_units(struct combat *def, struct emp_qelem *list, int a_spy, continue; /* Only supplied units can react */ - if (!has_supply(&land)) - continue; + if (list) { + resupply_all(&land); + putland(land.lnd_uid, &land); + if (!lnd_in_supply(&land)) + continue; + } else { + if (!lnd_could_be_supplied(&land)) + continue; + } if (!in_oparea((struct empobj *)&land, def->x, def->y)) continue; diff --git a/src/lib/subs/supply.c b/src/lib/subs/supply.c index ce5bf894..d112cea8 100644 --- a/src/lib/subs/supply.c +++ b/src/lib/subs/supply.c @@ -86,6 +86,16 @@ resupply_commod(struct lndstr *lp, i_type type) } } +int +lnd_in_supply(struct lndstr *lp) +{ + if (!opt_NOFOOD) { + if (lp->lnd_item[I_FOOD] < get_minimum(lp, I_FOOD)) + return 0; + } + return lp->lnd_item[I_SHELL] >= get_minimum(lp, I_SHELL); +} + /* * Actually get the commod */ @@ -410,7 +420,7 @@ get_minimum(struct lndstr *lp, i_type type) } int -has_supply(struct lndstr *lp) +lnd_could_be_supplied(struct lndstr *lp) { int shells_needed, shells, keepshells; int food, food_needed, keepfood;