Opened 7 years ago

Closed 7 years ago

#4813 closed defect (fixed)

Cleanup ambiguous confusing rmgen2 globals

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

Description

rmgen2, originally introduced in r17903 does some confusing things that should be sorted out

1. Delete g_MapInfo:
This is a global attempting to remove duplication. But the name just confuses the reader who also encounters g_Map and g_MapSettings. The property has the terrible characteristic of halfway being initialized in initMapSettings and halfway in resetTerrain. It's global reference requires rmgen2 maps to rewrite the entire terrain before doing anything else for no reason.

The global can be removed altogether as all properties can be removed.

Properties redundant with global getters:

  • numPlayers is getNumPlayers()
  • mapSize, is getMapSize()
  • mapArea is getMapArea()
  • teams is getTeams()

Properties that instead should be unified with rmgen1 duplication:

  • startAngle = randFloat(0, TWO_PI) for radial player placement
  • centerOfMap is not widely used in rmgen2 but many duplication thereof in rmgen1 can be found, so should be a more general unification

Properties completely broken:

  • mapRadius = -PI / 4 That's not a radius but the default building orientation. Thus the only use in createBase is compeltely bonkers (doesn't place -PI/4 grass bushes).

Properties that should be arguments:

  • mapHeight that's a bad one. In most cases it's the same as BaseHeight from the JSON file, thus redundant with getBaseMapHeight. But in some cases (Frontier) the map changes (randomizes) the base height. Changing g_Map.BaseHeight instead is impossible as of r20265 and shouldn't be done as it should rather be a function argument instead of a global.

2. Rename ambiguous rmgen2 functions:

  • getTeams to getTeamsArray to somewhat distinguish it from sortPlayers
  • initBiome sounds like it were an important init function of the random biome system, while it only does some forest floor initialization of rmgen2, so it should be renamed to reflect that.
  • initMapSettings() sounds like an important map initialization of rmgen1 but in fact only initialized the removed global and called the forest floor init function. This function can be removed.

Change History (1)

comment:1 by elexis, 7 years ago

Resolution: fixed
Status: assignedclosed

In 20278:

Remove confusing rmgen2 g_MapInfo and initMapSettings, fixes #4813.

Rename initBiome to initForestFloor, getTeams to getTeamsArray.
Unifying duplicate coordinate computation and inlining unneeded createArea helper variables in Lions Den.

Note: See TracTickets for help on using tickets.