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

Function produceCompanies

src/OpenLoco/src/World/CompanyManager.cpp:885–907  ·  view source on GitHub ↗

0x004306D1

Source from the content-addressed store, hash-verified

883
884 // 0x004306D1
885 static void produceCompanies()
886 {
887 if (getCompetitorStartDelay() == 0 && getMaxCompetingCompanies() != 0)
888 {
889 int32_t activeCompanies = 0;
890 for (const auto& company : companies())
891 {
892 if (!isPlayerCompany(company.id()))
893 {
894 activeCompanies++;
895 }
896 }
897
898 auto& prng = gPrng1();
899 if (prng.randNext(16) == 0)
900 {
901 if (prng.randNext(getMaxCompetingCompanies()) + 1 > activeCompanies)
902 {
903 createAiCompany();
904 }
905 }
906 }
907 }
908
909 Company* getOpponent()
910 {

Callers 1

updateFunction · 0.85

Calls 7

getCompetitorStartDelayFunction · 0.85
getMaxCompetingCompaniesFunction · 0.85
companiesFunction · 0.85
isPlayerCompanyFunction · 0.85
createAiCompanyFunction · 0.85
idMethod · 0.45
randNextMethod · 0.45

Tested by

no test coverage detected