navigate: Don't scatter ships on canal entry

When attempting to enter a sector with a ship that can't go there
while the navigating ships are all in the same sector, navigate stops
and prompts without removing the incapable ship from the group.  If
another ship has already entered the sector, the group becomes
scattered.

This can happen only when navigating a mixed group of ships with and
without canal capability into a canal.  Broken in commit 74e4e281,
v4.3.0.

Remove the incapable ship from the group when another ship can enter
the sector.  This avoids scattering ships.

Don't remove incapable ships when no ship can enter the sector.
Without this, navigate would remove everyone and end then.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
This commit is contained in:
Markus Armbruster 2014-12-28 17:42:44 +01:00
parent 6e386d101a
commit d89825116e
4 changed files with 33 additions and 21 deletions

View file

@ -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, &sect);
navigate = shp_check_nav(&mlp->unit.ship, &sect);
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 {