]> git.pond.sub.org Git - empserver/commitdiff
march attack assault: Hit mines like ships do
authorMarkus Armbruster <armbru@pond.sub.org>
Mon, 29 Dec 2014 17:05:30 +0000 (18:05 +0100)
committerMarkus Armbruster <armbru@pond.sub.org>
Sat, 28 Feb 2015 15:13:15 +0000 (16:13 +0100)
When ships enter a sector with sea mines, any minesweepers sweep, then
hit mines, and finally all ships (including the minesweepers) hit
mines.  Sweeping in a sector (navigate sub-command 'm') works the same
without the final step.

When land units enter a sector with land mines, any engineers sweep,
and then all land units (including the engineers) hit mines.  Sweeping
in a sector (march sub-command 'm') works the same, which means
non-engineers can hit mines then.  Broken in Empire 2.

Actually broken for ships too then.  4.0.17 fixed ships, but neglected
to fix land units.

Change the land unit code to work like the ship code.  Fixes march
sub-command 'm' not to expose non-engineers to mines.  Changes march,
attack and assault with option INTERDICT_ATT enabled to expose
engineers twice.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
include/land.h
src/lib/commands/navi.c
src/lib/subs/lndsub.c
tests/navi-march/02-march-1
tests/navi-march/final.xdump
tests/navi-march/journal.log

index e426647742f7522b167afd5ffd3655f14fbf71d8..83cd7322fd032fad80954f4c60995cb377aeeabc 100644 (file)
@@ -173,7 +173,7 @@ extern int lnd_sabo(struct lndstr *, short *);
 extern double lnd_fire_range(struct lndstr *);
 
 /* src/lib/subs/lndsub.c */
-extern void lnd_sweep(struct emp_qelem *, int, int, natid);
+extern int lnd_sweep(struct emp_qelem *, int, int, natid);
 extern int lnd_interdict(struct emp_qelem *, coord, coord, natid);
 extern void lnd_sel(struct nstr_item *, struct emp_qelem *);
 extern struct ulist *lnd_insque(struct lndstr *, struct emp_qelem *);
index db2b99f94c2c6c5d0285b9bb22e1563da32d5005..26ac5413b9a24f992bd40f0da1d7c87458914d90 100644 (file)
@@ -199,8 +199,7 @@ do_unit_move(struct emp_qelem *ulist, double *minmob, double *maxmob)
            if (type == EF_SHIP)
                stopping |= shp_sweep(ulist, 1, 1, player->cnum);
            else {
-               lnd_sweep(ulist, 1, 1, player->cnum);
-               stopping |= lnd_check_mines(ulist);
+               stopping |= lnd_sweep(ulist, 1, 1, player->cnum);
            }
            continue;
        case 'r':
index f4190720485cf3cbcb4ad931608231469f317731..ab21fc6f63837095b64f6bfa2483c2db285975fd 100644 (file)
@@ -52,6 +52,7 @@
 #include "unit.h"
 #include "xy.h"
 
+static int lnd_check_one_mines(struct ulist *, int);
 static void lnd_stays(natid, char *, struct ulist *);
 static int lnd_hit_mine(struct lndstr *);
 static int has_helpful_engineer(coord, coord, natid);
@@ -581,7 +582,7 @@ lnd_put_one(struct ulist *llp)
  * a player.  Else it's an automatic "on the move" sweep.
  * If TAKEMOB is non-zero, require and charge mobility.
  */
-void
+int
 lnd_sweep(struct emp_qelem *land_list, int explicit, int takemob,
          natid actor)
 {
@@ -590,6 +591,7 @@ lnd_sweep(struct emp_qelem *land_list, int explicit, int takemob,
     struct ulist *llp;
     struct sctstr sect;
     int mines, m, max, sshells, lshells;
+    int stopping = 0;
 
     for (qp = land_list->q_back; qp != land_list; qp = next) {
        next = qp->q_back;
@@ -641,7 +643,13 @@ 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);
+       }
     }
+    return stopping;
 }
 
 static int
@@ -1096,7 +1104,9 @@ lnd_mar_one_sector(struct emp_qelem *list, int dir, natid actor)
     }
     if (QEMPTY(list))
        return stopping;
-    lnd_sweep(list, 0, 1, actor);
+    stopping |= lnd_sweep(list, 0, 1, actor);
+    if (QEMPTY(list))
+       return stopping;
     stopping |= lnd_check_mines(list);
     if (QEMPTY(list))
        return stopping;
index baff6b74a17fbe026f96be37d9c3baad66e6ce7d..97202094e4dedd9eca9ba098917b4fb97e39cefc 100644 (file)
@@ -127,6 +127,5 @@ march 135/130/131/136/137/138/139
 j
 | implicit sweep, not all capable
 mmmh
-| BUG: non-sweeper hits mine
 | BUG: mobility use low
 || TODO interdiction
index 6cd302da567b94946cc759e537f57fa075d3e536..0ecbc8e5285213b8988fd8ed97b22d3622818ae4 100644 (file)
@@ -89,7 +89,7 @@ owner xloc yloc des effic mobil off loyal terr0 terr1 terr2 terr3 dterr xdist yd
 1 2 6 10 100 0 0 0 0 0 0 0 0 2 6 0 0 0 0 10 0 0 0 0 0 1 100 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 0 0 0 0 0 0 0 0 0 0 0 healthy 0 0 0 0 0 0 0 0
 1 4 6 10 100 0 0 0 0 0 0 0 0 4 6 0 0 0 0 10 0 0 0 0 0 1 100 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 0 0 0 0 0 0 0 0 0 0 0 healthy 0 0 0 0 0 0 0 0
 1 6 6 10 100 0 0 0 0 0 0 0 0 6 6 0 0 0 0 10 0 0 0 0 0 1 100 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 0 0 0 0 0 0 0 0 0 0 2 healthy 0 0 0 0 0 0 0 0
-1 8 6 10 100 0 0 0 0 0 0 0 0 8 6 0 0 0 0 10 0 0 0 0 0 0 100 0 21 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 0 0 0 0 0 0 0 0 58 healthy 0 0 0 0 0 0 0 0
+1 8 6 10 100 0 0 0 0 0 0 0 0 8 6 0 0 0 0 10 0 0 0 0 0 0 100 0 22 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 0 0 0 0 0 0 0 0 61 healthy 0 0 0 0 0 0 0 0
 0 10 6 10 100 0 0 0 0 0 0 0 0 10 6 0 0 0 0 10 0 0 0 0 0 0 100 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 0 0 0 0 0 0 0 0 0 0 0 healthy 0 0 0 0 0 0 0 0
 0 12 6 10 100 0 0 0 0 0 0 0 0 12 6 0 0 0 0 10 0 0 0 0 0 0 100 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 0 0 0 0 0 0 0 0 0 0 0 healthy 0 0 0 0 0 0 0 0
 0 14 6 10 100 0 0 0 0 0 0 0 0 14 6 0 0 0 0 10 0 0 0 0 0 0 100 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 0 0 0 0 0 0 0 0 0 0 0 healthy 0 0 0 0 0 0 0 0
@@ -265,13 +265,13 @@ uid owner xloc yloc type effic mobil off tech opx opy mission radius army ship h
 120 1 2 0 15 100 127 0 130 2 0 none 1 "" -1 0 42 () "" 0 5 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0
 121 1 7 7 15 100 52 0 130 7 7 none 1 "" -1 0 42 () "" 0 5 3 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0
 128 1 9 7 15 100 -23 0 130 7 7 none 1 "" -1 0 42 () "" 0 5 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0
-130 1 8 6 15 94 52 0 130 6 6 none 1 "" -1 0 42 () "" 0 4 3 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0
-131 1 8 6 15 100 52 0 130 6 6 none 1 "" -1 0 42 () "" 0 5 3 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0
-135 1 8 6 0 85 104 0 30 6 6 none 3 "" -1 0 42 () "" 0 5 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0
-136 1 8 6 0 83 104 0 30 6 6 none 3 "" -1 0 42 () "" 0 4 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0
-137 1 8 6 0 55 90 0 30 6 6 none 3 "" -1 0 42 () "" 0 3 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0
-138 1 8 6 0 76 104 0 30 6 6 none 3 "" -1 0 42 () "" 0 4 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0
-139 1 8 6 0 100 104 0 30 6 6 none 3 "" -1 0 42 () "" 0 5 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0
+130 1 8 6 15 94 52 0 130 6 6 none 1 "" -1 0 42 () "" 0 5 3 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0
+131 1 8 6 15 96 48 0 130 6 6 none 1 "" -1 0 42 () "" 0 5 3 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0
+135 1 8 6 0 100 104 0 30 6 6 none 3 "" -1 0 42 () "" 0 5 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0
+136 1 8 6 0 100 104 0 30 6 6 none 3 "" -1 0 42 () "" 0 5 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0
+137 1 8 6 0 100 104 0 30 6 6 none 3 "" -1 0 42 () "" 0 5 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0
+138 1 8 6 0 100 104 0 30 6 6 none 3 "" -1 0 42 () "" 0 5 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0
+139 1 8 6 0 84 88 0 30 6 6 none 3 "" -1 0 42 () "" 0 4 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0
 149 0 0 0 0 0 0 0 0 0 0 none 0 "" -1 0 0 () "" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0
 /config
 config nuke
@@ -280,7 +280,7 @@ uid owner xloc yloc type effic mobil off tech opx opy mission radius stockpile p
 config news
 actor action victim times duration time
 1 25 0 21 0 0
-1 56 0 15 0 0
+1 56 0 11 0 0
 /config
 config trade
 uid owner type unitid price maxbidder markettime xloc yloc
index a8a5a1d6567877be88348c56a7a138e0cabafdc1..b2d9d09840091ce26664f7a4f429a66f4d89e8a0 100644 (file)
     Play#1 output Play#1 1 Sweep...
     Play#1 output Play#1 1 Sweep...
     Play#1 output Play#1 1 Blammo! Landmines detected in 8,6!
-    Play#1 output Play#1 1     cav  cavalry #137 takes 14
+    Play#1 output Play#1 1     eng  engineer #131 takes 4
+    Play#1 output Play#1 1 Blammo! Landmines detected in 8,6!
+    Play#1 output Play#1 1     cav  cavalry #139 takes 16
     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:89.7: 8,6>
+    Play#1 output Play#1 4 <104.7:86.0: 8,6>
     Play#1 input mmmh
     Play#1 output Play#1 1 cav  cavalry #135 is not an engineer!
     Play#1 output Play#1 1 Sweep...
     Play#1 output Play#1 1 cav  cavalry #137 is not an engineer!
     Play#1 output Play#1 1 cav  cavalry #138 is not an engineer!
     Play#1 output Play#1 1 cav  cavalry #139 is not an engineer!
-    Play#1 output Play#1 1 Blammo! Landmines detected in 8,6!
-    Play#1 output Play#1 1     cav  cavalry #137 takes 18
     Play#1 output Play#1 1 cav  cavalry #135 is not an engineer!
     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 Blammo! Landmines detected in 8,6!
+    Play#1 output Play#1 1     eng  engineer #130 takes 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 cav  cavalry #137 is not an engineer!
     Play#1 output Play#1 1 cav  cavalry #138 is not an engineer!
     Play#1 output Play#1 1 cav  cavalry #139 is not an engineer!
-    Play#1 output Play#1 1 Blammo! Landmines detected in 8,6!
-    Play#1 output Play#1 1     cav  cavalry #137 takes 22
-    Play#1 output Play#1 1 Blammo! Landmines detected in 8,6!
-    Play#1 output Play#1 1     cav  cavalry #138 takes 24
     Play#1 output Play#1 1 cav  cavalry #135 is not an engineer!
     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 Sweep...
+    Play#1 output Play#1 1 Sweep...
     Play#1 output Play#1 1 cav  cavalry #136 is not an engineer!
     Play#1 output Play#1 1 cav  cavalry #137 is not an engineer!
     Play#1 output Play#1 1 cav  cavalry #138 is not an engineer!
     Play#1 output Play#1 1 cav  cavalry #139 is not an engineer!
-    Play#1 output Play#1 1 Blammo! Landmines detected in 8,6!
-    Play#1 output Play#1 1     cav  cavalry #135 takes 15
-    Play#1 output Play#1 1 Blammo! Landmines detected in 8,6!
-    Play#1 output Play#1 1     eng  engineer #130 takes 6
-    Play#1 output Play#1 1 Blammo! Landmines detected in 8,6!
-    Play#1 output Play#1 1     cav  cavalry #136 takes 17
     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 eng  engineer #131 stopped at 8,6
     Play#0 output Play#0 1   1  120 eng  engineer      2,0       100%   5   0 127   0 130  42%  0  0
     Play#0 output Play#0 1   1  121 eng  engineer      7,7       100%   5   0  52   0 130  42%  0  0
     Play#0 output Play#0 1   1  128 eng  engineer      9,7       100%   5   0 -23   0 130  42%  0  0
-    Play#0 output Play#0 1   1  130 eng  engineer      8,6        94%   4   0  52   0 130  42%  0  0
-    Play#0 output Play#0 1   1  131 eng  engineer      8,6       100%   5   0  52   0 130  42%  0  0
-    Play#0 output Play#0 1   1  135 cav  cavalry       8,6        85%   5   0 104   0  30  42%  0  0
-    Play#0 output Play#0 1   1  136 cav  cavalry       8,6        83%   4   0 104   0  30  42%  0  0
-    Play#0 output Play#0 1   1  137 cav  cavalry       8,6        55%   3   0  90   0  30  42%  0  0
-    Play#0 output Play#0 1   1  138 cav  cavalry       8,6        76%   4   0 104   0  30  42%  0  0
-    Play#0 output Play#0 1   1  139 cav  cavalry       8,6       100%   5   0 104   0  30  42%  0  0
+    Play#0 output Play#0 1   1  130 eng  engineer      8,6        94%   5   0  52   0 130  42%  0  0
+    Play#0 output Play#0 1   1  131 eng  engineer      8,6        96%   5   0  48   0 130  42%  0  0
+    Play#0 output Play#0 1   1  135 cav  cavalry       8,6       100%   5   0 104   0  30  42%  0  0
+    Play#0 output Play#0 1   1  136 cav  cavalry       8,6       100%   5   0 104   0  30  42%  0  0
+    Play#0 output Play#0 1   1  137 cav  cavalry       8,6       100%   5   0 104   0  30  42%  0  0
+    Play#0 output Play#0 1   1  138 cav  cavalry       8,6       100%   5   0 104   0  30  42%  0  0
+    Play#0 output Play#0 1   1  139 cav  cavalry       8,6        84%   4   0  88   0  30  42%  0  0
     Play#0 output Play#0 1 68 units
     Play#0 output Play#0 6 0 637
     Play#0 input lcar * ?shell#0
     Play#0 output Play#0 1 lnd# unit    x,y    a  eff  civ mil  uw  sh gun pet irn dst bar oil lcm hcm rad
     Play#0 output Play#0 1  111 eng     6,6       100%   0   5   0   1   0   0   0   0   0   0   0   0   0
     Play#0 output Play#0 1  121 eng     7,7       100%   0   5   0   3   0   0   0   0   0   0   0   0   0
-    Play#0 output Play#0 1  130 eng     8,6        94%   0   4   0   3   0   0   0   0   0   0   0   0   0
-    Play#0 output Play#0 1  131 eng     8,6       100%   0   5   0   3   0   0   0   0   0   0   0   0   0
+    Play#0 output Play#0 1  130 eng     8,6        94%   0   5   0   3   0   0   0   0   0   0   0   0   0
+    Play#0 output Play#0 1  131 eng     8,6        96%   0   5   0   3   0   0   0   0   0   0   0   0   0
     Play#0 output Play#0 1 4 units
     Play#0 output Play#0 6 0 637
     Play#0 input lret * ?rflags#0