]> git.pond.sub.org Git - empserver/commitdiff
(navi, march): Simplify convoluted logic. Old code tried path finding
authorMarkus Armbruster <armbru@pond.sub.org>
Sun, 18 Jun 2006 08:53:06 +0000 (08:53 +0000)
committerMarkus Armbruster <armbru@pond.sub.org>
Sun, 18 Jun 2006 08:53:06 +0000 (08:53 +0000)
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
src/lib/commands/navi.c

index 25934c664e1dc0ab2185f3aa30e9640ae36c0a69..270236289b48caae86d54604c85587aa60de903f 100644 (file)
@@ -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");
index 793c3bd65c79135a7baa86226f14dbb1b2b4e7f7..1d444a2cd9bd66cf231d8a0e90307d09721dc9ae 100644 (file)
@@ -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");