]> git.pond.sub.org Git - empserver/commitdiff
fairland: Set isecs[] for continents as well & simplify
authorMarkus Armbruster <armbru@pond.sub.org>
Sat, 25 Jul 2020 05:28:28 +0000 (07:28 +0200)
committerMarkus Armbruster <armbru@pond.sub.org>
Tue, 5 Jan 2021 09:41:36 +0000 (10:41 +0100)
isecs[] is left zero for continents.  Set it to @sc instead, and
simplify two loops over land sectors.

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

index c22e5b72fb550bdc1c4d6c65069065553de5b6a0..0e3b10db40c08599582ac0b05eafcc99ce8860f7 100644 (file)
@@ -685,6 +685,7 @@ try_to_grow(int c, int newx, int newy, int d)
     }
     sectx[c][secs] = newx;
     secty[c][secs] = newy;
+    isecs[c]++;
     own[newx][newy] = c;
     return 1;
 }
@@ -798,6 +799,7 @@ grow_continents(void)
        sectx[c][1] = new_x(capx[c] + 2);
        secty[c][1] = capy[c];
        own[sectx[c][1]][secty[c][1]] = c;
+       isecs[c] = 2;
     }
 
     for (secs = 2; secs < sc && !fl_status; ++secs) {
@@ -866,7 +868,6 @@ grow_islands(void)
        } while (secs < isiz && grow_one_sector(c));
        find_coast(c);
        qprint(" %d(%d)", c - nc + 1, secs);
-       isecs[c] = secs;
        ctot++;
     }
 }
@@ -932,7 +933,7 @@ elevate_land(void)
 
     for (c = 0; c < ctot; ++c) {
        total = 0;
-       ns = (c < nc) ? sc : isecs[c];
+       ns = isecs[c];
        nm = (pm * ns) / 100;
 
 /* Place the mountains */
@@ -1282,13 +1283,7 @@ set_coastal_flags(void)
     int i, j;
     struct sctstr *sp;
 
-    for (i = 0; i < nc; ++i) {
-       for (j = 0; j < sc; j++) {
-           sp = getsectp(sectx[i][j], secty[i][j]);
-           sp->sct_coastal = sectc[i][j];
-       }
-    }
-    for (i = nc; i < nc + ni; ++i) {
+    for (i = 0; i < nc + ni; ++i) {
        for (j = 0; j < isecs[i]; j++) {
            sp = getsectp(sectx[i][j], secty[i][j]);
            sp->sct_coastal = sectc[i][j];