File diff r23953:ba75d2f3b530 → r23954:8e43140b9a66
src/economy.cpp
Show inline comments
 
@@ -109,16 +109,15 @@ static PriceMultipliers _price_base_mult
 
 * @return the value of the company.
 
 */
 
Money CalculateCompanyValue(const Company *c, bool including_loan)
 
{
 
	Owner owner = c->index;
 

	
 
	Station *st;
 
	uint num = 0;
 

	
 
	FOR_ALL_STATIONS(st) {
 
	for (const Station *st : Station::Iterate()) {
 
		if (st->owner == owner) num += CountBits((byte)st->facilities);
 
	}
 

	
 
	Money value = num * _price[PR_STATION_VALUE] * 25;
 

	
 
	Vehicle *v;
 
@@ -185,15 +184,13 @@ int UpdateCompanyRatingAndValue(Company 
 
		}
 
	}
 

	
 
	/* Count stations */
 
	{
 
		uint num = 0;
 
		const Station *st;
 

	
 
		FOR_ALL_STATIONS(st) {
 
		for (const Station *st : Station::Iterate()) {
 
			/* Only count stations that are actually serviced */
 
			if (st->owner == owner && (st->time_since_load <= 20 || st->time_since_unload <= 20)) num += CountBits((byte)st->facilities);
 
		}
 
		_score_part[owner][SCORE_STATIONS] = num;
 
	}
 

	
 
@@ -511,24 +508,22 @@ void ChangeOwnershipOfCompanyItems(Owner
 
	}
 

	
 
	/* Add airport infrastructure count of the old company to the new one. */
 
	if (new_owner != INVALID_OWNER) Company::Get(new_owner)->infrastructure.airport += Company::Get(old_owner)->infrastructure.airport;
 

	
 
	/* convert owner of stations (including deleted ones, but excluding buoys) */
 
	Station *st;
 
	FOR_ALL_STATIONS(st) {
 
	for (Station *st : Station::Iterate()) {
 
		if (st->owner == old_owner) {
 
			/* if a company goes bankrupt, set owner to OWNER_NONE so the sign doesn't disappear immediately
 
			 * also, drawing station window would cause reading invalid company's colour */
 
			st->owner = new_owner == INVALID_OWNER ? OWNER_NONE : new_owner;
 
		}
 
	}
 

	
 
	/* do the same for waypoints (we need to do this here so deleted waypoints are converted too) */
 
	Waypoint *wp;
 
	FOR_ALL_WAYPOINTS(wp) {
 
	for (Waypoint *wp : Waypoint::Iterate()) {
 
		if (wp->owner == old_owner) {
 
			wp->owner = new_owner == INVALID_OWNER ? OWNER_NONE : new_owner;
 
		}
 
	}
 

	
 
	Sign *si;
 
@@ -660,14 +655,13 @@ static void CompaniesGenStatistics()
 
		CompanyCheckBankrupt(c);
 
	}
 

	
 
	Backup<CompanyID> cur_company(_current_company, FILE_LINE);
 

	
 
	if (!_settings_game.economy.infrastructure_maintenance) {
 
		Station *st;
 
		FOR_ALL_STATIONS(st) {
 
		for (const Station *st : Station::Iterate()) {
 
			cur_company.Change(st->owner);
 
			CommandCost cost(EXPENSES_PROPERTY, _price[PR_STATION_VALUE] >> 1);
 
			SubtractMoneyFromCompany(cost);
 
		}
 
	} else {
 
		/* Improved monthly infrastructure costs. */