From 0385c67a8fce0c17c341364cc340428de08c8b45 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Sat, 19 Feb 2011 13:50:10 +0100 Subject: [PATCH] Fix when best_path() prints A* performance statistics Print them when A* actually runs, not when best_path() finds a path. Statistics for unsuccessful runs were lost, and old statistics were printed for path cache hits. --- src/lib/common/path.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/lib/common/path.c b/src/lib/common/path.c index 965da6e29..9cdf959ec 100644 --- a/src/lib/common/path.c +++ b/src/lib/common/path.c @@ -98,6 +98,7 @@ best_path(struct sctstr *from, struct sctstr *to, char *path, int mob_type) static struct bestp *mybestpath; struct as_data *adp; struct as_path *ap; + int res; if (!mybestpath) mybestpath = bp_init(); @@ -110,19 +111,19 @@ best_path(struct sctstr *from, struct sctstr *to, char *path, int mob_type) adp->to.y = to->sct_y; mybestpath->bp_mobtype = mob_type; - if (as_search(adp) < 0) + res = as_search(adp); +#ifdef AS_STATS + as_stats(adp, stderr); + fprintf(stderr, "neighbor cache %zu bytes\n", + WORLD_SZ() * 6 * sizeof(struct sctstr *)); +#endif + if (res < 0) return -1; ap = adp->path; } if (bp_path(ap, path) < 0) return -1; - -#ifdef AS_STATS - as_stats(adp, stderr); - fprintf(stderr, "neighbor cache %zu bytes\n", - WORLD_SZ() * 6 * sizeof(struct sctstr *)); -#endif /* AS_STATS */ return 0; } -- 2.43.0