From b340b2d194d377fe522a61c90d154f88edd7c8c4 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Sat, 26 Feb 2011 16:54:40 +0100 Subject: [PATCH] Cover sea & air in new path finder's regression test-bed Make TEST_PATH_FIND cover sea & air paths in addition to land paths. --- src/lib/common/path.c | 52 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/src/lib/common/path.c b/src/lib/common/path.c index e901d485..ff907cbd 100644 --- a/src/lib/common/path.c +++ b/src/lib/common/path.c @@ -475,12 +475,64 @@ BestShipPath(char *path, int fx, int fy, int tx, int ty, int owner) map = ef_ptr(EF_BMAP, owner); if (!map) 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); +#endif } char * 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); +#endif } #endif /* !USE_PATH_FIND */