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

Function GetNumberOfIndustries

src/industry_cmd.cpp:2357–2376  ·  view source on GitHub ↗

* Get wanted number of industries on the map. * @return Wanted number of industries at the map. */

Source from the content-addressed store, hash-verified

2355 * @return Wanted number of industries at the map.
2356 */
2357static uint GetNumberOfIndustries()
2358{
2359 /* Number of industries on a 256x256 map. */
2360 static const uint16_t numof_industry_table[] = {
2361 0, // none
2362 0, // minimal
2363 10, // very low
2364 25, // low
2365 55, // normal
2366 80, // high
2367 0, // custom
2368 };
2369
2370 assert(lengthof(numof_industry_table) == ID_END);
2371 uint difficulty = (_game_mode != GM_EDITOR) ? _settings_game.difficulty.industry_density : (uint)ID_VERY_LOW;
2372
2373 if (difficulty == ID_CUSTOM) return std::min<uint>(IndustryPool::MAX_SIZE, _settings_game.game_creation.custom_industry_number);
2374
2375 return std::min<uint>(IndustryPool::MAX_SIZE, Map::ScaleBySize(numof_industry_table[difficulty]));
2376}
2377
2378/**
2379 * Try to place the industry in the game.

Callers 1

GenerateIndustriesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected