(bestownedpath): Return NULL on long path instead of "?". Terminate
returned path with 'h'. This makes BestShipPath() and BestAirPath() more similar to BestLandPath(). Simplify callers.
This commit is contained in:
parent
9c27a771b3
commit
abb9ae2338
3 changed files with 6 additions and 7 deletions
|
@ -474,12 +474,10 @@ sorde(void)
|
||||||
c = BestShipPath(buf, ship.shp_x,
|
c = BestShipPath(buf, ship.shp_x,
|
||||||
ship.shp_y, ship.shp_destx[0],
|
ship.shp_y, ship.shp_destx[0],
|
||||||
ship.shp_desty[0], ship.shp_own);
|
ship.shp_desty[0], ship.shp_own);
|
||||||
if (!c || !*c)
|
if (!c)
|
||||||
pr(" no route possible");
|
pr(" no route possible");
|
||||||
else if (*c == 'h')
|
else if (*c == 'h')
|
||||||
pr(" has arrived");
|
pr(" has arrived");
|
||||||
else if (*c == '?')
|
|
||||||
pr(" route too long");
|
|
||||||
else {
|
else {
|
||||||
/* distance to destination */
|
/* distance to destination */
|
||||||
eta_calc(&ship, c, &len, &updates);
|
eta_calc(&ship, c, &len, &updates);
|
||||||
|
|
|
@ -176,8 +176,8 @@ bestownedpath(s_char *bpath,
|
||||||
maxy = y + 1;
|
maxy = y + 1;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
if (++routelen == MAXROUTE)
|
if (++routelen == MAXROUTE - 1)
|
||||||
return "?";
|
return NULL;
|
||||||
markedsectors = 0;
|
markedsectors = 0;
|
||||||
for (scanx = minx; scanx <= maxx; scanx++) {
|
for (scanx = minx; scanx <= maxx; scanx++) {
|
||||||
x = XNORM(scanx);
|
x = XNORM(scanx);
|
||||||
|
@ -200,7 +200,8 @@ bestownedpath(s_char *bpath,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (tx == ex && ty == ey) {
|
if (tx == ex && ty == ey) {
|
||||||
bpath[routelen] = 0;
|
bpath[routelen] = 'h';
|
||||||
|
bpath[routelen + 1] = 0;
|
||||||
while (routelen--) {
|
while (routelen--) {
|
||||||
i = ((mapindex[tx][ty]) >> 13) - 1;
|
i = ((mapindex[tx][ty]) >> 13) - 1;
|
||||||
bpath[routelen] = dirchar[i];
|
bpath[routelen] = dirchar[i];
|
||||||
|
|
|
@ -285,7 +285,7 @@ nav_ship(struct shpstr *sp)
|
||||||
cp = BestShipPath(buf, sp->shp_x, sp->shp_y,
|
cp = BestShipPath(buf, sp->shp_x, sp->shp_y,
|
||||||
sp->shp_destx[0], sp->shp_desty[0],
|
sp->shp_destx[0], sp->shp_desty[0],
|
||||||
sp->shp_own);
|
sp->shp_own);
|
||||||
if (cp == 0 || (*cp == '\0') || (*cp == '?')) {
|
if (cp == 0) {
|
||||||
wu(0, cnum,
|
wu(0, cnum,
|
||||||
"%s bad path, ship put on standby\n", prship(sp));
|
"%s bad path, ship put on standby\n", prship(sp));
|
||||||
sp->shp_autonav |= AN_STANDBY;
|
sp->shp_autonav |= AN_STANDBY;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue