]> git.pond.sub.org Git - empserver/commitdiff
board: Fix mobility cost when defender's efficiency < 100%
authorMarkus Armbruster <armbru@pond.sub.org>
Tue, 3 Feb 2015 06:44:23 +0000 (07:44 +0100)
committerMarkus Armbruster <armbru@pond.sub.org>
Mon, 2 Mar 2015 07:20:51 +0000 (08:20 +0100)
The cost is meant to be proportional to efficiency / 100, but the code
truncates the fraction to zero.  Broken in Empire 2.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
src/lib/subs/attsub.c
tests/retreat/final.xdump
tests/retreat/journal.log

index 4248f19e31e9bbf628012fe727aa0359547750a9..955cdd24b52bba231ea11d9bdc24ce627ff3ba36 100644 (file)
@@ -856,7 +856,7 @@ calc_mobcost(int combat_mode, struct combat *off, struct combat *def,
        case EF_SHIP:
            /* the 2 in the formula below is a fudge factor */
            getship(def->shp_uid, &ship);
-           off->mobcost += (def->eff / 100) * (shp_speed(&ship) / 2);
+           off->mobcost += shp_speed(&ship) / 2 * def->eff / 100;
        }
     }
 }
index 874d35b0ad74c047de6ef5f48cc2f930d26d3766..aa32bc4f912a5417c047f46c8b5357bd1663331e 100644 (file)
@@ -30,7 +30,7 @@ uid owner xloc yloc type effic mobil off tech opx opy mission radius fleet civil
 2 1 -3 1 10 93 118 0 45 0 0 none 0 "" 0 9 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 0 "" -3 1 1 (injured torpedoed sonared helpless bombed depth-charged boarded) "bgyujnbgy"
 3 1 -3 1 10 100 127 0 45 0 0 none 0 "a" 0 10 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 0 "" -3 1 1 () ""
 4 1 -5 1 10 100 127 0 45 0 0 none 0 "a" 0 10 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 0 "" -3 1 1 (group helpless) "b"
-5 1 -5 1 17 96 63 0 70 0 0 none 0 "" 0 6 31 1 0 0 0 0 0 0 0 0 0 0 healthy 0 0 "" -3 1 1 () ""
+5 1 -5 1 17 96 61 0 70 0 0 none 0 "" 0 6 31 1 0 0 0 0 0 0 0 0 0 0 healthy 0 0 "" -3 1 1 () ""
 6 1 -1 3 18 100 97 0 165 0 0 none 0 "" 0 10 21 1 0 0 0 0 0 0 0 0 0 0 healthy 0 0 "" -3 1 1 () ""
 7 1 -5 1 10 100 127 0 45 0 0 none 0 "a" 0 10 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 0 "" -3 1 1 (group helpless) "b"
 9 2 -4 -2 17 60 127 0 70 0 0 none 0 "" 0 60 38 1 0 0 0 0 0 0 0 0 0 0 healthy 0 0 "" -3 1 1 () ""
index fee3e622b2e172b1ecdb3736f28ba4137283495a..16343a97bb53f4706b73b85428a535bb5fdcc21d 100644 (file)
     Play#0 output Play#0 1   1    2 lc   light cruis   -3,1        93%   0   9   0   0  0  0  0  0 118   45
     Play#0 output Play#0 1   1    3 lc   light cruis   -3,1    a  100%   0  10   0   0  0  0  0  0 127   45
     Play#0 output Play#0 1   1    4 lc   light cruis   -5,1    a  100%   0  10   0   0  0  0  0  0 127   45
-    Play#0 output Play#0 1   1    5 dd   destroyer     -5,1        96%   0   6   0   0  0  0  0  0  63   70
+    Play#0 output Play#0 1   1    5 dd   destroyer     -5,1        96%   0   6   0   0  0  0  0  0  61   70
     Play#0 output Play#0 1   1    6 sb   submarine     -1,3       100%   0  10   0   0  0  0  0  0  97  165
     Play#0 output Play#0 1   1    7 lc   light cruis   -5,1    a  100%   0  10   0   0  0  0  0  0 127   45
     Play#0 output Play#0 1   2    9 dd   destroyer     -4,-2       60%   0  60   0   0  0  0  0  0 127   70