From: Markus Armbruster Date: Mon, 17 Aug 2020 06:39:22 +0000 (+0200) Subject: fairland: Eliminate macro ELEV, it's an abomination X-Git-Url: http://git.pond.sub.org/?p=empserver;a=commitdiff_plain;h=60a89a83c7e3b514f1475ce3263f5df4217f9a32;hp=fe86ea430a8e295a0bd129309cc5a4333cecb41d fairland: Eliminate macro ELEV, it's an abomination Signed-off-by: Markus Armbruster --- diff --git a/src/util/fairland.c b/src/util/fairland.c index 592b07dd0..02f1ee0d1 100644 --- a/src/util/fairland.c +++ b/src/util/fairland.c @@ -1300,7 +1300,6 @@ distance_to_what(int x, int y, int flag) return d; } -#define ELEV elev[sectx[c][i]][secty[c][i]] #define distance_to_sea() (sectc[c][i]?1:distance_to_what(sectx[c][i], secty[c][i], 0)) #define distance_to_mountain() distance_to_what(sectx[c][i], secty[c][i], 2) @@ -1309,8 +1308,8 @@ distance_to_what(int x, int y, int flag) static void elevate_land(void) { - int i, mountain_search, k, c, total, ns, nm, highest, where, h, newk, - r, dk; + int i, mountain_search, k, c, total, ns, nm, r, x, y; + int highest, where, h, newk, dk; for (c = 0; c < nc + ni; ++c) { total = 0; @@ -1328,16 +1327,19 @@ elevate_land(void) k && mountain_search < MOUNTAIN_SEARCH_MAX; ++mountain_search) { r = roll0(total); - for (i = 0; i < ns; ++i) - if (r < weight[i] && ELEV == -INFINITE_ELEVATION && + for (i = 0; i < ns; ++i) { + x = sectx[c][i]; + y = secty[c][i]; + if (r < weight[i] && elev[x][y] == -INFINITE_ELEVATION && (c >= nc || ((!(capx[c] == sectx[c][i] && capy[c] == secty[c][i])) && (!(new_x(capx[c] + 2) == sectx[c][i] && capy[c] == secty[c][i]))))) { - ELEV = INFINITE_ELEVATION; + elev[x][y] = INFINITE_ELEVATION; break; } + } --k; } @@ -1352,7 +1354,9 @@ elevate_land(void) highest = 0; where = -1; for (i = 0; i < ns; ++i) { - if (ELEV == -INFINITE_ELEVATION && + x = sectx[c][i]; + y = secty[c][i]; + if (elev[x][y] == -INFINITE_ELEVATION && (c >= nc || ((!(capx[c] == sectx[c][i] && capy[c] == secty[c][i])) && (!(new_x(capx[c] + 2) == sectx[c][i] && @@ -1378,17 +1382,19 @@ elevate_land(void) /* Elevate the mountains and capitals */ for (i = 0; i < ns; ++i) { - if (ELEV == INFINITE_ELEVATION) { + x = sectx[c][i]; + y = secty[c][i]; + if (elev[x][y] == INFINITE_ELEVATION) { if (dsea[i] == 1) - ELEV = HILLMIN + roll0(PLATMIN - HILLMIN); + elev[x][y] = HILLMIN + roll0(PLATMIN - HILLMIN); else - ELEV = HIGHMIN + roll0((256 - HIGHMIN) / 2) + + elev[x][y] = HIGHMIN + roll0((256 - HIGHMIN) / 2) + roll0((256 - HIGHMIN) / 2); } else if (c < nc && (((capx[c] == sectx[c][i] && capy[c] == secty[c][i])) || ((new_x(capx[c] + 2) == sectx[c][i] && capy[c] == secty[c][i])))) - ELEV = PLATMIN; + elev[x][y] = PLATMIN; } } }