]> git.pond.sub.org Git - empserver/commitdiff
fairland: Report missing and stunted islands
authorMarkus Armbruster <armbru@pond.sub.org>
Sat, 25 Jul 2020 06:13:54 +0000 (08:13 +0200)
committerMarkus Armbruster <armbru@pond.sub.org>
Tue, 5 Jan 2021 09:41:36 +0000 (10:41 +0100)
fairland can create fewer and smaller islands than the user requested.
Report like this:

    No room for island #13
    6 stunted islands

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

index 3025f86e85846775295475fa521e961ecf608513..c42fbbb3d3ddd928bdae3c3955373e5275387e07 100644 (file)
@@ -861,21 +861,32 @@ place_island(int c, int *xp, int *yp)
 static void
 grow_islands(void)
 {
+    int stunted_islands = 0;
     int c, secs, x, y, isiz;
 
     for (c = nc; c < nc + ni; ++c) {
-       secs = 0;
-       if (!place_island(c, &x, &y))
-           return;
+       if (!place_island(c, &x, &y)) {
+           qprint("\nNo room for island #%d", c - nc + 1);
+           break;
+       }
+
        isiz = roll(is) + roll0(is);
-       do {
-           ++secs;
+       for (secs = 1; secs < isiz; secs++) {
            find_coast(c);
-       } while (secs < isiz && grow_one_sector(c));
+           if (!grow_one_sector(c)) {
+               stunted_islands++;
+               break;
+           }
+       }
+
        find_coast(c);
        qprint(" %d(%d)", c - nc + 1, secs);
        ctot++;
     }
+
+    if (stunted_islands)
+       qprint("\n%d stunted island%s",
+              stunted_islands, splur(stunted_islands));
 }
 
 /****************************************************************************
index ed57497fc94ff3a0fac2bdd42f1ad502dfeec952..fb80fb9628b2a6950bcefee51113d4e886b958b1 100644 (file)
@@ -26,6 +26,8 @@ try #3 (out of 10)...
 placing capitals...
 growing continents...
 growing islands: 1(14) 2(20) 3(11) 4(16) 5(14) 6(8) 7(2) 8(3) 9(4) 10(5) 11(14) 12(3)
+No room for island #13
+6 stunted islands
 elevating land...
 writing to sectors file...