fairland: Eliminate macro ELEV, it's an abomination
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
This commit is contained in:
parent
fd164c5860
commit
7f1bbcad94
1 changed files with 17 additions and 11 deletions
|
@ -1301,7 +1301,6 @@ distance_to_what(int x, int y, int flag)
|
||||||
return d;
|
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_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)
|
#define distance_to_mountain() distance_to_what(sectx[c][i], secty[c][i], 2)
|
||||||
|
|
||||||
|
@ -1310,8 +1309,8 @@ distance_to_what(int x, int y, int flag)
|
||||||
static void
|
static void
|
||||||
elevate_land(void)
|
elevate_land(void)
|
||||||
{
|
{
|
||||||
int i, mountain_search, k, c, total, ns, nm, highest, where, h, newk,
|
int i, mountain_search, k, c, total, ns, nm, r, x, y;
|
||||||
r, dk;
|
int highest, where, h, newk, dk;
|
||||||
|
|
||||||
for (c = 0; c < nc + ni; ++c) {
|
for (c = 0; c < nc + ni; ++c) {
|
||||||
total = 0;
|
total = 0;
|
||||||
|
@ -1329,16 +1328,19 @@ elevate_land(void)
|
||||||
k && mountain_search < MOUNTAIN_SEARCH_MAX;
|
k && mountain_search < MOUNTAIN_SEARCH_MAX;
|
||||||
++mountain_search) {
|
++mountain_search) {
|
||||||
r = roll0(total);
|
r = roll0(total);
|
||||||
for (i = 0; i < ns; ++i)
|
for (i = 0; i < ns; ++i) {
|
||||||
if (r < weight[i] && ELEV == -INFINITE_ELEVATION &&
|
x = sectx[c][i];
|
||||||
|
y = secty[c][i];
|
||||||
|
if (r < weight[i] && elev[x][y] == -INFINITE_ELEVATION &&
|
||||||
(c >= nc ||
|
(c >= nc ||
|
||||||
((!(capx[c] == sectx[c][i] &&
|
((!(capx[c] == sectx[c][i] &&
|
||||||
capy[c] == secty[c][i])) &&
|
capy[c] == secty[c][i])) &&
|
||||||
(!(new_x(capx[c] + 2) == sectx[c][i] &&
|
(!(new_x(capx[c] + 2) == sectx[c][i] &&
|
||||||
capy[c] == secty[c][i]))))) {
|
capy[c] == secty[c][i]))))) {
|
||||||
ELEV = INFINITE_ELEVATION;
|
elev[x][y] = INFINITE_ELEVATION;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
--k;
|
--k;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1353,7 +1355,9 @@ elevate_land(void)
|
||||||
highest = 0;
|
highest = 0;
|
||||||
where = -1;
|
where = -1;
|
||||||
for (i = 0; i < ns; ++i) {
|
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] &&
|
(c >= nc || ((!(capx[c] == sectx[c][i] &&
|
||||||
capy[c] == secty[c][i])) &&
|
capy[c] == secty[c][i])) &&
|
||||||
(!(new_x(capx[c] + 2) == sectx[c][i] &&
|
(!(new_x(capx[c] + 2) == sectx[c][i] &&
|
||||||
|
@ -1379,17 +1383,19 @@ elevate_land(void)
|
||||||
/* Elevate the mountains and capitals */
|
/* Elevate the mountains and capitals */
|
||||||
|
|
||||||
for (i = 0; i < ns; ++i) {
|
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)
|
if (dsea[i] == 1)
|
||||||
ELEV = HILLMIN + roll0(PLATMIN - HILLMIN);
|
elev[x][y] = HILLMIN + roll0(PLATMIN - HILLMIN);
|
||||||
else
|
else
|
||||||
ELEV = HIGHMIN + roll0((256 - HIGHMIN) / 2) +
|
elev[x][y] = HIGHMIN + roll0((256 - HIGHMIN) / 2) +
|
||||||
roll0((256 - HIGHMIN) / 2);
|
roll0((256 - HIGHMIN) / 2);
|
||||||
} else if (c < nc &&
|
} else if (c < nc &&
|
||||||
(((capx[c] == sectx[c][i] && capy[c] == secty[c][i])) ||
|
(((capx[c] == sectx[c][i] && capy[c] == secty[c][i])) ||
|
||||||
((new_x(capx[c] + 2) == sectx[c][i] &&
|
((new_x(capx[c] + 2) == sectx[c][i] &&
|
||||||
capy[c] == secty[c][i]))))
|
capy[c] == secty[c][i]))))
|
||||||
ELEV = PLATMIN;
|
elev[x][y] = PLATMIN;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue