File diff r13040:fc076d743e2f → r13041:acd808f364d5
src/subsidy.cpp
Show inline comments
 
@@ -164,49 +164,49 @@ static bool CheckSubsidyDuplicate(CargoI
 
		if (s->cargo_type == cargo &&
 
				s->src_type == src_type && s->src == src &&
 
				s->dst_type == dst_type && s->dst == dst) {
 
			return true;
 
		}
 
	}
 
	return false;
 
}
 

	
 
static Subsidy *FindSubsidyPassengerRoute()
 
{
 
	assert(Subsidy::CanAllocateItem());
 

	
 
	const Town *src = Town::GetRandom();
 
	if (src->population < SUBSIDY_PAX_MIN_POPULATION ||
 
			src->pct_pass_transported > SUBSIDY_MAX_PCT_TRANSPORTED) {
 
		return NULL;
 
	}
 

	
 
	const Town *dst = Town::GetRandom();
 
	if (dst->population < SUBSIDY_PAX_MIN_POPULATION || src == dst) {
 
		return NULL;
 
	}
 

	
 
	if (DistanceManhattan(src->xy, src->xy) > SUBSIDY_MAX_DISTANCE) return NULL;
 
	if (DistanceManhattan(src->xy, dst->xy) > SUBSIDY_MAX_DISTANCE) return NULL;
 
	if (CheckSubsidyDuplicate(CT_PASSENGERS, ST_TOWN, src->index, ST_TOWN, dst->index)) return NULL;
 

	
 
	Subsidy *s = new Subsidy();
 
	s->cargo_type = CT_PASSENGERS;
 
	s->src_type = s->dst_type = ST_TOWN;
 
	s->src = src->index;
 
	s->dst = dst->index;
 

	
 
	return s;
 
}
 

	
 
static Subsidy *FindSubsidyCargoRoute()
 
{
 
	assert(Subsidy::CanAllocateItem());
 

	
 
	const Industry *i = Industry::GetRandom();
 
	if (i == NULL) return NULL;
 

	
 
	CargoID cargo;
 
	int trans, total;
 

	
 
	/* Randomize cargo type */
 
	if (i->produced_cargo[1] != CT_INVALID && HasBit(Random(), 0)) {
 
		cargo = i->produced_cargo[1];