From c8ead1ec33d6813906ea4f111e07abbf41a4f741 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Mon, 29 Dec 2014 22:45:20 +0100 Subject: [PATCH] subs: Report where exactly ships and land units sweep mines 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 --- src/lib/subs/lndsub.c | 7 ++++++- src/lib/subs/shpsub.c | 7 ++++++- tests/navi-march/journal.log | 15 +++++++++++++++ 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/lib/subs/lndsub.c b/src/lib/subs/lndsub.c index 5d34e7e28..ab2172307 100644 --- a/src/lib/subs/lndsub.c +++ b/src/lib/subs/lndsub.c @@ -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) diff --git a/src/lib/subs/shpsub.c b/src/lib/subs/shpsub.c index 2c8423c3a..cd76965a3 100644 --- a/src/lib/subs/shpsub.c +++ b/src/lib/subs/shpsub.c @@ -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); diff --git a/tests/navi-march/journal.log b/tests/navi-march/journal.log index 93c6e6392..3d17768a1 100644 --- a/tests/navi-march/journal.log +++ b/tests/navi-march/journal.log @@ -569,6 +569,7 @@ 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... @@ -587,6 +588,7 @@ 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 @@ -599,10 +601,12 @@ 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 @@ -615,6 +619,7 @@ 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... @@ -642,6 +647,7 @@ 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 @@ -652,6 +658,7 @@ 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... @@ -664,6 +671,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 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... @@ -1212,6 +1220,7 @@ 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... @@ -1220,6 +1229,7 @@ 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... @@ -1238,6 +1248,7 @@ 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... @@ -1251,6 +1262,7 @@ 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... @@ -1265,6 +1277,7 @@ 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... @@ -1273,6 +1286,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 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! @@ -1281,6 +1295,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 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... -- 2.43.0