]> git.pond.sub.org Git - empserver/commitdiff
Fix land unit attack mobility cost
authorMarkus Armbruster <armbru@pond.sub.org>
Sun, 28 Dec 2008 13:01:15 +0000 (14:01 +0100)
committerMarkus Armbruster <armbru@pond.sub.org>
Sun, 28 Dec 2008 17:26:45 +0000 (18:26 +0100)
Land units were erroneously charged the much lower raw path cost,
except when attacking high-mobility terrain (mountains).  Broken in
commit 2673a258, v4.3.6.

src/lib/subs/attsub.c

index bec3fd8ff28b0e2111653ed0aa61e46a19f92d34..61548ba0a64f009a2ab23062f5df47c72df83753 100644 (file)
@@ -966,7 +966,7 @@ ask_olist(int combat_mode, struct combat *off, struct combat *def,
 {
     struct nstr_item ni;
     struct lndstr land;
-    double mobcost;
+    double pathcost, mobcost;
     struct ulist *llp;
     struct lchrstr *lcp;
     double att_val;
@@ -1040,14 +1040,14 @@ ask_olist(int combat_mode, struct combat *off, struct combat *def,
             * 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) {
                    pr("%s does not have enough mobility (%d needed)\n",
                       prland(&land), (int)ceil(mobcost));