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

Function PlaceIndustry

src/industry_cmd.cpp:2386–2394  ·  view source on GitHub ↗

* Try to place the industry in the game. * Since there is no feedback why placement fails, there is no other option * than to try a few times before concluding it does not work. * @param type Industry type of the desired industry. * @param try_hard Try very hard to find a place. (Used to place at least one industry per type.) * @return Pointer to created industry, or \c nullptr if creatio

Source from the content-addressed store, hash-verified

2384 * @return Pointer to created industry, or \c nullptr if creation failed.
2385 */
2386static Industry *PlaceIndustry(IndustryType type, IndustryAvailabilityCallType creation_type, bool try_hard)
2387{
2388 uint tries = try_hard ? 10000u : 2000u;
2389 for (; tries > 0; tries--) {
2390 Industry *ind = CreateNewIndustry(RandomTile(), type, creation_type);
2391 if (ind != nullptr) return ind;
2392 }
2393 return nullptr;
2394}
2395
2396/**
2397 * Try to build a industry on the map.

Callers 2

PlaceInitialIndustryFunction · 0.85
TryBuildNewIndustryMethod · 0.85

Calls 1

CreateNewIndustryFunction · 0.85

Tested by

no test coverage detected