/*
* Empire - A multi-player, client/server Internet based war game.
- * Copyright (C) 1986-2008, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ * Copyright (C) 1986-2009, Dave Pare, Jeff Bailey, Thomas Ruschak,
* Ken Stevens, Steve McClure
*
* This program is free software; you can redistribute it and/or modify
{
struct nstr_item ni;
struct lndstr land;
- double mobcost;
+ double pathcost, mobcost;
+ int reqmob;
struct ulist *llp;
struct lchrstr *lcp;
double att_val;
* of high-mobility sectors (mountains): for those we
* still require attack mobility.
*/
- mobcost = att_mobcost(off->own, def, lnd_mobtype(&land));
- if (mobcost < 1.0) {
+ pathcost = att_mobcost(off->own, def, lnd_mobtype(&land));
+ mobcost = lnd_pathcost(&land, pathcost);
+ if (pathcost < 1.0) {
if (land.lnd_mobil <= 0) {
pr("%s is out of mobility\n", prland(&land));
continue;
}
} else {
- mobcost = lnd_pathcost(&land, mobcost);
- if (land.lnd_mobil < mobcost) {
+ reqmob = MIN(land_mob_max, (int)ceil(mobcost));
+ if (land.lnd_mobil < reqmob) {
pr("%s does not have enough mobility (%d needed)\n",
- prland(&land), (int)ceil(mobcost));
+ prland(&land), reqmob);
continue;
}
}
}
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;
}
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)
while (nxtitem(&ni, &land) && dtotal + new_land * eff < 1.2 * ototal) {
if (!land.lnd_own)
continue;
- if (!land.lnd_rad_max)
+ if (land.lnd_mission != MI_RESERVE)
continue;
if ((land.lnd_x == def->x) && (land.lnd_y == def->y))
continue;
continue;
/* Only supplied units can react */
- if (!has_supply(&land))
- continue;
-
- if (land.lnd_mission == MI_RESERVE) {
- if (!in_oparea((struct empobj *)&land, def->x, def->y))
+ if (list) {
+ resupply_all(&land);
+ putland(land.lnd_uid, &land);
+ if (!lnd_in_supply(&land))
continue;
} else {
- if (mapdist(land.lnd_x, land.lnd_y, def->x, def->y)
- > lnd_reaction_range(&land))
+ if (!lnd_could_be_supplied(&land))
continue;
}
+ if (!in_oparea((struct empobj *)&land, def->x, def->y))
+ continue;
+
getsect(land.lnd_x, land.lnd_y, §);
getsect(def->x, def->y, &dsect);
if (!BestLandPath(buf, §, &dsect, &pathcost,