diff --git a/src/lib/subs/lndsub.c b/src/lib/subs/lndsub.c index 2f344594..268d5522 100644 --- a/src/lib/subs/lndsub.c +++ b/src/lib/subs/lndsub.c @@ -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(§); - 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(§); 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; } diff --git a/src/lib/subs/shpsub.c b/src/lib/subs/shpsub.c index ea13e57d..fb2a35ac 100644 --- a/src/lib/subs/shpsub.c +++ b/src/lib/subs/shpsub.c @@ -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(§); - 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(§); 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; } diff --git a/tests/navi-march/01-navigate-1 b/tests/navi-march/01-navigate-1 index 8074492d..a6bbbf0d 100644 --- a/tests/navi-march/01-navigate-1 +++ b/tests/navi-march/01-navigate-1 @@ -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 diff --git a/tests/navi-march/02-march-1 b/tests/navi-march/02-march-1 index b0131478..3fd10ca0 100644 --- a/tests/navi-march/02-march-1 +++ b/tests/navi-march/02-march-1 @@ -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 diff --git a/tests/navi-march/journal.log b/tests/navi-march/journal.log index f27417ca..a3d51cfb 100644 --- a/tests/navi-march/journal.log +++ b/tests/navi-march/journal.log @@ -139,7 +139,7 @@ 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! @@ -157,6 +157,11 @@ 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 @@ -646,7 +651,7 @@ 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! @@ -658,6 +663,11 @@ 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... @@ -671,6 +681,11 @@ 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... @@ -679,6 +694,11 @@ 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 @@ -813,7 +833,7 @@ 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! @@ -831,6 +851,11 @@ 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% @@ -1275,7 +1300,7 @@ 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... @@ -1285,6 +1310,12 @@ 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... @@ -1294,6 +1325,11 @@ 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... @@ -1304,13 +1340,19 @@ 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