Fix navigate and march to find paths longer than 7 sectors again
authorMarkus Armbruster <armbru@pond.sub.org>
Tue, 12 Jul 2011 05:11:31 +0000 (07:11 +0200)
committerMarkus Armbruster <armbru@pond.sub.org>
Tue, 12 Jul 2011 05:12:57 +0000 (07:12 +0200)
Broken in commit 8f008bf8, v4.3.27.  How embarrassing...

include/unit.h
src/lib/commands/navi.c
src/lib/subs/unitsub.c

index 08ceeb5be689a4c2bc029e3a812220f232781fd8..dd99dd74a81bc534dcf709f3fc2b865111a95e56 100644 (file)
@@ -57,7 +57,7 @@ extern void unit_onresize(int);
 extern char *unit_nameof(struct empobj *);
 extern void unit_list(struct emp_qelem *);
 extern void unit_put(struct emp_qelem *list, natid actor);
-extern char *unit_path(int, struct empobj *, char *);
+extern char *unit_path(int, struct empobj *, char *, size_t);
 extern void unit_view(struct emp_qelem *);
 extern int unit_update_cargo(struct empobj *);
 extern void unit_drop_cargo(struct empobj *, natid);
index cc5d51dbded17d3cf380a9c48f3b38db2fb47d0f..a02ca63d9b3a304179d0ca9109f2a0ad005e0a58 100644 (file)
@@ -91,7 +91,7 @@ do_unit_move(struct emp_qelem *ulist, int *together,
 
     if (player->argp[2]) {
        strcpy(buf, player->argp[2]);
-       cp = unit_path(*together, leader, buf);
+       cp = unit_path(*together, leader, buf, sizeof(buf));
     }
 
     *pt = '\0';
@@ -151,7 +151,7 @@ do_unit_move(struct emp_qelem *ulist, int *together,
                continue;
            }
            if (cp)
-               cp = unit_path(*together, leader, cp);
+               cp = unit_path(*together, leader, buf, sizeof(buf));
        }
        if (type == EF_SHIP) {
            rad_map_set(player->cnum, leader->x, leader->y, leader->effic,
index 1cb156cd96a5cffad1649e012320b5aeaedc085c..4545d906121a70b2354a01972ef7966e1af2f024 100644 (file)
@@ -151,7 +151,7 @@ unit_put(struct emp_qelem *list, natid actor)
 }
 
 char *
-unit_path(int together, struct empobj *unit, char *buf)
+unit_path(int together, struct empobj *unit, char *buf, size_t bufsz)
 {
     coord destx;
     coord desty;
@@ -196,13 +196,13 @@ unit_path(int together, struct empobj *unit, char *buf)
            return NULL;
        }
     }
-    len = path_find_route(buf, sizeof(buf), unit->x, unit->y, destx, desty);
+    len = path_find_route(buf, bufsz, unit->x, unit->y, destx, desty);
     if (len == 0 || unit->ef_type == EF_LAND) {
-       if (len + 1 < sizeof(buf))
+       if (len + 1 < bufsz)
            strcpy(buf + len, "h");
        len++;
     }
-    if (len >= sizeof(buf)) {
+    if (len >= bufsz) {
        pr("Can't handle path to %s, it's too long, sorry\n",
           xyas(destx, desty, player->cnum));
        return NULL;