Fix automatic supply of defending and reacting units
Being in supply is relevant for defending and reacting units. The code used has_supply() to check that. Contrary to its name, has_supply() does not check whether the land unit has enough supplies to be in supply, but whether it has or could draw enough. So, defending and reacting units did not actually draw any missing supplies. Fix that in get_dlist() and att_reacting_units() by calling resupply_all(), then checking with new lnd_in_supply() instead of has_supply(). The fix of att_reacting_units() is complicated by the fact that it is also used in the strength command, and should keep not drawing supplies there. Rename has_supply() to lnd_could_be_supplied(). Replace its uses immediately after resupply_all() by lnd_in_supply().
This commit is contained in:
parent
07561b4772
commit
5ea0d19c20
6 changed files with 30 additions and 10 deletions
|
@ -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",
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue