Opened 7 years ago

Closed 6 years ago

Last modified 6 years ago

#4805 closed defect (fixed)

Remove extreme amounts of rmgen duplication

Reported by: elexis Owned by: elexis
Priority: Must Have Milestone: Alpha 23
Component: Maps Keywords:
Cc: Patch:

Description (last modified by elexis)

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 (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 createArea calls also contain tileClass painters that are useless, since they are overwritten by a later paintTerrainBasedOnHeight (every painter in unknown*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 the Passes variant).

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

Change History (56)

comment:1 by elexis, 7 years ago

Description: modified (diff)

Didn't check anything before r13948.

Alpha 20:

In r17728:
Move duplicate code of the area- and object-group placing methods to retryPlacing and two coordinate-randomization functions.

In r17910:
Remove unused variables, duplicate comments and trailing whitespace from volcanic lands.

Alpha 21:

In r17981:
Remove triple X comment pollution from maps.

In r18142 by FeXoR:
Removing function euclid_distance as duplication of getDistance.

In r18816:
Don't place chicken inside civic centers and unify chicken placement code.

In r18871:
Remove duplicate fish placement from english channel.

In r18872:
Remove unused clWater and clRiver tile class from maps that don't have water nor rivers.

In r18873:
Remove duplicate comments and add more progress updates.

Alpha 22:

In r19236:
Remove non-functional shallow generation code from the Unknown random maps.

In r19282: Replace more than 30 duplicate grass tuft placement calls with a single function call.

In r19305:
Use pickRandom in random map scripts.
Patch By: bb

In r19453:
Remove useless terrain painting that is overwritten with the paintTerrainBasedOnHeight calls following that.

In r19721:
Delete rmgen randInt duplicate. Patch By: bb

In r19807:
Move duplicate rmgen functions from caledonian meadows and wild lake to the rmgen libraries.

Alpha 23:

In r20144:
Remove 1400 useless random map script comments.

In r20146:
Remove 23 copies of the random mapgen terrain init loop (including 16 copies of unused x and z vars).

In r20148:
Replace 55 playerarray sorting loops copies with calls to two random mapgen helper functions. Rename randomizePlayers as it paradoxically called sortPlayers on the result.

In r20149:
Unify 36 copies of the radial playerplacement loop of random mapscripts. Trim unused PlayerAngle, StartAngle and baseRadius variables.

In r20151:
Merge the 14 copies of the player placement code on river maps.

In r20153:
Create arrays with [], not new Array in random map scripts

In r20185:
Reverse engineer and unify the 14 copies of the river drawing random mapgen code.

Splits unrecognizably blended magic numbers and makes them available for map editors.

Removes copied terms of copies of conditions of copied of functions,
unused variables, overwritten values, checks that are always true, dead code from checks that are always false and
things like 9 pairs of unneeded parentheses in a single line that was copied several times.

Remove the useless RectPlacer terrain painting call on Guadalquivir River.
Make danubius river borders parallel and drop thetha/seed differences.
Use planar instead of slopy water ground level for Phoenician Levant.

Copied and obscured by
r11137 Aegan Sea, Guadalquivir River, Hyrcanian Shores, Phoenician Levan, Nile,
r12545 Unknown,
r12654 Unknown Land,
r12747 Unknown Nomad,
r12786 English Channel,
r13134 Kerala,
r19434 Danubius.

In r20186:
Unify 34 copies of the civic center tile class setting of random map scripts.

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

In r20222:
Fix division by zero in r12545 and r12654 for the gulf map layout with only one player.

In r20233:
Northern lights river cleanup following r20185.

comment:2 by elexis, 7 years ago

In 20294:

Remove about 360 unused variables in random map scripts, refs #4805.
Remove unused hasTextureInRadius from rP11266.

comment:3 by elexis, 7 years ago

In 20295:

Replace hardcoded trigonometry magic numbers on Corinthian Isthmus with a rotateCoordinates computation, allowing to change the river angle arbitrarily.

The new math library file will contain five more math helpers used by random maps, refs #4804.
These functions are agnostic of random map vocabulary, so could possibly be moved to or unified with globalscripts.

Cleanup and label obscure createArea calls in this map, unify duplicate magic numbers, refs #4805.
Remove three useless LayeredPainter calls that are overwritten by the paintTerrainBasedOnHeight tShore and tWater calls afterwards.

comment:4 by elexis, 7 years ago

In r20296:

Corsica & Sardinia cleanup.

Unify clCorsica, clSardinia to clIsland and the duplicate resource placement calls using that.
Move and simplify the logic determining which texture to paint depending on height and slope to a function getCosricaSardiniaTerrain.
Inline the createTerrain to greatly increase readability while possibly reducing performance slightly.
Fix whitespace of createObjectGroup calls.

comment:5 by elexis, 7 years ago

In 20297:

Unify Cycladic Archipelago Island duplication in a helper function createCycladicArchipelagoIsland, refs #4805, rP11653.
Do not place starting resources but random resources on non-player islands.

comment:6 by elexis, 7 years ago

In r20301:

Cleanup most createArea and some createObjectGroup calls in random map scripts.

Inline the placer, terrainPainter, elevationPainter, group and sizes helper variables that are used only once.
Thus do not hoist variable declarations from unrelated scopes.
Remove few dozens of painters that are overpainted by the paintBasedOnTerrainHeight call afterwards.
Remove 334 noisy misaligned code comments ( terrains widths blend radius and some variation).
Label the createArea calls so that the reader knows what they do.
Remove unbenefitial Math.PI/8 grass min/max angle limitation.
Use height variables for the SmoothElevationPainter calls so that levels can be modified more easily.
Use Math prototype functions instead of the unfortunate rmgen proxies.
Does not touch starting base code, Unknown maps, Snowflake Searocks and Corsica & Sardinia which need special treatment.

comment:7 by elexis, 7 years ago

In r20306:

Unify duplicate Corsica & Sardinia island generation, refs rP11266.

The code for the other island was copied in a varying order with only the values changed to 1 - x.
Unite the island, subisland, creeks, beaches, main relief, first plateau, second plateau and passages
code under a single loop to display the logical relation
instead of scattering many paragraphs and executing unrelated (starting base) code in between.

Cleanup affected createArea calls as in rP20301.

comment:8 by elexis, 7 years ago

In r20308:

Unify beyond ridiculous Snowflake Searocks duplication gore, refs r11137.

The island generation code was copied once for

the small mapsize and 2 players
the small mapsize and 3 players
the small mapsize and 4 players
the small mapsize and more than 4 players
the medium mapsize and up to 4 players
the medium mapsize and more than 4 players
the normal mapsize and up to 5 players
the normal mapsize and up to 7 players
the normal mapsize and 8 players
the large mapsize and up to 5 players
the large mapsize and more than 5 players


Within each of these copies there were three copies of the island createArea+placer+painters call and about 10 unreadable island connection setter copies.

Support mapgenerations with only one player.
Cleanup createAreas calls as in rP20301 and broken indentation.
Fix missing forests due to a missing parentheses in the forest count of that commit.

comment:9 by elexis, 7 years ago

In 20350:

Unify duplicate Breadth-First-Search traversing of the LayeredPainter and SmoothElevationPainter in a new helper function, refs #4805, making it much more comprehensible what each part does.
Document the two classes, the new function and every step of their execution, refs #4831.
Unify SmoothElevationPainter height computation duplication, remove pointless comments, use array functions and the prefix increment operator.

comment:10 by elexis, 7 years ago

In 20354:

Remove SemiRandomElevationPainter from Pyrenean Sierra, which is a painful straight copy of the SmoothElevationPainter introduced in rP12248, refs #4805.

It should have been added to the painters file instead of to the map if a copy was acceptable.
Add the only simple capability it added (an unnoticeable random elevation difference to each vertex) to the SmoothElevationPainter to make it universally accessible.
That painter also had a bug, because it replaced the roughness with 5 if 0 was given.

comment:11 by elexis, 7 years ago

In 20355:

Move SimpleGroup and RandomGroup from placers.js to a new file, because they aren't Placers, refs #4804.
Document what a Group is, refs #4831.
Remove duplicate place function by calling the SimpleGroup from the RandomGroup, refs #4805.
Move the default parameters from the function body to the function header, remove duplicate CELL_SIZE division, pointless comment and use let instead of var.

comment:12 by elexis, 6 years ago

In 20357:

Move SimpleObject and RandomObject from placers.js to a new file, because they aren't Placers, refs #4804.
Define what an Object is, refs #4831.
Remove RandomObject duplication from rP9388 by just calling the SimpleObject with a random template, refs #4805.

Remove the tautologous (!fail) check and replace needless multilevel fail-check nesting with two && operators.
Move default parameters from the function body to the function header and rename resultObjs to entities.
Throw errors instead of printing something if min > max.

comment:13 by elexis, 6 years ago

In 20388:

rmgen cleanup.

Remove PointXZ class which is essentially a subset of Vector2D, refs #4834, #4804.
Remove Point3D which is unused and the same as Vector3D without the math features, refs #4805.

comment:14 by elexis, 6 years ago

In 20406:

Delete the remains of rmgen/utilityfunctions.js, refs #4804 by
cleaning up the createForests function.

Remove g_numStragglerTrees and clForest references from the rmgen library.
Compute the number of forest- and straggler trees in a new function instead of hiding it and obstructing the placement code.
Remove unused numMultiplier argument.

Replace duplication of these three functions with calls to them, refs #4805.
Remove duplicate random biome JSON constants of the Islands, Migration and Snowflake Searocks map.
There is significant partial createForests duplication that should be unified eventually.

comment:15 by elexis, 6 years ago

In 20411:

Unify 5 copies of the tributary river placement code, refs #4805.

comment:16 by elexis, 6 years ago

In 20415:

Move starting player entity rmgen functions from misc.js to a new player.js, refs #4804.
Remove two duplicates of the starting entity placement code in the Fortress map of rP11361 and placeCivDefaultEntities of rP11754 by just making the distance an argument, refs #4805.

Equally to the starting cavalry, don't spawn special units like dogs or worker elephants on Fortress twice, but only the women and Infantry.
Consider the weird kwargs iberWalls argument of placeCivDefaultEntities from rP11754 deprecated and just make the orientation a regular optional argument.
Rename createStartingPlayerEntities to placeStartingEntities.

comment:17 by elexis, 6 years ago

In 20417:

Unify Caledonian Meadows and Wild Lake player location duplication from rP19704 / rP18781, refs #4805.
Move getOrderOfPointsForShortestClosePath from library.js to math.js, refs #4804 and name it sortPointsShortestCycle.

comment:18 by elexis, 6 years ago

In r20420:

Obliterate Unknown (r12545), Unknown Land (r12654) and Unknown Nomad (r12747) triplication of doom, fixes #4317.

Refactor by moving from procedural programming to functional programming.
Fix the horrendous shoreline performance bug on "Continent" of Unknown as in r14162 by dropping the historic differences between the maps.

Remove misleading player coordinate computation when generating the terrain on Unknown Nomad, because the players are spawned elsewhere then.
Remove names like md, mdd1 and mdd2 with different connotations in every landscape type.
Remove six more paintRiver copies in the "Edge Seas" variant as in r20185.
Remove createShoreJaggedness and createExtensionsOrIslands duplication within this triplication.
Remove heightmap initialization octuplication by adding initHeight.
Remove horizontal/vertical duplication by using logical operators.
Remove Painters redundant with the paintTerrainBasedOnHeight calls, pointless comments and cleanup createArea calls as in r20301.
Remove some forest helper duplication as in r20406.
Remove references to Math proxies and use the prototype functions directly.
Remove whitespace issues.

Describe remaining calls with human-readable log messages.
Always spawn enough treasures for a CC (instead of sometimes only giving enough for a dock), refs r16447.
Generate "Mainland" variant with the same probability as the other landscape types.
Generate "Central Sea" variant on Unknown Land too by forcing an Isthmus then.
Don't split players on Unknown Nomad on the "Rivers And Lake" variation, because the resource imbalance is too drastic.
Consistently call markPlayerArea before terrain generation on non-Nomad maps.

Differential Revision: ​https://code.wildfiregames.com/D252

comment:19 by elexis, 6 years ago

In r20429:

Extend the random map river algorithm (r20185) to allow arbitrary start and end points.

Reverse engineer and cleanup obfuscated Rivers map code, refs r11137. Use vector algebra to replace magic equations and express geometric intend. Fix seed typo by removing river curve duplicate.

On the Rivers map, use areAllies directly instead of copying the diplomacies to a 2D array called isRiver. Use modulo operator instead of an if-statement with duplication to determine the neighbor of the last player, refs r11174.

comment:20 by elexis, 6 years ago

In r20437: Unify rmgen modifyTilesBasedOnHeight (r20189) with the HeightPlacer (r20361).

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.

comment:21 by elexis, 6 years ago

In r20463:
Survival Of The Fittest cleanup:
Replace complicated starting unit code with a call to placeStartingEntities equal to r20415.
Use distributePointsOnCircle to remove sin/cos/distance computations.
Add map center getter for rmgen code, refs #4854.

comment:22 by elexis, 6 years ago

In 20466:

Unify 7 variants of the rmgen player line-positioning code, refs #4805.
Drop the negligible per-player location randomization on Latium.

comment:23 by elexis, 6 years ago

In 20469:

Unify the other axis of the 8 remaining playerPlacementRiver calls following rP20151, refs #4805.
Use the rotateAround function from rP20468, refs #4845.
Freely randomize the river angle on Corinthian Isthmus following rP20295 and rP20468, refs #4855.

comment:24 by elexis, 6 years ago

In 20472:

On both Deep Forest (rP11444) and Schwarzwald (rP15327) random maps, replace the copy of the magic number approximating the engine constant specifying the impassable map border tiles with a passability check from the library. Refs #4814, #4805.
Remove the duplication of the subsequent createArea call as in rP20301.

comment:25 by elexis, 6 years ago

Milestone: Alpha 23Backlog
Owner: elexis removed
Status: assignednew

comment:26 by elexis, 6 years ago

In 20693:

Remove duplication on Sahel Watering Holes using the modulo operator, refs #4805.
Use mapCenter getter from rP20463 / #4854 and distributePointsOnCircle from rP20416 to shorten.

comment:27 by elexis, 6 years ago

In 20703:

Add rmgen playerPlacementCustomAngle helper function for random maps that are gulfs or place players on a circle with a non-uniform distribution.

Remove ocean duplication on Pyrenean Sierra, fix sign of the removed lololo variable and simplify the player angle equation, refs #4805, rP12248.
Use mapCenter getter from #4854 on Gulf Of Bothnia, Pyrenean Sierra and the Unknown gulf variant.

comment:28 by elexis, 6 years ago

In 20704:

Pyrenean Sierra terrain painting cleanup, refs rP12248.

Remove redundant heightchecking conditions, unify place calls and use ternaries, equal to rP20296, refs #4805.

comment:29 by elexis, 6 years ago

In 20732:

Deobfuscate, deduplicate and fix Corsica vs. Sardinia and Pyrenean Sierra, refs rP11266, rP12248.

Use vector algebra instead of adding one equation for each dimension everywhere, refs #4845.
Add common createPassage terrain helper function to unify straightPassageMaker and the modified copy PassMaker, refs #4805.

On Corsica vs Sardinia:

Comfort island shaping by
not hardcoding and not hiding magic numbers behind magic equations,
not specifying areas and deriving the radius from the disk area,
but always refer to newly introduced radius globals and compute the area using diskArea from rP20332.

Don't give some players 10% more map area and place all circular island parts at the same center location in the map corner.
Don't place trees and mines into passages.
Simplify and order numbers, increase fail fractions from 4 to 10.
Use mapCenter getter from refs #4854.

comment:30 by elexis, 6 years ago

In 20758:

Simplify rmgen distanceOfPointFromLine and checkIfIntersect a lot by using vector algebra, refs #4845, #4805, rP13605, rP13613, rP20429.
First createRamp cleanup, rP13618.

comment:31 by elexis, 6 years ago

In 20761:

Delete createRamp which is the same as createPassage, refs #4805, rP13618, rP11266, rP12248.
Use vector algebra to compute the ramp position, refs #4845.

comment:32 by elexis, 6 years ago

In 20780:

Delete createShallowsPassage / passageMaker from rP11152 and use the unified createPassage function from rP20732 (rP11266, rP12248) to achieve the same shallows generation, refs #4805.

Place shallows at every tributary river rather than leaving out the last 35 percent of the mapsize.
Use vector algebra to do the horizontal/vertical rotation, refs #4845.

comment:33 by elexis, 6 years ago

In 20788:

Refactor Alpine Valley mountainrange code, refs rP13611, rP13613.

Describe the algorithm using graph theory vocabulary.
Split code into small functions, making it easier to digest and remove duplication, refs #4805.
Use a prototype to avoid any possible naming conflicts.
Add helper variables to reduce array lookup nesting.
Remove non-functional unneeded max-distance check, refs rP13619.
Use mapCenter getter, refs #4854.

comment:34 by elexis, 6 years ago

In 20806:

Use createPassage from rP20732 to connect islands on Snowflake Searocks to remove weird math, just like rP20780 and rP20761, refs #4805.
Use vector algebra to simplify and mapCenter getter, refs #4845, #4854.

comment:35 by elexis, 6 years ago

Owner: set to elexis
Resolution: fixed
Status: newclosed

In 20815:

Implement random map script playerbase function.
Unifies 54 variants of the rmgen playerbase code, fixes #4805.

Add retry loops to prevent collisions of starting resources, fixes #4600 and
resources placed outside of the map area, fixes #4796.

Lays the foundation to test for collisions with Iberian walls, refs #2192 and
allows to rearrange the starting resources on all random maps without being confronted with code.

Delete remains of misc.js, leaving the rmgen files sorted by logic, fixes #4804.
Concludes what was started in rP18816, rP19282, specifically the 82 rmgen commits starting rP20115, rP20301.
Uses vector algebra, refs #4845.
Removes many Math proxy calls, refs #4933.
Removes 35 unused elevation and 24 unused cliffRadius variables, demonstrating the copy&paste antipattern.
Reduce iberian-wall hardcoding to one line, refs #4940.

comment:36 by elexis, 6 years ago

Milestone: BacklogAlpha 23

comment:37 by elexis, 6 years ago

In 20861:

Extend the rmgen AndConstraint to be more permissive and receive falsy values or a Constraint to remove some Constraint conversion duplication, refs #4805.

comment:38 by elexis, 6 years ago

In 20864:

Remove distributeEntitiesByHeight / derivateEntitiesByHeight from rP18141 / rP15327.
Fix collisions of mines with trees and berries on Schwarzwald.

It can't achieve anything that a createArea or createObjectGroups call with a HeightConstraint (rP20862) or HeightPlacer (rP15327, rP20361) can't achieve too,
while it can't perform many crucial tasks like testing for arbitrary Constraints, using custom shapes determined by a Placer or limiting the amount of entities,
thus the unconventional code is redundant, refs #4805, #3764.

comment:39 by elexis, 6 years ago

In 20879:

Extract a RandomPathPlacer prototype from Deep Forest (rP11444) and Schwarzwald (rP15327) duplication, refs #4805, #4804.

This allows creation of paths that are not linear nor sine-shaped like the PathPlacer, refs #892.
To mimic the per-tile path elevation randomization on Deep Forest, use a SmoothElevationPainter and it's randomization argument from rP20354.
Use vector algebra and the mapCenter getter, refs #4845, #4854.

comment:40 by elexis, 6 years ago

In 20888:

Use paintRiver on Latium, refs #4805, rP20185.

comment:41 by elexis, 6 years ago

In 20914:

Pyrenean Sierra sigmoid-based Mountainrange cleanup, refs rP12248.

Use vector algebra and remove duplication, refs #4845, #4805.
Unify the first createTerrain call with InitMap.
Move mountain constants and the information which height receives which texture to the top.

comment:42 by elexis, 6 years ago

In 20943:

Unify Corsica & Sardinia and Pyrennean Sierra slope and smoothened height computation, refs #4805, rP11266, rP12248.
Receive vectors as arguments, refs #4992 and don't introduce a RandomMap object proxy.

comment:43 by elexis, 6 years ago

In 20972:

Revert ineffective Alpine Lakes code from rP14131.

It is ineffective because the first action of createAreas is to overwrite the carefully chosen location with a random location.
The code was evidently copied to Island Stronghold, Polar Sea and African Plains, refs #4805.

comment:44 by elexis, 6 years ago

In 21069:

rmgen random placement and Entity instantiation refactoring, fixes #4992.

ChainPlacer, ClumpPlacer, SimpleObject receive the vectors that are in place everywhere already, refs #4845.
Add public setCenterPosition to CenteredPlacer and Group rather than writing private properties of the prototypes.
ChainPlacer and ClumpPlacer simplifications, deduplication and renames, refs #4805.

Replace placeObject global with RandomMap placeEntity members, refs #4804.
Split to placeEntityPassable / placeEntityAnywhere, as well as validTilePassable / validTileAnywhere to more cleanly distinguish actor and casual entity placement.
No more does SimpleObject create Entity instances and register entityIDs if they are never placed.
Removes the map global reference from the Entity constructor, refs #4964.
By definition of what is passed to the engine, an Entity has an ID and position, so keep it impossible to create Entities without IDs.

Implement randomPositionOnTile so that there aren't different implementations thereof, including unintented ones as in ardennes_forest.js in rP21021.
On Caledonian Meadows, remove unused pathplacing code, to be superseded by #4368.
On Schwarzwald, delete unused startLocations following rP20864.
On Latium, replace complicated duplicated hardcoded fish location computation with a simple HeightConstraint, refs #4960.

comment:45 by elexis, 6 years ago

In 21080:

Implement getBoundingBox and getPointsInBoundingBox rmgen helper.

Removes the according duplication in placers and makes the loops over these points onedimensional, refs #4805.
JSdoc for centric placers, refs #4831.

comment:46 by elexis, 6 years ago

In 21132:

Abstract the vertex locations on a tile in rmgen, refs #4805.

comment:47 by elexis, 6 years ago

In 21140:

Pass Infinity as the fail fraction to the ClumpPlacer if failed tiles should be ignored, rather than sometimes passing 100%, 400%, 1000% or 10000%, refs #4805.

comment:48 by elexis, 6 years ago

In 21141:

Pass Infinity to the ChainPlacer if failed tiles should be ignored, rather than different numbers above 1 that have the same effect, refs #4805.

comment:49 by elexis, 6 years ago

In 21171:

Make Belgian Uplands a circular map and clean it's code, refs rP12813.

Replace needlessly complicated code with a call to HeightConstraint, stayClasses and randomPlayerLocations, refs #4805.
Do texture painting and actor placement at the impassable map border too.
Replace another occurrence of the number of impassable tiles at the map border, refs #4034.
Delete useless clone from rP18141 since setRandomHeightmap replaces the result.
Remove unneeded setReliefmap and operate on the target heightmap directly.

comment:50 by elexis, 6 years ago

In 21182:

Implement ElevationBlendingPainter which interpolates the height of the given area with the desired height.

Primary use case, as represented on Caledonian Meadows, is creating a path through impassable area, mountains or water, refs #4952.
Supersedes placeRandomPathToHeight from the heightmap library, refs #3764.
The painter has the advantage that it can be applied to arbitrary areas with arbitrary forms of smoothing (or no smoothing).
Replace the rectangularSmoothToHeight calls that only smooth an area with a SmoothElevationPainter call.
Replace placeRandomPathToHeight which is a copy of the the RandomPathPlacer from rP20879, refs #4805.

comment:51 by elexis, 6 years ago

In 21206:

Move the randomPlayerLocations rmgen2/ function to rmgen/, so that one can use it without importing rmgen2, refs #4947, Belgian Uplands rP21171, Islets D1277.

Delete rmgen2 placeRadial which is equal to playerPlacementCircle from rP20149, refs #4805.
Remove createBase calls from rmgen2 player playerbase location functions, so that they can be called without placing the bases.
Let them return the same data that rmgen/ functions return, refs #4947.
Delete placeRandom as it remains empty.
Rename sortPlayersByLocation to groupPlayersCycle, groupPlayersByLocations to groupPlayersByArea,
randomPlayerLocations to playerPlacementRandom and addBases to createBasesByPattern.

comment:52 by elexis, 6 years ago

In 21300:

Ambush bluffs rework.
Remove ugly large circle patterns around the playerbase on Ambush, fixes #4993.
To ensure passability, create ramps from the playerbase to the bluffs.

Change the circular player avoidance to a ChainPlacer generating more heterogenous pattern.
Use vectors in rmgen2 bluffs creation and simplify equations, refs #4992.
Don't turn inaccessible bluffs to plateaus but don't place them until it is certain they are passable.

Increase minimum distance from the playerbase to the mapcenter by picking different distance values per playerbase pattern in g_PlayerbaseTypes.
Attempt to improve bluffs performance by avoiding bluffIgnore by 0 instead of bluff by 12, refs #5011.
Implement AdjacentToAreaConstraint and deleteTerrainEntity.
Delete createBoundingBox and use getBoundingBox, refs #4947, #4805.
Delete fadeToGround and nextToFeature and use conventional createArea calls with the SmoothingPainter of rP21175, refs #5027.
Paint bluff cliffs slightly more accurately using the SlopeConstraint from rP21085, refs #5004.

comment:53 by elexis, 6 years ago

In 21408:

Beat 24 LayeredPainters with identical neighboring layers for not doing anything but wasting performance and confusing developers, refs #4805.
Remove an unneeded else after break.

comment:54 by elexis, 6 years ago

In 21416:

Move Danubius triggerscript function to compose random templates and garrison all entities of a given identity class to TriggerHelper.

Delete the copy thereof in Elephantine, refs #4805, #5040.
Use absolute paths for template names.

comment:55 by elexis, 6 years ago

In 21433:

Unify the two copies of the custom dock placement logic on Hellas and Pompeii, refs #4805.

Extend it to only place docks where the according body of water has a minimum size, fixes #5065.
Compute the dock angle similar to GetDockAngle from Commands.js (as the previous angle computation is wrong if the large body of water doesn't lie in that direction).

comment:56 by elexis, 6 years ago

In 21445:

Refactor and move random template composition triggerscript code used for gaia attacker waves from Danubius (rP19434 / D204) and Survival Of The Fittest (rP19359 / D145) to the TriggerHelper.

Eases implementation of new maps with diverse scripted attackers, refs #5040, D11 and map difficulties, refs #4963, D1189.
Replaces hardcoded templatenames with calls to a new TriggerHelper function to query template names, given Classes, Civ, Rank or Packed state.
Removes the duplicated template counting logic, that was intertwined with map specific unit classes balancing logic, refs #4805.

Use mimos garrison function from rP20659 / D1146 to support doubleclicking on garrisoned gaia heroes on Danubius, fixing the bug described in comment:10 of #4291.
Fix wrong (Trigger) prototype reference in rP21416.

Note: See TracTickets for help on using tickets.