HomeWildfire Games

Remove some more recursive duplication in the rmgen library (painting terrain…

Description

Remove some more recursive duplication in the rmgen library (painting terrain based on height).

Event Timeline

leper added inline comments.
/ps/trunk/binaries/data/mods/public/maps/random/rmgen/misc.js
337

The mode documentation seemed somewhat useful, since now (at least just looking at that file) I have to read the code.

Which leads me to wonder why we don't just make users provide minheight-1 or maxheight+1 if they want that. No clue how many users of this are or if that is something that would make things nicer/easier to understand though.

elexis added inline comments.Sep 17 2017, 10:08 AM
/ps/trunk/binaries/data/mods/public/maps/random/rmgen/misc.js
337

Comments should state something which isn't obvious from glancing at the code.
Due to the compactness and symmetry, it's easier to understand the code than the comment (especially looking up again which mode corresponds to which behavior after having it read the first time).
height is a float.

elexis added inline comments.Nov 10 2017, 10:14 PM
/ps/trunk/binaries/data/mods/public/maps/random/rmgen/misc.js
337

In fact the numbers should be global constants (similar to ELEVATION_MODIFY in painter.js) instead of repeating a random 3 or 1 magic numbers throughout the maps.

The modifyTilesBasedOnHeight can be removed altogether and the functions can just become a createArea call after the HeightPlacer receives this mode as an argument, replacing these 140 lines with something like 10.