From bd51dea51ac16d25b0b45ad92c9d657408cb96fe Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Sun, 18 Jun 2006 08:53:06 +0000 Subject: [PATCH] (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. --- src/lib/commands/marc.c | 4 ++-- src/lib/commands/navi.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lib/commands/marc.c b/src/lib/commands/marc.c index 25934c66..27023628 100644 --- a/src/lib/commands/marc.c +++ b/src/lib/commands/marc.c @@ -112,6 +112,8 @@ march(void) stopping = 1; continue; } + if (cp && !(cp = lnd_path(together, lnd, buf))) + cp = buf; } if (cp == 0 || *cp == '\0') cp = &dirch[DIR_STOP]; @@ -160,8 +162,6 @@ march(void) } else { dir = chkdir(*cp++, DIR_STOP, DIR_LAST); if (dir < 0) { - if (NULL != (cp = lnd_path(together, lnd, buf))) - continue; direrr("`%c' to stop", 0, 0); pr(", `i' to list units, `f' to change leader,\n"); pr("`r' to radar, `l' to look, `M' to map, `B' to bmap,\n"); diff --git a/src/lib/commands/navi.c b/src/lib/commands/navi.c index 793c3bd6..1d444a2c 100644 --- a/src/lib/commands/navi.c +++ b/src/lib/commands/navi.c @@ -128,6 +128,8 @@ navi(void) stopping = 1; continue; } + if (cp && !(cp = shp_path(together, shp, buf))) + cp = buf; } radmapnopr(shp->shp_x, shp->shp_y, (int)shp->shp_effic, (int)techfact(shp->shp_tech, @@ -184,8 +186,6 @@ navi(void) } else { dir = chkdir(*cp++, DIR_STOP, DIR_VIEW); if (dir < 0) { - if (NULL != (cp = shp_path(together, shp, buf))) - continue; direrr("`%c' to stop", ", `%c' to view, ", 0); 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");