Changeset - r18293:c9afcb11eab2
[Not reviewed]
master
0 1 0
frosch - 13 years ago 2011-11-08 17:24:01
frosch@openttd.org
(svn r23139) -Change: [NewGRF v8] Do no longer apply base cost fallbacks.
1 file changed with 2 insertions and 1 deletions:
0 comments (0 inline, 0 general)
src/newgrf.cpp
Show inline comments
 
@@ -8661,51 +8661,52 @@ static void FinalisePriceBaseMultipliers
 
			DEBUG(grf, 3, "Price base multiplier %d from '%s' propagated to '%s'", p, source->filename, dest->filename);
 
			dest->price_base_multipliers[p] = source->price_base_multipliers[p];
 
		}
 
	}
 

	
 
	/* The 'master grf' now have the correct multipliers. Assign them to the 'addon grfs' to make everything consistent. */
 
	for (int i = 0; i < num_grfs; i++) {
 
		if (grf_overrides[i] < 0) continue;
 
		GRFFile *source = _grf_files[i];
 
		GRFFile *dest = _grf_files[grf_overrides[i]];
 

	
 
		uint32 features = (source->grf_features | dest->grf_features) & override_features;
 
		source->grf_features |= features;
 
		dest->grf_features |= features;
 

	
 
		for (Price p = PR_BEGIN; p < PR_END; p++) {
 
			if (!HasBit(features, _price_base_specs[p].grf_feature)) continue;
 
			if (source->price_base_multipliers[p] != dest->price_base_multipliers[p]) {
 
				DEBUG(grf, 3, "Price base multiplier %d from '%s' propagated to '%s'", p, dest->filename, source->filename);
 
			}
 
			source->price_base_multipliers[p] = dest->price_base_multipliers[p];
 
		}
 
	}
 

	
 
	/* Apply fallback prices */
 
	/* Apply fallback prices for grf version < 8 */
 
	const GRFFile * const *end = _grf_files.End();
 
	for (GRFFile **file = _grf_files.Begin(); file != end; file++) {
 
		if ((*file)->grf_version >= 8) continue;
 
		PriceMultipliers &price_base_multipliers = (*file)->price_base_multipliers;
 
		for (Price p = PR_BEGIN; p < PR_END; p++) {
 
			Price fallback_price = _price_base_specs[p].fallback_price;
 
			if (fallback_price != INVALID_PRICE && price_base_multipliers[p] == INVALID_PRICE_MODIFIER) {
 
				/* No price multiplier has been set.
 
				 * So copy the multiplier from the fallback price, maybe a multiplier was set there. */
 
				price_base_multipliers[p] = price_base_multipliers[fallback_price];
 
			}
 
		}
 
	}
 

	
 
	/* Decide local/global scope of price base multipliers */
 
	for (GRFFile **file = _grf_files.Begin(); file != end; file++) {
 
		PriceMultipliers &price_base_multipliers = (*file)->price_base_multipliers;
 
		for (Price p = PR_BEGIN; p < PR_END; p++) {
 
			if (price_base_multipliers[p] == INVALID_PRICE_MODIFIER) {
 
				/* No multiplier was set; set it to a neutral value */
 
				price_base_multipliers[p] = 0;
 
			} else {
 
				if (!HasBit((*file)->grf_features, _price_base_specs[p].grf_feature)) {
 
					/* The grf does not define any objects of the feature,
 
					 * so it must be a difficulty setting. Apply it globally */
 
					DEBUG(grf, 3, "'%s' sets global price base multiplier %d", (*file)->filename, p);
 
					SetPriceBaseMultiplier(p, price_base_multipliers[p]);
0 comments (0 inline, 0 general)