HomeWildfire Games

Unify rmgen modifyTilesBasedOnHeight (rP20189) with the HeightPlacer (rP20361).

Description

Unify rmgen modifyTilesBasedOnHeight (rP20189) with the HeightPlacer (rP20361).

Create global constants for the elevation modes and make that Placer more versatile by adding the mode argument.
Improves the performance of these functions by not repeating the mode, createTerrain and getTileClass lookups every tile.
Move the functions to library.js, refs #4804.

Event Timeline

elexis added inline comments.Nov 10 2017, 11:34 PM
/ps/trunk/binaries/data/mods/public/maps/random/rmgen/placer_noncentered.js
44

g_ would seem really out of place to me, since this isn't high-level code but feels as close to the engine as JS gets:

createArea(
	new HeightPlacer(g_Elevation_IncludeMin_IncludeMax, heightRange.min, heighLimits[2]),

g_Something typically hold high level values.
In rmgen we only have g_Environment, g_Map, g_MapSettings and g_Camera - all of which contain user values.

ALSOALLCAPSCONSTSSEEMUGLY.

If someone feels otherwise this can still be easily changed until calls to the paintSomethingBasedOnHeight functions replace the magic numbers with the constants.

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

And CamelCase_CamelCase_CamelCase looks acceptable? That's worse than g_CamelCase and CAPS_WITH_UNDERSCORES. (Not that I'm actually going to read rms code.)