fairland: Simplify how write_sect() iterates over sectors
authorMarkus Armbruster <armbru@pond.sub.org>
Fri, 21 Aug 2020 11:12:11 +0000 (13:12 +0200)
committerMarkus Armbruster <armbru@pond.sub.org>
Sun, 17 Jan 2021 20:24:28 +0000 (21:24 +0100)
Iterating over IDs is slightly simpler than iterating over
coordinates, so do that.

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

index 56aac1bda78bb2cb9e5b1cca8aa9e6a74bb4cc2d..e07f08868030a277612c0bb6f4255e56f3fad584 100644 (file)
@@ -1433,19 +1433,17 @@ add_resources(struct sctstr *sct)
 static void
 write_sects(void)
 {
-    struct sctstr *sct;
-    int x, y;
+    struct sctstr *sp;
+    int i;
 
-    for (y = 0; y < WORLD_Y; y++) {
-       for (x = y % 2; x < WORLD_X; x += 2) {
-           sct = getsectp(x, y);
-           sct->sct_elev = elev[sct->sct_uid];
-           sct->sct_type = elev_to_sct_type(sct->sct_elev);
-           sct->sct_newtype = sct->sct_type;
-           sct->sct_dterr = own[sct->sct_uid] + 1;
-           sct->sct_coastal = is_coastal(sct->sct_x, sct->sct_y);
-           add_resources(sct);
-       }
+    for (i = 0; i < WORLD_SZ(); i++) {
+       sp = getsectid(i);
+       sp->sct_elev = elev[i];
+       sp->sct_type = elev_to_sct_type(sp->sct_elev);
+       sp->sct_newtype = sp->sct_type;
+       sp->sct_dterr = own[i] + 1;
+       sp->sct_coastal = is_coastal(sp->sct_x, sp->sct_y);
+       add_resources(sp);
     }
 }