MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / GetDefaultTownsForMapSize

Function GetDefaultTownsForMapSize

src/town_cmd.cpp:2432–2439  ·  view source on GitHub ↗

* Calculate the number of towns which should be on the map according to the current "town density" newgame setting and the map size. * If the number of towns is set to "custom", the function will always return that value instead. * @return The number of towns. */

Source from the content-addressed store, hash-verified

2430 * @return The number of towns.
2431 */
2432uint GetDefaultTownsForMapSize()
2433{
2434 static const uint8_t num_initial_towns[4] = {5, 11, 23, 46}; // very low, low, normal, high
2435 if (_settings_game.difficulty.number_towns == static_cast<uint>(CUSTOM_TOWN_NUMBER_DIFFICULTY)) {
2436 return _settings_newgame.game_creation.custom_town_number;
2437 }
2438 return Map::ScaleBySize(num_initial_towns[_settings_game.difficulty.number_towns]);
2439}
2440
2441/**
2442 * Generate a number of towns with a given layout.

Callers 2

OnClickMethod · 0.85
GenerateTownsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected