Opened 7 years ago
Last modified 6 years ago
#4805 closed defect
Remove extreme amounts of rmgen duplication — at Initial Version
Reported by: | elexis | Owned by: | elexis |
---|---|---|---|
Priority: | Must Have | Milestone: | Alpha 23 |
Component: | Maps | Keywords: | |
Cc: | Patch: |
Description
The random map scripts have been created by copying code instead of moving it to a helper function and calling it multiple times.
Global copies:
- 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.
- 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
createArea
calls also contain tileClass painters that are useless, since they are overwritten by a laterpaintTerrainBasedOnHeight
(every painter inunknown*js
). - 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_FOREST
mechanism 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
Unknown
maps with thePasses
variant).
Copies within maps:
- Unknown, Unknown Land and Unknown Nomad (r12545, r12654, 12747) 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
Note:
See TracTickets
for help on using tickets.