Changeset - r20838:c4bef7c0db02
[Not reviewed]
master
0 1 0
fonsinchen - 11 years ago 2013-10-19 11:17:29
fonsinchen@openttd.org
(svn r25882) -Change [FS#5766]: Don't offer subsidies for auto-distributed cargo.
1 file changed with 22 insertions and 5 deletions:
0 comments (0 inline, 0 general)
src/subsidy.cpp
Show inline comments
 
@@ -345,13 +345,16 @@ bool FindSubsidyTownCargoRoute()
 
	FOR_EACH_SET_CARGO_ID(cid, town_cargo_produced) {
 
		if (cargo_number == 0) break;
 
		cargo_number--;
 
	}
 

	
 
	/* Avoid using invalid NewGRF cargoes. */
 
	if (!CargoSpec::Get(cid)->IsValid()) return false;
 
	if (!CargoSpec::Get(cid)->IsValid() ||
 
			_settings_game.linkgraph.GetDistributionType(cid) != DT_MANUAL) {
 
		return false;
 
	}
 

	
 
	/* Quit if the percentage transported is large enough. */
 
	if (src_town->GetPercentTransported(cid) > SUBSIDY_MAX_PCT_TRANSPORTED) return false;
 

	
 
	SourceID src = src_town->index;
 

	
 
@@ -385,14 +388,19 @@ bool FindSubsidyIndustryCargoRoute()
 
		cid = src_ind->produced_cargo[0];
 
		trans = src_ind->last_month_pct_transported[0];
 
		total = src_ind->last_month_production[0];
 
	}
 

	
 
	/* Quit if no production in this industry
 
	 * or if the pct transported is already large enough */
 
	if (total == 0 || trans > SUBSIDY_MAX_PCT_TRANSPORTED || cid == CT_INVALID) return false;
 
	 * or if the pct transported is already large enough
 
	 * or if the cargo is automatically distributed */
 
	if (total == 0 || trans > SUBSIDY_MAX_PCT_TRANSPORTED ||
 
			cid == CT_INVALID ||
 
			_settings_game.linkgraph.GetDistributionType(cid) != DT_MANUAL) {
 
		return false;
 
	}
 

	
 
	SourceID src = src_ind->index;
 

	
 
	return FindSubsidyCargoDestination(cid, src_type, src);
 
}
 

	
 
@@ -477,21 +485,30 @@ void SubsidyMonthlyLoop()
 
			}
 
			delete s;
 
			modified = true;
 
		}
 
	}
 

	
 
	if (modified) RebuildSubsidisedSourceAndDestinationCache();
 
	if (modified) {
 
		RebuildSubsidisedSourceAndDestinationCache();
 
	} else if (_settings_game.linkgraph.distribution_pax != DT_MANUAL &&
 
			   _settings_game.linkgraph.distribution_mail != DT_MANUAL &&
 
			   _settings_game.linkgraph.distribution_armoured != DT_MANUAL &&
 
			   _settings_game.linkgraph.distribution_default != DT_MANUAL) {
 
		/* Return early if there are no manually distributed cargoes and if we
 
		 * don't need to invalidate the subsidies window. */
 
		return;
 
	}
 

	
 
	bool passenger_subsidy = false;
 
	bool town_subsidy = false;
 
	bool industry_subsidy = false;
 

	
 
	int random_chance = RandomRange(16);
 

	
 
	if (random_chance < 2) {
 
	if (random_chance < 2 && _settings_game.linkgraph.distribution_pax == DT_MANUAL) {
 
		/* There is a 1/8 chance each month of generating a passenger subsidy. */
 
		int n = 1000;
 

	
 
		do {
 
			passenger_subsidy = FindSubsidyPassengerRoute();
 
		} while (!passenger_subsidy && n--);
0 comments (0 inline, 0 general)