fairland: Tweak rural elevations for simplicity

elevate_land() computes the sequence of elevations 97, 97 - delta,
... in fixed point with a scaling factor of 100.  Switch to
floating-point, because it's simpler.  Elevations (and thus resources)
change slightly due to reduced rounding errors.

Note that we map elevations less than 1 to 1 both before and after the
patch.  Odd.  Turns out this mitigates a bug: mountain placement can
place fewer mountains than it should, and when that happens,
elevations go below 1 here.  The next commit will fix this.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
This commit is contained in:
Markus Armbruster 2020-08-19 13:31:09 +02:00
parent 7ce7440a34
commit dd9bda62eb
5 changed files with 778 additions and 780 deletions

View file

@ -1296,7 +1296,7 @@ elevate_land(void)
{
int max_nm = (pm * MAX(sc, is * 2)) / 100;
int i, off, mountain_search, k, c, total, ns, nm, r, x, y;
int highest, where, h, newk, dk;
int highest, where, h;
double elevation, delta;
for (c = 0; c < nc + ni; ++c) {
@ -1336,10 +1336,9 @@ elevate_land(void)
for (i = 0; i < ns; ++i)
dmoun[i] = distance_to_mountain();
dk = (ns - nm - ((c < nc) ? 3 : 1) > 0) ?
(100 * (HIGHMIN - LANDMIN)) / (ns - nm - ((c < nc) ? 3 : 1)) :
100 * INFINITE_ELEVATION;
for (k = 100 * (HIGHMIN - 1);; k -= dk) {
delta = (double)(HIGHMIN - 1 - LANDMIN)
/ (ns - nm - ((c < nc) ? 3 : 1));
for (elevation = HIGHMIN - 1;; elevation -= delta) {
highest = 0;
where = -1;
for (i = 0; i < ns; ++i) {
@ -1360,10 +1359,9 @@ elevate_land(void)
}
if (where == -1)
break;
newk = k / 100;
if (newk < LANDMIN)
newk = LANDMIN;
elev[sectx[c][where]][secty[c][where]] = newk;
if (elevation < LANDMIN)
elevation = LANDMIN;
elev[sectx[c][where]][secty[c][where]] = (int)(elevation + 0.5);
}
/* Elevate the mountains and capitals */