Keep coordinates normalized in getpath()
The old code is believed to be safe, but keeping coordinates normalized is cleaner.
This commit is contained in:
parent
1e6c04a34e
commit
6316c4185a
1 changed files with 4 additions and 6 deletions
|
@ -109,8 +109,6 @@ getpath(char *buf, char *arg, coord x, coord y, int onlyown,
|
||||||
}
|
}
|
||||||
|
|
||||||
getsect(x, y, §);
|
getsect(x, y, §);
|
||||||
nx = x;
|
|
||||||
ny = y;
|
|
||||||
|
|
||||||
more:
|
more:
|
||||||
while (*p) {
|
while (*p) {
|
||||||
|
@ -121,10 +119,10 @@ getpath(char *buf, char *arg, coord x, coord y, int onlyown,
|
||||||
pr("Destination sectors not allowed here!\n");
|
pr("Destination sectors not allowed here!\n");
|
||||||
break;
|
break;
|
||||||
case P_FLYING:
|
case P_FLYING:
|
||||||
bp = BestAirPath(buf2, nx, ny, dx, dy);
|
bp = BestAirPath(buf2, x, y, dx, dy);
|
||||||
break;
|
break;
|
||||||
case P_SAILING:
|
case P_SAILING:
|
||||||
bp = BestShipPath(buf2, nx, ny, dx, dy, player->cnum);
|
bp = BestShipPath(buf2, x, y, dx, dy, player->cnum);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (bp && p + strlen(bp) + 1 < buf + MAX_PATH_LEN) {
|
if (bp && p + strlen(bp) + 1 < buf + MAX_PATH_LEN) {
|
||||||
|
@ -157,8 +155,8 @@ getpath(char *buf, char *arg, coord x, coord y, int onlyown,
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
++p;
|
++p;
|
||||||
x = nx;
|
x = sect.sct_x;
|
||||||
y = ny;
|
y = sect.sct_y;
|
||||||
}
|
}
|
||||||
fly_map(x, y);
|
fly_map(x, y);
|
||||||
if (showdes) {
|
if (showdes) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue