File diff r23961:d62b62a4184a → r23962:50d7e69becd3
src/newgrf_industries.cpp
Show inline comments
 
@@ -88,14 +88,13 @@ uint32 GetIndustryIDAtOffset(TileIndex t
 
	return 0xFF << 8 | indtsp->grf_prop.subst_id; // so just give him the substitute
 
}
 

	
 
static uint32 GetClosestIndustry(TileIndex tile, IndustryType type, const Industry *current)
 
{
 
	uint32 best_dist = UINT32_MAX;
 
	const Industry *i;
 
	FOR_ALL_INDUSTRIES(i) {
 
	for (const Industry *i : Industry::Iterate()) {
 
		if (i->type != type || i == current) continue;
 

	
 
		best_dist = min(best_dist, DistanceManhattan(tile, i->location.tile));
 
	}
 

	
 
	return best_dist;
 
@@ -142,14 +141,13 @@ static uint32 GetCountAndDistanceOfClose
 
		 * In either case, just do the regular var67 */
 
		closest_dist = GetClosestIndustry(current->location.tile, ind_index, current);
 
		count = min(Industry::GetIndustryTypeCount(ind_index), UINT8_MAX); // clamp to 8 bit
 
	} else {
 
		/* Count only those who match the same industry type and layout filter
 
		 * Unfortunately, we have to do it manually */
 
		const Industry *i;
 
		FOR_ALL_INDUSTRIES(i) {
 
		for (const Industry *i : Industry::Iterate()) {
 
			if (i->type == ind_index && i != current && (i->selected_layout == layout_filter || layout_filter == 0) && (!town_filter || i->town == current->town)) {
 
				closest_dist = min(closest_dist, DistanceManhattan(current->location.tile, i->location.tile));
 
				count++;
 
			}
 
		}
 
	}