Compile-time option to switch off "multiple paths same source"
authorMarkus Armbruster <armbru@pond.sub.org>
Mon, 21 Feb 2011 22:52:42 +0000 (23:52 +0100)
committerMarkus Armbruster <armbru@pond.sub.org>
Tue, 12 Apr 2011 20:26:05 +0000 (22:26 +0200)
Just to facilitate benchmarking.

src/lib/update/finish.c

index 25b14d8737d96122475e61c5f1b684a695aad8b5..8fe2cb2bd3fd493c292962c77c0fd1feb1cf100e 100644 (file)
@@ -124,7 +124,7 @@ finish_sects(int etu)
 
 }
 
-#if defined(USE_PATH_FIND) || defined(TEST_PATH_FIND)
+#if (defined(USE_PATH_FIND) || defined(TEST_PATH_FIND)) && !defined(DIST_PATH_NO_REUSE)
 static int
 distcmp(const void *p, const void *q)
 {
@@ -154,6 +154,12 @@ assemble_dist_paths(double *import_cost)
     int uid, i;
     coord dx = 1, dy = 0;      /* invalid */
 
+#ifdef DIST_PATH_NO_REUSE
+    for (uid = 0; NULL != (sp = getsectid(uid)); uid++) {
+       import_cost[uid] = -1;
+       if (sp->sct_dist_x == sp->sct_x && sp->sct_dist_y == sp->sct_y)
+           continue;
+#else
     if (!job)
        job = malloc(WORLD_SZ() * sizeof(*job));
 
@@ -174,18 +180,25 @@ assemble_dist_paths(double *import_cost)
 
     for (i = 0; i < n; i++) {
        uid = job[i];
+#endif /* !DIST_PATH_NO_REUSE */
        sp = getsectid(uid);
        dist = getsectp(sp->sct_dist_x, sp->sct_dist_y);
        if (CANT_HAPPEN(!dist))
            continue;
        if (sp->sct_own != dist->sct_own)
            continue;
+#ifdef DIST_PATH_NO_REUSE
+       import_cost[uid] = path_find(sp->sct_dist_x, sp->sct_dist_y,
+                                    sp->sct_x, sp->sct_y, dist->sct_own,
+                                    MOB_MOVE);
+#else
        if (sp->sct_dist_x != dx || sp->sct_dist_y != dy) {
            dx = sp->sct_dist_x;
            dy = sp->sct_dist_y;
            path_find_from(dx, dy, dist->sct_own, MOB_MOVE);
        }
        import_cost[uid] = path_find_to(sp->sct_x, sp->sct_y);
+#endif
     }
 #endif /* USE_PATH_FIND || TEST_PATH_FIND */
 #if !defined(USE_PATH_FIND) || defined(TEST_PATH_FIND)