]> git.pond.sub.org Git - empserver/blobdiff - src/lib/subs/attsub.c
Fix automatic supply of defending and reacting units
[empserver] / src / lib / subs / attsub.c
index fa4ed2d09a126f677234e7ecdd9eb963e35fad38..7f47f1323057d6073e0e1e00d7fc6b30027250fb 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  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
@@ -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;