Loading

Paste #pv13oad55

  1.     /**
  2.     * Is the AI or GS config in the given slot eligible to start?
  3.     * @param slot The slot to query.
  4.     * @return True if and only if the given AI or GS Config slot can start.
  5.     */
  6.     static bool IsEligible(CompanyID slot)
  7.     {
  8.         if (slot == OWNER_DEITY) return _game_mode != GM_NORMAL && GameConfig::GetConfig()->GetInfo() != NULL;
  9.  
  10.         if (Company::IsValidID(slot) || slot < 0) return false;
  11.  
  12.         int total_ais = 0;
  13.         for (CompanyID cid = COMPANY_FIRST; cid < MAX_COMPANIES; cid++) {
  14.             if (Company::IsValidAiID(cid)) total_ais++;
  15.         }
  16.  
  17.         int slots_to_fill = max(GetGameSettings().difficulty.max_no_competitors - total_ais, 0);
  18.         int empty_slot = 0;
  19.         int max_fill = 0;
  20.         for (CompanyID cid = COMPANY_FIRST; cid < MAX_COMPANIES && slots_to_fill > empty_slot; cid++) {
  21.             if (!Company::IsValidID(cid)) empty_slot++;
  22.             max_fill++;
  23.         }
  24.  
  25.         return slot < max_fill;
  26.     }

Comments