]> git.pond.sub.org Git - empserver/commitdiff
retreat: Don't consume a retreat direction that wasn't followed
authorMarkus Armbruster <armbru@pond.sub.org>
Wed, 22 Jan 2014 19:46:53 +0000 (20:46 +0100)
committerMarkus Armbruster <armbru@pond.sub.org>
Sun, 16 Feb 2014 12:19:26 +0000 (13:19 +0100)
When a retreating ship or land unit runs into a sector it can't enter,
it stops.  The direction character that led it there is consumed, even
though it could not be followed.  The next retreat will then attempt
to follow the rest of the path.  Don't do that.

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

index d850aa0c1b7eede4fc7e9ec87d1c180f6c031075..f5655d7fed65b5abacc2c7f444ba4969efba479a 100644 (file)
@@ -201,9 +201,11 @@ retreat_ship1(struct shpstr *sp, char code, int orig)
            return 0;
        }
        dir = chkdir(sp->shp_rpath[0], DIR_STOP, DIR_LAST);
-       memmove(sp->shp_rpath, sp->shp_rpath+1, sizeof(sp->shp_rpath) - 1);
-       if (dir == DIR_STOP || CANT_HAPPEN(dir < 0))
+       if (dir == DIR_STOP || CANT_HAPPEN(dir < 0)) {
+           memmove(sp->shp_rpath, sp->shp_rpath + 1,
+                   sizeof(sp->shp_rpath) - 1);
            break;
+       }
        dx = diroff[dir][0];
        dy = diroff[dir][1];
 
@@ -227,6 +229,8 @@ retreat_ship1(struct shpstr *sp, char code, int orig)
        sp->shp_y = newy;
        sp->shp_mobil -= mobcost;
        sp->shp_mission = 0;
+       memmove(sp->shp_rpath, sp->shp_rpath + 1,
+               sizeof(sp->shp_rpath) - 1);
 
        mines = sect.sct_mines;
        changed = 0;
@@ -383,9 +387,11 @@ retreat_land1(struct lndstr *lp, char code, int orig)
            return 0;
        }
        dir = chkdir(lp->lnd_rpath[0], DIR_STOP, DIR_LAST);
-       memmove(lp->lnd_rpath, lp->lnd_rpath+1, sizeof(lp->lnd_rpath) - 1);
-       if (dir == DIR_STOP || CANT_HAPPEN(dir < 0))
+       if (dir == DIR_STOP || CANT_HAPPEN(dir < 0)) {
+           memmove(lp->lnd_rpath, lp->lnd_rpath + 1,
+                   sizeof(lp->lnd_rpath) - 1);
            break;
+       }
        dx = diroff[dir][0];
        dy = diroff[dir][1];
 
@@ -410,6 +416,8 @@ retreat_land1(struct lndstr *lp, char code, int orig)
        lp->lnd_y = newy;
        lp->lnd_mobil -= mobcost;
        lp->lnd_mission = 0;
+       memmove(lp->lnd_rpath, lp->lnd_rpath + 1,
+               sizeof(lp->lnd_rpath) - 1);
 
        mines = SCT_LANDMINES(&sect);
        if (mines <= 0 || sect.sct_oldown == lp->lnd_own)
index e8fa5cf9f631352fb52a5dabbfe7ced594edd991..a14d0bd5b8e898c1242144dc2f32c397fb8f05ba 100644 (file)
@@ -188,8 +188,8 @@ uid owner xloc yloc type effic mobil off tech opx opy mission radius fleet xstar
 38 0 0 0 0 0 127 0 0 0 0 none 0 "" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 0 0 "" 0 "" 0 0 0 () ""
 39 0 0 0 0 0 127 0 0 0 0 none 0 "" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 0 0 "" 0 "" 0 0 0 () ""
 40 2 1 3 10 91 -7 0 45 0 2 none 1 "" 0 0 0 0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 9 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 0 0 "" 40 "" -3 1 1 (injured) "nnnh"
-41 2 1 3 10 96 108 0 45 0 2 none 1 "" 0 0 0 0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 0 0 "" 41 "" -3 1 1 (injured) "h"
-42 2 -4 2 10 95 120 0 45 -4 2 interdiction 1 "" 0 0 0 0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 0 0 "" 42 "" -3 1 1 (injured) "gggh"
+41 2 1 3 10 96 108 0 45 0 2 none 1 "" 0 0 0 0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 0 0 "" 41 "" -3 1 1 (injured) "uh"
+42 2 -4 2 10 95 120 0 45 -4 2 interdiction 1 "" 0 0 0 0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 0 0 "" 42 "" -3 1 1 (injured) "ugggh"
 43 2 -6 4 16 76 86 0 40 0 0 none 0 "m" 0 0 0 0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 7 3 0 0 0 0 0 0 0 0 0 0 0 healthy 0 0 0 "" 43 "" -3 1 1 (group injured) "g"
 44 2 -6 4 16 63 70 0 40 0 0 none 0 "m" 0 0 0 0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 7 2 0 0 0 0 0 0 0 0 0 0 0 healthy 0 0 0 "" 44 "" -3 1 1 (group injured) "g"
 45 0 0 0 0 0 127 0 0 0 0 none 0 "" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 0 0 "" 0 "" 0 0 0 () ""
@@ -363,7 +363,7 @@ uid owner xloc yloc type effic mobil off tech opx opy mission radius army ship h
 7 0 0 0 0 0 127 0 0 0 0 none 0 "" -1 127 0 () "" 0 10 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0
 8 0 0 0 0 0 127 0 0 0 0 none 0 "" -1 127 0 () "" 0 10 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0
 9 2 1 1 7 93 119 0 50 0 0 none 0 "" -1 127 42 () "" 0 10 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0
-10 2 4 0 0 61 61 0 50 0 0 none 0 "" -1 127 42 () "" 0 6 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0
+10 2 4 0 0 61 61 0 50 0 0 none 0 "" -1 127 42 (bombed) "y" 0 6 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0
 11 0 0 0 0 0 127 0 0 0 0 none 0 "" -1 127 0 () "" 0 10 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0
 12 0 0 0 0 0 127 0 0 0 0 none 0 "" -1 127 0 () "" 0 10 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0
 13 0 0 0 0 0 127 0 0 0 0 none 0 "" -1 127 0 () "" 0 10 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0
@@ -394,8 +394,8 @@ uid owner xloc yloc type effic mobil off tech opx opy mission radius army ship h
 38 0 0 0 0 0 127 0 0 0 0 none 0 "" -1 127 0 () "" 0 10 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0
 39 0 0 0 0 0 127 0 0 0 0 none 0 "" -1 127 0 () "" 0 10 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0
 40 2 2 2 0 89 -15 0 50 1 1 none 3 "" -1 127 42 (bombed) "u" 0 9 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0
-41 2 3 1 0 86 99 0 50 1 1 none 3 "" -1 127 42 () "" 0 9 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0
-42 2 1 1 0 83 105 0 50 1 1 reserve 3 "" -1 127 42 () "" 0 9 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0
+41 2 3 1 0 86 99 0 50 1 1 none 3 "" -1 127 42 (bombed) "y" 0 9 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0
+42 2 1 1 0 83 105 0 50 1 1 reserve 3 "" -1 127 42 (bombed) "g" 0 9 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0
 43 2 0 0 15 96 110 0 130 0 0 none 0 "m" -1 127 42 (group bombed) "u" 0 10 2 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0
 44 2 0 0 15 90 103 0 130 0 0 none 0 "m" -1 127 42 (group bombed) "u" 0 10 3 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0
 45 0 0 0 0 0 127 0 0 0 0 none 0 "" -1 127 0 () "" 0 10 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0
index ab6364031c555553cea0ab7b06f01f4f92f7f9b7..5fb499dcc6d755a5061e89e4f21042de9c31c7af 100644 (file)
     Play#0 output Play#0 1   2   34 cs   cargo ship     3,1      n                   i
     Play#0 output Play#0 1   2   35 cs   cargo ship     0,2      n                   i
     Play#0 output Play#0 1   2   40 lc   light cruis    1,3      nnnh                i
-    Play#0 output Play#0 1   2   41 lc   light cruis    1,3                        i
-    Play#0 output Play#0 1   2   42 lc   light cruis   -4,2      gggh                i
+    Play#0 output Play#0 1   2   41 lc   light cruis    1,3      uh                  i
+    Play#0 output Play#0 1   2   42 lc   light cruis   -4,2      ugggh               i
     Play#0 output Play#0 1   2   43 ms   minesweeper   -6,4    m g          Yes      i
     Play#0 output Play#0 1   2   44 ms   minesweeper   -6,4    m g          Yes      i
     Play#0 output Play#0 1   2   50 sb   submarine     -9,1
     Play#0 output Play#0 1 own lnd#     unit type       x,y   ar path       as army? flags
     Play#0 output Play#0 1   1    2 inf  infantry      -3,1      yujnbgyuj           ihb
     Play#0 output Play#0 1   2    9 tra  train          1,1
-    Play#0 output Play#0 1   2   10 cav  cavalry        4,0
+    Play#0 output Play#0 1   2   10 cav  cavalry        4,0      y                   b
     Play#0 output Play#0 1   2   31 cav  cavalry        0,2      j                   b
     Play#0 output Play#0 1   2   32 cav  cavalry        3,1
     Play#0 output Play#0 1   2   33 cav  cavalry        1,1
     Play#0 output Play#0 1   2   34 cav  cavalry        1,1      j                   b
     Play#0 output Play#0 1   2   35 cav  cavalry        1,1      j                   b
     Play#0 output Play#0 1   2   40 cav  cavalry        2,2      u                   b
-    Play#0 output Play#0 1   2   41 cav  cavalry        3,1
-    Play#0 output Play#0 1   2   42 cav  cavalry        1,1
+    Play#0 output Play#0 1   2   41 cav  cavalry        3,1      y                   b
+    Play#0 output Play#0 1   2   42 cav  cavalry        1,1      g                   b
     Play#0 output Play#0 1   2   43 eng  engineer       0,0    m u          Yes      b
     Play#0 output Play#0 1   2   44 eng  engineer       0,0    m u          Yes      b
     Play#0 output Play#0 1   2   60 cav  cavalry        3,1