diff --git a/src/lib/subs/shpsub.c b/src/lib/subs/shpsub.c index f3f4e579..ce8f4fe9 100644 --- a/src/lib/subs/shpsub.c +++ b/src/lib/subs/shpsub.c @@ -770,6 +770,7 @@ shp_nav_one_sector(struct emp_qelem *list, int dir, natid actor, coord dy; coord newx; coord newy; + int move; int stopping = 0; double mobcost; char dp[80]; @@ -781,6 +782,21 @@ shp_nav_one_sector(struct emp_qelem *list, int dir, natid actor, } dx = diroff[dir][0]; dy = diroff[dir][1]; + + move = 0; + for (qp = list->q_back; qp != list; qp = next) { + next = qp->q_back; + mlp = (struct ulist *)qp; + newx = xnorm(mlp->unit.ship.shp_x + dx); + newy = ynorm(mlp->unit.ship.shp_y + dy); + getsect(newx, newy, §); + navigate = shp_check_nav(&mlp->unit.ship, §); + if (navigate == NAVOK && + (!sect.sct_own + || relations_with(sect.sct_own, actor) >= FRIENDLY)) + move = 1; + } + for (qp = list->q_back; qp != list; qp = next) { next = qp->q_back; mlp = (struct ulist *)qp; @@ -797,7 +813,7 @@ shp_nav_one_sector(struct emp_qelem *list, int dir, natid actor, xyas(newx, newy, actor)); else sprintf(dp, "can't go to %s", xyas(newx, newy, actor)); - if (together) { + if (together && !move) { mpr(actor, "%s\n", dp); return 1; } else { diff --git a/tests/navi-march/01-navigate-1 b/tests/navi-march/01-navigate-1 index fa19b32c..e2ad06fc 100644 --- a/tests/navi-march/01-navigate-1 +++ b/tests/navi-march/01-navigate-1 @@ -44,7 +44,6 @@ navi 54/55 n iyyh navi 57/56 n iyyh -| BUG: 54/55 moves pt n, pt/cs yy, 57/56 moves nothing n, cs/pt yy navi 58/59 nX h | enter canal 4,2 1% diff --git a/tests/navi-march/final.xdump b/tests/navi-march/final.xdump index 95baa013..889431e3 100644 --- a/tests/navi-march/final.xdump +++ b/tests/navi-march/final.xdump @@ -157,9 +157,9 @@ uid owner xloc yloc type effic mobil off tech opx opy mission radius fleet civil 52 1 2 0 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 () "" 53 1 4 0 9 100 127 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 () "" 54 1 0 0 9 100 99 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 () "" -55 1 -1 -1 2 100 97 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 () "" -56 1 -1 -1 9 100 108 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 () "" -57 1 -1 -1 2 100 97 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 () "" +55 1 1 1 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 () "" +56 1 0 0 9 100 99 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 () "" +57 1 1 1 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 () "" 58 1 1 1 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 () "" 59 1 1 1 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 () "" 60 1 5 1 9 100 127 0 40 5 1 none 0 "" 0 2 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 0 "" 1 1 1 () "" diff --git a/tests/navi-march/journal.log b/tests/navi-march/journal.log index 666d000a..c02fc22c 100644 --- a/tests/navi-march/journal.log +++ b/tests/navi-march/journal.log @@ -200,32 +200,29 @@ Play#1 input navi 54/55 n Play#1 command navigate Play#1 output Play#1 1 Flagship is pt patrol boat (#54) - Play#1 output Play#1 1 is too large to fit into the canal system at 2,2 + Play#1 output Play#1 1 cs cargo ship (#55) is too large to fit into the canal system at 2,2 & stays in 1,1 Play#1 output Play#1 1 h h Play#1 output Play#1 1 c c c Play#1 output Play#1 1 + + - Play#1 output Play#1 4 <127.0:117.8: 2,2> + Play#1 output Play#1 4 <117.8:117.8: 2,2> Play#1 input iyyh 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 54 pt patrol boat 2,2 100% 2 0 0 0 0 0 0 117 40 - Play#1 output Play#1 1 55 cs cargo ship 1,1 100% 5 0 0 0 0 0 0 127 20 Play#1 output Play#1 1 pt patrol boat (#54) stopped at 0,0 - Play#1 output Play#1 1 cs cargo ship (#55) stopped at -1,-1 Play#1 output Play#1 6 0 623 Play#1 input navi 57/56 n Play#1 command navigate Play#1 output Play#1 1 Flagship is cs cargo ship (#57) - Play#1 output Play#1 1 is too large to fit into the canal system at 2,2 - Play#1 output Play#1 1 . = - Play#1 output Play#1 1 h h h - Play#1 output Play#1 1 c c - Play#1 output Play#1 4 <127.0:127.0: 1,1> + Play#1 output Play#1 1 cs cargo ship (#57) is too large to fit into the canal system at 2,2 & stays in 1,1 + Play#1 output Play#1 1 Changing flagship to pt patrol boat (#56) + Play#1 output Play#1 1 h h + Play#1 output Play#1 1 c c c + Play#1 output Play#1 1 + + + Play#1 output Play#1 4 <117.8:117.8: 2,2> Play#1 input iyyh 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 57 cs cargo ship 1,1 100% 5 0 0 0 0 0 0 127 20 - Play#1 output Play#1 1 56 pt patrol boat 1,1 100% 2 0 0 0 0 0 0 127 40 - Play#1 output Play#1 1 cs cargo ship (#57) stopped at -1,-1 - Play#1 output Play#1 1 pt patrol boat (#56) stopped at -1,-1 + Play#1 output Play#1 1 56 pt patrol boat 2,2 100% 2 0 0 0 0 0 0 117 40 + Play#1 output Play#1 1 pt patrol boat (#56) stopped at 0,0 Play#1 output Play#1 6 0 622 Play#1 input navi 58/59 nX Play#1 command navigate @@ -1409,9 +1406,9 @@ Play#0 output Play#0 1 1 52 pt patrol boat 2,0 100% 0 2 0 0 0 0 0 0 117 40 Play#0 output Play#0 1 1 53 pt patrol boat 4,0 100% 0 2 0 0 0 0 0 0 127 40 Play#0 output Play#0 1 1 54 pt patrol boat 0,0 100% 0 2 0 0 0 0 0 0 99 40 - Play#0 output Play#0 1 1 55 cs cargo ship -1,-1 100% 0 5 0 0 0 0 0 0 97 20 - Play#0 output Play#0 1 1 56 pt patrol boat -1,-1 100% 0 2 0 0 0 0 0 0 108 40 - Play#0 output Play#0 1 1 57 cs cargo ship -1,-1 100% 0 5 0 0 0 0 0 0 97 20 + Play#0 output Play#0 1 1 55 cs cargo ship 1,1 100% 0 5 0 0 0 0 0 0 127 20 + Play#0 output Play#0 1 1 56 pt patrol boat 0,0 100% 0 2 0 0 0 0 0 0 99 40 + Play#0 output Play#0 1 1 57 cs cargo ship 1,1 100% 0 5 0 0 0 0 0 0 127 20 Play#0 output Play#0 1 1 58 cs cargo ship 1,1 100% 0 5 0 0 0 0 0 0 127 20 Play#0 output Play#0 1 1 59 cs cargo ship 1,1 100% 0 5 0 0 0 0 0 0 127 20 Play#0 output Play#0 1 1 60 pt patrol boat 5,1 100% 0 2 0 0 0 0 0 0 127 40