* 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. */
| 1352 | * @return the index of the first available company. |
| 1353 | */ |
| 1354 | CompanyID 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 | |
| 1373 | static std::vector<FaceSpec> _faces; ///< All company manager face styles. |
| 1374 |
no test coverage detected