From: Markus Armbruster Date: Tue, 12 Jul 2011 05:11:31 +0000 (+0200) Subject: Fix navigate and march to find paths longer than 7 sectors again X-Git-Tag: v4.3.28~8 X-Git-Url: http://git.pond.sub.org/?p=empserver;a=commitdiff_plain;h=0faf0034e57a95fd97f1709a7c6284cbd4a41a11 Fix navigate and march to find paths longer than 7 sectors again Broken in commit 8f008bf8, v4.3.27. How embarrassing... --- diff --git a/include/unit.h b/include/unit.h index 08ceeb5be..dd99dd74a 100644 --- a/include/unit.h +++ b/include/unit.h @@ -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); diff --git a/src/lib/commands/navi.c b/src/lib/commands/navi.c index cc5d51dbd..a02ca63d9 100644 --- a/src/lib/commands/navi.c +++ b/src/lib/commands/navi.c @@ -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, diff --git a/src/lib/subs/unitsub.c b/src/lib/subs/unitsub.c index 1cb156cd9..4545d9061 100644 --- a/src/lib/subs/unitsub.c +++ b/src/lib/subs/unitsub.c @@ -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;