File diff r27882:e0b47acdb939 → r27883:ddbd33508a8a
src/company_cmd.cpp
Show inline comments
 
@@ -656,13 +656,13 @@ static void HandleBankruptcyTakeover(Com
 
{
 
	/* Amount of time out for each company to take over a company;
 
	 * Timeout is a quarter (3 months of 30 days) divided over the
 
	 * number of companies. The minimum number of days in a quarter
 
	 * is 90: 31 in January, 28 in February and 31 in March.
 
	 * Note that the company going bankrupt can't buy itself. */
 
	static const int TAKE_OVER_TIMEOUT = 3 * 30 * DAY_TICKS / (MAX_COMPANIES - 1);
 
	static const int TAKE_OVER_TIMEOUT = 3 * 30 * Ticks::DAY_TICKS / (MAX_COMPANIES - 1);
 

	
 
	assert(c->bankrupt_asked != 0);
 

	
 
	/* We're currently asking some company to buy 'us' */
 
	if (c->bankrupt_timeout != 0) {
 
		c->bankrupt_timeout -= MAX_COMPANIES;
 
@@ -714,13 +714,13 @@ void OnTick_Companies()
 
	if (c != nullptr) {
 
		if (c->name_1 != 0) GenerateCompanyName(c);
 
		if (c->bankrupt_asked != 0) HandleBankruptcyTakeover(c);
 
	}
 

	
 
	if (_new_competitor_timeout.HasFired() && _game_mode != GM_MENU && AI::CanStartNew()) {
 
		int32_t timeout = _settings_game.difficulty.competitors_interval * 60 * TICKS_PER_SECOND;
 
		int32_t timeout = _settings_game.difficulty.competitors_interval * 60 * Ticks::TICKS_PER_SECOND;
 
		/* If the interval is zero, start as many competitors as needed then check every ~10 minutes if a company went bankrupt and needs replacing. */
 
		if (timeout == 0) {
 
			/* count number of competitors */
 
			uint8_t n = 0;
 
			for (const Company *cc : Company::Iterate()) {
 
				if (cc->is_ai) n++;
 
@@ -728,13 +728,13 @@ void OnTick_Companies()
 

	
 
			for (auto i = 0; i < _settings_game.difficulty.max_no_competitors; i++) {
 
				if (_networking && Company::GetNumItems() >= _settings_client.network.max_companies) break;
 
				if (n++ >= _settings_game.difficulty.max_no_competitors) break;
 
				Command<CMD_COMPANY_CTRL>::Post(CCA_NEW_AI, INVALID_COMPANY, CRR_NONE, INVALID_CLIENT_ID);
 
			}
 
			timeout = 10 * 60 * TICKS_PER_SECOND;
 
			timeout = 10 * 60 * Ticks::TICKS_PER_SECOND;
 
		}
 
		/* Randomize a bit when the AI is actually going to start; ranges from 87.5% .. 112.5% of indicated value. */
 
		timeout += ScriptObject::GetRandomizer(OWNER_NONE).Next(timeout / 4) - timeout / 8;
 

	
 
		_new_competitor_timeout.Reset(std::max(1, timeout));
 
	}