]> git.pond.sub.org Git - empserver/commitdiff
fairland: Use INT_MAX as initial minimal distance in iso()
authorMarkus Armbruster <armbru@pond.sub.org>
Sun, 26 Jul 2020 05:30:58 +0000 (07:30 +0200)
committerMarkus Armbruster <armbru@pond.sub.org>
Tue, 5 Jan 2021 09:41:36 +0000 (10:41 +0100)
Simpler and more obviously correct than WORLD_X + WORLD_Y.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
src/util/fairland.c

index a4c0c06a74e7f2f32dc2e265327d2ae110aef758..7f58e0254217dc76a47b897c7c7ef1e92b9bfcf4 100644 (file)
@@ -99,6 +99,7 @@
 
 #include <assert.h>
 #include <errno.h>
 
 #include <assert.h>
 #include <errno.h>
+#include <limits.h>
 #include <stdarg.h>
 #include <stdio.h>
 #include <unistd.h>
 #include <stdarg.h>
 #include <stdio.h>
 #include <unistd.h>
@@ -518,12 +519,15 @@ init(void)
   DRIFT THE CAPITALS UNTIL THEY ARE AS FAR AWAY FROM EACH OTHER AS POSSIBLE
 ****************************************************************************/
 
   DRIFT THE CAPITALS UNTIL THEY ARE AS FAR AWAY FROM EACH OTHER AS POSSIBLE
 ****************************************************************************/
 
-/* How isolated is capital j?
-*/
+/*
+ * How isolated is capital @j at @newx,@newy?
+ * Return the distance to the closest other capital.
+ */
 static int
 iso(int j, int newx, int newy)
 {
 static int
 iso(int j, int newx, int newy)
 {
-    int i, md, d = WORLD_X + WORLD_Y;
+    int d = INT_MAX;
+    int i, md;
 
     for (i = 0; i < nc; ++i) {
        if (i == j)
 
     for (i = 0; i < nc; ++i) {
        if (i == j)