Loading

Paste #pefzfn0mf

  1. void MaybeStartNewCompany() {
  2.     uint current_companies = (uint)Company::GetNumItems();
  3.  
  4.     /* Count number of existing AI only companies. */
  5.     uint current_ais = 0;
  6.     Company *c;
  7.     FOR_ALL_COMPANIES(c) {
  8.         if (c->is_ai) current_ais++;
  9.     }
  10.  
  11.     uint max_network_companies = networking ? settings_client.network.max_companies : MAX_COMPANIES;
  12.     uint ais_to_start = 0;
  13.     for (CompanyID company_id = COMPANY_FIRST; company_id < MAX_COMPANIES && current_companies < max_network_companies && current_ais < _settings_game.difficulty.max_no_competitors; company_id++) {
  14.         if (Company::IsValidID(c))
  15.             continue;
  16.         if (AIConfig::GetConfig(company_id, AIConfig::SSS_FORCE_GAME)->GetSetting("start_date") != 0)
  17.             break;
  18.         ais_to_start++;
  19.         current_companies++;
  20.         current_ais++;
  21.     }
  22.     if (ais_to_start > 0) {
  23.         DoCommandP(0, CCA_NEW_AI | INVALID_COMPANY << 16, ais_to_start, CMD_COMPANY_CTRL);
  24.     }
  25. }

Comments