id summary reporter owner description type status priority milestone component resolution keywords cc phab_field 4804 Sort rmgen functions by logic elexis elexis "The old school `rmgen` directory is a bit messy, because three of the files don't have a clear separation of functions according to logic: * `utilityfunctions.js` contains some frequently used elevation and entity placement helpers. * The filename is arbitrary and should be renamed before random unrelated code is added there. * It could be split to `terrain_helpers.js` and `placer_helpers.js` or similar. * Its tileClass hardcodings can lead to reference errors and have to be removed. * `misc.js` * contains some frequently helper functions for the starting base that should be moved to a new file `startingentities.js`. That file will be extended with new helper functions that will replace the duplication of the starting base code in every rmgen file. * contains some frequently used terrain and placer helper functions too. * contains a lot of linear algebra unrelated to any rmgen implementation and should be moved to a new file * contains some rmgen1 brand functions which are deeply connected to the code in `constraint.js`, `tileclass.js` and `painter.js` and hence should be moved there * contains the four `modifyTilesBasedOnHeight` functions. They could be either moved to the three files above or the other short global helpers which don't fit anywhere in `library.js`. * `library.js`: * contains some starting base functions which should be moved to the new file. * contains some engine hardcodings, which should be replaced with an engine getter sometime (FeXoR ticket somewhere) * contains some useful short globals like `fractionToTiles` * contains a lot of silly proxies like `sin = Math.sin` and `PI = Math.PI` which should be deleted * contains some unrelated math helpers like `getAngle` or `getDistance` which can be moved to the new math file After that, `library.js` will be about 100 to 200 lines of code only, `misc.js` and `utilityfunctions.js` deleted. So it will be easier for new readers to understand the rmgen library. `placers.js` and `pathplacer.js` will become `placer_centered.js` (`ClumpPlacer, ChainPlacer`, can be used at random places meeting a given constraint) and `placers_noncentered.js` (`RectPlacer, PathPlacer`, can only be used to place at hardcoded coordinates). " defect closed Should Have Alpha 23 Maps fixed