]> git.pond.sub.org Git - empserver/commitdiff
edit: Fix fortification limit of embarked planes and land units
authorMarkus Armbruster <armbru@pond.sub.org>
Thu, 10 May 2018 16:32:54 +0000 (18:32 +0200)
committerMarkus Armbruster <armbru@pond.sub.org>
Tue, 5 Jan 2021 09:38:57 +0000 (10:38 +0100)
We generally preserve the invariant "land units and missiles loaded on
a land unit or ship are never fortified / hardened": fortify and
harden refuse to touch embarked land units and missiles, load and
lload zap land unit fortification on load, and refuse to load hardened
missiles.

The exception is edit, which happily fortifies embarked land units
(edit u key 'F'), hardens embarked missiles (edit p key 'F'), loads
fortified land units (edit u keys 'S' and 'Y') and hardened planes
(edit p keys 's' and 'y').

Fix the first two by correcting the new value's upper limit to zero
for embarked land units and planes.  The next commit will take care of
the rest.

The fix is visible in tests where test setup fortifies land units with
"edit u * F ?..." without excepting embarked ones.

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

index c345f168f845fdd3ae1b7bc727dc519b0a0da4a0..f843d2b8634e245ce92a4ca296a11e81ed294050 100644 (file)
@@ -31,7 +31,7 @@
  *     Chad Zabel, 1994
  *     Steve McClure, 1998-2000
  *     Ron Koenderink, 2003-2009
- *     Markus Armbruster, 2003-2017
+ *     Markus Armbruster, 2003-2018
  */
 
 #include <config.h>
@@ -1001,6 +1001,8 @@ edit_land(struct lndstr *land, char *key, char *p)
        break;
     case 'F':
        arg = LIMIT_TO(arg, 0, 127);
+       if (land->lnd_ship >= 0 || land->lnd_land >= 0)
+           arg = 0;
        divine_unit_change((struct empobj *)land, "Fortification",
                           arg != land->lnd_harden, arg - land->lnd_harden,
                           "from %d to %d", land->lnd_harden, arg);
@@ -1134,7 +1136,10 @@ edit_plane(struct plnstr *plane, char *key, char *p)
        pln_set_tech(plane, arg);
        break;
     case 'F':
-       arg = LIMIT_TO(arg, 0, pcp->pl_flags & P_M ? 127 : 0);
+       arg = LIMIT_TO(arg, 0, 127);
+       if (!(pcp->pl_flags & P_M)
+           || plane->pln_ship >= 0 || plane->pln_land >= 0)
+           arg = 0;
        divine_unit_change((struct empobj *)plane, "Fortification",
                           arg != plane->pln_harden, arg - plane->pln_harden,
                           "from %d to %d", plane->pln_harden, arg);
index 89882198f486879365261e65703e75259b52f624..e0603ad6c33db0e9641ed1e285387d3f8ee103ee 100644 (file)
@@ -213,8 +213,8 @@ uid owner xloc yloc type effic mobil off tech opx opy mission radius army ship h
 11 2 1 1 0 100 127 0 30 1 1 reserve 3 "" -1 127 42 (bombed) "hhhhn" 0 5 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0
 12 1 1 1 0 100 127 0 30 1 1 reserve 3 "" -1 127 42 (bombed) "hhhhn" 0 5 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0
 13 1 1 1 0 100 127 0 30 1 1 reserve 3 "" -1 127 42 (bombed) "hhhhn" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0
-14 1 1 1 0 100 127 0 30 1 1 reserve 3 "" 1 127 42 (bombed) "hhhhn" 0 2 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0
-15 1 1 1 0 100 127 0 30 1 1 reserve 3 "" -1 127 42 (bombed) "hhhhn" 0 2 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 1 0
+14 1 1 1 0 100 127 0 30 1 1 reserve 3 "" 1 0 42 (bombed) "hhhhn" 0 2 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0
+15 1 1 1 0 100 127 0 30 1 1 reserve 3 "" -1 0 42 (bombed) "hhhhn" 0 2 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 1 0
 20 1 3 3 0 100 105 0 30 1 3 none 3 "" -1 0 42 () "" 0 5 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0
 21 1 2 4 0 100 105 0 30 1 3 none 3 "" -1 0 42 () "" 0 5 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0
 22 1 3 3 7 100 60 0 40 0 0 none 0 "" -1 0 42 () "" 0 5 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0
index f6e94d1d4da6d5dfba3edff0c7e91145bca9729e..c98402f058a26f5f8d2e5d250245051e6d1c72e0 100644 (file)
     Play#0 output Play#0 1   2   11 cav  cavalry       1,1       100%   5 127 127   0  30  42%  0  0
     Play#0 output Play#0 1   1   12 cav  cavalry       1,1       100%   5 127 127   0  30  42%  0  0
     Play#0 output Play#0 1   1   13 cav  cavalry       1,1       100%   0 127 127   0  30  42%  0  0
-    Play#0 output Play#0 1   1   14 cav  cavalry       1,1       100%   2 127 127   0  30  42%  0  0    1S
-    Play#0 output Play#0 1   1   15 cav  cavalry       1,1       100%   2 127 127   0  30  42%  0  0    1L
+    Play#0 output Play#0 1   1   14 cav  cavalry       1,1       100%   2   0 127   0  30  42%  0  0    1S
+    Play#0 output Play#0 1   1   15 cav  cavalry       1,1       100%   2   0 127   0  30  42%  0  0    1L
     Play#0 output Play#0 1   1   20 cav  cavalry       3,3       100%   5   0 105   0  30  42%  0  0
     Play#0 output Play#0 1   1   21 cav  cavalry       2,4       100%   5   0 105   0  30  42%  0  0
     Play#0 output Play#0 1   1   22 tra  train         3,3       100%   5   0  60   0  40  42%  0  0
index 2cbcb8df9e530976247573ee841dda85c7dfde86..e5836501abe8eb3bf9b4e72bf7672d9c495039e0 100644 (file)
@@ -125,10 +125,10 @@ uid owner xloc yloc type effic mobil off tech opx opy mission radius army ship h
 28 2 2 2 0 100 107 0 50 3 1 none 3 "g" -1 0 42 (group injured) "g" 0 10 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0
 29 2 4 0 0 100 127 0 50 4 0 reserve 3 "g" -1 127 42 (group bombed) "bhg" 0 10 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0
 30 0 0 2 0 0 105 0 50 0 2 reserve 3 "c" -1 127 42 (group bombed) "j" 0 9 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0
-31 2 0 2 0 100 127 0 50 0 2 reserve 3 "c" 35 127 42 (group bombed) "j" 0 10 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0
+31 2 0 2 0 99 126 0 50 0 2 reserve 3 "c" 35 0 42 (group bombed) "j" 0 10 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0
 32 2 0 2 0 100 127 0 50 0 2 reserve 3 "c" -1 127 42 (group bombed) "j" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0
 33 2 -1 1 0 85 108 0 50 -1 1 reserve 3 "" -1 127 42 (bombed) "j" 0 9 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0
-34 2 0 2 0 100 127 0 50 0 2 reserve 3 "c" -1 127 42 (group bombed) "j" 0 10 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 9 0
+34 2 0 2 0 99 126 0 50 0 2 reserve 3 "c" -1 0 42 (group bombed) "j" 0 10 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 9 0
 35 2 0 2 0 100 0 0 50 0 2 reserve 3 "c" -1 127 42 (group bombed) "j" 0 10 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0
 36 2 0 2 0 100 127 0 50 0 2 reserve 3 "c" -1 127 42 (group bombed) "j" 0 10 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0
 37 2 1 1 7 82 105 0 50 0 0 none 0 "" -1 127 42 (bombed) "j" 0 9 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0
index 96438e58eff2cf216d89f579b7b2a069a93cfed3..a849edf3b6d075d6ab3dacbab1ec884bf2298b01 100644 (file)
     Play#0 output Play#0 1 cav  cavalry #36 is on the trading block, and can't retreat!
     Play#0 output Play#0 1 0,2 takes 4% collateral damage
     Play#0 output Play#0 1     tra  train #9 takes 1
+    Play#0 output Play#0 1     cav  cavalry #31 takes 1
+    Play#0 output Play#0 1     cav  cavalry #34 takes 1
     Play#0 output Play#0 1 1 planes spotted over -1,1
     Play#0 output Play#0 1 1 bombs did 40% damage to cav  cavalry #33 at -1,1
     Play#0 output Play#0 1     cav  cavalry #33 takes 15
     Play#0 output Play#0 1   2   27 cav  cavalry       3,1    g  100%  10 127 127   0  50  42%  0  0
     Play#0 output Play#0 1   2   28 cav  cavalry       2,2    g  100%  10   0 107   0  50  42%  0  0
     Play#0 output Play#0 1   2   29 cav  cavalry       4,0    g  100%  10 127 127   0  50  42%  0  0
-    Play#0 output Play#0 1   2   31 cav  cavalry       0,2    c  100%  10 127 127   0  50  42%  0  0   35S
+    Play#0 output Play#0 1   2   31 cav  cavalry       0,2    c   99%  10   0 126   0  50  42%  0  0   35S
     Play#0 output Play#0 1   2   32 cav  cavalry       0,2    c  100%   0 127 127   0  50  42%  0  0
     Play#0 output Play#0 1   2   33 cav  cavalry      -1,1        85%   9 127 108   0  50  42%  0  0
-    Play#0 output Play#0 1   2   34 cav  cavalry       0,2    c  100%  10 127 127   0  50  42%  0  0    9L
+    Play#0 output Play#0 1   2   34 cav  cavalry       0,2    c   99%  10   0 126   0  50  42%  0  0    9L
     Play#0 output Play#0 1   2   35 cav  cavalry       0,2    c  100%  10 127   0   0  50  42%  0  0
     Play#0 output Play#0 1   2   36 cav  cavalry       0,2    c  100%  10 127 127   0  50  42%  0  0
     Play#0 output Play#0 1   2   37 tra  train         1,1        82%   9 127 105   0  50  42%  0  0