]> git.pond.sub.org Git - empserver/commitdiff
(bestownedpath): Return NULL on long path instead of "?". Terminate
authorMarkus Armbruster <armbru@pond.sub.org>
Wed, 5 Apr 2006 09:30:38 +0000 (09:30 +0000)
committerMarkus Armbruster <armbru@pond.sub.org>
Wed, 5 Apr 2006 09:30:38 +0000 (09:30 +0000)
returned path with 'h'.  This makes BestShipPath() and BestAirPath()
more similar to BestLandPath().  Simplify callers.

src/lib/commands/orde.c
src/lib/common/bestpath.c
src/lib/update/nav_ship.c

index 3cd98a5d1d77c8ccdca6bccb28d960be9ab995da..3b6706a84679a9b2fd2fcd740c6ec9ef587eb5fe 100644 (file)
@@ -474,12 +474,10 @@ sorde(void)
                c = BestShipPath(buf, ship.shp_x,
                                 ship.shp_y, ship.shp_destx[0],
                                 ship.shp_desty[0], ship.shp_own);
-               if (!c || !*c)
+               if (!c)
                    pr(" no route possible");
                else if (*c == 'h')
                    pr(" has arrived");
-               else if (*c == '?')
-                   pr(" route too long");
                else {
                    /* distance to destination */
                    eta_calc(&ship, c, &len, &updates);
index be1591022c0b0e9a64739e4af66d4c473a9dbb44..0d9c011ac4ff05fc7edb9345e3c2aa243845a080 100644 (file)
@@ -176,8 +176,8 @@ bestownedpath(s_char *bpath,
     maxy = y + 1;
 
     do {
-       if (++routelen == MAXROUTE)
-           return "?";
+       if (++routelen == MAXROUTE - 1)
+           return NULL;
        markedsectors = 0;
        for (scanx = minx; scanx <= maxx; scanx++) {
            x = XNORM(scanx);
@@ -200,7 +200,8 @@ bestownedpath(s_char *bpath,
                                }
                            }
                            if (tx == ex && ty == ey) {
-                               bpath[routelen] = 0;
+                               bpath[routelen] = 'h';
+                               bpath[routelen + 1] = 0;
                                while (routelen--) {
                                    i = ((mapindex[tx][ty]) >> 13) - 1;
                                    bpath[routelen] = dirchar[i];
index 9907e012e358f6316e455d72dae6856cfcd3f4ab..9c8e501895c9d3d511447c58d03c43113e7139e4 100644 (file)
@@ -285,7 +285,7 @@ nav_ship(struct shpstr *sp)
            cp = BestShipPath(buf, sp->shp_x, sp->shp_y,
                              sp->shp_destx[0], sp->shp_desty[0],
                              sp->shp_own);
-           if (cp == 0 || (*cp == '\0') || (*cp == '?')) {
+           if (cp == 0) {
                wu(0, cnum,
                   "%s bad path, ship put on standby\n", prship(sp));
                sp->shp_autonav |= AN_STANDBY;