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

Function GetFirstPlayableCompanyID

src/company_cmd.cpp:1354–1371  ·  view source on GitHub ↗

* Get the index of the first available company. It attempts, * from first to last, and as soon as the attempt succeeds, * to get the index of the company: * 1st - get the first existing human company. * 2nd - get the first non-existing company. * 3rd - get CompanyID::Begin(). * @return the index of the first available company. */

Source from the content-addressed store, hash-verified

1352 * @return the index of the first available company.
1353 */
1354CompanyID GetFirstPlayableCompanyID()
1355{
1356 for (Company *c : Company::Iterate()) {
1357 if (Company::IsHumanID(c->index)) {
1358 return c->index;
1359 }
1360 }
1361
1362 if (Company::CanAllocateItem()) {
1363 for (CompanyID c = CompanyID::Begin(); c < MAX_COMPANIES; ++c) {
1364 if (!Company::IsValidID(c)) {
1365 return c;
1366 }
1367 }
1368 }
1369
1370 return CompanyID::Begin();
1371}
1372
1373static std::vector<FaceSpec> _faces; ///< All company manager face styles.
1374

Callers 3

OnStartGameFunction · 0.85
NetworkOnGameStartFunction · 0.85
AfterLoadGameFunction · 0.85

Calls 1

BeginFunction · 0.85

Tested by

no test coverage detected