Changeset - r9750:1e2535e15958
[Not reviewed]
master
0 14 0
frosch - 16 years ago 2008-07-30 18:23:12
frosch@openttd.org
(svn r13885) -Fix [FS#2168]: Var 0x7F is not feature-specific.
14 files changed with 32 insertions and 59 deletions:
0 comments (0 inline, 0 general)
src/cargotype.h
Show inline comments
 
@@ -25,7 +25,6 @@ enum TownEffect {
 
struct CargoSpec {
 
	uint8 bitnum;
 
	CargoLabel label;
 
	uint32 grfid;
 
	uint8 legend_colour;
 
	uint8 rating_colour;
 
	uint8 weight;
 
@@ -46,6 +45,7 @@ struct CargoSpec {
 
	SpriteID sprite;
 

	
 
	uint16 classes;
 
	const struct GRFFile *grffile;   ///< NewGRF where 'group' belongs to
 
	const struct SpriteGroup *group;
 

	
 
	bool IsValid() const;
src/newgrf.cpp
Show inline comments
 
@@ -1732,7 +1732,7 @@ static bool CargoChangeInfo(uint cid, in
 
			case 0x08: /* Bit number of cargo */
 
				cs->bitnum = grf_load_byte(&buf);
 
				if (cs->IsValid()) {
 
					cs->grfid = _cur_grffile->grfid;
 
					cs->grffile = _cur_grffile;
 
					SetBit(_cargo_mask, cid + i);
 
				} else {
 
					ClrBit(_cargo_mask, cid + i);
 
@@ -3045,6 +3045,7 @@ static void CanalMapSpriteGroup(byte *bu
 
			continue;
 
		}
 

	
 
		_water_feature[cf].grffile = _cur_grffile;
 
		_water_feature[cf].group = _cur_grffile->spritegroups[groupid];
 
	}
 
}
 
@@ -3198,7 +3199,7 @@ static void CargoMapSpriteGroup(byte *bu
 
		}
 

	
 
		CargoSpec *cs = &_cargo[cid];
 
		cs->grfid = _cur_grffile->grfid;
 
		cs->grffile = _cur_grffile;
 
		cs->group = _cur_grffile->spritegroups[groupid];
 
	}
 
}
src/newgrf_canal.cpp
Show inline comments
 
@@ -71,7 +71,7 @@ static const SpriteGroup *CanalResolveRe
 
}
 

	
 

	
 
static void NewCanalResolver(ResolverObject *res, TileIndex tile)
 
static void NewCanalResolver(ResolverObject *res, TileIndex tile, const GRFFile *grffile)
 
{
 
	res->GetRandomBits = &CanalGetRandomBits;
 
	res->GetTriggers   = &CanalGetTriggers;
 
@@ -88,6 +88,7 @@ static void NewCanalResolver(ResolverObj
 
	res->trigger         = 0;
 
	res->reseed          = 0;
 
	res->count           = 0;
 
	res->grffile         = grffile;
 
}
 

	
 

	
 
@@ -96,7 +97,7 @@ SpriteID GetCanalSprite(CanalFeature fea
 
	ResolverObject object;
 
	const SpriteGroup *group;
 

	
 
	NewCanalResolver(&object, tile);
 
	NewCanalResolver(&object, tile, _water_feature[feature].grffile);
 

	
 
	group = Resolve(_water_feature[feature].group, &object);
 
	if (group == NULL || group->type != SGT_RESULT) return 0;
src/newgrf_canal.h
Show inline comments
 
@@ -21,6 +21,7 @@ enum CanalFeature {
 

	
 
struct WaterFeature {
 
	const SpriteGroup *group;
 
	const GRFFile *grffile;   ///< newgrf where 'group' belongs to
 
	uint8 callbackmask;
 
	uint8 flags;
 
};
src/newgrf_cargo.cpp
Show inline comments
 
@@ -67,6 +67,7 @@ static void NewCargoResolver(ResolverObj
 
	res->trigger         = 0;
 
	res->reseed          = 0;
 
	res->count           = 0;
 
	res->grffile         = cs->grffile;
 
}
 

	
 

	
src/newgrf_engine.cpp
Show inline comments
 
@@ -439,16 +439,6 @@ static void VehicleSetTriggers(const Res
 
}
 

	
 

	
 
static uint32 GetGRFParameter(EngineID engine_type, byte parameter)
 
{
 
	const GRFFile *file = GetEngineGRF(engine_type);
 

	
 
	if (file == NULL) return 0;
 
	if (parameter >= file->param_end) return 0;
 
	return file->param[parameter];
 
}
 

	
 

	
 
static uint8 LiveryHelper(EngineID engine, const Vehicle *v)
 
{
 
	const Livery *l;
 
@@ -479,7 +469,6 @@ static uint32 VehicleGetVariable(const R
 
			case 0x49: return _cur_year; // 'Long' format build year
 
			case 0xC4: return Clamp(_cur_year, ORIGINAL_BASE_YEAR, ORIGINAL_MAX_YEAR) - ORIGINAL_BASE_YEAR; // Build year
 
			case 0xDA: return INVALID_VEHICLE; // Next vehicle
 
			case 0x7F: return GetGRFParameter(object->u.vehicle.self_type, parameter); // Read GRF parameter
 
		}
 

	
 
		*available = false;
 
@@ -632,8 +621,6 @@ static uint32 VehicleGetVariable(const R
 
				return count;
 
			}
 

	
 
		case 0x7F: return GetGRFParameter(v->engine_type, parameter); // Read GRF parameter
 

	
 
		case 0xFE:
 
		case 0xFF: {
 
			uint16 modflags = 0;
 
@@ -832,6 +819,9 @@ static inline void NewVehicleResolver(Re
 
	res->trigger         = 0;
 
	res->reseed          = 0;
 
	res->count           = 0;
 

	
 
	const Engine *e = GetEngine(engine_type);
 
	res->grffile         = (e != NULL ? e->grffile : NULL);
 
}
 

	
 

	
src/newgrf_generic.cpp
Show inline comments
 
@@ -113,7 +113,7 @@ static const SpriteGroup *GenericCallbac
 
}
 

	
 

	
 
static inline void NewGenericResolver(ResolverObject *res)
 
static inline void NewGenericResolver(ResolverObject *res, const GRFFile *grffile)
 
{
 
	res->GetRandomBits = &GenericCallbackGetRandomBits;
 
	res->GetTriggers   = &GenericCallbackGetTriggers;
 
@@ -128,6 +128,7 @@ static inline void NewGenericResolver(Re
 
	res->trigger         = 0;
 
	res->reseed          = 0;
 
	res->count           = 0;
 
	res->grffile         = grffile;
 
}
 

	
 

	
 
@@ -166,7 +167,7 @@ uint16 GetAiPurchaseCallbackResult(uint8
 
{
 
	ResolverObject object;
 

	
 
	NewGenericResolver(&object);
 
	NewGenericResolver(&object, *file);
 

	
 
	object.callback = CBID_GENERIC_AI_PURCHASE_SELECTION;
 
	object.u.generic.cargo_type        = cargo_type;
src/newgrf_house.cpp
Show inline comments
 
@@ -183,15 +183,6 @@ static uint32 GetNumHouses(HouseID house
 
	return map_class_count << 24 | town_class_count << 16 | map_id_count << 8 | town_id_count;
 
}
 

	
 
static uint32 GetGRFParameter(HouseID house_id, byte parameter)
 
{
 
	const HouseSpec *hs = GetHouseSpecs(house_id);
 
	const GRFFile *file = hs->grffile;
 

	
 
	if (parameter >= file->param_end) return 0;
 
	return file->param[parameter];
 
}
 

	
 
uint32 GetNearbyTileInformation(byte parameter, TileIndex tile)
 
{
 
	tile = GetNearbyTile(parameter, tile);
 
@@ -369,9 +360,6 @@ static uint32 HouseGetVariable(const Res
 

	
 
		/* Distance test for some house types */
 
		case 0x65: return GetDistanceFromNearbyHouse(parameter, tile, object->u.house.house_id);
 

	
 
		/* Read GRF parameter */
 
		case 0x7F: return GetGRFParameter(object->u.house.house_id, parameter);
 
	}
 

	
 
	DEBUG(grf, 1, "Unhandled house property 0x%X", variable);
 
@@ -410,6 +398,9 @@ static void NewHouseResolver(ResolverObj
 
	res->trigger         = 0;
 
	res->reseed          = 0;
 
	res->count           = 0;
 

	
 
	const HouseSpec *hs = GetHouseSpecs(house_id);
 
	res->grffile         = (hs != NULL ? hs->grffile : NULL);
 
}
 

	
 
uint16 GetHouseCallback(CallbackID callback, uint32 param1, uint32 param2, HouseID house_id, Town *town, TileIndex tile)
src/newgrf_industries.cpp
Show inline comments
 
@@ -41,15 +41,6 @@ IndustryType MapNewGRFIndustryType(Indus
 
	return _industry_mngr.GetID(GB(grf_type, 0, 6), grf_id);
 
}
 

	
 
static uint32 GetGRFParameter(IndustryType ind_id, byte parameter)
 
{
 
	const IndustrySpec *indspec = GetIndustrySpec(ind_id);
 
	const GRFFile *file = indspec->grf_prop.grffile;
 

	
 
	if (parameter >= file->param_end) return 0;
 
	return file->param[parameter];
 
}
 

	
 
/**
 
 * Finds the distance for the closest tile with water/land given a tile
 
 * @param tile  the tile to find the distance too
 
@@ -230,8 +221,6 @@ uint32 IndustryGetVariable(const Resolve
 
	if (industry == NULL) {
 
		/* industry does not exist, only use those variables that are "safe" */
 
		switch (variable) {
 
			/* Read GRF parameter */
 
			case 0x7F: return GetGRFParameter(type, parameter);
 
			/* Manhattan distance of closes dry/water tile */
 
			case 0x43: return GetClosestWaterDistance(tile, (indspec->behaviour & INDUSTRYBEH_BUILT_ONWATER) == 0);
 
		}
 
@@ -318,9 +307,6 @@ uint32 IndustryGetVariable(const Resolve
 
		/* Get a variable from the persistent storage */
 
		case 0x7C: return industry->psa.Get(parameter);
 

	
 
		/* Read GRF parameter */
 
		case 0x7F: return GetGRFParameter(type, parameter);
 

	
 
		/* Industry structure access*/
 
		case 0x80: return industry->xy;
 
		case 0x81: return GB(industry->xy, 8, 8);
 
@@ -430,6 +416,9 @@ static void NewIndustryResolver(Resolver
 
	res->trigger         = 0;
 
	res->reseed          = 0;
 
	res->count           = 0;
 

	
 
	const IndustrySpec *indspec = GetIndustrySpec(type);
 
	res->grffile         = (indspec != NULL ? indspec->grf_prop.grffile : NULL);
 
}
 

	
 
uint16 GetIndustryCallback(CallbackID callback, uint32 param1, uint32 param2, Industry *industry, IndustryType type, TileIndex tile)
src/newgrf_industrytiles.cpp
Show inline comments
 
@@ -30,15 +30,6 @@
 
#include "table/sprites.h"
 
#include "table/strings.h"
 

	
 
static uint32 GetGRFParameter(IndustryGfx indtile_id, byte parameter)
 
{
 
	const IndustryTileSpec *indtspec = GetIndustryTileSpec(indtile_id);
 
	const GRFFile *file = indtspec->grf_prop.grffile;
 

	
 
	if (parameter >= file->param_end) return 0;
 
	return file->param[parameter];
 
}
 

	
 
/**
 
 * Based on newhouses equivalent, but adapted for newindustries
 
 * @param parameter from callback.  It's in fact a pair of coordinates
 
@@ -110,9 +101,6 @@ static uint32 IndustryTileGetVariable(co
 

	
 
		/* Get industry tile ID at offset */
 
		case 0x62 : return GetIndustryIDAtOffset(GetNearbyTile(parameter, tile), inds);
 

	
 
		/* Read GRF parameter */
 
		case 0x7F: return GetGRFParameter(GetIndustryGfx(tile), parameter);
 
	}
 

	
 
	DEBUG(grf, 1, "Unhandled industry tile property 0x%X", variable);
 
@@ -174,6 +162,9 @@ static void NewIndustryTileResolver(Reso
 
	res->trigger         = 0;
 
	res->reseed          = 0;
 
	res->count           = 0;
 

	
 
	const IndustryTileSpec *its = GetIndustryTileSpec(gfx);
 
	res->grffile         = (its != NULL ? its->grf_prop.grffile : NULL);
 
}
 

	
 
void IndustryDrawTileLayout(const TileInfo *ti, const SpriteGroup *group, byte rnd_color, byte stage, IndustryGfx gfx)
src/newgrf_spritegroup.cpp
Show inline comments
 
@@ -97,6 +97,10 @@ static inline uint32 GetVariable(const R
 

	
 
		case 0x7D: return _temp_store.Get(parameter);
 

	
 
		case 0x7F:
 
			if (object == NULL || object->grffile == NULL || parameter >= object->grffile->param_end) return 0;
 
			return object->grffile->param[parameter];
 

	
 
		/* Not a common variable, so evalute the feature specific variables */
 
		default: return object->GetVariable(object, variable, parameter, available);
 
	}
src/newgrf_spritegroup.h
Show inline comments
 
@@ -218,6 +218,8 @@ struct ResolverObject {
 

	
 
	BaseStorageArray *psa; ///< The persistent storage array of this resolved object.
 

	
 
	const GRFFile *grffile; ///< GRFFile the resolved SpriteGroup belongs to
 

	
 
	union {
 
		struct {
 
			const struct Vehicle *self;
src/newgrf_station.cpp
Show inline comments
 
@@ -590,6 +590,7 @@ static void NewStationResolver(ResolverO
 
	res->trigger         = 0;
 
	res->reseed          = 0;
 
	res->count           = 0;
 
	res->grffile         = (statspec != NULL ? statspec->grffile : NULL);
 
}
 

	
 
static const SpriteGroup *ResolveStation(ResolverObject *object)
src/table/cargo_const.h
Show inline comments
 
@@ -3,7 +3,7 @@
 
/** @file cargo_const.h Table of all default cargo types */
 

	
 
#define MK(bt, label, c, e, f, g, h, fr, te, ks1, ks2, ks3, ks4, ks5, l, m) \
 
          {bt, label, 0, c, c, e, f, {g, h}, fr, te, 0, 0, ks1, ks2, ks3, ks4, ks5, l, m, NULL}
 
          {bt, label, c, c, e, f, {g, h}, fr, te, 0, 0, ks1, ks2, ks3, ks4, ks5, l, m, NULL, NULL}
 
static const CargoSpec _default_cargo[] = {
 
	MK(  0, 'PASS', 152,  1, 3185,  0,  24, false, TE_PASSENGERS,
 
		STR_000F_PASSENGERS,     STR_002F_PASSENGER,      STR_PASSENGERS, STR_QUANTITY_PASSENGERS,   STR_ABBREV_PASSENGERS,
0 comments (0 inline, 0 general)