(navi, march): Simplify convoluted logic. Old code tried path finding

whenever the next direction in the path string is bad.  It then passed
the whole path string to shp_path(), which makes no sense unless we're
at the beginning of it, but luckily failed in that case.  Change to
try path finding right after prompting for new input.
This commit is contained in:
Markus Armbruster 2006-06-18 08:53:06 +00:00
parent b63c69ef20
commit bd51dea51a
2 changed files with 4 additions and 4 deletions

View file

@ -112,6 +112,8 @@ march(void)
stopping = 1; stopping = 1;
continue; continue;
} }
if (cp && !(cp = lnd_path(together, lnd, buf)))
cp = buf;
} }
if (cp == 0 || *cp == '\0') if (cp == 0 || *cp == '\0')
cp = &dirch[DIR_STOP]; cp = &dirch[DIR_STOP];
@ -160,8 +162,6 @@ march(void)
} else { } else {
dir = chkdir(*cp++, DIR_STOP, DIR_LAST); dir = chkdir(*cp++, DIR_STOP, DIR_LAST);
if (dir < 0) { if (dir < 0) {
if (NULL != (cp = lnd_path(together, lnd, buf)))
continue;
direrr("`%c' to stop", 0, 0); direrr("`%c' to stop", 0, 0);
pr(", `i' to list units, `f' to change leader,\n"); pr(", `i' to list units, `f' to change leader,\n");
pr("`r' to radar, `l' to look, `M' to map, `B' to bmap,\n"); pr("`r' to radar, `l' to look, `M' to map, `B' to bmap,\n");

View file

@ -128,6 +128,8 @@ navi(void)
stopping = 1; stopping = 1;
continue; continue;
} }
if (cp && !(cp = shp_path(together, shp, buf)))
cp = buf;
} }
radmapnopr(shp->shp_x, shp->shp_y, (int)shp->shp_effic, radmapnopr(shp->shp_x, shp->shp_y, (int)shp->shp_effic,
(int)techfact(shp->shp_tech, (int)techfact(shp->shp_tech,
@ -184,8 +186,6 @@ navi(void)
} else { } else {
dir = chkdir(*cp++, DIR_STOP, DIR_VIEW); dir = chkdir(*cp++, DIR_STOP, DIR_VIEW);
if (dir < 0) { if (dir < 0) {
if (NULL != (cp = shp_path(together, shp, buf)))
continue;
direrr("`%c' to stop", ", `%c' to view, ", 0); direrr("`%c' to stop", ", `%c' to view, ", 0);
pr("`i' to list ships, `f' to change flagship,\n"); pr("`i' to list ships, `f' to change flagship,\n");
pr("`r' to radar, `s' to sonar, `l' to look, `M' to map, `B' to bmap,\n"); pr("`r' to radar, `s' to sonar, `l' to look, `M' to map, `B' to bmap,\n");