]> git.pond.sub.org Git - empserver/commitdiff
tend: Don't tend land units to multiple target ships
authorMarkus Armbruster <armbru@pond.sub.org>
Mon, 11 Sep 2017 05:37:49 +0000 (07:37 +0200)
committerMarkus Armbruster <armbru@pond.sub.org>
Tue, 5 Jan 2021 06:25:17 +0000 (07:25 +0100)
Each land unit is tended to each target ship in turn, and ends up on
the last one that can take it..  The load-tend test demonstrates this
with command "tend land 173 s 150/165":

    spy  infiltrator #320 transferred from sbc  cargo submarine (#173) to cs   cargo ship (#150)
    spy  infiltrator #320 transferred from sbc  cargo submarine (#173) to ls   landing ship (#165)
    spy  infiltrator #321 is not on sbc  cargo submarine (#173)!
    spy  infiltrator #322 transferred from sbc  cargo submarine (#173) to cs   cargo ship (#150)
    spy  infiltrator #322 transferred from sbc  cargo submarine (#173) to ls   landing ship (#165)

Has been that way ever since Empire 2 added tending of land units.

Fix by breaking tend_land()'s loop over all target ships after a
successful transfer.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
src/lib/commands/tend.c
tests/load-tend/03-tend-1
tests/load-tend/final.xdump
tests/load-tend/journal.log

index 57256d780607b29160bfb55d097d421b8535bcad..d9482b22f19e544431e665383964544275bf53c3 100644 (file)
@@ -30,7 +30,7 @@
  *     Dave Pare, 1986
  *     Thomas Ruschak, 1992
  *     Steve McClure, 2000
- *     Markus Armbruster, 2004-2012
+ *     Markus Armbruster, 2004-2017
  */
 
 #include <config.h>
@@ -280,6 +280,7 @@ tend_land(struct shpstr *tenderp, char *units)
            expose_ship(tenderp, &target);
            putship(target.shp_uid, &target);
            putship(tenderp->shp_uid, tenderp);
+           break;
        }
     }
     return 0;
index dac00d4c225de3ebe41f5d18d9bef9d91341b2e8..ad756eba14313bc46f043831a625ea2dcd85a4af 100644 (file)
@@ -173,7 +173,6 @@ tend land 165 320/321/322 171
 tend land 165/171 s 173
 | spy can use light and non-light slot
 tend land 173 s 150/165
-| BUG: #173 transfers spy first to #150, then same spy to #165
 |
 || to foreign ships
 tend land 166 330 162
index 07a678d8ae2aa46a1b5f535194f277e08100a89d..8d55fe0004deaa273dafbf9dd09687e3e97208be 100644 (file)
@@ -458,7 +458,7 @@ uid owner xloc yloc type effic mobil off tech opx opy mission radius army ship h
 315 1 1 -1 1 100 60 0 40 1 -1 none 0 "" 165 0 42 () "" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0
 316 1 1 -1 1 100 60 0 40 1 -1 none 0 "" 165 0 42 () "" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0
 317 1 1 -1 1 100 60 0 40 1 -1 none 0 "" 165 0 42 () "" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0
-320 1 1 -1 8 100 60 0 40 1 -1 none 0 "s" 165 0 42 () "" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0
+320 1 1 -1 8 100 60 0 40 1 -1 none 0 "s" 150 0 42 () "" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0
 321 1 1 -1 8 100 60 0 40 1 -1 none 0 "s" 171 0 42 () "" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0
 322 1 1 -1 8 100 60 0 40 1 -1 none 0 "s" 172 0 42 () "" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0
 330 2 0 -2 1 100 60 0 40 0 0 none 0 "" 162 0 42 () "" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0
index 74c1db2191763f04e815dd278ff16c0c19c0f076..49742005e84071ab60381681c6a7e65b0a81ddfd 100644 (file)
     Play#1 input tend land 173 s 150/165
     Play#1 command tend
     Play#1 output Play#1 1 spy  infiltrator #320 transferred from sbc  cargo submarine (#173) to cs   cargo ship (#150)
-    Play#1 output Play#1 1 spy  infiltrator #320 transferred from sbc  cargo submarine (#173) to ls   landing ship (#165)
     Play#1 output Play#1 1 spy  infiltrator #321 is not on sbc  cargo submarine (#173)!
-    Play#1 output Play#1 1 spy  infiltrator #322 transferred from sbc  cargo submarine (#173) to cs   cargo ship (#150)
+    Play#1 output Play#1 1 cs   cargo ship (#150) doesn't have room for any more land units!
     Play#1 output Play#1 1 spy  infiltrator #322 transferred from sbc  cargo submarine (#173) to ls   landing ship (#165)
     Play#1 output Play#1 6 0 381
     Play#1 input tend land 166 330 162
     Play#0 output Play#0 1   1  112 cs   cargo ship    -2,0       100%   0   0   0   0  0  0  0  2  90  145
     Play#0 output Play#0 1   1  113 sbc  cargo subma   -2,0       100%   0   0   0   0  0  0  0  1  90  150
     Play#0 output Play#0 1   1  115 cs   cargo ship    -2,0       100%   0   0   0   0  0  0  0  2  90  150
-    Play#0 output Play#0 1   1  150 cs   cargo ship     1,-1   t  100%  17  17  23  19  0  0  0  1  90  145
+    Play#0 output Play#0 1   1  150 cs   cargo ship     1,-1   t  100%  17  17  23  19  0  0  0  2  90  145
     Play#0 output Play#0 1   1  151 cs   cargo ship     1,-1   t  100%  17  17  23  21  0  0  0  0  90  145
     Play#0 output Play#0 1   1  152 cs   cargo ship     1,-1   t  100%  22  22  18  20  0  0  0  0  90  145
     Play#0 output Play#0 1   1  153 cs   cargo ship     1,-1   t  100%  22  22  18  21  0  0  0  1  90  145
     Play#0 output Play#0 1   2  162 cs   cargo ship     0,-2   u  100%  20  20  20  25  0  0  0  1  90  145
     Play#0 output Play#0 1   3  163 cs   cargo ship     0,-2   u  100%  20  20  20  25  0  0  0  1  90  145
     Play#0 output Play#0 1   4  164 cs   cargo ship     0,-2   u  100%  20  19  20  21  0  0  0  0  90  145
-    Play#0 output Play#0 1   1  165 ls   landing shi    1,-1      100%   0  20   0  20  0  0  0  4  90  145
+    Play#0 output Play#0 1   1  165 ls   landing shi    1,-1      100%   0  20   0  20  0  0  0  3  90  145
     Play#0 output Play#0 1   1  166 cs   cargo ship     0,-2      100%  20  22  20   8  0  0  0  2  90  145
     Play#0 output Play#0 1   1  170 frg  frigate        1,-1      100%   0  20   0  20  0  0  0  2  90  145
     Play#0 output Play#0 1   1  171 sb   submarine      1,-1      100%   0  20   0  20  0  0  0  1  90  145
     Play#0 output Play#0 1   1  315 linf light infa    1,-1      100%   0   0  60   0  40  42%  0  0  165S
     Play#0 output Play#0 1   1  316 linf light infa    1,-1      100%   0   0  60   0  40  42%  0  0  165S
     Play#0 output Play#0 1   1  317 linf light infa    1,-1      100%   0   0  60   0  40  42%  0  0  165S
-    Play#0 output Play#0 1   1  320 spy  infiltrato    1,-1   s  100%   0   0  60   0  40  42%  0  0  165S
+    Play#0 output Play#0 1   1  320 spy  infiltrato    1,-1   s  100%   0   0  60   0  40  42%  0  0  150S
     Play#0 output Play#0 1   1  321 spy  infiltrato    1,-1   s  100%   0   0  60   0  40  42%  0  0  171S
     Play#0 output Play#0 1   1  322 spy  infiltrato    1,-1   s  100%   0   0  60   0  40  42%  0  0  172S
     Play#0 output Play#0 1   2  330 linf light infa    0,-2      100%   0   0  60   0  40  42%  0  0  162S