Changeset - r22756:8ffd1846f871
[Not reviewed]
master
0 23 0
frosch - 6 years ago 2018-03-11 13:19:41
frosch@openttd.org
(svn r27984) -Codechange: Make ScopeResolver constructors/destructors inlineable. Speedup sprite resolving by about 8 percent.
23 files changed with 145 insertions and 220 deletions:
0 comments (0 inline, 0 general)
src/newgrf_airport.cpp
Show inline comments
 
@@ -26,7 +26,18 @@ struct AirportScopeResolver : public Sco
 
	byte layout;        ///< Layout of the airport to build.
 
	TileIndex tile;     ///< Tile for the callback, only valid for airporttile callbacks.
 

	
 
	AirportScopeResolver(ResolverObject &ro, TileIndex tile, Station *st, byte airport_id, byte layout);
 
	/**
 
	 * Constructor of the scope resolver for an airport.
 
	 * @param ro Surrounding resolver.
 
	 * @param tile %Tile for the callback, only valid for airporttile callbacks.
 
	 * @param st %Station of the airport for which the callback is run, or \c NULL for build gui.
 
	 * @param airport_id Type of airport for which the callback is run.
 
	 * @param layout Layout of the airport to build.
 
	 */
 
	AirportScopeResolver(ResolverObject &ro, TileIndex tile, Station *st, byte airport_id, byte layout)
 
			: ScopeResolver(ro), st(st), airport_id(airport_id), layout(layout), tile(tile)
 
	{
 
	}
 

	
 
	/* virtual */ uint32 GetRandomBits() const;
 
	/* virtual */ uint32 GetVariable(byte variable, uint32 parameter, bool *available) const;
 
@@ -242,22 +253,6 @@ AirportResolverObject::AirportResolverOb
 
	this->root_spritegroup = AirportSpec::Get(airport_id)->grf_prop.spritegroup[0];
 
}
 

	
 
/**
 
 * Constructor of the scope resolver for an airport.
 
 * @param ro Surrounding resolver.
 
 * @param tile %Tile for the callback, only valid for airporttile callbacks.
 
 * @param st %Station of the airport for which the callback is run, or \c NULL for build gui.
 
 * @param airport_id Type of airport for which the callback is run.
 
 * @param layout Layout of the airport to build.
 
 */
 
AirportScopeResolver::AirportScopeResolver(ResolverObject &ro, TileIndex tile, Station *st, byte airport_id, byte layout) : ScopeResolver(ro)
 
{
 
	this->st = st;
 
	this->airport_id = airport_id;
 
	this->layout = layout;
 
	this->tile = tile;
 
}
 

	
 
SpriteID GetCustomAirportSprite(const AirportSpec *as, byte layout)
 
{
 
	AirportResolverObject object(INVALID_TILE, NULL, as->GetIndex(), layout);
src/newgrf_airporttiles.cpp
Show inline comments
 
@@ -222,21 +222,6 @@ AirportTileResolverObject::AirportTileRe
 
	this->root_spritegroup = ats->grf_prop.spritegroup[0];
 
}
 

	
 
/**
 
 * Constructor of the scope resolver specific for airport tiles.
 
 * @param ats Specification of the airport tiles.
 
 * @param tile %Tile for the callback, only valid for airporttile callbacks.
 
 * @param st Station of the airport for which the callback is run, or \c NULL for build gui.
 
 */
 
AirportTileScopeResolver::AirportTileScopeResolver(ResolverObject &ro, const AirportTileSpec *ats, TileIndex tile, Station *st) : ScopeResolver(ro)
 
{
 
	assert(st != NULL);
 

	
 
	this->st = st;
 
	this->airport_id = st->airport.type;
 
	this->tile = tile;
 
}
 

	
 
uint16 GetAirportTileCallback(CallbackID callback, uint32 param1, uint32 param2, const AirportTileSpec *ats, Station *st, TileIndex tile, int extra_data = 0)
 
{
 
	AirportTileResolverObject object(ats, tile, st, callback, param1, param2);
src/newgrf_airporttiles.h
Show inline comments
 
@@ -17,6 +17,7 @@
 
#include "newgrf_animation_type.h"
 
#include "newgrf_commons.h"
 
#include "newgrf_spritegroup.h"
 
#include "station_base.h"
 

	
 
/** Scope resolver for handling the tiles of an airport. */
 
struct AirportTileScopeResolver : public ScopeResolver {
 
@@ -24,7 +25,18 @@ struct AirportTileScopeResolver : public
 
	byte airport_id;     ///< Type of airport for which the callback is run.
 
	TileIndex tile;      ///< Tile for the callback, only valid for airporttile callbacks.
 

	
 
	AirportTileScopeResolver(ResolverObject &ro, const AirportTileSpec *ats, TileIndex tile, Station *st);
 
	/**
 
	 * Constructor of the scope resolver specific for airport tiles.
 
	 * @param ats Specification of the airport tiles.
 
	 * @param tile %Tile for the callback, only valid for airporttile callbacks.
 
	 * @param st Station of the airport for which the callback is run, or \c NULL for build gui.
 
	 */
 
	AirportTileScopeResolver(ResolverObject &ro, const AirportTileSpec *ats, TileIndex tile, Station *st)
 
		: ScopeResolver(ro), st(st), tile(tile)
 
	{
 
		assert(st != NULL);
 
		this->airport_id = st->airport.type;
 
	}
 

	
 
	/* virtual */ uint32 GetRandomBits() const;
 
	/* virtual */ uint32 GetVariable(byte variable, uint32 parameter, bool *available) const;
src/newgrf_canal.cpp
Show inline comments
 
@@ -25,7 +25,10 @@ WaterFeature _water_feature[CF_END];
 
struct CanalScopeResolver : public ScopeResolver {
 
	TileIndex tile; ///< Tile containing the canal.
 

	
 
	CanalScopeResolver(ResolverObject &ro, TileIndex tile);
 
	CanalScopeResolver(ResolverObject &ro, TileIndex tile)
 
		: ScopeResolver(ro), tile(tile)
 
	{
 
	}
 

	
 
	/* virtual */ uint32 GetRandomBits() const;
 
	/* virtual */ uint32 GetVariable(byte variable, uint32 parameter, bool *available) const;
 
@@ -110,11 +113,6 @@ struct CanalResolverObject : public Reso
 
	return group->loaded[0];
 
}
 

	
 
CanalScopeResolver::CanalScopeResolver(ResolverObject &ro, TileIndex tile) : ScopeResolver(ro)
 
{
 
	this->tile = tile;
 
}
 

	
 
/**
 
 * Canal resolver constructor.
 
 * @param feature Which canal feature we want.
src/newgrf_engine.cpp
Show inline comments
 
@@ -938,21 +938,6 @@ static uint32 VehicleGetVariable(Vehicle
 
}
 

	
 
/**
 
 * Scope resolver of a single vehicle.
 
 * @param ro Surrounding resolver.
 
 * @param engine_type Engine type
 
 * @param v %Vehicle being resolved.
 
 * @param info_view Indicates if the item is being drawn in an info window.
 
 */
 
VehicleScopeResolver::VehicleScopeResolver(ResolverObject &ro, EngineID engine_type, const Vehicle *v, bool info_view)
 
		: ScopeResolver(ro)
 
{
 
	this->v = v;
 
	this->self_type = engine_type;
 
	this->info_view = info_view;
 
}
 

	
 
/**
 
 * Get the grf file associated with an engine type.
 
 * @param engine_type Engine to query.
 
 * @return grf file associated with the engine.
src/newgrf_engine.h
Show inline comments
 
@@ -26,7 +26,17 @@ struct VehicleScopeResolver : public Sco
 
	EngineID self_type;      ///< Type of the vehicle.
 
	bool info_view;          ///< Indicates if the item is being drawn in an info window.
 

	
 
	VehicleScopeResolver(ResolverObject &ro, EngineID engine_type, const Vehicle *v, bool info_view);
 
	/**
 
	 * Scope resolver of a single vehicle.
 
	 * @param ro Surrounding resolver.
 
	 * @param engine_type Engine type
 
	 * @param v %Vehicle being resolved.
 
	 * @param info_view Indicates if the item is being drawn in an info window.
 
	 */
 
	VehicleScopeResolver(ResolverObject &ro, EngineID engine_type, const Vehicle *v, bool info_view)
 
		: ScopeResolver(ro), v(v), self_type(engine_type), info_view(info_view)
 
	{
 
	}
 

	
 
	void SetVehicle(const Vehicle *v) { this->v = v; }
 

	
src/newgrf_generic.cpp
Show inline comments
 
@@ -31,7 +31,16 @@ struct GenericScopeResolver : public Sco
 
	uint8 count;
 
	uint8 station_size;
 

	
 
	GenericScopeResolver(ResolverObject &ro, bool ai_callback);
 
	/**
 
	 * Generic scope resolver.
 
	 * @param ro Surrounding resolver.
 
	 * @param ai_callback Callback comes from the AI.
 
	 */
 
	GenericScopeResolver(ResolverObject &ro, bool ai_callback)
 
		: ScopeResolver(ro), cargo_type(0), default_selection(0), src_industry(0), dst_industry(0), distance(0),
 
		event(), count(0), station_size(0), ai_callback(ai_callback)
 
	{
 
	}
 

	
 
	/* virtual */ uint32 GetVariable(byte variable, uint32 parameter, bool *available) const;
 

	
 
@@ -145,24 +154,6 @@ GenericResolverObject::GenericResolverOb
 
{
 
}
 

	
 
/**
 
 * Generic scope resolver.
 
 * @param ro Surrounding resolver.
 
 * @param ai_callback Callback comes from the AI.
 
 */
 
GenericScopeResolver::GenericScopeResolver(ResolverObject &ro, bool ai_callback) : ScopeResolver(ro)
 
{
 
	this->cargo_type = 0;
 
	this->default_selection = 0;
 
	this->src_industry = 0;
 
	this->dst_industry = 0;
 
	this->distance = 0;
 
	this->event = (AIConstructionEvent)0;
 
	this->count = 0;
 
	this->station_size = 0;
 
	this->ai_callback = ai_callback;
 
}
 

	
 

	
 
/**
 
 * Follow a generic feature callback list and return the first successful
src/newgrf_house.cpp
Show inline comments
 
@@ -32,28 +32,6 @@ static HouseClassMapping _class_mapping[
 
HouseOverrideManager _house_mngr(NEW_HOUSE_OFFSET, NUM_HOUSES, INVALID_HOUSE_ID);
 

	
 
/**
 
 * Constructor of a house scope resolver.
 
 * @param ro Surrounding resolver.
 
 * @param house_id House type being queried.
 
 * @param tile %Tile containing the house.
 
 * @param town %Town containing the house.
 
 * @param not_yet_constructed House is still under construction.
 
 * @param initial_random_bits Random bits during construction checks.
 
 * @param watched_cargo_triggers Cargo types that triggered the watched cargo callback.
 
 */
 
HouseScopeResolver::HouseScopeResolver(ResolverObject &ro, HouseID house_id, TileIndex tile, Town *town,
 
			bool not_yet_constructed, uint8 initial_random_bits, uint32 watched_cargo_triggers)
 
		: ScopeResolver(ro)
 
{
 
	this->house_id = house_id;
 
	this->tile = tile;
 
	this->town = town;
 
	this->not_yet_constructed = not_yet_constructed;
 
	this->initial_random_bits = initial_random_bits;
 
	this->watched_cargo_triggers = watched_cargo_triggers;
 
}
 

	
 
/**
 
 * Retrieve the grf file associated with a house.
 
 * @param house_id House to query.
 
 * @return The associated GRF file (may be \c NULL).
src/newgrf_house.h
Show inline comments
 
@@ -27,8 +27,22 @@ struct HouseScopeResolver : public Scope
 
	uint16 initial_random_bits;    ///< Random bits during construction checks.
 
	uint32 watched_cargo_triggers; ///< Cargo types that triggered the watched cargo callback.
 

	
 
	/**
 
	 * Constructor of a house scope resolver.
 
	 * @param ro Surrounding resolver.
 
	 * @param house_id House type being queried.
 
	 * @param tile %Tile containing the house.
 
	 * @param town %Town containing the house.
 
	 * @param not_yet_constructed House is still under construction.
 
	 * @param initial_random_bits Random bits during construction checks.
 
	 * @param watched_cargo_triggers Cargo types that triggered the watched cargo callback.
 
	 */
 
	HouseScopeResolver(ResolverObject &ro, HouseID house_id, TileIndex tile, Town *town,
 
			bool not_yet_constructed, uint8 initial_random_bits, uint32 watched_cargo_triggers);
 
			bool not_yet_constructed, uint8 initial_random_bits, uint32 watched_cargo_triggers)
 
		: ScopeResolver(ro), house_id(house_id), tile(tile), town(town), not_yet_constructed(not_yet_constructed),
 
		initial_random_bits(initial_random_bits), watched_cargo_triggers(watched_cargo_triggers)
 
	{
 
	}
 

	
 
	/* virtual */ uint32 GetRandomBits() const;
 
	/* virtual */ uint32 GetVariable(byte variable, uint32 parameter, bool *available) const;
src/newgrf_industries.cpp
Show inline comments
 
@@ -458,23 +458,6 @@ TownScopeResolver *IndustriesResolverObj
 
}
 

	
 
/**
 
 * Scope resolver for industries.
 
 * @param ro Surrounding resolver.
 
 * @param tile %Tile owned by the industry.
 
 * @param industry %Industry being resolved.
 
 * @param type Type of the industry.
 
 * @param random_bits Random bits of the new industry.
 
 */
 
IndustriesScopeResolver::IndustriesScopeResolver(ResolverObject &ro, TileIndex tile, Industry *industry, IndustryType type, uint32 random_bits)
 
	: ScopeResolver(ro)
 
{
 
	this->tile = tile;
 
	this->industry = industry;
 
	this->type = type;
 
	this->random_bits = random_bits;
 
}
 

	
 
/**
 
 * Perform an industry callback.
 
 * @param callback The callback to perform.
 
 * @param param1 The first parameter.
src/newgrf_industries.h
Show inline comments
 
@@ -21,7 +21,18 @@ struct IndustriesScopeResolver : public 
 
	IndustryType type;  ///< Type of the industry.
 
	uint32 random_bits; ///< Random bits of the new industry.
 

	
 
	IndustriesScopeResolver(ResolverObject &ro, TileIndex tile, Industry *industry, IndustryType type, uint32 random_bits = 0);
 
	/**
 
	 * Scope resolver for industries.
 
	 * @param ro Surrounding resolver.
 
	 * @param tile %Tile owned by the industry.
 
	 * @param industry %Industry being resolved.
 
	 * @param type Type of the industry.
 
	 * @param random_bits Random bits of the new industry.
 
	 */
 
	IndustriesScopeResolver(ResolverObject &ro, TileIndex tile, Industry *industry, IndustryType type, uint32 random_bits = 0)
 
		: ScopeResolver(ro), tile(tile), industry(industry), type(type), random_bits(random_bits)
 
	{
 
	}
 

	
 
	/* virtual */ uint32 GetRandomBits() const;
 
	/* virtual */ uint32 GetVariable(byte variable, uint32 parameter, bool *available) const;
src/newgrf_industrytiles.cpp
Show inline comments
 
@@ -146,18 +146,6 @@ IndustryTileResolverObject::IndustryTile
 
	this->root_spritegroup = GetIndustryTileSpec(gfx)->grf_prop.spritegroup[0];
 
}
 

	
 
/**
 
 * Constructor of the scope resolver for the industry tile.
 
 * @param ro Surrounding resolver.
 
 * @param industry %Industry owning the tile.
 
 * @param tile %Tile of the industry.
 
 */
 
IndustryTileScopeResolver::IndustryTileScopeResolver(ResolverObject &ro, Industry *industry, TileIndex tile) : ScopeResolver(ro)
 
{
 
	this->industry = industry;
 
	this->tile = tile;
 
}
 

	
 
static void IndustryDrawTileLayout(const TileInfo *ti, const TileLayoutSpriteGroup *group, byte rnd_colour, byte stage, IndustryGfx gfx)
 
{
 
	const DrawTileSprites *dts = group->ProcessRegisters(&stage);
src/newgrf_industrytiles.h
Show inline comments
 
@@ -21,7 +21,16 @@ struct IndustryTileScopeResolver : publi
 
	Industry *industry; ///< Industry owning the tiles.
 
	TileIndex tile;     ///< %Tile being resolved.
 

	
 
	IndustryTileScopeResolver(ResolverObject &ro, Industry *industry, TileIndex tile);
 
	/**
 
	 * Constructor of the scope resolver for the industry tile.
 
	 * @param ro Surrounding resolver.
 
	 * @param industry %Industry owning the tile.
 
	 * @param tile %Tile of the industry.
 
	 */
 
	IndustryTileScopeResolver(ResolverObject &ro, Industry *industry, TileIndex tile)
 
		: ScopeResolver(ro), industry(industry), tile(tile)
 
	{
 
	}
 

	
 
	/* virtual */ uint32 GetRandomBits() const;
 
	/* virtual */ uint32 GetVariable(byte variable, uint32 parameter, bool *available) const;
src/newgrf_object.cpp
Show inline comments
 
@@ -128,21 +128,6 @@ bool NewGRFClass<Tspec, Tid, Tmax>::IsUI
 

	
 
INSTANTIATE_NEWGRF_CLASS_METHODS(ObjectClass, ObjectSpec, ObjectClassID, OBJECT_CLASS_MAX)
 

	
 
/**
 
 * Constructor of an object scope resolver.
 
 * @param ro Surrounding resolver.
 
 * @param obj Object being resolved.
 
 * @param tile %Tile of the object.
 
 * @param view View of the object.
 
 */
 
ObjectScopeResolver::ObjectScopeResolver(ResolverObject &ro, Object *obj, TileIndex tile, uint8 view)
 
		: ScopeResolver(ro)
 
{
 
	this->obj = obj;
 
	this->tile = tile;
 
	this->view = view;
 
}
 

	
 
/* virtual */ uint32 ObjectScopeResolver::GetRandomBits() const
 
{
 
	return IsValidTile(this->tile) && IsTileType(this->tile, MP_OBJECT) ? GetObjectRandomBits(this->tile) : 0;
src/newgrf_object.h
Show inline comments
 
@@ -104,7 +104,17 @@ struct ObjectScopeResolver : public Scop
 
	TileIndex tile;     ///< The tile related to the object.
 
	uint8 view;         ///< The view of the object.
 

	
 
	ObjectScopeResolver(ResolverObject &ro, Object *obj, TileIndex tile, uint8 view = 0);
 
	/**
 
	 * Constructor of an object scope resolver.
 
	 * @param ro Surrounding resolver.
 
	 * @param obj Object being resolved.
 
	 * @param tile %Tile of the object.
 
	 * @param view View of the object.
 
	 */
 
	ObjectScopeResolver(ResolverObject &ro, Object *obj, TileIndex tile, uint8 view = 0)
 
		: ScopeResolver(ro), obj(obj), tile(tile), view(view)
 
	{
 
	}
 

	
 
	/* virtual */ uint32 GetRandomBits() const;
 
	/* virtual */ uint32 GetVariable(byte variable, uint32 parameter, bool *available) const;
src/newgrf_railtype.cpp
Show inline comments
 
@@ -68,18 +68,6 @@
 
}
 

	
 
/**
 
 * Constructor of the railtype scope resolvers.
 
 * @param ro Surrounding resolver.
 
 * @param tile %Tile containing the track. For track on a bridge this is the southern bridgehead.
 
 * @param context Are we resolving sprites for the upper halftile, or on a bridge?
 
 */
 
RailTypeScopeResolver::RailTypeScopeResolver(ResolverObject &ro, TileIndex tile, TileContext context) : ScopeResolver(ro)
 
{
 
	this->tile = tile;
 
	this->context = context;
 
}
 

	
 
/**
 
 * Resolver object for rail types.
 
 * @param rti Railtype. NULL in NewGRF Inspect window.
 
 * @param tile %Tile containing the track. For track on a bridge this is the southern bridgehead.
src/newgrf_railtype.h
Show inline comments
 
@@ -21,7 +21,16 @@ struct RailTypeScopeResolver : public Sc
 
	TileIndex tile;      ///< Tracktile. For track on a bridge this is the southern bridgehead.
 
	TileContext context; ///< Are we resolving sprites for the upper halftile, or on a bridge?
 

	
 
	RailTypeScopeResolver(ResolverObject &ro, TileIndex tile, TileContext context);
 
	/**
 
	 * Constructor of the railtype scope resolvers.
 
	 * @param ro Surrounding resolver.
 
	 * @param tile %Tile containing the track. For track on a bridge this is the southern bridgehead.
 
	 * @param context Are we resolving sprites for the upper halftile, or on a bridge?
 
	 */
 
	RailTypeScopeResolver(ResolverObject &ro, TileIndex tile, TileContext context)
 
		: ScopeResolver(ro), tile(tile), context(context)
 
	{
 
	}
 

	
 
	/* virtual */ uint32 GetRandomBits() const;
 
	/* virtual */ uint32 GetVariable(byte variable, uint32 parameter, bool *available) const;
src/newgrf_spritegroup.cpp
Show inline comments
 
@@ -83,13 +83,6 @@ static inline uint32 GetVariable(const R
 
	}
 
}
 

	
 
ScopeResolver::ScopeResolver(ResolverObject &ro)
 
		: ro(ro)
 
{
 
}
 

	
 
ScopeResolver::~ScopeResolver() {}
 

	
 
/**
 
 * Get a few random bits. Default implementation has no random bits.
 
 * @return Random bits.
 
@@ -130,27 +123,6 @@ ScopeResolver::~ScopeResolver() {}
 
/* virtual */ void ScopeResolver::StorePSA(uint reg, int32 value) {}
 

	
 
/**
 
 * Resolver constructor.
 
 * @param grffile NewGRF file associated with the object (or \c NULL if none).
 
 * @param callback Callback code being resolved (default value is #CBID_NO_CALLBACK).
 
 * @param callback_param1 First parameter (var 10) of the callback (only used when \a callback is also set).
 
 * @param callback_param2 Second parameter (var 18) of the callback (only used when \a callback is also set).
 
 */
 
ResolverObject::ResolverObject(const GRFFile *grffile, CallbackID callback, uint32 callback_param1, uint32 callback_param2)
 
		: default_scope(*this)
 
{
 
	this->callback = callback;
 
	this->callback_param1 = callback_param1;
 
	this->callback_param2 = callback_param2;
 
	this->ResetState();
 

	
 
	this->grffile = grffile;
 
	this->root_spritegroup = NULL;
 
}
 

	
 
ResolverObject::~ResolverObject() {}
 

	
 
/**
 
 * Get the real sprites of the grf.
 
 * @param group Group to get.
 
 * @return The available sprite group.
src/newgrf_spritegroup.h
Show inline comments
 
@@ -288,8 +288,8 @@ struct IndustryProductionSpriteGroup : S
 
struct ScopeResolver {
 
	ResolverObject &ro; ///< Surrounding resolver object.
 

	
 
	ScopeResolver(ResolverObject &ro);
 
	virtual ~ScopeResolver();
 
	ScopeResolver(ResolverObject &ro) : ro(ro) {}
 
	virtual ~ScopeResolver() {}
 

	
 
	virtual uint32 GetRandomBits() const;
 
	virtual uint32 GetTriggers() const;
 
@@ -305,8 +305,20 @@ struct ScopeResolver {
 
 * to get the results of callbacks, rerandomisations or normal sprite lookups.
 
 */
 
struct ResolverObject {
 
	ResolverObject(const GRFFile *grffile, CallbackID callback = CBID_NO_CALLBACK, uint32 callback_param1 = 0, uint32 callback_param2 = 0);
 
	virtual ~ResolverObject();
 
	/**
 
	 * Resolver constructor.
 
	 * @param grffile NewGRF file associated with the object (or \c NULL if none).
 
	 * @param callback Callback code being resolved (default value is #CBID_NO_CALLBACK).
 
	 * @param callback_param1 First parameter (var 10) of the callback (only used when \a callback is also set).
 
	 * @param callback_param2 Second parameter (var 18) of the callback (only used when \a callback is also set).
 
	 */
 
	ResolverObject(const GRFFile *grffile, CallbackID callback = CBID_NO_CALLBACK, uint32 callback_param1 = 0, uint32 callback_param2 = 0)
 
		: default_scope(*this), callback(callback), callback_param1(callback_param1), callback_param2(callback_param2), grffile(grffile), root_spritegroup(NULL)
 
	{
 
		this->ResetState();
 
	}
 

	
 
	virtual ~ResolverObject() {}
 

	
 
	ScopeResolver default_scope; ///< Default implementation of the grf scope.
 

	
src/newgrf_station.cpp
Show inline comments
 
@@ -579,23 +579,6 @@ StationResolverObject::~StationResolverO
 
}
 

	
 
/**
 
 * Constructor for station scopes.
 
 * @param ro Surrounding resolver.
 
 * @param statspec Station (type) specification.
 
 * @param st Instance of the station.
 
 * @param tile %Tile of the station.
 
 */
 
StationScopeResolver::StationScopeResolver(ResolverObject &ro, const StationSpec *statspec, BaseStation *st, TileIndex tile)
 
	: ScopeResolver(ro)
 
{
 
	this->tile = tile;
 
	this->st = st;
 
	this->statspec = statspec;
 
	this->cargo_type = CT_INVALID;
 
	this->axis = INVALID_AXIS;
 
}
 

	
 
/**
 
 * Resolve sprites for drawing a station tile.
 
 * @param statspec Station spec
 
 * @param st Station (NULL in GUI)
src/newgrf_station.h
Show inline comments
 
@@ -30,7 +30,17 @@ struct StationScopeResolver : public Sco
 
	CargoID cargo_type;                 ///< Type of cargo of the station.
 
	Axis axis;                          ///< Station axis, used only for the slope check callback.
 

	
 
	StationScopeResolver(ResolverObject &ro, const StationSpec *statspec, BaseStation *st, TileIndex tile);
 
	/**
 
	 * Constructor for station scopes.
 
	 * @param ro Surrounding resolver.
 
	 * @param statspec Station (type) specification.
 
	 * @param st Instance of the station.
 
	 * @param tile %Tile of the station.
 
	 */
 
	StationScopeResolver(ResolverObject &ro, const StationSpec *statspec, BaseStation *st, TileIndex tile)
 
		: ScopeResolver(ro), tile(tile), st(st), statspec(statspec), cargo_type(CT_INVALID), axis(INVALID_AXIS)
 
	{
 
	}
 

	
 
	/* virtual */ uint32 GetRandomBits() const;
 
	/* virtual */ uint32 GetTriggers() const;
src/newgrf_town.cpp
Show inline comments
 
@@ -16,18 +16,6 @@
 

	
 
#include "safeguards.h"
 

	
 
/**
 
 * Resolver of a town scope.
 
 * @param ro Surrounding resolver.
 
 * @param t %Town of the scope.
 
 * @param readonly Scope may change persistent storage of the town.
 
 */
 
TownScopeResolver::TownScopeResolver(ResolverObject &ro, Town *t, bool readonly) : ScopeResolver(ro)
 
{
 
	this->t = t;
 
	this->readonly = readonly;
 
}
 

	
 
/* virtual */ uint32 TownScopeResolver::GetVariable(byte variable, uint32 parameter, bool *available) const
 
{
 
	switch (variable) {
src/newgrf_town.h
Show inline comments
 
@@ -25,7 +25,16 @@ struct TownScopeResolver : public ScopeR
 
	Town *t;       ///< %Town of the scope.
 
	bool readonly; ///< When set, persistent storage of the town is read-only,
 

	
 
	TownScopeResolver(ResolverObject &ro, Town *t, bool readonly);
 
	/**
 
	 * Resolver of a town scope.
 
	 * @param ro Surrounding resolver.
 
	 * @param t %Town of the scope.
 
	 * @param readonly Scope may change persistent storage of the town.
 
	 */
 
	TownScopeResolver(ResolverObject &ro, Town *t, bool readonly)
 
		: ScopeResolver(ro), t(t), readonly(readonly)
 
	{
 
	}
 

	
 
	virtual uint32 GetVariable(byte variable, uint32 parameter, bool *available) const;
 
	virtual void StorePSA(uint reg, int32 value);
0 comments (0 inline, 0 general)