From 797abf4c8ffaaa6faf8a8326cbcaafc2dbf7a021 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Mon, 5 Jan 2015 11:07:50 +0100 Subject: [PATCH] navigate march: Wipe mission and retreat orders less eagerly navi() uses shp_sel() to collect ships, then shp_nav() to drop ineligible ships. shp_sel() wipes mission and retreat orders. Stupid when shp_nav() will drop them right away. Avoid that by having shp_sel() check shp_nav()'s conditions, too. navi()'s shp_nav() call won't find anything to drop now. The call will be removed shortly. This drops "& stays in" from some failure reports, since shp_nav()'s reject messages end with "& stays in X,Y", and shp_sel()'s don't. Likewise for marc(), lnd_sel(), lnd_mar(). Signed-off-by: Markus Armbruster --- src/lib/subs/lndsub.c | 9 +++++-- src/lib/subs/shpsub.c | 10 ++++++-- tests/navi-march/final.xdump | 22 ++++++++-------- tests/navi-march/journal.log | 50 +++++++++++++++++++++++++----------- 4 files changed, 61 insertions(+), 30 deletions(-) diff --git a/src/lib/subs/lndsub.c b/src/lib/subs/lndsub.c index 5b70555d3..b5a4d1139 100644 --- a/src/lib/subs/lndsub.c +++ b/src/lib/subs/lndsub.c @@ -461,7 +461,8 @@ lnd_may_mar(struct lndstr *lp, struct lndstr *ldr, char *suffix) void lnd_sel(struct nstr_item *ni, struct emp_qelem *list) { - struct lndstr land; + struct lndstr land, *ldr = NULL; + struct ulist *llp; int this_mot; int mobtype = MOB_MOVE; /* indeterminate */ @@ -481,6 +482,8 @@ lnd_sel(struct nstr_item *ni, struct emp_qelem *list) continue; } } + if (!lnd_may_mar(&land, ldr, "")) + continue; /* * The marching code gets confused when trains and non-trains * march together. Disallow for now. @@ -504,7 +507,9 @@ lnd_sel(struct nstr_item *ni, struct emp_qelem *list) land.lnd_rflags = 0; memset(land.lnd_rpath, 0, sizeof(land.lnd_rpath)); putland(land.lnd_uid, &land); - lnd_insque(&land, list); + llp = lnd_insque(&land, list); + if (!ldr) + ldr = &llp->unit.land; } } diff --git a/src/lib/subs/shpsub.c b/src/lib/subs/shpsub.c index 0f38f875a..92e5f0b8a 100644 --- a/src/lib/subs/shpsub.c +++ b/src/lib/subs/shpsub.c @@ -114,7 +114,8 @@ shp_may_nav(struct shpstr *sp, struct shpstr *flg, char *suffix) void shp_sel(struct nstr_item *ni, struct emp_qelem *list) { - struct shpstr ship; + struct shpstr ship, *flg = NULL; + struct ulist *mlp; emp_initque(list); while (nxtitem(ni, &ship)) { @@ -132,11 +133,16 @@ shp_sel(struct nstr_item *ni, struct emp_qelem *list) continue; } } + if (!shp_may_nav(&ship, flg, "")) + continue; + ship.shp_mission = 0; ship.shp_rflags = 0; memset(ship.shp_rpath, 0, sizeof(ship.shp_rpath)); putship(ship.shp_uid, &ship); - shp_insque(&ship, list); + mlp = shp_insque(&ship, list); + if (!flg) + flg = &mlp->unit.ship; } } diff --git a/tests/navi-march/final.xdump b/tests/navi-march/final.xdump index cc204e88a..1cee895da 100644 --- a/tests/navi-march/final.xdump +++ b/tests/navi-march/final.xdump @@ -133,15 +133,15 @@ uid owner xloc yloc type effic mobil off tech opx opy mission radius fleet civil 10 1 -1 -1 9 100 117 0 40 0 0 none 0 "" 0 2 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 0 "" 1 1 1 () "" 11 2 0 0 9 100 127 0 40 0 0 interdiction 0 "" 0 2 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 0 "" 1 1 1 (bombed) "hhhhn" 12 1 0 0 9 100 127 0 40 0 0 interdiction 0 "" 0 2 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 0 "" 1 1 1 (bombed) "hhhhn" -13 1 0 0 9 100 127 0 40 0 0 none 0 "" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 0 "" 1 1 1 () "" +13 1 0 0 9 100 127 0 40 0 0 interdiction 0 "" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 0 "" 1 1 1 (bombed) "hhhhn" 20 1 0 0 9 100 117 0 40 1 1 none 0 "" 0 2 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 0 "" 1 1 1 () "" -21 1 3 1 9 100 127 0 40 3 1 none 0 "" 0 2 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 0 "" 1 1 1 () "" +21 1 3 1 9 100 127 0 40 3 1 interdiction 0 "" 0 2 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 0 "" 1 1 1 (bombed) "hhhhn" 22 1 3 -1 9 100 117 0 40 2 0 none 0 "" 0 2 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 0 "" 1 1 1 () "" -23 1 6 0 9 100 127 0 40 6 0 none 0 "" 0 2 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 0 "" 1 1 1 () "" +23 1 6 0 9 100 127 0 40 6 0 interdiction 0 "" 0 2 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 0 "" 1 1 1 (bombed) "hhhhn" 24 1 1 1 9 100 117 0 40 2 2 none 0 "" 0 2 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 0 "" 1 1 1 () "" -25 1 4 2 9 100 127 0 40 4 2 none 0 "" 0 2 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 0 "" 1 1 1 () "" -26 1 2 2 2 100 127 0 20 0 0 none 0 "" 0 5 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 0 "" 1 1 1 () "" -27 1 1 -1 9 100 127 0 40 1 -1 none 0 "" 0 2 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 0 "" 1 1 1 () "" +25 1 4 2 9 100 127 0 40 4 2 interdiction 0 "" 0 2 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 0 "" 1 1 1 (bombed) "hhhhn" +26 1 2 2 2 100 127 0 20 0 0 none 0 "" 0 5 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 0 "" 1 1 1 (bombed) "hhhhn" +27 1 1 -1 9 100 127 0 40 1 -1 interdiction 0 "" 0 2 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 0 "" 1 1 1 (bombed) "hhhhn" 28 1 3 -1 9 100 117 0 40 4 0 none 0 "" 0 2 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 0 "" 1 1 1 () "" 30 1 10 -6 9 100 108 0 40 9 -5 none 0 "" 0 2 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 0 "" 1 1 1 () "" 31 0 11 -5 9 0 53 0 40 9 -5 none 0 "" 0 2 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 0 "" 1 1 1 () "" @@ -211,15 +211,15 @@ uid owner xloc yloc type effic mobil off tech opx opy mission radius army ship h 10 1 2 2 0 100 104 0 30 1 1 none 3 "" -1 0 42 () "" 0 5 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0 11 2 1 1 0 100 127 0 30 1 1 reserve 3 "" -1 127 42 (bombed) "hhhhn" 0 5 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0 12 1 1 1 0 100 127 0 30 1 1 reserve 3 "" -1 127 42 (bombed) "hhhhn" 0 5 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0 -13 1 1 1 0 100 127 0 30 1 1 none 3 "" -1 127 42 () "" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0 -14 1 1 1 0 100 127 0 30 1 1 none 3 "" 1 127 42 () "" 0 2 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0 -15 1 1 1 0 100 127 0 30 1 1 none 3 "" -1 127 42 () "" 0 2 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 1 0 +13 1 1 1 0 100 127 0 30 1 1 reserve 3 "" -1 127 42 (bombed) "hhhhn" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0 +14 1 1 1 0 100 127 0 30 1 1 reserve 3 "" 1 127 42 (bombed) "hhhhn" 0 2 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0 +15 1 1 1 0 100 127 0 30 1 1 reserve 3 "" -1 127 42 (bombed) "hhhhn" 0 2 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 1 0 20 1 3 3 0 100 105 0 30 1 3 none 3 "" -1 0 42 () "" 0 5 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0 21 1 2 4 0 100 105 0 30 1 3 none 3 "" -1 0 42 () "" 0 5 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0 22 1 3 3 7 100 60 0 40 0 0 none 0 "" -1 0 42 () "" 0 5 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0 23 1 3 3 7 50 -5 0 40 0 0 none 0 "" -1 0 42 () "" 0 5 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0 -24 1 2 2 7 100 127 0 40 0 0 none 0 "" -1 127 42 () "" 0 5 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0 -25 1 -5 3 0 100 127 0 30 -5 3 none 3 "" -1 127 42 () "" 0 5 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0 +24 1 2 2 7 100 127 0 40 0 0 none 0 "" -1 127 42 (bombed) "hhhhn" 0 5 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0 +25 1 -5 3 0 100 127 0 30 -5 3 reserve 3 "" -1 127 42 (bombed) "hhhhn" 0 5 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0 30 1 7 5 0 100 93 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 31 0 8 6 0 0 85 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 32 1 7 5 0 87 93 0 30 6 6 none 3 "" -1 0 42 () "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0 diff --git a/tests/navi-march/journal.log b/tests/navi-march/journal.log index 975cdb493..cd7474590 100644 --- a/tests/navi-march/journal.log +++ b/tests/navi-march/journal.log @@ -65,7 +65,7 @@ Play#1 input navi 12/10/19/11/13 Play#1 command navigate Play#1 output Play#1 1 ship #12 inelligible - it's for sale. - Play#1 output Play#1 1 pt patrol boat (#13) is crewless & stays in 0,0 + Play#1 output Play#1 1 pt patrol boat (#13) is crewless Play#1 output Play#1 1 Flagship is pt patrol boat (#10) Play#1 output Play#1 1 . i Play#1 output Play#1 1 . . = @@ -81,7 +81,7 @@ Play#1 output Play#1 6 0 636 Play#1 input navi 21 h Play#1 command navigate - Play#1 output Play#1 1 pt patrol boat (#21) is caught in a construction zone & stays in 3,1 + Play#1 output Play#1 1 pt patrol boat (#21) is caught in a construction zone Play#1 output Play#1 1 No ships Play#1 output Play#1 1 command failed Play#1 output Play#1 6 0 635 @@ -92,31 +92,31 @@ Play#1 output Play#1 6 0 634 Play#1 input navi 23 h Play#1 command navigate - Play#1 output Play#1 1 pt patrol boat (#23) is caught in a construction zone & stays in 6,0 + Play#1 output Play#1 1 pt patrol boat (#23) is caught in a construction zone Play#1 output Play#1 1 No ships Play#1 output Play#1 1 command failed Play#1 output Play#1 6 0 633 Play#1 input navi 24/26 yh Play#1 command navigate - Play#1 output Play#1 1 cs cargo ship (#26) is landlocked & stays in 2,2 + Play#1 output Play#1 1 cs cargo ship (#26) is landlocked Play#1 output Play#1 1 Flagship is pt patrol boat (#24) Play#1 output Play#1 1 pt patrol boat (#24) stopped at 1,1 Play#1 output Play#1 6 0 632 Play#1 input navi 25 h Play#1 command navigate - Play#1 output Play#1 1 pt patrol boat (#25) is caught in a construction zone & stays in 4,2 + Play#1 output Play#1 1 pt patrol boat (#25) is caught in a construction zone Play#1 output Play#1 1 No ships Play#1 output Play#1 1 command failed Play#1 output Play#1 6 0 631 Play#1 input navi 27 h Play#1 command navigate - Play#1 output Play#1 1 pt patrol boat (#27) is landlocked & stays in 1,-1 + Play#1 output Play#1 1 pt patrol boat (#27) is landlocked Play#1 output Play#1 1 No ships Play#1 output Play#1 1 command failed Play#1 output Play#1 6 0 630 Play#1 input nav 28/10 yh Play#1 command navigate - Play#1 output Play#1 1 pt patrol boat (#10) is not with the flagship & stays in -1,-1 + Play#1 output Play#1 1 pt patrol boat (#10) is not with the flagship Play#1 output Play#1 1 Flagship is pt patrol boat (#28) Play#1 output Play#1 1 pt patrol boat (#28) stopped at 3,-1 Play#1 output Play#1 6 0 629 @@ -751,9 +751,9 @@ Play#1 input march 12/10/19/11/13/14/15 Play#1 command march Play#1 output Play#1 1 unit #12 inelligible - it's for sale. - Play#1 output Play#1 1 cav cavalry #13 has no mil on it to guide it & stays in 1,1 - Play#1 output Play#1 1 cav cavalry #14 is on a ship & stays in 1,1 - Play#1 output Play#1 1 cav cavalry #15 is on a unit & stays in 1,1 + Play#1 output Play#1 1 cav cavalry #13 has no mil on it to guide it + Play#1 output Play#1 1 cav cavalry #14 is on a ship + Play#1 output Play#1 1 cav cavalry #15 is on a unit Play#1 output Play#1 1 Leader is cav cavalry #10 Play#1 output Play#1 1 . = Play#1 output Play#1 1 h h h @@ -777,19 +777,19 @@ Play#1 output Play#1 6 0 585 Play#1 input march 24 nh Play#1 command march - Play#1 output Play#1 1 tra train #24 is stuck off the rail system & stays in 2,2 + Play#1 output Play#1 1 tra train #24 is stuck off the rail system Play#1 output Play#1 1 No lands Play#1 output Play#1 1 command failed Play#1 output Play#1 6 0 584 Play#1 input march 25 gh Play#1 command march - Play#1 output Play#1 1 cav cavalry #25 has been kidnapped by 3 & stays in -5,3 + Play#1 output Play#1 1 cav cavalry #25 has been kidnapped by 3 Play#1 output Play#1 1 No lands Play#1 output Play#1 1 command failed Play#1 output Play#1 6 0 583 Play#1 input march 21/10 nh Play#1 command march - Play#1 output Play#1 1 cav cavalry #10 is not with the leader & stays in 2,2 + Play#1 output Play#1 1 cav cavalry #10 is not with the leader Play#1 output Play#1 1 Leader is cav cavalry #21 Play#1 output Play#1 1 cav cavalry #21 stopped at 2,4 Play#1 output Play#1 6 0 582 @@ -1454,13 +1454,24 @@ Play#0 output Play#0 1 1 4 oe oil explora 1,1 hhhhn b Play#0 output Play#0 1 2 11 pt patrol boat 0,0 hhhhn b Play#0 output Play#0 1 1 12 pt patrol boat 0,0 hhhhn b - Play#0 output Play#0 1 3 ships + Play#0 output Play#0 1 1 13 pt patrol boat 0,0 hhhhn b + Play#0 output Play#0 1 1 21 pt patrol boat 3,1 hhhhn b + Play#0 output Play#0 1 1 23 pt patrol boat 6,0 hhhhn b + Play#0 output Play#0 1 1 25 pt patrol boat 4,2 hhhhn b + Play#0 output Play#0 1 1 26 cs cargo ship 2,2 hhhhn b + Play#0 output Play#0 1 1 27 pt patrol boat 1,-1 hhhhn b + Play#0 output Play#0 1 9 ships Play#0 output Play#0 6 0 639 Play#0 input miss s * ?mission#0 q Play#0 command mission Play#0 output Play#0 1 Thing x,y op-sect rad mission Play#0 output Play#0 1 pt patrol boat (#11) 0,0 0,0 0 is on an interdiction mission Play#0 output Play#0 1 pt patrol boat (#12) 0,0 0,0 0 is on an interdiction mission + Play#0 output Play#0 1 pt patrol boat (#13) 0,0 0,0 0 is on an interdiction mission + Play#0 output Play#0 1 pt patrol boat (#21) 3,1 3,1 0 is on an interdiction mission + Play#0 output Play#0 1 pt patrol boat (#23) 6,0 6,0 0 is on an interdiction mission + Play#0 output Play#0 1 pt patrol boat (#25) 4,2 4,2 0 is on an interdiction mission + Play#0 output Play#0 1 pt patrol boat (#27) 1,-1 1,-1 0 is on an interdiction mission Play#0 output Play#0 6 0 637 Play#0 input land * Play#0 command land @@ -1551,7 +1562,12 @@ Play#0 output Play#0 1 1 4 eng engineer 1,1 hhhhn b Play#0 output Play#0 1 2 11 cav cavalry 1,1 hhhhn b Play#0 output Play#0 1 1 12 cav cavalry 1,1 hhhhn b - Play#0 output Play#0 1 4 units + Play#0 output Play#0 1 1 13 cav cavalry 1,1 hhhhn b + Play#0 output Play#0 1 1 14 cav cavalry 1,1 hhhhn b + Play#0 output Play#0 1 1 15 cav cavalry 1,1 hhhhn b + Play#0 output Play#0 1 1 24 tra train 2,2 hhhhn b + Play#0 output Play#0 1 1 25 cav cavalry -5,3 hhhhn b + Play#0 output Play#0 1 9 units Play#0 output Play#0 6 0 636 Play#0 input miss l * ?mission#0 q Play#0 command mission @@ -1559,6 +1575,10 @@ Play#0 output Play#0 1 eng engineer #4 1,1 1,1 1 is on a reserve mission Play#0 output Play#0 1 cav cavalry #11 1,1 1,1 3 is on a reserve mission Play#0 output Play#0 1 cav cavalry #12 1,1 1,1 3 is on a reserve mission + Play#0 output Play#0 1 cav cavalry #13 1,1 1,1 3 is on a reserve mission + Play#0 output Play#0 1 cav cavalry #14 1,1 1,1 3 is on a reserve mission + Play#0 output Play#0 1 cav cavalry #15 1,1 1,1 3 is on a reserve mission + Play#0 output Play#0 1 cav cavalry #25 -5,3 -5,3 3 is on a reserve mission Play#0 output Play#0 6 0 634 Play#0 input ctld Play#0 output Play#0 1 Bye-bye -- 2.43.0