Remove extreme amounts of rmgen duplication
|Reported by:||elexis||Owned by:||elexis|
|Priority:||Must Have||Milestone:||Alpha 23|
Description (last modified by )
The random map scripts have been created by copying code instead of moving it to a helper function and calling it multiple times.
- 50-60 copies of the initial base and starting resources placement code. This means if we want nomad on all maps, add retry loops to check for resource collisions with the map or iberian walls, all copies have to be changed (refs #4600, #4796).
- Includes dozens of copies of slightly modified radial, linear or river player placement code.
- Several hundred of createArea calls that copy a comment explaining the arguments in every call, could become twice as short and not violate the variable declaration scope if they would inline variables. Many
createAreacalls also contain tileClass painters that are useless, since they are overwritten by a later
paintTerrainBasedOnHeight(every painter in
- About 1400 of comments that are identical to the log entry one line below (removed in r20144)
- Two dozen of copies that use the
P_FORESTmechanism to create forests
- Two dozen of copies of a riverPlacement code.
- Dozens of mine, tree and grass patch placement functions that can probably be abstracted.
- A workaround is copied to every PathPlacer call that is supposed to not end shortly before the map border (most importantly for rivers like on Lorraine Plain or on the mountains in the
Unknownmaps with the
Copies within maps:
- Unknown, Unknown Land and Unknown Nomad (r12545, r12654, r12747) are a very long copy of each other with different intransparent bugfixes (r14162) applied to different parts of the different maps.
- Snowflake Searocks copied the entire map generation code about 8 times with negligibly different constants for different mapsizes
- Corsica & Sardinia (r11266) copies the island generation code for Corsica and Sardinia
- Cycladic Archipelago (r11137) has a copy to create an Island for the player islands and the central islands
- Fortress (r11361) comes with twice the number of starting units and achieves that by calling a rmgen function and then appending a copy of that function ot the map.
- Wild Lake (r19704) copies the starting location code from Caledonian Meadows
- Islands copies the island generation code (but I didn't find a way to abstract cleanly)
- Lorraine Plain, English Channel and the Unknown maps copy the tributary generation code