Changeset - r28644:46fa59fd512b
[Not reviewed]
master
0 1 0
Peter Nelson - 4 months ago 2024-01-07 19:32:42
peter1138@openttd.org
Change: Passenger subsidies are generated for any TPE_PASSENGER cargo type.
1 file changed with 10 insertions and 4 deletions:
0 comments (0 inline, 0 general)
src/subsidy.cpp
Show inline comments
 
@@ -286,9 +286,13 @@ bool FindSubsidyPassengerRoute()
 
{
 
	if (!Subsidy::CanAllocateItem()) return false;
 

	
 
	/* Pick a random TPE_PASSENGER type */
 
	uint32_t r = RandomRange(static_cast<uint>(CargoSpec::town_production_cargoes[TPE_PASSENGERS].size()));
 
	CargoID cid = CargoSpec::town_production_cargoes[TPE_PASSENGERS][r]->Index();
 

	
 
	const Town *src = Town::GetRandom();
 
	if (src->cache.population < SUBSIDY_PAX_MIN_POPULATION ||
 
			src->GetPercentTransported(CT_PASSENGERS) > SUBSIDY_MAX_PCT_TRANSPORTED) {
 
			src->GetPercentTransported(cid) > SUBSIDY_MAX_PCT_TRANSPORTED) {
 
		return false;
 
	}
 

	
 
@@ -298,9 +302,9 @@ bool FindSubsidyPassengerRoute()
 
	}
 

	
 
	if (DistanceManhattan(src->xy, dst->xy) > SUBSIDY_MAX_DISTANCE) return false;
 
	if (CheckSubsidyDuplicate(CT_PASSENGERS, SourceType::Town, src->index, SourceType::Town, dst->index)) return false;
 
	if (CheckSubsidyDuplicate(cid, SourceType::Town, src->index, SourceType::Town, dst->index)) return false;
 

	
 
	CreateSubsidy(CT_PASSENGERS, SourceType::Town, src->index, SourceType::Town, dst->index);
 
	CreateSubsidy(cid, SourceType::Town, src->index, SourceType::Town, dst->index);
 

	
 
	return true;
 
}
 
@@ -332,7 +336,9 @@ bool FindSubsidyTownCargoRoute()
 
	}
 

	
 
	/* Passenger subsidies are not handled here. */
 
	town_cargo_produced[CT_PASSENGERS] = 0;
 
	for (const CargoSpec *cs : CargoSpec::town_production_cargoes[TPE_PASSENGERS]) {
 
		town_cargo_produced[cs->Index()] = 0;
 
	}
 

	
 
	uint8_t cargo_count = town_cargo_produced.GetCount();
 

	
0 comments (0 inline, 0 general)