1
0
Fork 0

Revert: "Change: Allow AI companies to start immediately."

This reverts commit 011257dc88.

This commit was not working properly. Attempts are made to fix it,
but so close to 1.9, it sounds a lot better to revert it from the
1.9 branch, and keep developing it further in 1.10.
pull/7443/head
Patric Stout 2019-03-24 16:48:11 +01:00
parent 7a9782e6f4
commit cf7a1fc8c6
5 changed files with 8 additions and 26 deletions

View File

@ -32,7 +32,7 @@ public:
START_NEXT_EASY = DAYS_IN_YEAR * 2,
START_NEXT_MEDIUM = DAYS_IN_YEAR,
START_NEXT_HARD = DAYS_IN_YEAR / 2,
START_NEXT_MIN = 0,
START_NEXT_MIN = 1,
START_NEXT_MAX = 3600,
START_NEXT_DEVIATION = 60,
};

View File

@ -127,14 +127,3 @@ void AIConfig::SetSetting(const char *name, int value)
ScriptConfig::SetSetting(name, value);
}
void AIConfig::AddRandomDeviation()
{
int start_date = this->GetSetting("start_date");
ScriptConfig::AddRandomDeviation();
/* start_date = 0 is a special case, where random deviation does not occur.
* If start_date was not already 0, then a minimum value of 1 must apply. */
this->SetSetting("start_date", start_date != 0 ? max(1, this->GetSetting("start_date")) : 0);
}

View File

@ -32,7 +32,6 @@ public:
/* virtual */ int GetSetting(const char *name) const;
/* virtual */ void SetSetting(const char *name, int value);
/* virtual */ void AddRandomDeviation();
/**
* When ever the AI Scanner is reloaded, all infos become invalid. This

View File

@ -595,10 +595,10 @@ void StartupCompanies()
}
/** Start a new competitor company if possible. */
static bool MaybeStartNewCompany()
static void MaybeStartNewCompany()
{
#ifdef ENABLE_NETWORK
if (_networking && Company::GetNumItems() >= _settings_client.network.max_companies) return false;
if (_networking && Company::GetNumItems() >= _settings_client.network.max_companies) return;
#endif /* ENABLE_NETWORK */
Company *c;
@ -612,10 +612,8 @@ static bool MaybeStartNewCompany()
if (n < (uint)_settings_game.difficulty.max_no_competitors) {
/* Send a command to all clients to start up a new AI.
* Works fine for Multiplayer and Singleplayer */
return DoCommandP(0, CCA_NEW_AI | INVALID_COMPANY << 16, 0, CMD_COMPANY_CTRL);
DoCommandP(0, CCA_NEW_AI | INVALID_COMPANY << 16, 0, CMD_COMPANY_CTRL);
}
return false;
}
/** Initialize the pool of companies. */
@ -716,15 +714,11 @@ void OnTick_Companies()
}
if (_next_competitor_start == 0) {
/* AI::GetStartNextTime() can return 0. */
_next_competitor_start = max(1, AI::GetStartNextTime() * DAY_TICKS);
_next_competitor_start = AI::GetStartNextTime() * DAY_TICKS;
}
if (_game_mode != GM_MENU && AI::CanStartNew() && --_next_competitor_start == 0) {
/* Allow multiple AIs to possibly start in the same tick. */
do {
if (!MaybeStartNewCompany()) break;
} while (AI::GetStartNextTime() == 0);
if (AI::CanStartNew() && _game_mode != GM_MENU && --_next_competitor_start == 0) {
MaybeStartNewCompany();
}
_cur_company_tick_index = (_cur_company_tick_index + 1) % MAX_COMPANIES;

View File

@ -139,7 +139,7 @@ public:
/**
* Randomize all settings the Script requested to be randomized.
*/
virtual void AddRandomDeviation();
void AddRandomDeviation();
/**
* Is this config attached to an Script? In other words, is there a Script