MCPcopy Create free account
hub / github.com/OpenLoco/OpenLoco / createNewIndustry

Function createNewIndustry

src/OpenLoco/src/World/IndustryManager.cpp:451–477  ·  view source on GitHub ↗

0x0045979C & 0x00459949

Source from the content-addressed store, hash-verified

449
450 // 0x0045979C & 0x00459949
451 void createNewIndustry(const uint8_t indObjId, const bool buildImmediately, const int32_t numAttempts)
452 {
453 // Try find valid coordinates for this industry
454 for (auto attempt = 0; attempt < numAttempts; ++attempt)
455 {
456 auto randomIndustryLoc = findRandomNewIndustryLocation(indObjId);
457 if (randomIndustryLoc.has_value())
458 {
459 GameCommands::IndustryPlacementArgs args;
460 args.type = indObjId;
461 args.buildImmediately = buildImmediately;
462 args.pos = *randomIndustryLoc;
463 // To match vanilla we will do this.
464 // TODO: Once match confirmed replace with two randNext() calls
465 const auto temp = gPrng1().srand_0();
466 gPrng1().randNext();
467 args.srand0 = gPrng1().srand_0() - temp;
468 args.srand1 = gPrng1().srand_1();
469
470 auto res = GameCommands::doCommand(args, GameCommands::Flags::apply);
471 if (res != GameCommands::kFailure)
472 {
473 break;
474 }
475 }
476 }
477 }
478
479 // 0x00459659
480 static void tryCreateNewIndustriesMonthly()

Callers 2

generateIndustriesFunction · 0.85

Calls 5

srand_0Method · 0.80
srand_1Method · 0.80
doCommandFunction · 0.50
randNextMethod · 0.45

Tested by

no test coverage detected