/** * Is the AI or GS config in the given slot eligible to start? * @param slot The slot to query. * @return True if and only if the given AI or GS Config slot can start. */ static bool IsEligible(CompanyID slot) { if (slot == OWNER_DEITY) return _game_mode != GM_NORMAL && GameConfig::GetConfig()->GetInfo() != NULL; if (Company::IsValidID(slot) || slot < 0) return false; int total_ais = 0; for (CompanyID cid = COMPANY_FIRST; cid < MAX_COMPANIES; cid++) { if (Company::IsValidAiID(cid)) total_ais++; } int slots_to_fill = max(GetGameSettings().difficulty.max_no_competitors - total_ais, 0); int empty_slot = 0; int max_fill = 0; for (CompanyID cid = COMPANY_FIRST; cid < MAX_COMPANIES && slots_to_fill > empty_slot; cid++) { if (!Company::IsValidID(cid)) empty_slot++; max_fill++; } return slot < max_fill; }