Cover sea & air in new path finder's regression test-bed

Make TEST_PATH_FIND cover sea & air paths in addition to land paths.
This commit is contained in:
Markus Armbruster 2011-02-26 16:54:40 +01:00
parent 70ef6066f2
commit b340b2d194

View file

@ -475,12 +475,64 @@ BestShipPath(char *path, int fx, int fy, int tx, int ty, int owner)
map = ef_ptr(EF_BMAP, owner); map = ef_ptr(EF_BMAP, owner);
if (!map) if (!map)
return NULL; return NULL;
#ifdef TEST_PATH_FIND
double newc = path_find(fx, fy, tx, ty, owner, MOB_SAIL);
char *p = bestownedpath(path, map, fx, fy, tx, ty, owner);
double c;
size_t l;
char buf[MAX_PATH_LEN];
if (!p)
c = -1.0;
else {
l = strlen(p);
if (p[l-1] == 'h')
l--;
c = l;
}
if (c != newc) {
path_find_route(buf, sizeof(buf), fx, fy, tx, ty);
printf("%d,%d -> %d,%d %d: old %g, new %g, %g off\n",
fx, fy, tx, ty, MOB_FLY, c, newc, c - newc);
printf("\told: %s\n", p);
printf("\tnew: %s\n", buf);
}
return p;
#else
return bestownedpath(path, map, fx, fy, tx, ty, owner); return bestownedpath(path, map, fx, fy, tx, ty, owner);
#endif
} }
char * char *
BestAirPath(char *path, int fx, int fy, int tx, int ty) BestAirPath(char *path, int fx, int fy, int tx, int ty)
{ {
#ifdef TEST_PATH_FIND
double newc = path_find(fx, fy, tx, ty, 0, MOB_FLY);
char *p = bestownedpath(path, NULL, fx, fy, tx, ty, -1);
double c;
size_t l;
char buf[MAX_PATH_LEN];
if (!p)
c = -1.0;
else {
l = strlen(p);
if (p[l-1] == 'h')
l--;
c = l;
}
if (c != newc) {
path_find_route(buf, sizeof(buf), fx, fy, tx, ty);
printf("%d,%d -> %d,%d %d: old %g, new %g, %g off\n",
fx, fy, tx, ty, MOB_FLY, c, newc, c - newc);
printf("\told: %s\n", p);
printf("\tnew: %s\n", buf);
}
return p;
#else
return bestownedpath(path, NULL, fx, fy, tx, ty, -1); return bestownedpath(path, NULL, fx, fy, tx, ty, -1);
#endif
} }
#endif /* !USE_PATH_FIND */ #endif /* !USE_PATH_FIND */