From 0f1e14f0f33886f92cbfcb6c1a8b7d21a22393d9 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Sat, 11 Aug 2012 16:46:25 +0200 Subject: [PATCH] Fix flying commands for destination equal to assembly point bomb, drop, fly, paradrop, recon and sweep fail when given a destination sector equal to the assembly point. Broken in commit 404a76f7, v4.3.27. Reported by Tom Johnson. Before that commit, getpath() returned NULL on error, "" when input is an empty path, "h" when it's coordinates of the assembly point, and a non-empty path otherwise. The commit accidentally changed it to return "" instead of "h". Instead of changing it back, make it return NULL when input is an empty path, and change bomb() & friends to accept empty flight paths. This also affects sail: it now fails when you give it an empty path, just like bomb & friends. Path "h" still works. --- src/lib/commands/bomb.c | 3 +-- src/lib/commands/drop.c | 3 +-- src/lib/commands/fly.c | 3 +-- src/lib/commands/para.c | 3 +-- src/lib/commands/reco.c | 3 +-- src/lib/subs/paths.c | 4 ++-- 6 files changed, 7 insertions(+), 12 deletions(-) diff --git a/src/lib/commands/bomb.c b/src/lib/commands/bomb.c index e17f411c..ddfb3d2b 100644 --- a/src/lib/commands/bomb.c +++ b/src/lib/commands/bomb.c @@ -108,8 +108,7 @@ bomb(void) return RET_SYN; ax = ap_sect.sct_x; ay = ap_sect.sct_y; - if (!getpath(flightpath, player->argp[5], ax, ay, 0, 0, MOB_FLY) - || *flightpath == 0) + if (!getpath(flightpath, player->argp[5], ax, ay, 0, 0, MOB_FLY)) return RET_SYN; tx = ax; ty = ay; diff --git a/src/lib/commands/drop.c b/src/lib/commands/drop.c index 330f9cd4..cb6273b2 100644 --- a/src/lib/commands/drop.c +++ b/src/lib/commands/drop.c @@ -61,8 +61,7 @@ drop(void) return RET_SYN; ax = ap_sect.sct_x; ay = ap_sect.sct_y; - if (!getpath(flightpath, player->argp[4], ax, ay, 0, 0, MOB_FLY) - || *flightpath == 0) + if (!getpath(flightpath, player->argp[4], ax, ay, 0, 0, MOB_FLY)) return RET_SYN; tx = ax; ty = ay; diff --git a/src/lib/commands/fly.c b/src/lib/commands/fly.c index f861b331..c7f7ca64 100644 --- a/src/lib/commands/fly.c +++ b/src/lib/commands/fly.c @@ -65,8 +65,7 @@ fly(void) return RET_SYN; ax = ap_sect.sct_x; ay = ap_sect.sct_y; - if (!getpath(flightpath, player->argp[4], ax, ay, 0, 0, MOB_FLY) - || *flightpath == 0) + if (!getpath(flightpath, player->argp[4], ax, ay, 0, 0, MOB_FLY)) return RET_SYN; tx = ax; ty = ay; diff --git a/src/lib/commands/para.c b/src/lib/commands/para.c index da5ac9ac..85cdb54d 100644 --- a/src/lib/commands/para.c +++ b/src/lib/commands/para.c @@ -64,8 +64,7 @@ para(void) return RET_SYN; ax = ap_sect.sct_x; ay = ap_sect.sct_y; - if (!getpath(flightpath, player->argp[4], ax, ay, 0, 0, MOB_FLY) - || *flightpath == 0) + if (!getpath(flightpath, player->argp[4], ax, ay, 0, 0, MOB_FLY)) return RET_SYN; tx = ax; ty = ay; diff --git a/src/lib/commands/reco.c b/src/lib/commands/reco.c index 381bbf54..bee553ac 100644 --- a/src/lib/commands/reco.c +++ b/src/lib/commands/reco.c @@ -63,8 +63,7 @@ reco(void) return RET_SYN; ax = ap_sect.sct_x; ay = ap_sect.sct_y; - if (!getpath(flightpath, player->argp[4], ax, ay, 0, 0, MOB_FLY) - || *flightpath == 0) + if (!getpath(flightpath, player->argp[4], ax, ay, 0, 0, MOB_FLY)) return RET_SYN; tx = ax; ty = ay; diff --git a/src/lib/subs/paths.c b/src/lib/subs/paths.c index f1875964..7de13c18 100644 --- a/src/lib/subs/paths.c +++ b/src/lib/subs/paths.c @@ -143,7 +143,7 @@ more: break; } if (dir == DIR_STOP) { - p[1] = 0; + *p = 0; return buf; } ++p; @@ -170,7 +170,7 @@ more: strcpy(p, bp); if (*bp) goto more; - return buf; + return buf[0] ? buf : NULL; } /*