]> git.pond.sub.org Git - empserver/commitdiff
navigate march: Stop on non-fatal mine hits, too
authorMarkus Armbruster <armbru@pond.sub.org>
Mon, 5 Jan 2015 19:23:46 +0000 (20:23 +0100)
committerMarkus Armbruster <armbru@pond.sub.org>
Mon, 2 Mar 2015 07:20:47 +0000 (08:20 +0100)
We stop on mine hits only when they're fatal.  Has always been that
way.  When interdiction was added in Chainsaw, it worked the same.
Empire 2 changed the commands to stop on any interdiction damage.  Now
stop on any mine damage, too.

Interdiction can fail to do damage (all bombs miss), and mines can be
detected without damage (by sweeping).  Perhaps we should stop then as
well.  Left for another day.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
src/lib/subs/lndsub.c
src/lib/subs/shpsub.c
tests/navi-march/01-navigate-1
tests/navi-march/02-march-1
tests/navi-march/journal.log

index 2f344594003607d5c62192ae236a67a595f2f704..268d5522caf5d9fd21f238f6b9730a937b7ac157 100644 (file)
@@ -691,11 +691,7 @@ lnd_sweep(struct emp_qelem *land_list, int explicit, int takemob,
        sect.sct_item[I_SHELL] = sshells;
        putland(llp->unit.land.lnd_uid, &llp->unit.land);
        putsect(&sect);
-       if (lnd_check_one_mines(llp, 1)) {
-           stopping = 1;
-           emp_remque(qp);
-           free(qp);
-       }
+       stopping |= lnd_check_one_mines(llp, 1);
     }
     return stopping;
 }
@@ -715,8 +711,11 @@ lnd_check_one_mines(struct ulist *llp, int with_eng)
        sect.sct_mines--;
        putsect(&sect);
        putland(llp->unit.land.lnd_uid, &llp->unit.land);
-       if (!llp->unit.land.lnd_own)
-           return 1;
+       if (!llp->unit.land.lnd_own) {
+           emp_remque(&llp->queue);
+           free(llp);
+       }
+       return 1;
     }
     return 0;
 }
@@ -726,18 +725,12 @@ lnd_check_mines(struct emp_qelem *land_list)
 {
     struct emp_qelem *qp;
     struct emp_qelem *next;
-    struct ulist *llp;
     int stopping = 0;
     int with_eng = !!lnd_find_capable(land_list, L_ENGINEER);
 
     for (qp = land_list->q_back; qp != land_list; qp = next) {
        next = qp->q_back;
-       llp = (struct ulist *)qp;
-       if (lnd_check_one_mines(llp, with_eng)) {
-           stopping = 1;
-           emp_remque(qp);
-           free(qp);
-       }
+       stopping |= lnd_check_one_mines((struct ulist *)qp, with_eng);
     }
     return stopping;
 }
index ea13e57d34e7d21f646ffde265450596c2ef3639..fb2a35aced833fe9ea6a3d2670440a5005d13c58 100644 (file)
@@ -298,11 +298,7 @@ shp_sweep(struct emp_qelem *ship_list, int explicit, int takemob,
        mlp->unit.ship.shp_item[I_SHELL] = shells;
        putship(mlp->unit.ship.shp_uid, &mlp->unit.ship);
        putsect(&sect);
-       if (shp_check_one_mines(mlp)) {
-           stopping = 1;
-           emp_remque(qp);
-           free(qp);
-       }
+       stopping |= shp_check_one_mines(mlp);
     }
     if (changed)
        writemap(actor);
@@ -328,8 +324,11 @@ shp_check_one_mines(struct ulist *mlp)
            writemap(actor);
        putsect(&sect);
        putship(mlp->unit.ship.shp_uid, &mlp->unit.ship);
-       if (!mlp->unit.ship.shp_own)
-           return 1;
+       if (!mlp->unit.ship.shp_own) {
+           emp_remque(&mlp->queue);
+           free(mlp);
+       }
+       return 1;
     }
     return 0;
 }
@@ -339,17 +338,11 @@ shp_check_mines(struct emp_qelem *ship_list)
 {
     struct emp_qelem *qp;
     struct emp_qelem *next;
-    struct ulist *mlp;
     int stopping = 0;
 
     for (qp = ship_list->q_back; qp != ship_list; qp = next) {
        next = qp->q_back;
-       mlp = (struct ulist *)qp;
-       if (shp_check_one_mines(mlp)) {
-           stopping = 1;
-           emp_remque(qp);
-           free(qp);
-       }
+       stopping |= shp_check_one_mines((struct ulist *)qp);
     }
     return stopping;
 }
index 8074492d50c1aebb5b6c480f55fa9f0703e1842f..a6bbbf0d318ed3f4d00ddb50b3d7eb186490a74d 100644 (file)
@@ -29,7 +29,8 @@ navi 31/30 jX
 iyh
 | lose crew, by hitting mines in 11,-5
 | at least one hit must lose crew; use __cmd to force it if necessary
-navi 32/33/34/35/36/37/38/39 jiyh
+navi 32/33/34/35/36/37/38/39 jX
+iyh
 | TODO sink ship at navi prompt, changing leader
 | TODO slap bridge onto ship at navi prompt
 || sector entry
@@ -124,5 +125,8 @@ navi 129 nmh
 navi 135/130/131/136/137/138/139
 j
 | implicit sweep, not all capable
-mmmh
+mf
+mf
+mf
+h
 || TODO interdiction
index b0131478af093f76781b4af356329ec46aa4ff49..3fd10ca09093836dd1e90b3c3992b8b4de2ad42b 100644 (file)
@@ -28,7 +28,8 @@ iyh
 | lose crew, by hitting mines in 8,6
 | at least one hit must lose crew; use __cmd to force it if necessary
 __cmd added -1 0 0
-march 32/33/34/35/36/37/38/39 jiyh
+march 32/33/34/35/36/37/38/39 jX
+iyh
 | TODO destroy land unit at march prompt, changing leader
 | TODO kidnap at march prompt
 || sector entry
@@ -124,5 +125,8 @@ mh
 march 135/130/131/136/137/138/139
 j
 | implicit sweep, not all capable
-mmmh
+mf
+mf
+mf
+h
 || TODO interdiction
index f27417caf2cb6845ec30d078565432380a30da6c..a3d51cfbeb1956bae4272d95ead11b19756105ef 100644 (file)
     Play#1 output Play#1 1   30 pt   patrol boat   11,-5     100%   2   0   0  0  0  0  0 117  40
     Play#1 output Play#1 1 pt   patrol boat (#30) stopped at 10,-6
     Play#1 output Play#1 6 0 629
-    Play#1 input navi 32/33/34/35/36/37/38/39 jiyh
+    Play#1 input navi 32/33/34/35/36/37/38/39 jX
     Play#1 command navigate
     Play#1 output Play#1 1 Flagship is pt   patrol boat (#32)
     Play#1 output Play#1 1 Kawhomp! Mine detected in 11,-5!
     Play#1 output Play#1 1 Kawhomp! Mine detected in 11,-5!
     Play#1 output Play#1 1     pt   patrol boat (#39) takes 36
     Play#1 output Play#1 1 pt   patrol boat (#38) is crewless & stays in 11,-5
+    Play#1 output Play#1 1  . .
+    Play#1 output Play#1 1 . X .
+    Play#1 output Play#1 1  . .
+    Play#1 output Play#1 4 <117.8:75.0: 11,-5>
+    Play#1 input iyh
     Play#1 output Play#1 1 shp#     ship type       x,y   fl  eff mil  sh gun pn he xl ln mob tech
     Play#1 output Play#1 1   32 pt   patrol boat   11,-5      75%   1   0   0  0  0  0  0  88  40
     Play#1 output Play#1 1   33 pt   patrol boat   11,-5      80%   1   0   0  0  0  0  0  94  40
     Play#1 output Play#1 1 . X .
     Play#1 output Play#1 1  . .
     Play#1 output Play#1 4 <117.8:76.0: 11,-5>
-    Play#1 input mmmh
+    Play#1 input mf
     Play#1 output Play#1 1 Approaching minefield at 11,-5...
     Play#1 output Play#1 1 Sweep...
     Play#1 output Play#1 1 Kawhomp! Mine detected in 11,-5!
     Play#1 output Play#1 1 Sweep...
     Play#1 output Play#1 1 Kawhomp! Mine detected in 11,-5!
     Play#1 output Play#1 1     ms   minesweeper (#131) takes 10
+    Play#1 output Play#1 1  . .
+    Play#1 output Play#1 1 . X .
+    Play#1 output Play#1 1  . .
+    Play#1 output Play#1 4 <117.8:47.0: 11,-5>
+    Play#1 input mf
     Play#1 output Play#1 1 Approaching minefield at 11,-5...
     Play#1 output Play#1 1 Sweep...
     Play#1 output Play#1 1 Sweep...
     Play#1 output Play#1 1 Sweep...
     Play#1 output Play#1 1 Sweep...
     Play#1 output Play#1 1 Sweep...
+    Play#1 output Play#1 1  . .
+    Play#1 output Play#1 1 . X .
+    Play#1 output Play#1 1  . .
+    Play#1 output Play#1 4 <117.8:18.0: 11,-5>
+    Play#1 input mf
     Play#1 output Play#1 1 Approaching minefield at 11,-5...
     Play#1 output Play#1 1 Sweep...
     Play#1 output Play#1 1 Sweep...
     Play#1 output Play#1 1     ms   minesweeper (#130) takes 10
     Play#1 output Play#1 1 Sweep...
     Play#1 output Play#1 1 Sweep...
+    Play#1 output Play#1 1  . .
+    Play#1 output Play#1 1 . X .
+    Play#1 output Play#1 1  . .
+    Play#1 output Play#1 4 <117.8:-11.1: 11,-5>
+    Play#1 input h
     Play#1 output Play#1 1 pt   patrol boat (#135) stopped at 11,-5
     Play#1 output Play#1 1 ms   minesweeper (#130) stopped at 11,-5
     Play#1 output Play#1 1 ms   minesweeper (#131) stopped at 11,-5
     Play#1 input __cmd added -1 0 0
     Play#1 command __cmd
     Play#1 output Play#1 6 0 582
-    Play#1 input march 32/33/34/35/36/37/38/39 jiyh
+    Play#1 input march 32/33/34/35/36/37/38/39 jX
     Play#1 command march
     Play#1 output Play#1 1 Leader is cav  cavalry #32
     Play#1 output Play#1 1 Blammo! Landmines detected in 8,6!
     Play#1 output Play#1 1 Blammo! Landmines detected in 8,6!
     Play#1 output Play#1 1     cav  cavalry #39 takes 16
     Play#1 output Play#1 1 cav  cavalry #36 has no mil on it to guide it & stays in 8,6
+    Play#1 output Play#1 1  m m
+    Play#1 output Play#1 1 m m m
+    Play#1 output Play#1 1  m m
+    Play#1 output Play#1 4 <104.7:81.0: 8,6>
+    Play#1 input iyh
     Play#1 output Play#1 1 lnd#     land type       x,y    a  eff mil  sh gun xl ln  mu tech retr
     Play#1 output Play#1 1   32 cav  cavalry        8,6       87%   1   0   0  0  0  90  30  42%
     Play#1 output Play#1 1   33 cav  cavalry        8,6      100%   1   0   0  0  0 104  30  42%
     Play#1 output Play#1 1 m m m
     Play#1 output Play#1 1  m m
     Play#1 output Play#1 4 <104.7:86.0: 8,6>
-    Play#1 input mmmh
+    Play#1 input mf
     Play#1 output Play#1 1 Approaching minefield at 8,6...
     Play#1 output Play#1 1 Sweep...
     Play#1 output Play#1 1 Sweep...
     Play#1 output Play#1 1 Sweep...
     Play#1 output Play#1 1 Sweep...
     Play#1 output Play#1 1 Sweep...
+    Play#1 output Play#1 1 Changing leader to eng  engineer #130
+    Play#1 output Play#1 1  m m
+    Play#1 output Play#1 1 m m m
+    Play#1 output Play#1 1  m m
+    Play#1 output Play#1 4 <104.7:73.6: 8,6>
+    Play#1 input mf
     Play#1 output Play#1 1 Approaching minefield at 8,6...
     Play#1 output Play#1 1 Sweep...
     Play#1 output Play#1 1 Sweep...
     Play#1 output Play#1 1 Sweep...
     Play#1 output Play#1 1 Sweep...
     Play#1 output Play#1 1 Sweep...
+    Play#1 output Play#1 1  m m
+    Play#1 output Play#1 1 m m m
+    Play#1 output Play#1 1  m m
+    Play#1 output Play#1 4 <104.7:61.0: 8,6>
+    Play#1 input mf
     Play#1 output Play#1 1 Approaching minefield at 8,6...
     Play#1 output Play#1 1 Sweep...
     Play#1 output Play#1 1 Sweep...
     Play#1 output Play#1 1 Sweep...
     Play#1 output Play#1 1 Sweep...
     Play#1 output Play#1 1 Sweep...
-    Play#1 output Play#1 1 cav  cavalry #135 stopped at 8,6
-    Play#1 output Play#1 1 eng  engineer #130 stopped at 8,6
+    Play#1 output Play#1 1 Changing leader to eng  engineer #131
+    Play#1 output Play#1 1  m m
+    Play#1 output Play#1 1 m m m
+    Play#1 output Play#1 1  m m
+    Play#1 output Play#1 4 <104.7:48.6: 8,6>
+    Play#1 input h
     Play#1 output Play#1 1 eng  engineer #131 stopped at 8,6
     Play#1 output Play#1 1 cav  cavalry #136 stopped at 8,6
     Play#1 output Play#1 1 cav  cavalry #137 stopped at 8,6
     Play#1 output Play#1 1 cav  cavalry #138 stopped at 8,6
     Play#1 output Play#1 1 cav  cavalry #139 stopped at 8,6
+    Play#1 output Play#1 1 cav  cavalry #135 stopped at 8,6
+    Play#1 output Play#1 1 eng  engineer #130 stopped at 8,6
     Play#1 output Play#1 6 0 547
     Play#1 input ctld
     Play#1 output Play#1 1 Bye-bye