]> git.pond.sub.org Git - empserver/commitdiff
subs: Report where exactly ships and land units sweep mines
authorMarkus Armbruster <armbru@pond.sub.org>
Mon, 29 Dec 2014 21:45:20 +0000 (22:45 +0100)
committerMarkus Armbruster <armbru@pond.sub.org>
Sat, 28 Feb 2015 15:13:15 +0000 (16:13 +0100)
shp_sweep() and lnd_sweep() print only a couple of "Sweep...".
Sometimes, the sector isn't obvious, e.g. when you march multiple
sectors in one go, sweeping along the way.

Print "Approaching minefield at X,Y..." right before the first sweep
in a sector.

Note that retreat.c duplicates the sweeping code.  Retreating ships
report sweeping with coordinates since commit dcd0794, v4.2.21.
Retreating land units still sweep silently.  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/journal.log

index 5d34e7e287cc6e7a51796ec780fa4237d73519c7..ab21723073ca7cf4274a613489fcb7ba18681f05 100644 (file)
@@ -607,7 +607,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;
+    int stopping = 0, first = 1;
 
     llp = lnd_find_capable(land_list, L_ENGINEER);
     if (!llp) {
@@ -653,6 +653,11 @@ lnd_sweep(struct emp_qelem *land_list, int explicit, int takemob,
        sshells = sect.sct_item[I_SHELL];
        for (m = 0; mines > 0 && m < max * 2; m++) {
            if (chance(0.5 * lchr[llp->unit.land.lnd_type].l_att)) {
+               if (first) {
+                   mpr(actor, "Approaching minefield at %s...\n",
+                       xyas(sect.sct_x, sect.sct_y, actor));
+                   first = 0;
+               }
                mpr(actor, "Sweep...\n");
                mines--;
                if (lshells < max)
index 2c8423c3a35428ceb77e646aaf0a94513e9048b2..cd76965a336966423f19938682629991edff7c1a 100644 (file)
@@ -224,7 +224,7 @@ shp_sweep(struct emp_qelem *ship_list, int explicit, int takemob,
     struct sctstr sect;
     int mines, m, max, shells;
     int changed = 0;
-    int stopping = 0;
+    int stopping = 0, first = 1;
 
     mlp = shp_find_capable(ship_list, M_SWEEP);
     if (!mlp) {
@@ -265,6 +265,11 @@ shp_sweep(struct emp_qelem *ship_list, int explicit, int takemob,
        shells = mlp->unit.ship.shp_item[I_SHELL];
        for (m = 0; mines > 0 && m < 5; m++) {
            if (chance(0.66)) {
+               if (first) {
+                   mpr(actor, "Approaching minefield at %s...\n",
+                       xyas(sect.sct_x, sect.sct_y, actor));
+                   first = 0;
+               }
                mpr(actor, "Sweep...\n");
                mines--;
                shells = MIN(max, shells + 1);
index 93c6e639200fbe28c9373550719dad5399b72482..3d17768a1afdb241df31ea2908c294a9141c99ab 100644 (file)
     Play#1 input navi 121/122/128 j
     Play#1 command navigate
     Play#1 output Play#1 1 Flagship is ms   minesweeper (#121)
+    Play#1 output Play#1 1 Approaching minefield at 11,-3...
     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  121 ms   minesweeper   11,-3     100%   5   1   0  0  0  0  0 113  40
     Play#1 output Play#1 1  122 ms   minesweeper   11,-3     100%   5   3   0  0  0  0  0 113  40
     Play#1 output Play#1 1  128 ms   minesweeper   11,-3     100%   5   5   0  0  0  0  0 -12  40
+    Play#1 output Play#1 1 Approaching minefield at 11,-3...
     Play#1 output Play#1 1 Sweep...
     Play#1 output Play#1 1 ms   minesweeper (#128) is out of mobility!
     Play#1 output Play#1 1 ms   minesweeper (#128) is out of mobility & stays in 11,-3
     Play#1 input navi 129 nmh
     Play#1 command navigate
     Play#1 output Play#1 1 Flagship is ms   minesweeper (#129)
+    Play#1 output Play#1 1 Approaching minefield at 10,-2...
     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 Approaching minefield at 10,-2...
     Play#1 output Play#1 1 Sweep...
     Play#1 output Play#1 1 Sweep...
     Play#1 output Play#1 1 ms   minesweeper (#129) stopped at 10,-2
     Play#1 output Play#1 1  . .
     Play#1 output Play#1 4 <127.0:127.0: 9,-5>
     Play#1 input j
+    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  . .
     Play#1 output Play#1 4 <117.8:76.0: 11,-5>
     Play#1 input mmmh
+    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     ms   minesweeper (#130) takes 15
     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 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 Sweep...
+    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 input march 121/128 j
     Play#1 command march
     Play#1 output Play#1 1 Leader is eng  engineer #121
+    Play#1 output Play#1 1 Approaching minefield at 9,7...
     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 4 <89.7:-23.8: 9,7>
     Play#1 input mi
+    Play#1 output Play#1 1 Approaching minefield at 9,7...
     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 4 <64.9:64.9: 7,7>
     Play#1 input mh
+    Play#1 output Play#1 1 Approaching minefield at 7,7...
     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 4 <127.0:127.0: 6,6>
     Play#1 input j
+    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  m m
     Play#1 output Play#1 4 <104.7:86.0: 8,6>
     Play#1 input mmmh
+    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 Sweep...
+    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 Blammo! Landmines detected in 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 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...