Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#4854 closed defect (fixed)

rmgen MapCenter getter

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

Description

There are as many references to the map center, variable names and the means of obtaining that location as there are random map scripts. We should have a simple GetMapCenter() function to remove the variability.

Change History (16)

comment:1 by elexis, 6 years ago

In 20463:

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

comment:2 by elexis, 6 years ago

In 20468:

Add rotateAround Vector2D function.
Remove the rmgen rotateCoordinates helper function from rP20295 and clean the implementation of that commit, refs #4845, #4804.
Deepfreeze mapCenter vector from rP20463 used here to prevent accidental overwrites with the mutating Vector2D functions, refs #4854.

comment:3 by elexis, 6 years ago

In r20703:
Use mapCenter getter from #4854 on Gulf Of Bothnia, Pyrenean Sierra and the Unknown gulf variant.

comment:4 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:5 by elexis, 6 years ago

In r20780:
Delete createShallowsPassage / passageMaker from r11152 and use the unified createPassage function from r20732 (r11266, r12248) 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.
Use mapCenter getter on Lorraine Plain and Sahel Watering Holes.

comment:6 by elexis, 6 years ago

In 20787:

Return an array of Vector2D instead of an array of X coordinates and an array of Z coordinates from distributePointsOnCircle, so that one can iterate over the result, refs #4845.
Use map center getter for Rivers and the Unknown maps, refs #4854.

comment:7 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:8 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:9 by elexis, 6 years ago

In 20859:

Cleanup createArea calls on Neareastern Badlands as in rP20301.

Use a separate tileclass for the oasis.
Use the mapCenter getter, refs #4854 and move important height and radius constants to the top.

comment:10 by elexis, 6 years ago

In 20871:

paintRiver cleanup.

Pass vectors, refs #4845.
Pass tile sizes rather than percent numbers of the map, refs #4939.
Replace some water- and land-functions with more common createArea+RectPlacer and paintTerrainBasedOnHeight calls.

Implement getMapBounds to make references easier to read, refs #4854 (and thus less error-prone, refs rP20465).
Move height constants to the top of the files.

Fix Aegean Sea, English Channel and Danubius fadeWidth off by factor of 2 in rP20185.
Fix forgotton clWater in unknown_common of rP20866 and move that createUnknownObjects call to common.

comment:11 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:12 by elexis, 6 years ago

In 20882:

Merge all playerX and playerZ arrays into one array of Vector2D items.

This way random map scripts can do vector math and pass the result to library functions that do further vector math on them and leave shorter code, refs #4845.
Pass tilegrid coordinates rather than percent numbers to the playerbase functions too, refs #4939.
Some more mapCenter calls, refs #4854.

comment:13 by elexis, 6 years ago

In 20891:

Cleanup Island Stronghold starting resources code using vector algebra, mapcenter getter, distributePointsOnCircle, refs #4845, #4854.
Since it is the only map with stronghold placement where the mines are placed facing away from the team center, this code should be moved to a library eventually, refs #3851.

comment:14 by elexis, 6 years ago

Milestone: BacklogAlpha 23

comment:15 by elexis, 6 years ago

Owner: set to elexis
Resolution: fixed
Status: newclosed

In 20892:

Don't call it centerOfMap, center, mid, centerX, centerZ, fractionToTiles(0.5), Math.round(fractionToTiles(0.5)), mapSize / 2, mapSize * 0.5, but just mapCenter everywhere and get it from the library.
Fixes #4854, refs #4845.

comment:16 by elexis, 6 years ago

In r20996:

Move getMapCenter and getMapBounds to the RandomMap? object, refs #4964.

The reference to the global should not be hidden behind a proxy function and object orientation is preferable over procedural code in general.

Note: See TracTickets for help on using tickets.