From d87bd9649688c8b9daf7f1ecf98c41bb83453dca Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Sun, 28 Dec 2014 19:58:52 +0100 Subject: [PATCH] march: Don't permit trains to march out of sectors without rail Signed-off-by: Markus Armbruster --- src/lib/subs/lndsub.c | 13 +++++++++++++ tests/navi-march/02-march-1 | 1 - tests/navi-march/final.xdump | 2 +- tests/navi-march/journal.log | 7 ++++--- 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/lib/subs/lndsub.c b/src/lib/subs/lndsub.c index c5194ee0..1acc57d1 100644 --- a/src/lib/subs/lndsub.c +++ b/src/lib/subs/lndsub.c @@ -499,6 +499,19 @@ lnd_mar(struct emp_qelem *list, double *minmobp, double *maxmobp, lnd_stays(actor, "has no mil on it to guide it", llp); continue; } + switch (lnd_check_mar(lp, §)) { + case LND_STUCK_NOT: + break; + case LND_STUCK_NO_RAIL: + lnd_stays(actor, "is stuck off the rail system", llp); + continue; + default: + CANT_REACH(); + /* fall through */ + case LND_STUCK_IMPASSABLE: + lnd_stays(actor, "is stuck", llp); + continue; + } if (relations_with(sect.sct_own, actor) != ALLIED && !(lchr[lp->lnd_type].l_flags & L_SPY) && sect.sct_own) { diff --git a/tests/navi-march/02-march-1 b/tests/navi-march/02-march-1 index 726f8035..387d0d77 100644 --- a/tests/navi-march/02-march-1 +++ b/tests/navi-march/02-march-1 @@ -14,7 +14,6 @@ march 20/22 jh march 22/21/23 jh | no rail in 2,2 march 24 nh -| BUG: not stuck | kidnapped in -5,3 march 25 gh || get stuck on the way diff --git a/tests/navi-march/final.xdump b/tests/navi-march/final.xdump index 889431e3..f4383455 100644 --- a/tests/navi-march/final.xdump +++ b/tests/navi-march/final.xdump @@ -217,7 +217,7 @@ uid owner xloc yloc type effic mobil off tech opx opy mission radius army ship h 21 1 1 3 0 100 127 0 30 1 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 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 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 +24 1 2 2 7 100 127 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 25 1 -5 3 0 100 127 0 30 -5 3 none 3 "" -1 0 42 () "" 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 diff --git a/tests/navi-march/journal.log b/tests/navi-march/journal.log index c02fc22c..a0ecf9c4 100644 --- a/tests/navi-march/journal.log +++ b/tests/navi-march/journal.log @@ -776,8 +776,9 @@ Play#1 output Play#1 6 0 585 Play#1 input march 24 nh Play#1 command march - Play#1 output Play#1 1 Leader is tra train #24 - Play#1 output Play#1 1 tra train #24 stopped at 3,3 + 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 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 @@ -1491,7 +1492,7 @@ Play#0 output Play#0 1 1 21 cav cavalry 1,3 100% 5 127 127 0 30 42% 0 0 Play#0 output Play#0 1 1 22 tra train 3,3 100% 5 0 60 0 40 42% 0 0 Play#0 output Play#0 1 1 23 tra train 3,3 50% 5 0 -5 0 40 42% 0 0 - Play#0 output Play#0 1 1 24 tra train 3,3 100% 5 0 60 0 40 42% 0 0 + Play#0 output Play#0 1 1 24 tra train 2,2 100% 5 0 127 0 40 42% 0 0 Play#0 output Play#0 1 1 25 cav cavalry -5,3 100% 5 0 127 0 30 42% 0 0 Play#0 output Play#0 1 1 30 cav cavalry 7,5 100% 5 0 93 0 30 42% 0 0 Play#0 output Play#0 1 1 32 cav cavalry 7,5 87% 1 0 93 0 30 42% 0 0