HomeWildfire Games

Implements random map system, fixes #6.
AuditedrP9096

Description

Implements random map system, fixes #6.
Includes default library "rmgen" w/ API based on rmgen tool.
Modifies rmgen scripts Cantabrian Highlands, Neareastern Badlands, and Latium.
Old map support dropped from MapReader.
Fixes a few bugs in existing game setup and initialization scripts.

Details

Auditors
elexis
Committed
benMar 22 2011, 2:34 AM
Parents
rP9095
Branches
Unknown
Tags
Unknown

Event Timeline

elexis added a subscriber: elexis.Oct 16 2017, 11:52 AM
elexis added inline comments.
/ps/trunk/binaries/data/mods/public/maps/random/rmgen/placer.js
156

unused

elexis raised a concern with this commit.Oct 17 2017, 2:51 PM

This was a very important patch in 0 A.D. history as it allowed modifying the random map gen library without having to mess with C++ code.

/ps/trunk/binaries/data/mods/public/maps/random/rmgen/painter.js
1

Order of painters is awkward (ElevationPainter, LayeredPainter, SmoothElevationPainter, TerrainPainter) should be (TerrainPainter, LayeredPainter, ElevationPainter, SmoothElevationPainter) so that painters are grouped by what they do (texture or elevation) and in the order of increasing complexity (simple, complex).

50

The Breadth-First-Search algorithm copy & pasted by LayeredPainter and SmoothElevationPainter, rendering both functions unintelligible, so neither improvable nor maintainable.

195

comments redundant with code

283

semi-redundant if statements with redundant partial consequents

/ps/trunk/binaries/data/mods/public/maps/random/rmgen/placer.js
72

The cubic interpolation could have been moved to a function,
so that it could be tested,
exchanged easily with a different interpolation algorithm and
used in other places of the code,
for example the pathplacer introduced by rP11152 which copies this code.

/ps/trunk/binaries/data/mods/public/maps/random/rmgen/random.js
1

There were thousands of lines of code that were replaced in alpha 22 with patches by bb to get rid of these functions again.

/ps/trunk/binaries/data/mods/public/maps/random/rmgen/terrain.js
42

Not a fan of these code separators. Let the code speak for itself.

This commit now has outstanding concerns.Oct 17 2017, 2:51 PM

This commit transcribed what was identically present in C++ before.
The original C++ rmgen system was introduced in rP2293 (What was that ASCII generator though?).
The SmoothElevationPainter was introduced in rP2519.
The first two random maps were Cantabrian Highlands rP2683 and Neareastern Badlands rP2733.
The C++ rmgen code was removed after this commit in rP9219.

/ps/trunk/binaries/data/mods/public/maps/random/rmgen/painter.js
182

heightmapSize would have been more clear (refs #4825).

elexis added inline comments.Oct 26 2017, 3:08 PM
/ps/trunk/binaries/data/mods/public/maps/random/rmgen/painter.js
1

Painters ordered by complexity and functionality in rP20347 and rP20349.

50

The duplication existed since rP2519 and was removed in rP20350.

182

Changed to that in rP20350.

195

Removed by rP20350.

283

Unified in rP20350.

elexis added inline comments.Oct 31 2017, 2:55 PM
/ps/trunk/binaries/data/mods/public/maps/random/rmgen/placer.js
156

Deleted in rP20357.

197

Just use && to test all conditions at once instead of of nesting in the else part. Fixed in rP20357.

220

always met

/ps/trunk/binaries/data/mods/public/maps/random/rmgen/vector.js
8

Why does this use y and not z and introduce a Point?
This Vector2D is now in globalscripts, used in the simulation and in every place I found uses y where z is meant, so it should become X, Z in that class IMO. This way the rmgen use of PointXZ also has the advantages of being able to use the vector math directly.
But I see that r9271 made some effort to change y to z.

elexis accepted this commit.Jan 22 2018, 6:25 AM

There were 5 months of rewriting the random map script and random map generation library put into this, which addresses all duplication concerns, the requested sorting, adds documentation and switches almost all operations to vector algebra.
It is an ingenious library!

All concerns with this commit have now been addressed.Jan 22 2018, 6:25 AM
elexis added inline comments.Feb 10 2018, 2:50 PM
/ps/trunk/binaries/data/mods/public/maps/random/rmgen/placer.js
18

This prevents getting a large circular area if the center is out of bounds or fails the constraint, even when the fail fraction is infinity.
By definition of the fail fraction, it's wrong code, even though the idea is that it may help with performance (assuming that the center fails, that most of the rest fails too)

elexis added inline comments.Feb 20 2018, 4:39 AM
/ps/trunk/binaries/data/mods/public/maps/random/rmgen/placer.js
162

this is not a placer, see #4804

182

The Object has the avoidSelf mechanism, but no mechanism to avoid other objects in the same SimpleGroup leading to small stone mines unreachable in great stone mines, see D189.