summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2013-11-24 14:41:19 +0000
committerfrosch <frosch@openttd.org>2013-11-24 14:41:19 +0000
commitdb894b0b3fa13413cdb76989cfcd2bb789243b77 (patch)
treefd61e4df264893e0c41b0d989f3294c3b4909b63
parent45a5aba8d55c68f54885c1de27684e8544e111d9 (diff)
downloadopenttd-db894b0b3fa13413cdb76989cfcd2bb789243b77.tar.xz
(svn r26085) -Codechange: Pass ResolverObjects as reference instead of pointer since they are never NULL.
-rw-r--r--src/base_station_base.h2
-rw-r--r--src/newgrf_airport.cpp14
-rw-r--r--src/newgrf_airporttiles.cpp12
-rw-r--r--src/newgrf_airporttiles.h2
-rw-r--r--src/newgrf_canal.cpp10
-rw-r--r--src/newgrf_cargo.cpp4
-rw-r--r--src/newgrf_engine.cpp28
-rw-r--r--src/newgrf_engine.h2
-rw-r--r--src/newgrf_generic.cpp18
-rw-r--r--src/newgrf_house.cpp20
-rw-r--r--src/newgrf_house.h2
-rw-r--r--src/newgrf_industries.cpp22
-rw-r--r--src/newgrf_industries.h2
-rw-r--r--src/newgrf_industrytiles.cpp16
-rw-r--r--src/newgrf_industrytiles.h2
-rw-r--r--src/newgrf_object.cpp18
-rw-r--r--src/newgrf_object.h2
-rw-r--r--src/newgrf_railtype.cpp8
-rw-r--r--src/newgrf_railtype.h2
-rw-r--r--src/newgrf_spritegroup.cpp44
-rw-r--r--src/newgrf_spritegroup.h17
-rw-r--r--src/newgrf_station.cpp42
-rw-r--r--src/newgrf_station.h2
-rw-r--r--src/newgrf_town.cpp14
-rw-r--r--src/newgrf_town.h2
-rw-r--r--src/station_base.h2
-rw-r--r--src/waypoint_base.h2
27 files changed, 155 insertions, 156 deletions
diff --git a/src/base_station_base.h b/src/base_station_base.h
index 812692bb1..53e104a82 100644
--- a/src/base_station_base.h
+++ b/src/base_station_base.h
@@ -103,7 +103,7 @@ struct BaseStation : StationPool::PoolItem<&_station_pool> {
* @param available will return false if ever the variable asked for does not exist
* @return the value stored in the corresponding variable
*/
- virtual uint32 GetNewGRFVariable(const struct ResolverObject *object, byte variable, byte parameter, bool *available) const = 0;
+ virtual uint32 GetNewGRFVariable(const struct ResolverObject &object, byte variable, byte parameter, bool *available) const = 0;
/**
* Update the coordinated of the sign (as shown in the viewport).
diff --git a/src/newgrf_airport.cpp b/src/newgrf_airport.cpp
index 4b43af483..c03eb2465 100644
--- a/src/newgrf_airport.cpp
+++ b/src/newgrf_airport.cpp
@@ -24,7 +24,7 @@ struct AirportScopeResolver : public ScopeResolver {
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);
+ AirportScopeResolver(ResolverObject &ro, TileIndex tile, Station *st, byte airport_id, byte layout);
/* virtual */ uint32 GetRandomBits() const;
/* virtual */ uint32 GetVariable(byte variable, uint32 parameter, bool *available) const;
@@ -216,7 +216,7 @@ void AirportOverrideManager::SetEntitySpec(AirportSpec *as)
if (value == 0) return;
/* Create storage on first modification. */
- uint32 grfid = (this->ro->grffile != NULL) ? this->ro->grffile->grfid : 0;
+ uint32 grfid = (this->ro.grffile != NULL) ? this->ro.grffile->grfid : 0;
assert(PersistentStorage::CanAllocateItem());
this->st->airport.psa = new PersistentStorage(grfid);
}
@@ -235,7 +235,7 @@ void AirportOverrideManager::SetEntitySpec(AirportSpec *as)
*/
AirportResolverObject::AirportResolverObject(TileIndex tile, Station *st, byte airport_id, byte layout,
CallbackID callback, uint32 param1, uint32 param2)
- : ResolverObject(AirportSpec::Get(airport_id)->grf_prop.grffile, callback, param1, param2), airport_scope(this, tile, st, airport_id, layout)
+ : ResolverObject(AirportSpec::Get(airport_id)->grf_prop.grffile, callback, param1, param2), airport_scope(*this, tile, st, airport_id, layout)
{
}
@@ -247,7 +247,7 @@ AirportResolverObject::AirportResolverObject(TileIndex tile, Station *st, byte a
* @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)
+AirportScopeResolver::AirportScopeResolver(ResolverObject &ro, TileIndex tile, Station *st, byte airport_id, byte layout) : ScopeResolver(ro)
{
this->st = st;
this->airport_id = airport_id;
@@ -258,7 +258,7 @@ AirportScopeResolver::AirportScopeResolver(ResolverObject *ro, TileIndex tile, S
SpriteID GetCustomAirportSprite(const AirportSpec *as, byte layout)
{
AirportResolverObject object(INVALID_TILE, NULL, as->GetIndex(), layout);
- const SpriteGroup *group = SpriteGroup::Resolve(as->grf_prop.spritegroup[0], &object);
+ const SpriteGroup *group = SpriteGroup::Resolve(as->grf_prop.spritegroup[0], object);
if (group == NULL) return as->preview_sprite;
return group->GetResult();
@@ -267,7 +267,7 @@ SpriteID GetCustomAirportSprite(const AirportSpec *as, byte layout)
uint16 GetAirportCallback(CallbackID callback, uint32 param1, uint32 param2, Station *st, TileIndex tile)
{
AirportResolverObject object(tile, st, st->airport.type, st->airport.layout, callback, param1, param2);
- const SpriteGroup *group = SpriteGroup::Resolve(st->airport.GetSpec()->grf_prop.spritegroup[0], &object);
+ const SpriteGroup *group = SpriteGroup::Resolve(st->airport.GetSpec()->grf_prop.spritegroup[0], object);
if (group == NULL) return CALLBACK_FAILED;
return group->GetCallbackResult();
@@ -283,7 +283,7 @@ uint16 GetAirportCallback(CallbackID callback, uint32 param1, uint32 param2, Sta
StringID GetAirportTextCallback(const AirportSpec *as, byte layout, uint16 callback)
{
AirportResolverObject object(INVALID_TILE, NULL, as->GetIndex(), layout, (CallbackID)callback);
- const SpriteGroup *group = SpriteGroup::Resolve(as->grf_prop.spritegroup[0], &object);
+ const SpriteGroup *group = SpriteGroup::Resolve(as->grf_prop.spritegroup[0], object);
uint16 cb_res = (group != NULL) ? group->GetCallbackResult() : CALLBACK_FAILED;
if (cb_res == CALLBACK_FAILED || cb_res == 0x400) return STR_UNDEFINED;
if (cb_res > 0x400) {
diff --git a/src/newgrf_airporttiles.cpp b/src/newgrf_airporttiles.cpp
index 78773608f..cc9471c80 100644
--- a/src/newgrf_airporttiles.cpp
+++ b/src/newgrf_airporttiles.cpp
@@ -178,7 +178,7 @@ static uint32 GetAirportTileIDAtOffset(TileIndex tile, const Station *st, uint32
case 0x44: return GetAnimationFrame(this->tile);
/* Land info of nearby tiles */
- case 0x60: return GetNearbyAirportTileInformation(parameter, this->tile, this->st->index, this->ro->grffile->grf_version >= 8);
+ case 0x60: return GetNearbyAirportTileInformation(parameter, this->tile, this->st->index, this->ro.grffile->grf_version >= 8);
/* Animation stage of nearby tiles */
case 0x61: {
@@ -190,7 +190,7 @@ static uint32 GetAirportTileIDAtOffset(TileIndex tile, const Station *st, uint32
}
/* Get airport tile ID at offset */
- case 0x62: return GetAirportTileIDAtOffset(GetNearbyTile(parameter, this->tile), this->st, this->ro->grffile->grfid);
+ case 0x62: return GetAirportTileIDAtOffset(GetNearbyTile(parameter, this->tile), this->st, this->ro.grffile->grfid);
}
DEBUG(grf, 1, "Unhandled airport tile variable 0x%X", variable);
@@ -215,7 +215,7 @@ static uint32 GetAirportTileIDAtOffset(TileIndex tile, const Station *st, uint32
*/
AirportTileResolverObject::AirportTileResolverObject(const AirportTileSpec *ats, TileIndex tile, Station *st,
CallbackID callback, uint32 callback_param1, uint32 callback_param2)
- : ResolverObject(ats->grf_prop.grffile, callback, callback_param1, callback_param2), tiles_scope(this, ats, tile, st)
+ : ResolverObject(ats->grf_prop.grffile, callback, callback_param1, callback_param2), tiles_scope(*this, ats, tile, st)
{
}
@@ -225,7 +225,7 @@ AirportTileResolverObject::AirportTileResolverObject(const AirportTileSpec *ats,
* @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)
+AirportTileScopeResolver::AirportTileScopeResolver(ResolverObject &ro, const AirportTileSpec *ats, TileIndex tile, Station *st) : ScopeResolver(ro)
{
assert(st != NULL);
@@ -237,7 +237,7 @@ AirportTileScopeResolver::AirportTileScopeResolver(ResolverObject *ro, const Air
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);
- const SpriteGroup *group = SpriteGroup::Resolve(ats->grf_prop.spritegroup[0], &object);
+ const SpriteGroup *group = SpriteGroup::Resolve(ats->grf_prop.spritegroup[0], object);
if (group == NULL) return CALLBACK_FAILED;
return group->GetCallbackResult();
@@ -275,7 +275,7 @@ bool DrawNewAirportTile(TileInfo *ti, Station *st, StationGfx gfx, const Airport
}
AirportTileResolverObject object(airts, ti->tile, st);
- const SpriteGroup *group = SpriteGroup::Resolve(airts->grf_prop.spritegroup[0], &object);
+ const SpriteGroup *group = SpriteGroup::Resolve(airts->grf_prop.spritegroup[0], object);
if (group == NULL || group->type != SGT_TILELAYOUT) {
return false;
}
diff --git a/src/newgrf_airporttiles.h b/src/newgrf_airporttiles.h
index 6c68682d4..4d25aa924 100644
--- a/src/newgrf_airporttiles.h
+++ b/src/newgrf_airporttiles.h
@@ -24,7 +24,7 @@ struct AirportTileScopeResolver : public ScopeResolver {
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);
+ AirportTileScopeResolver(ResolverObject &ro, const AirportTileSpec *ats, TileIndex tile, Station *st);
/* virtual */ uint32 GetRandomBits() const;
/* virtual */ uint32 GetVariable(byte variable, uint32 parameter, bool *available) const;
diff --git a/src/newgrf_canal.cpp b/src/newgrf_canal.cpp
index ef678a0cc..7310186c0 100644
--- a/src/newgrf_canal.cpp
+++ b/src/newgrf_canal.cpp
@@ -23,7 +23,7 @@ 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);
/* virtual */ uint32 GetRandomBits() const;
/* virtual */ uint32 GetVariable(byte variable, uint32 parameter, bool *available) const;
@@ -108,7 +108,7 @@ struct CanalResolverObject : public ResolverObject {
return group->loaded[0];
}
-CanalScopeResolver::CanalScopeResolver(ResolverObject *ro, TileIndex tile) : ScopeResolver(ro)
+CanalScopeResolver::CanalScopeResolver(ResolverObject &ro, TileIndex tile) : ScopeResolver(ro)
{
this->tile = tile;
}
@@ -123,7 +123,7 @@ CanalScopeResolver::CanalScopeResolver(ResolverObject *ro, TileIndex tile) : Sco
*/
CanalResolverObject::CanalResolverObject(const GRFFile *grffile, TileIndex tile,
CallbackID callback, uint32 callback_param1, uint32 callback_param2)
- : ResolverObject(grffile, callback, callback_param1, callback_param2), canal_scope(this, tile)
+ : ResolverObject(grffile, callback, callback_param1, callback_param2), canal_scope(*this, tile)
{
}
@@ -136,7 +136,7 @@ CanalResolverObject::CanalResolverObject(const GRFFile *grffile, TileIndex tile,
SpriteID GetCanalSprite(CanalFeature feature, TileIndex tile)
{
CanalResolverObject object(_water_feature[feature].grffile, tile);
- const SpriteGroup *group = SpriteGroup::Resolve(_water_feature[feature].group, &object);
+ const SpriteGroup *group = SpriteGroup::Resolve(_water_feature[feature].group, object);
if (group == NULL) return 0;
return group->GetResult();
@@ -154,7 +154,7 @@ SpriteID GetCanalSprite(CanalFeature feature, TileIndex tile)
static uint16 GetCanalCallback(CallbackID callback, uint32 param1, uint32 param2, CanalFeature feature, TileIndex tile)
{
CanalResolverObject object(_water_feature[feature].grffile, tile, callback, param1, param2);
- const SpriteGroup *group = SpriteGroup::Resolve(_water_feature[feature].group, &object);
+ const SpriteGroup *group = SpriteGroup::Resolve(_water_feature[feature].group, object);
if (group == NULL) return CALLBACK_FAILED;
return group->GetCallbackResult();
diff --git a/src/newgrf_cargo.cpp b/src/newgrf_cargo.cpp
index d6227b801..4186b53f6 100644
--- a/src/newgrf_cargo.cpp
+++ b/src/newgrf_cargo.cpp
@@ -50,7 +50,7 @@ CargoResolverObject::CargoResolverObject(const CargoSpec *cs, CallbackID callbac
SpriteID GetCustomCargoSprite(const CargoSpec *cs)
{
CargoResolverObject object(cs);
- const SpriteGroup *group = SpriteGroup::Resolve(cs->group, &object);
+ const SpriteGroup *group = SpriteGroup::Resolve(cs->group, object);
if (group == NULL) return 0;
return group->GetResult();
@@ -60,7 +60,7 @@ SpriteID GetCustomCargoSprite(const CargoSpec *cs)
uint16 GetCargoCallback(CallbackID callback, uint32 param1, uint32 param2, const CargoSpec *cs)
{
CargoResolverObject object(cs, callback, param1, param2);
- const SpriteGroup *group = SpriteGroup::Resolve(cs->group, &object);
+ const SpriteGroup *group = SpriteGroup::Resolve(cs->group, object);
if (group == NULL) return CALLBACK_FAILED;
return group->GetCallbackResult();
diff --git a/src/newgrf_engine.cpp b/src/newgrf_engine.cpp
index c48aaad9b..3119524b5 100644
--- a/src/newgrf_engine.cpp
+++ b/src/newgrf_engine.cpp
@@ -360,7 +360,7 @@ static byte MapAircraftMovementAction(const Aircraft *v)
/* This function must only be called when processing triggers -- any
* other time is an error. */
- assert(this->ro->trigger != 0);
+ assert(this->ro.trigger != 0);
if (v != NULL) v->waiting_triggers = triggers;
}
@@ -546,7 +546,7 @@ static uint32 VehicleGetVariable(Vehicle *v, const VehicleScopeResolver *object,
/* Unlike everywhere else the cargo translation table is only used since grf version 8, not 7.
* Note: The grffile == NULL case only happens if this function is called for default vehicles.
* And this is only done by CheckCaches(). */
- const GRFFile *grffile = object->ro->grffile;
+ const GRFFile *grffile = object->ro.grffile;
uint8 common_bitnum = (common_cargo_type == CT_INVALID) ? 0xFF :
(grffile == NULL || grffile->grf_version < 8) ? CargoSpec::Get(common_cargo_type)->bitnum : grffile->cargo_map[common_cargo_type];
@@ -617,7 +617,7 @@ static uint32 VehicleGetVariable(Vehicle *v, const VehicleScopeResolver *object,
case 0x4A: {
if (v->type != VEH_TRAIN) return 0;
RailType rt = GetTileRailType(v->tile);
- return (HasPowerOnRail(Train::From(v)->railtype, rt) ? 0x100 : 0) | GetReverseRailTypeTranslation(rt, object->ro->grffile);
+ return (HasPowerOnRail(Train::From(v)->railtype, rt) ? 0x100 : 0) | GetReverseRailTypeTranslation(rt, object->ro.grffile);
}
case 0x4B: // Long date of last service
@@ -643,8 +643,8 @@ static uint32 VehicleGetVariable(Vehicle *v, const VehicleScopeResolver *object,
if (!v->IsGroundVehicle() || parameter == 0x61) return 0;
/* Only allow callbacks that don't change properties to avoid circular dependencies. */
- if (object->ro->callback == CBID_NO_CALLBACK || object->ro->callback == CBID_RANDOM_TRIGGER || object->ro->callback == CBID_TRAIN_ALLOW_WAGON_ATTACH ||
- object->ro->callback == CBID_VEHICLE_START_STOP_CHECK || object->ro->callback == CBID_VEHICLE_32DAY_CALLBACK || object->ro->callback == CBID_VEHICLE_COLOUR_MAPPING) {
+ if (object->ro.callback == CBID_NO_CALLBACK || object->ro.callback == CBID_RANDOM_TRIGGER || object->ro.callback == CBID_TRAIN_ALLOW_WAGON_ATTACH ||
+ object->ro.callback == CBID_VEHICLE_START_STOP_CHECK || object->ro.callback == CBID_VEHICLE_32DAY_CALLBACK || object->ro.callback == CBID_VEHICLE_COLOUR_MAPPING) {
Vehicle *u = v->Move((int32)GetRegister(0x10F));
if (u == NULL) return 0;
@@ -935,7 +935,7 @@ static uint32 VehicleGetVariable(Vehicle *v, const VehicleScopeResolver *object,
* @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)
+VehicleScopeResolver::VehicleScopeResolver(ResolverObject &ro, EngineID engine_type, const Vehicle *v, bool info_view)
: ScopeResolver(ro)
{
this->v = v;
@@ -966,9 +966,9 @@ static const GRFFile *GetEngineGrfFile(EngineID engine_type)
VehicleResolverObject::VehicleResolverObject(EngineID engine_type, const Vehicle *v, bool info_view,
CallbackID callback, uint32 callback_param1, uint32 callback_param2)
: ResolverObject(GetEngineGrfFile(engine_type), callback, callback_param1, callback_param2),
- self_scope(this, engine_type, v, info_view),
- parent_scope(this, engine_type, ((v != NULL) ? v->First() : v), info_view),
- relative_scope(this, engine_type, v, info_view),
+ self_scope(*this, engine_type, v, info_view),
+ parent_scope(*this, engine_type, ((v != NULL) ? v->First() : v), info_view),
+ relative_scope(*this, engine_type, v, info_view),
cached_relative_count(0)
{
}
@@ -1019,7 +1019,7 @@ static const SpriteGroup *GetVehicleSpriteGroup(EngineID engine, const Vehicle *
SpriteID GetCustomEngineSprite(EngineID engine, const Vehicle *v, Direction direction, EngineImageType image_type)
{
VehicleResolverObject object(engine, v, false, CBID_NO_CALLBACK, image_type);
- const SpriteGroup *group = SpriteGroup::Resolve(GetVehicleSpriteGroup(engine, v), &object);
+ const SpriteGroup *group = SpriteGroup::Resolve(GetVehicleSpriteGroup(engine, v), object);
if (group == NULL || group->GetNumResults() == 0) return 0;
return group->GetResult() + (direction % group->GetNumResults());
@@ -1036,7 +1036,7 @@ SpriteID GetRotorOverrideSprite(EngineID engine, const Aircraft *v, bool info_vi
VehicleResolverObject object(engine, v, info_view, CBID_NO_CALLBACK, image_type);
const SpriteGroup *group = GetWagonOverrideSpriteSet(engine, CT_DEFAULT, engine);
- group = SpriteGroup::Resolve(group, &object);
+ group = SpriteGroup::Resolve(group, object);
if (group == NULL || group->GetNumResults() == 0) return 0;
@@ -1069,7 +1069,7 @@ bool UsesWagonOverride(const Vehicle *v)
uint16 GetVehicleCallback(CallbackID callback, uint32 param1, uint32 param2, EngineID engine, const Vehicle *v)
{
VehicleResolverObject object(engine, v, false, callback, param1, param2);
- const SpriteGroup *group = SpriteGroup::Resolve(GetVehicleSpriteGroup(engine, v, false), &object);
+ const SpriteGroup *group = SpriteGroup::Resolve(GetVehicleSpriteGroup(engine, v, false), object);
if (group == NULL) return CALLBACK_FAILED;
return group->GetCallbackResult();
@@ -1090,7 +1090,7 @@ uint16 GetVehicleCallbackParent(CallbackID callback, uint32 param1, uint32 param
VehicleResolverObject object(engine, v, false, callback, param1, param2);
object.parent_scope.SetVehicle(parent);
- const SpriteGroup *group = SpriteGroup::Resolve(GetVehicleSpriteGroup(engine, v, false), &object);
+ const SpriteGroup *group = SpriteGroup::Resolve(GetVehicleSpriteGroup(engine, v, false), object);
if (group == NULL) return CALLBACK_FAILED;
return group->GetCallbackResult();
@@ -1121,7 +1121,7 @@ static void DoTriggerVehicle(Vehicle *v, VehicleTrigger trigger, byte base_rando
VehicleResolverObject object(v->engine_type, v, false, CBID_RANDOM_TRIGGER);
object.trigger = trigger;
- const SpriteGroup *group = SpriteGroup::Resolve(GetVehicleSpriteGroup(v->engine_type, v), &object);
+ const SpriteGroup *group = SpriteGroup::Resolve(GetVehicleSpriteGroup(v->engine_type, v), object);
if (group == NULL) return;
byte new_random_bits = Random();
diff --git a/src/newgrf_engine.h b/src/newgrf_engine.h
index 7eb65f134..5e1661cca 100644
--- a/src/newgrf_engine.h
+++ b/src/newgrf_engine.h
@@ -26,7 +26,7 @@ struct VehicleScopeResolver : public ScopeResolver {
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);
+ VehicleScopeResolver(ResolverObject &ro, EngineID engine_type, const Vehicle *v, bool info_view);
void SetVehicle(const Vehicle *v) { this->v = v; }
diff --git a/src/newgrf_generic.cpp b/src/newgrf_generic.cpp
index 75e25c3d4..f1305636d 100644
--- a/src/newgrf_generic.cpp
+++ b/src/newgrf_generic.cpp
@@ -29,7 +29,7 @@ struct GenericScopeResolver : public ScopeResolver {
uint8 count;
uint8 station_size;
- GenericScopeResolver(ResolverObject *ro, bool ai_callback);
+ GenericScopeResolver(ResolverObject &ro, bool ai_callback);
/* virtual */ uint32 GetVariable(byte variable, uint32 parameter, bool *available) const;
@@ -104,7 +104,7 @@ void AddGenericCallback(uint8 feature, const GRFFile *file, const SpriteGroup *g
{
if (this->ai_callback) {
switch (variable) {
- case 0x40: return this->ro->grffile->cargo_map[this->cargo_type];
+ case 0x40: return this->ro.grffile->cargo_map[this->cargo_type];
case 0x80: return this->cargo_type;
case 0x81: return CargoSpec::Get(this->cargo_type)->bitnum;
@@ -139,7 +139,7 @@ void AddGenericCallback(uint8 feature, const GRFFile *file, const SpriteGroup *g
* @param ai_callback Callback comes from the AI.
* @param callback Callback ID.
*/
-GenericResolverObject::GenericResolverObject(bool ai_callback, CallbackID callback) : ResolverObject(NULL, callback), generic_scope(this, ai_callback)
+GenericResolverObject::GenericResolverObject(bool ai_callback, CallbackID callback) : ResolverObject(NULL, callback), generic_scope(*this, ai_callback)
{
}
@@ -148,7 +148,7 @@ GenericResolverObject::GenericResolverObject(bool ai_callback, CallbackID callba
* @param ro Surrounding resolver.
* @param ai_callback Callback comes from the AI.
*/
-GenericScopeResolver::GenericScopeResolver(ResolverObject *ro, bool ai_callback) : ScopeResolver(ro)
+GenericScopeResolver::GenericScopeResolver(ResolverObject &ro, bool ai_callback) : ScopeResolver(ro)
{
this->cargo_type = 0;
this->default_selection = 0;
@@ -173,16 +173,16 @@ GenericScopeResolver::GenericScopeResolver(ResolverObject *ro, bool ai_callback)
* May be NULL if not required.
* @return callback value if successful or CALLBACK_FAILED
*/
-static uint16 GetGenericCallbackResult(uint8 feature, ResolverObject *object, uint32 param1_grfv7, uint32 param1_grfv8, const GRFFile **file)
+static uint16 GetGenericCallbackResult(uint8 feature, ResolverObject &object, uint32 param1_grfv7, uint32 param1_grfv8, const GRFFile **file)
{
assert(feature < lengthof(_gcl));
/* Test each feature callback sprite group. */
for (GenericCallbackList::const_iterator it = _gcl[feature].begin(); it != _gcl[feature].end(); ++it) {
const SpriteGroup *group = it->group;
- object->grffile = it->file;
+ object.grffile = it->file;
/* Set callback param based on GRF version. */
- object->callback_param1 = it->file->grf_version >= 8 ? param1_grfv8 : param1_grfv7;
+ object.callback_param1 = it->file->grf_version >= 8 ? param1_grfv8 : param1_grfv7;
group = SpriteGroup::Resolve(group, object);
if (group == NULL || group->GetCallbackResult() == CALLBACK_FAILED) continue;
@@ -238,7 +238,7 @@ uint16 GetAiPurchaseCallbackResult(uint8 feature, CargoID cargo_type, uint8 defa
object.generic_scope.count = count;
object.generic_scope.station_size = station_size;
- uint16 callback = GetGenericCallbackResult(feature, &object, 0, 0, file);
+ uint16 callback = GetGenericCallbackResult(feature, object, 0, 0, file);
if (callback != CALLBACK_FAILED) callback = GB(callback, 0, 8);
return callback;
}
@@ -264,7 +264,7 @@ void AmbientSoundEffectCallback(TileIndex tile)
/* Run callback. */
const GRFFile *grf_file;
- uint16 callback = GetGenericCallbackResult(GSF_SOUNDFX, &object, param1_v7, param1_v8, &grf_file);
+ uint16 callback = GetGenericCallbackResult(GSF_SOUNDFX, object, param1_v7, param1_v8, &grf_file);
if (callback != CALLBACK_FAILED) PlayTileSound(grf_file, callback, tile);
}
diff --git a/src/newgrf_house.cpp b/src/newgrf_house.cpp
index 9a7ff4444..a31ac4bc4 100644
--- a/src/newgrf_house.cpp
+++ b/src/newgrf_house.cpp
@@ -39,7 +39,7 @@ HouseOverrideManager _house_mngr(NEW_HOUSE_OFFSET, NUM_HOUSES, INVALID_HOUSE_ID)
* @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,
+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)
{
@@ -78,8 +78,8 @@ HouseResolverObject::HouseResolverObject(HouseID house_id, TileIndex tile, Town
CallbackID callback, uint32 param1, uint32 param2,
bool not_yet_constructed, uint8 initial_random_bits, uint32 watched_cargo_triggers)
: ResolverObject(GetHouseSpecGrf(house_id), callback, param1, param2),
- house_scope(this, house_id, tile, town, not_yet_constructed, initial_random_bits, watched_cargo_triggers),
- town_scope(this, town, not_yet_constructed) // Don't access StorePSA if house is not yet constructed.
+ house_scope(*this, house_id, tile, town, not_yet_constructed, initial_random_bits, watched_cargo_triggers),
+ town_scope(*this, town, not_yet_constructed) // Don't access StorePSA if house is not yet constructed.
{
}
@@ -352,7 +352,7 @@ static uint32 GetDistanceFromNearbyHouse(uint8 parameter, TileIndex tile, HouseI
}
/* Land info for nearby tiles. */
- case 0x62: return GetNearbyTileInformation(parameter, this->tile, this->ro->grffile->grf_version >= 8);
+ case 0x62: return GetNearbyTileInformation(parameter, this->tile, this->ro.grffile->grf_version >= 8);
/* Current animation frame of nearby house tiles */
case 0x63: {
@@ -362,7 +362,7 @@ static uint32 GetDistanceFromNearbyHouse(uint8 parameter, TileIndex tile, HouseI
/* Cargo acceptance history of nearby stations */
case 0x64: {
- CargoID cid = GetCargoTranslation(parameter, this->ro->grffile);
+ CargoID cid = GetCargoTranslation(parameter, this->ro.grffile);
if (cid == CT_INVALID) return 0;
/* Extract tile offset. */
@@ -400,7 +400,7 @@ static uint32 GetDistanceFromNearbyHouse(uint8 parameter, TileIndex tile, HouseI
/* Information about the grf local classid if the house has a class */
uint houseclass = 0;
if (hs->class_id != HOUSE_NO_CLASS) {
- houseclass = (hs->grf_prop.grffile == this->ro->grffile ? 1 : 2) << 8;
+ houseclass = (hs->grf_prop.grffile == this->ro.grffile ? 1 : 2) << 8;
houseclass |= _class_mapping[hs->class_id].class_id;
}
/* old house type or grf-local houseid */
@@ -408,7 +408,7 @@ static uint32 GetDistanceFromNearbyHouse(uint8 parameter, TileIndex tile, HouseI
if (this->house_id < NEW_HOUSE_OFFSET) {
local_houseid = this->house_id;
} else {
- local_houseid = (hs->grf_prop.grffile == this->ro->grffile ? 1 : 2) << 8;
+ local_houseid = (hs->grf_prop.grffile == this->ro.grffile ? 1 : 2) << 8;
local_houseid |= hs->grf_prop.local_id;
}
return houseclass << 16 | local_houseid;
@@ -440,7 +440,7 @@ uint16 GetHouseCallback(CallbackID callback, uint32 param1, uint32 param2, House
HouseResolverObject object(house_id, tile, town, callback, param1, param2,
not_yet_constructed, initial_random_bits, watched_cargo_triggers);
- const SpriteGroup *group = SpriteGroup::Resolve(HouseSpec::Get(house_id)->grf_prop.spritegroup[0], &object);
+ const SpriteGroup *group = SpriteGroup::Resolve(HouseSpec::Get(house_id)->grf_prop.spritegroup[0], object);
if (group == NULL) return CALLBACK_FAILED;
return group->GetCallbackResult();
@@ -490,7 +490,7 @@ void DrawNewHouseTile(TileInfo *ti, HouseID house_id)
HouseResolverObject object(house_id, ti->tile, Town::GetByTile(ti->tile));
- const SpriteGroup *group = SpriteGroup::Resolve(hs->grf_prop.spritegroup[0], &object);
+ const SpriteGroup *group = SpriteGroup::Resolve(hs->grf_prop.spritegroup[0], object);
if (group != NULL && group->type == SGT_TILELAYOUT) {
/* Limit the building stage to the number of stages supplied. */
const TileLayoutSpriteGroup *tlgroup = (const TileLayoutSpriteGroup *)group;
@@ -615,7 +615,7 @@ static void DoTriggerHouse(TileIndex tile, HouseTrigger trigger, byte base_rando
HouseResolverObject object(hid, tile, Town::GetByTile(tile), CBID_RANDOM_TRIGGER);
object.trigger = trigger;
- const SpriteGroup *group = SpriteGroup::Resolve(hs->grf_prop.spritegroup[0], &object);
+ const SpriteGroup *group = SpriteGroup::Resolve(hs->grf_prop.spritegroup[0], object);
if (group == NULL) return;
byte new_random_bits = Random();
diff --git a/src/newgrf_house.h b/src/newgrf_house.h
index d6d4beb5d..37c167947 100644
--- a/src/newgrf_house.h
+++ b/src/newgrf_house.h
@@ -27,7 +27,7 @@ struct HouseScopeResolver : public ScopeResolver {
uint16 initial_random_bits; ///< Random bits during construction checks.
uint32 watched_cargo_triggers; ///< Cargo types that triggered the watched cargo callback.
- HouseScopeResolver(ResolverObject *ro, HouseID house_id, TileIndex tile, Town *town,
+ HouseScopeResolver(ResolverObject &ro, HouseID house_id, TileIndex tile, Town *town,
bool not_yet_constructed, uint8 initial_random_bits, uint32 watched_cargo_triggers);
/* virtual */ uint32 GetRandomBits() const;
diff --git a/src/newgrf_industries.cpp b/src/newgrf_industries.cpp
index e0953434e..c9ae6168b 100644
--- a/src/newgrf_industries.cpp
+++ b/src/newgrf_industries.cpp
@@ -159,7 +159,7 @@ static uint32 GetCountAndDistanceOfClosestInstance(byte param_setID, byte layout
/* virtual */ uint32 IndustriesScopeResolver::GetVariable(byte variable, uint32 parameter, bool *available) const
{
- if (this->ro->callback == CBID_INDUSTRY_LOCATION) {
+ if (this->ro.callback == CBID_INDUSTRY_LOCATION) {
/* Variables available during construction check. */
switch (variable) {
@@ -185,7 +185,7 @@ static uint32 GetCountAndDistanceOfClosestInstance(byte param_setID, byte layout
case 0x89: return min(DistanceManhattan(this->industry->town->xy, this->tile), 255);
/* Lowest height of the tile */
- case 0x8A: return Clamp(GetTileZ(this->tile) * (this->ro->grffile->grf_version >= 8 ? 1 : TILE_HEIGHT), 0, 0xFF);
+ case 0x8A: return Clamp(GetTileZ(this->tile) * (this->ro.grffile->grf_version >= 8 ? 1 : TILE_HEIGHT), 0, 0xFF);
/* Distance to the nearest water/land tile */
case 0x8B: return GetClosestWaterDistance(this->tile, (GetIndustrySpec(this->industry->type)->behaviour & INDUSTRYBEH_BUILT_ONWATER) == 0);
@@ -201,7 +201,7 @@ static uint32 GetCountAndDistanceOfClosestInstance(byte param_setID, byte layout
const IndustrySpec *indspec = GetIndustrySpec(this->type);
if (this->industry == NULL) {
- DEBUG(grf, 1, "Unhandled variable 0x%X (no available industry) in callback 0x%x", variable, this->ro->callback);
+ DEBUG(grf, 1, "Unhandled variable 0x%X (no available industry) in callback 0x%x", variable, this->ro.callback);
*available = false;
return UINT_MAX;
@@ -251,7 +251,7 @@ static uint32 GetCountAndDistanceOfClosestInstance(byte param_setID, byte layout
case 0x46: return this->industry->construction_date; // Date when built - long format - (in days)
/* Get industry ID at offset param */
- case 0x60: return GetIndustryIDAtOffset(GetNearbyTile(parameter, this->industry->location.tile, false), this->industry, this->ro->grffile->grfid);
+ case 0x60: return GetIndustryIDAtOffset(GetNearbyTile(parameter, this->industry->location.tile, false), this->industry, this->ro.grffile->grfid);
/* Get random tile bits at offset param */
case 0x61: {
@@ -263,7 +263,7 @@ static uint32 GetCountAndDistanceOfClosestInstance(byte param_setID, byte layout
/* Land info of nearby tiles */
case 0x62:
if (this->tile == INVALID_TILE) break;
- return GetNearbyIndustryTileInformation(parameter, this->tile, INVALID_INDUSTRY, false, this->ro->grffile->grf_version >= 8);
+ return GetNearbyIndustryTileInformation(parameter, this->tile, INVALID_INDUSTRY, false, this->ro.grffile->grf_version >= 8);
/* Animation stage of nearby tiles */
case 0x63: {
@@ -429,7 +429,7 @@ static const GRFFile *GetGrffile(IndustryType type)
IndustriesResolverObject::IndustriesResolverObject(TileIndex tile, Industry *indus, IndustryType type, uint32 random_bits,
CallbackID callback, uint32 callback_param1, uint32 callback_param2)
: ResolverObject(GetGrffile(type), callback, callback_param1, callback_param2),
- industries_scope(this, tile, indus, type, random_bits),
+ industries_scope(*this, tile, indus, type, random_bits),
town_scope(NULL)
{
}
@@ -455,7 +455,7 @@ TownScopeResolver *IndustriesResolverObject::GetTown()
t = ClosestTownFromTile(this->industries_scope.tile, UINT_MAX);
}
if (t == NULL) return NULL;
- this->town_scope = new TownScopeResolver(this, t, readonly);
+ this->town_scope = new TownScopeResolver(*this, t, readonly);
}
return this->town_scope;
}
@@ -468,7 +468,7 @@ TownScopeResolver *IndustriesResolverObject::GetTown()
* @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)
+IndustriesScopeResolver::IndustriesScopeResolver(ResolverObject &ro, TileIndex tile, Industry *industry, IndustryType type, uint32 random_bits)
: ScopeResolver(ro)
{
this->tile = tile;
@@ -490,7 +490,7 @@ IndustriesScopeResolver::IndustriesScopeResolver(ResolverObject *ro, TileIndex t
uint16 GetIndustryCallback(CallbackID callback, uint32 param1, uint32 param2, Industry *industry, IndustryType type, TileIndex tile)
{
IndustriesResolverObject object(tile, industry, type, 0, callback, param1, param2);
- const SpriteGroup *group = SpriteGroup::Resolve(GetIndustrySpec(type)->grf_prop.spritegroup[0], &object);
+ const SpriteGroup *group = SpriteGroup::Resolve(GetIndustrySpec(type)->grf_prop.spritegroup[0], object);
if (group == NULL) return CALLBACK_FAILED;
return group->GetCallbackResult();
@@ -523,7 +523,7 @@ CommandCost CheckIfCallBackAllowsCreation(TileIndex tile, IndustryType type, uin
ind.psa = NULL;
IndustriesResolverObject object(tile, &ind, type, seed, CBID_INDUSTRY_LOCATION, 0, creation_type);
- const SpriteGroup *group = SpriteGroup::Resolve(GetIndustrySpec(type)->grf_prop.spritegroup[0], &object);
+ const SpriteGroup *group = SpriteGroup::Resolve(GetIndustrySpec(type)->grf_prop.spritegroup[0], object);
/* Unlike the "normal" cases, not having a valid result means we allow
* the building of the industry, as that's how it's done in TTDP. */
@@ -596,7 +596,7 @@ void IndustryProductionCallback(Industry *ind, int reason)
}
SB(object.callback_param2, 8, 16, loop);
- const SpriteGroup *tgroup = SpriteGroup::Resolve(spec->grf_prop.spritegroup[0], &object);
+ const SpriteGroup *tgroup = SpriteGroup::Resolve(spec->grf_prop.spritegroup[0], object);
if (tgroup == NULL || tgroup->type != SGT_INDUSTRY_PRODUCTION) break;
const IndustryProductionSpriteGroup *group = (const IndustryProductionSpriteGroup *)tgroup;
diff --git a/src/newgrf_industries.h b/src/newgrf_industries.h
index 5c95fcdcb..57e44e8c0 100644
--- a/src/newgrf_industries.h
+++ b/src/newgrf_industries.h
@@ -21,7 +21,7 @@ struct IndustriesScopeResolver : public ScopeResolver {
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);
+ IndustriesScopeResolver(ResolverObject &ro, TileIndex tile, Industry *industry, IndustryType type, uint32 random_bits = 0);
/* virtual */ uint32 GetRandomBits() const;
/* virtual */ uint32 GetVariable(byte variable, uint32 parameter, bool *available) const;
diff --git a/src/newgrf_industrytiles.cpp b/src/newgrf_industrytiles.cpp
index 65e3c530d..965c55d49 100644
--- a/src/newgrf_industrytiles.cpp
+++ b/src/newgrf_industrytiles.cpp
@@ -78,7 +78,7 @@ uint32 GetRelativePosition(TileIndex tile, TileIndex ind_tile)
/* Land info of nearby tiles */
case 0x60: return GetNearbyIndustryTileInformation(parameter, this->tile,
- this->industry == NULL ? (IndustryID)INVALID_INDUSTRY : this->industry->index, true, this->ro->grffile->grf_version >= 8);
+ this->industry == NULL ? (IndustryID)INVALID_INDUSTRY : this->industry->index, true, this->ro.grffile->grf_version >= 8);
/* Animation stage of nearby tiles */
case 0x61: {
@@ -90,7 +90,7 @@ uint32 GetRelativePosition(TileIndex tile, TileIndex ind_tile)
}
/* Get industry tile ID at offset */
- case 0x62: return GetIndustryIDAtOffset(GetNearbyTile(parameter, this->tile), this->industry, this->ro->grffile->grfid);
+ case 0x62: return GetIndustryIDAtOffset(GetNearbyTile(parameter, this->tile), this->industry, this->ro.grffile->grfid);
}
DEBUG(grf, 1, "Unhandled industry tile variable 0x%X", variable);
@@ -144,8 +144,8 @@ static const GRFFile *GetIndTileGrffile(IndustryGfx gfx)
IndustryTileResolverObject::IndustryTileResolverObject(IndustryGfx gfx, TileIndex tile, Industry *indus,
CallbackID callback, uint32 callback_param1, uint32 callback_param2)
: ResolverObject(GetIndTileGrffile(gfx), callback, callback_param1, callback_param2),
- indtile_scope(this, indus, tile),
- ind_scope(this, tile, indus, indus->type)
+ indtile_scope(*this, indus, tile),
+ ind_scope(*this, tile, indus, indus->type)
{
}
@@ -155,7 +155,7 @@ IndustryTileResolverObject::IndustryTileResolverObject(IndustryGfx gfx, TileInde
* @param industry %Industry owning the tile.
* @param tile %Tile of the industry.
*/
-IndustryTileScopeResolver::IndustryTileScopeResolver(ResolverObject *ro, Industry *industry, TileIndex tile) : ScopeResolver(ro)
+IndustryTileScopeResolver::IndustryTileScopeResolver(ResolverObject &ro, Industry *industry, TileIndex tile) : ScopeResolver(ro)
{
this->industry = industry;
this->tile = tile;
@@ -190,7 +190,7 @@ uint16 GetIndustryTileCallback(CallbackID callback, uint32 param1, uint32 param2
assert(industry->index == INVALID_INDUSTRY || IsTileType(tile, MP_INDUSTRY));
IndustryTileResolverObject object(gfx_id, tile, industry, callback, param1, param2);
- const SpriteGroup *group = SpriteGroup::Resolve(GetIndustryTileSpec(gfx_id)->grf_prop.spritegroup[0], &object);
+ const SpriteGroup *group = SpriteGroup::Resolve(GetIndustryTileSpec(gfx_id)->grf_prop.spritegroup[0], object);
if (group == NULL || group->type != SGT_CALLBACK) return CALLBACK_FAILED;
return group->GetCallbackResult();
@@ -211,7 +211,7 @@ bool DrawNewIndustryTile(TileInfo *ti, Industry *i, IndustryGfx gfx, const Indus
IndustryTileResolverObject object(gfx, ti->tile, i);
- const SpriteGroup *group = SpriteGroup::Resolve(inds->grf_prop.spritegroup[0], &object);
+ const SpriteGroup *group = SpriteGroup::Resolve(inds->grf_prop.spritegroup[0], object);
if (group == NULL || group->type != SGT_TILELAYOUT) return false;
/* Limit the building stage to the number of stages supplied. */
@@ -328,7 +328,7 @@ static void DoTriggerIndustryTile(TileIndex tile, IndustryTileTrigger trigger, I
IndustryTileResolverObject object(gfx, tile, ind, CBID_RANDOM_TRIGGER);
object.trigger = trigger;
- const SpriteGroup *group = SpriteGroup::Resolve(itspec->grf_prop.spritegroup[0], &object);
+ const SpriteGroup *group = SpriteGroup::Resolve(itspec->grf_prop.spritegroup[0], object);
if (group == NULL) return;
byte new_random_bits = Random();
diff --git a/src/newgrf_industrytiles.h b/src/newgrf_industrytiles.h
index f5b88db83..394f75e1c 100644
--- a/src/newgrf_industrytiles.h
+++ b/src/newgrf_industrytiles.h
@@ -21,7 +21,7 @@ struct IndustryTileScopeResolver : public ScopeResolver {
Industry *industry; ///< Industry owning the tiles.
TileIndex tile; ///< %Tile being resolved.
- IndustryTileScopeResolver(ResolverObject *ro, Industry *industry, TileIndex tile);
+ IndustryTileScopeResolver(ResolverObject &ro, Industry *industry, TileIndex tile);
/* virtual */ uint32 GetRandomBits() const;
/* virtual */ uint32 GetVariable(byte variable, uint32 parameter, bool *available) const;
diff --git a/src/newgrf_object.cpp b/src/newgrf_object.cpp
index 57468d7c7..da12a51ee 100644
--- a/src/newgrf_object.cpp
+++ b/src/newgrf_object.cpp
@@ -133,7 +133,7 @@ INSTANTIATE_NEWGRF_CLASS_METHODS(ObjectClass, ObjectSpec, ObjectClassID, OBJECT_
* @param tile %Tile of the object.
* @param view View of the object.
*/
-ObjectScopeResolver::ObjectScopeResolver(ResolverObject *ro, Object *obj, TileIndex tile, uint8 view)
+ObjectScopeResolver::ObjectScopeResolver(ResolverObject &ro, Object *obj, TileIndex tile, uint8 view)
: ScopeResolver(ro)
{
this->obj = obj;
@@ -326,7 +326,7 @@ static uint32 GetCountAndDistanceOfClosestInstance(byte local_id, uint32 grfid,
case 0x48: return this->obj->view;
/* Get object ID at offset param */
- case 0x60: return GetObjectIDAtOffset(GetNearbyTile(parameter, this->tile), this->ro->grffile->grfid);
+ case 0x60: return GetObjectIDAtOffset(GetNearbyTile(parameter, this->tile), this->ro.grffile->grfid);
/* Get random tile bits at offset param */
case 0x61: {
@@ -335,7 +335,7 @@ static uint32 GetCountAndDistanceOfClosestInstance(byte local_id, uint32 grfid,
}
/* Land info of nearby tiles */
- case 0x62: return GetNearbyObjectTileInformation(parameter, this->tile, this->obj == NULL ? INVALID_OBJECT : this->obj->index, this->ro->grffile->grf_version >= 8);
+ case 0x62: return GetNearbyObjectTileInformation(parameter, this->tile, this->obj == NULL ? INVALID_OBJECT : this->obj->index, this->ro.grffile->grf_version >= 8);
/* Animation counter of nearby tile */
case 0x63: {
@@ -344,7 +344,7 @@ static uint32 GetCountAndDistanceOfClosestInstance(byte local_id, uint32 grfid,
}
/* Count of object, distance of closest instance */
- case 0x64: return GetCountAndDistanceOfClosestInstance(parameter, this->ro->grffile->grfid, this->tile, this->obj);
+ case 0x64: return GetCountAndDistanceOfClosestInstance(parameter, this->ro.grffile->grfid, this->tile, this->obj);
}
unhandled:
@@ -383,7 +383,7 @@ static const SpriteGroup *GetObjectSpriteGroup(const ObjectSpec *spec, const Obj
*/
ObjectResolverObject::ObjectResolverObject(const ObjectSpec *spec, Object *obj, TileIndex tile, uint8 view,
CallbackID callback, uint32 param1, uint32 param2)
- : ResolverObject(spec->grf_prop.grffile, callback, param1, param2), object_scope(this, obj, tile, view)
+ : ResolverObject(spec->grf_prop.grffile, callback, param1, param2), object_scope(*this, obj, tile, view)
{
this->town_scope = NULL;
}
@@ -408,7 +408,7 @@ TownScopeResolver *ObjectResolverObject::GetTown()
t = ClosestTownFromTile(this->object_scope.tile, UINT_MAX);
}
if (t == NULL) return NULL;
- this->town_scope = new TownScopeResolver(this, t, this->object_scope.obj == NULL);
+ this->town_scope = new TownScopeResolver(*this, t, this->object_scope.obj == NULL);
}
return this->town_scope;
}
@@ -427,7 +427,7 @@ TownScopeResolver *ObjectResolverObject::GetTown()
uint16 GetObjectCallback(CallbackID callback, uint32 param1, uint32 param2, const ObjectSpec *spec, Object *o, TileIndex tile, uint8 view)
{
ObjectResolverObject object(spec, o, tile, view, callback, param1, param2);
- const SpriteGroup *group = SpriteGroup::Resolve(GetObjectSpriteGroup(spec, o), &object);
+ const SpriteGroup *group = SpriteGroup::Resolve(GetObjectSpriteGroup(spec, o), object);
if (group == NULL) return CALLBACK_FAILED;
return group->GetCallbackResult();
@@ -470,7 +470,7 @@ void DrawNewObjectTile(TileInfo *ti, const ObjectSpec *spec)
Object *o = Object::GetByTile(ti->tile);
ObjectResolverObject object(spec, o, ti->tile);
- const SpriteGroup *group = SpriteGroup::Resolve(GetObjectSpriteGroup(spec, o), &object);
+ const SpriteGroup *group = SpriteGroup::Resolve(GetObjectSpriteGroup(spec, o), object);
if (group == NULL || group->type != SGT_TILELAYOUT) return;
DrawTileLayout(ti, (const TileLayoutSpriteGroup *)group, spec);
@@ -486,7 +486,7 @@ void DrawNewObjectTile(TileInfo *ti, const ObjectSpec *spec)
void DrawNewObjectTileInGUI(int x, int y, const ObjectSpec *spec, uint8 view)
{
ObjectResolverObject object(spec, NULL, INVALID_TILE, view);
- const SpriteGroup *group = SpriteGroup::Resolve(GetObjectSpriteGroup(spec, NULL), &object);
+ const SpriteGroup *group = SpriteGroup::Resolve(GetObjectSpriteGroup(spec, NULL), object);
if (group == NULL || group->type != SGT_TILELAYOUT) return;
const DrawTileSprites *dts = ((const TileLayoutSpriteGroup *)group)->ProcessRegisters(NULL);
diff --git a/src/newgrf_object.h b/src/newgrf_object.h
index 55b34e466..4a3b770d2 100644
--- a/src/newgrf_object.h
+++ b/src/newgrf_object.h
@@ -104,7 +104,7 @@ struct ObjectScopeResolver : public ScopeResolver {
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);
+ ObjectScopeResolver(ResolverObject &ro, Object *obj, TileIndex tile, uint8 view = 0);
/* virtual */ uint32 GetRandomBits() const;
/* virtual */ uint32 GetVariable(byte variable, uint32 parameter, bool *available) const;
diff --git a/src/newgrf_railtype.cpp b/src/newgrf_railtype.cpp
index 36ac7260a..de735193f 100644
--- a/src/newgrf_railtype.cpp
+++ b/src/newgrf_railtype.cpp
@@ -71,7 +71,7 @@
* @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)
+RailTypeScopeResolver::RailTypeScopeResolver(ResolverObject &ro, TileIndex tile, TileContext context) : ScopeResolver(ro)
{
this->tile = tile;
this->context = context;
@@ -86,7 +86,7 @@ RailTypeScopeResolver::RailTypeScopeResolver(ResolverObject *ro, TileIndex tile,
* @param param2 Extra parameter (second parameter of the callback, except railtypes do not have callbacks).
*/
RailTypeResolverObject::RailTypeResolverObject(TileIndex tile, TileContext context, const GRFFile *grffile, uint32 param1, uint32 param2)
- : ResolverObject(grffile, CBID_NO_CALLBACK, param1, param2), railtype_scope(this, tile, context)
+ : ResolverObject(grffile, CBID_NO_CALLBACK, param1, param2), railtype_scope(*this, tile, context)
{
}
@@ -105,7 +105,7 @@ SpriteID GetCustomRailSprite(const RailtypeInfo *rti, TileIndex tile, RailTypeSp
if (rti->group[rtsg] == NULL) return 0;
RailTypeResolverObject object(tile, context, rti->grffile[rtsg]);
- const SpriteGroup *group = SpriteGroup::Resolve(rti->group[rtsg], &object);
+ const SpriteGroup *group = SpriteGroup::Resolve(rti->group[rtsg], object);
if (group == NULL || group->GetNumResults() == 0) return 0;
return group->GetResult();
@@ -129,7 +129,7 @@ SpriteID GetCustomSignalSprite(const RailtypeInfo *rti, TileIndex tile, SignalTy
uint32 param2 = (type << 16) | (var << 8) | state;
RailTypeResolverObject object(tile, TCX_NORMAL, rti->grffile[RTSG_SIGNALS], param1, param2);
- const SpriteGroup *group = SpriteGroup::Resolve(rti->group[RTSG_SIGNALS], &object);
+ const SpriteGroup *group = SpriteGroup::Resolve(rti->group[RTSG_SIGNALS], object);
if (group == NULL || group->GetNumResults() == 0) return 0;
return group->GetResult();
diff --git a/src/newgrf_railtype.h b/src/newgrf_railtype.h
index c1977eaf8..8c5bce843 100644
--- a/src/newgrf_railtype.h
+++ b/src/newgrf_railtype.h
@@ -21,7 +21,7 @@ struct RailTypeScopeResolver : public ScopeResolver {
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);
+ RailTypeScopeResolver(ResolverObject &ro, TileIndex tile, TileContext context);
/* virtual */ uint32 GetRandomBits() const;
/* virtual */ uint32 GetVariable(byte variable, uint32 parameter, bool *available) const;
diff --git a/src/newgrf_spritegroup.cpp b/src/newgrf_spritegroup.cpp
index 7e60e82b1..2c3d19ff1 100644
--- a/src/newgrf_spritegroup.cpp
+++ b/src/newgrf_spritegroup.cpp
@@ -37,35 +37,35 @@ RandomizedSpriteGroup::~RandomizedSpriteGroup()
TemporaryStorageArray<int32, 0x110> _temp_store;
-static inline uint32 GetVariable(const ResolverObject *object, ScopeResolver *scope, byte variable, uint32 parameter, bool *available)
+static inline uint32 GetVariable(const ResolverObject &object, ScopeResolver *scope, byte variable, uint32 parameter, bool *available)
{
/* First handle variables common with Action7/9/D */
uint32 value;
- if (GetGlobalVariable(variable, &value, object->grffile)) return value;
+ if (GetGlobalVariable(variable, &value, object.grffile)) return value;
/* Non-common variable */
switch (variable) {
- case 0x0C: return object->callback;
- case 0x10: return object->callback_param1;
- case 0x18: return object->callback_param2;
- case 0x1C: return object->last_value;
+ case 0x0C: return object.callback;
+ case 0x10: return object.callback_param1;
+ case 0x18: return object.callback_param2;
+ case 0x1C: return object.last_value;
case 0x5F: return (scope->GetRandomBits() << 8) | scope->GetTriggers();
case 0x7D: return _temp_store.GetValue(parameter);
case 0x7F:
- if (object == NULL || object->grffile == NULL) return 0;
- return object->grffile->GetParam(parameter);
+ if (object.grffile == NULL) return 0;
+ return object.grffile->GetParam(parameter);
/* Not a common variable, so evaluate the feature specific variables */
default: return scope->GetVariable(variable, parameter, available);
}
}
-ScopeResolver::ScopeResolver(ResolverObject *ro)
+ScopeResolver::ScopeResolver(ResolverObject &ro)
+ : ro(ro)
{
- this->ro = ro;
}
ScopeResolver::~ScopeResolver() {}
@@ -123,7 +123,7 @@ ScopeResolver::~ScopeResolver() {}
* @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)
+ : default_scope(*this)
{
this->callback = callback;
this->callback_param1 = callback_param1;
@@ -216,13 +216,13 @@ static U EvalAdjustT(const DeterministicSpriteGroupAdjust *adjust, ScopeResolver
}
-const SpriteGroup *DeterministicSpriteGroup::Resolve(ResolverObject *object) const
+const SpriteGroup *DeterministicSpriteGroup::Resolve(ResolverObject &object) const
{
uint32 last_value = 0;
uint32 value = 0;
uint i;
- ScopeResolver *scope = object->GetScope(this->var_scope);
+ ScopeResolver *scope = object.GetScope(this->var_scope);
for (i = 0; i < this->num_adjusts; i++) {
DeterministicSpriteGroupAdjust *adjust = &this->adjusts[i];
@@ -259,7 +259,7 @@ const SpriteGroup *DeterministicSpriteGroup::Resolve(ResolverObject *object) con
last_value = value;
}
- object->last_value = last_value;
+ object.last_value = last_value;
if (this->num_ranges == 0) {
/* nvar == 0 is a special case -- we turn our value into a callback result */
@@ -279,21 +279,21 @@ const SpriteGroup *DeterministicSpriteGroup::Resolve(ResolverObject *object) con
}
-const SpriteGroup *RandomizedSpriteGroup::Resolve(ResolverObject *object) const
+const SpriteGroup *RandomizedSpriteGroup::Resolve(ResolverObject &object) const
{
- ScopeResolver *scope = object->GetScope(this->var_scope, this->count);
- if (object->trigger != 0) {
+ ScopeResolver *scope = object.GetScope(this->var_scope, this->count);
+ if (object.trigger != 0) {
/* Handle triggers */
/* Magic code that may or may not do the right things... */
byte waiting_triggers = scope->GetTriggers();
- byte match = this->triggers & (waiting_triggers | object->trigger);
+ byte match = this->triggers & (waiting_triggers | object.trigger);
bool res = (this->cmp_mode == RSG_CMP_ANY) ? (match != 0) : (match == this->triggers);
if (res) {
waiting_triggers &= ~match;
- object->reseed[this->var_scope] |= (this->num_groups - 1) << this->lowest_randbit;
+ object.reseed[this->var_scope] |= (this->num_groups - 1) << this->lowest_randbit;
} else {
- waiting_triggers |= object->trigger;
+ waiting_triggers |= object.trigger;
}
scope->SetTriggers(waiting_triggers);
@@ -306,9 +306,9 @@ const SpriteGroup *RandomizedSpriteGroup::Resolve(ResolverObject *object) const
}
-const SpriteGroup *RealSpriteGroup::Resolve(ResolverObject *object) const
+const SpriteGroup *RealSpriteGroup::Resolve(ResolverObject &object) const
{
- return object->ResolveReal(this);
+ return object.ResolveReal(this);
}
/**
diff --git a/src/newgrf_spritegroup.h b/src/newgrf_spritegroup.h
index dc05fe4f1..da26c1a0e 100644
--- a/src/newgrf_spritegroup.h
+++ b/src/newgrf_spritegroup.h
@@ -57,6 +57,7 @@ enum SpriteGroupType {
struct SpriteGroup;
typedef uint32 SpriteGroupID;
+struct ResolverObject;
/* SPRITE_WIDTH is 24. ECS has roughly 30 sprite groups per real sprite.
* Adding an 'extra' margin would be assuming 64 sprite groups per real
@@ -69,7 +70,7 @@ struct SpriteGroup : SpriteGroupPool::PoolItem<&_spritegroup_pool> {
protected:
SpriteGroup(SpriteGroupType type) : type(type) {}
/** Base sprite group resolver */
- virtual const SpriteGroup *Resolve(struct ResolverObject *object) const { return this; };
+ virtual const SpriteGroup *Resolve(ResolverObject &object) const { return this; };
public:
virtual ~SpriteGroup() {}
@@ -89,7 +90,7 @@ public:
* @param object information needed to resolve the group
* @return the resolved group
*/
- static const SpriteGroup *Resolve(const SpriteGroup *group, ResolverObject *object)
+ static const SpriteGroup *Resolve(const SpriteGroup *group, ResolverObject &object)
{
return group == NULL ? NULL : group->Resolve(object);
}
@@ -115,7 +116,7 @@ struct RealSpriteGroup : SpriteGroup {
const SpriteGroup **loading; ///< List of loading groups (can be SpriteIDs or Callback results)
protected:
- const SpriteGroup *Resolve(ResolverObject *object) const;
+ const SpriteGroup *Resolve(ResolverObject &object) const;
};
/* Shared by deterministic and random groups. */
@@ -204,7 +205,7 @@ struct DeterministicSpriteGroup : SpriteGroup {
const SpriteGroup *default_group;
protected:
- const SpriteGroup *Resolve(ResolverObject *object) const;
+ const SpriteGroup *Resolve(ResolverObject &object) const;
};
enum RandomizedSpriteGroupCompareMode {
@@ -228,7 +229,7 @@ struct RandomizedSpriteGroup : SpriteGroup {
const SpriteGroup **groups; ///< Take the group with appropriate index:
protected:
- const SpriteGroup *Resolve(ResolverObject *object) const;
+ const SpriteGroup *Resolve(ResolverObject &object) const;
};
@@ -301,8 +302,6 @@ struct IndustryProductionSpriteGroup : SpriteGroup {
uint8 again;
};
-struct ResolverObject;
-
/**
* Interface to query and set values specific to a single #VarSpriteGroupScope (action 2 scope).
*
@@ -310,9 +309,9 @@ struct ResolverObject;
* to different game entities from a #SpriteGroup-chain (action 1-2-3 chain).
*/
struct ScopeResolver {
- ResolverObject *ro; ///< Surrounding resolver object.
+ ResolverObject &ro; ///< Surrounding resolver object.
- ScopeResolver(ResolverObject *ro);
+ ScopeResolver(ResolverObject &ro);
virtual ~ScopeResolver();
virtual uint32 GetRandomBits() const;
diff --git a/src/newgrf_station.cpp b/src/newgrf_station.cpp
index a993acdfe..4bfb125d6 100644
--- a/src/newgrf_station.cpp
+++ b/src/newgrf_station.cpp
@@ -270,7 +270,7 @@ TownScopeResolver *StationResolverObject::GetTown()
t = ClosestTownFromTile(this->station_scope.tile, UINT_MAX);
}
if (t == NULL) return NULL;
- this->town_scope = new TownScopeResolver(this, t, this->station_scope.st == NULL);
+ this->town_scope = new TownScopeResolver(*this, t, this->station_scope.st == NULL);
}
return this->town_scope;
}
@@ -296,7 +296,7 @@ TownScopeResolver *StationResolverObject::GetTown()
Slope tileh = GetTileSlope(tile);
bool swap = (this->axis == AXIS_Y && HasBit(tileh, CORNER_W) != HasBit(tileh, CORNER_E));
- return GetNearbyTileInformation(tile, this->ro->grffile->grf_version >= 8) ^ (swap ? SLOPE_EW : 0);
+ return GetNearbyTileInformation(tile, this->ro.grffile->grf_version >= 8) ^ (swap ? SLOPE_EW : 0);
}
break;
@@ -355,7 +355,7 @@ TownScopeResolver *StationResolverObject::GetTown()
Slope tileh = GetTileSlope(tile);
bool swap = (axis == AXIS_Y && HasBit(tileh, CORNER_W) != HasBit(tileh, CORNER_E));
- return GetNearbyTileInformation(tile, this->ro->grffile->grf_version >= 8) ^ (swap ? SLOPE_EW : 0);
+ return GetNearbyTileInformation(tile, this->ro.grffile->grf_version >= 8) ^ (swap ? SLOPE_EW : 0);
}
case 0x68: { // Station info of nearby tiles
@@ -386,7 +386,7 @@ TownScopeResolver *StationResolverObject::GetTown()
return this->st->GetNewGRFVariable(this->ro, variable, parameter, available);
}
-uint32 Station::GetNewGRFVariable(const ResolverObject *object, byte variable, byte parameter, bool *available) const
+uint32 Station::GetNewGRFVariable(const ResolverObject &object, byte variable, byte parameter, bool *available) const
{
switch (variable) {
case 0x48: { // Accepted cargo types
@@ -409,7 +409,7 @@ uint32 Station::GetNewGRFVariable(const ResolverObject *object, byte variable, b
/* Handle cargo variables with parameter, 0x60 to 0x65 and 0x69 */
if ((variable >= 0x60 && variable <= 0x65) || variable == 0x69) {
- CargoID c = GetCargoTranslation(parameter, object->grffile);
+ CargoID c = GetCargoTranslation(parameter, object.grffile);
if (c == CT_INVALID) {
switch (variable) {
@@ -457,7 +457,7 @@ uint32 Station::GetNewGRFVariable(const ResolverObject *object, byte variable, b
return UINT_MAX;
}
-uint32 Waypoint::GetNewGRFVariable(const ResolverObject *object, byte variable, byte parameter, bool *available) const
+uint32 Waypoint::GetNewGRFVariable(const ResolverObject &object, byte variable, byte parameter, bool *available) const
{
switch (variable) {
case 0x48: return 0; // Accepted cargo types
@@ -546,7 +546,7 @@ uint32 Waypoint::GetNewGRFVariable(const ResolverObject *object, byte variable,
StationResolverObject::StationResolverObject(const StationSpec *statspec, BaseStation *st, TileIndex tile,
CallbackID callback, uint32 callback_param1, uint32 callback_param2)
: ResolverObject((statspec != NULL ? statspec->grf_prop.grffile : NULL), callback, callback_param1, callback_param2),
- station_scope(this, statspec, st, tile), town_scope(NULL)
+ station_scope(*this, statspec, st, tile), town_scope(NULL)
{
/* Invalidate all cached vars */
_svc.valid = 0;
@@ -564,7 +564,7 @@ StationResolverObject::~StationResolverObject()
* @param st Instance of the station.
* @param tile %Tile of the station.
*/
-StationScopeResolver::StationScopeResolver(ResolverObject *ro, const StationSpec *statspec, BaseStation *st, TileIndex tile)
+StationScopeResolver::StationScopeResolver(ResolverObject &ro, const StationSpec *statspec, BaseStation *st, TileIndex tile)
: ScopeResolver(ro)
{
this->tile = tile;
@@ -574,19 +574,19 @@ StationScopeResolver::StationScopeResolver(ResolverObject *ro, const StationSpec
this->axis = INVALID_AXIS;
}
-static const SpriteGroup *ResolveStation(StationResolverObject *object)
+static const SpriteGroup *ResolveStation(StationResolverObject &object)
{
CargoID ctype = CT_DEFAULT_NA;
- if (object->station_scope.st == NULL) {
+ if (object.station_scope.st == NULL) {
/* No station, so we are in a purchase list */
ctype = CT_PURCHASE;
- } else if (Station::IsExpected(object->station_scope.st)) {
- const Station *st = Station::From(object->station_scope.st);
+ } else if (Station::IsExpected(object.station_scope.st)) {
+ const Station *st = Station::From(object.station_scope.st);
/* Pick the first cargo that we have waiting */
const CargoSpec *cs;
FOR_ALL_CARGOSPECS(cs) {
- if (object->station_scope.statspec->grf_prop.spritegroup[cs->Index()] != NULL &&
+ if (object.station_scope.statspec->grf_prop.spritegroup[cs->Index()] != NULL &&
st->goods[cs->Index()].cargo.TotalCount() > 0) {
ctype = cs->Index();
break;
@@ -594,15 +594,15 @@ static const SpriteGroup *ResolveStation(StationResolverObject *object)
}
}
- const SpriteGroup *group = object->station_scope.statspec->grf_prop.spritegroup[ctype];
+ const SpriteGroup *group = object.station_scope.statspec->grf_prop.spritegroup[ctype];
if (group == NULL) {
ctype = CT_DEFAULT;
- group = object->station_scope.statspec->grf_prop.spritegroup[ctype];
+ group = object.station_scope.statspec->grf_prop.spritegroup[ctype];
if (group == NULL) return NULL;
}
/* Remember the cargo type we've picked */
- object->station_scope.cargo_type = ctype;
+ object.station_scope.cargo_type = ctype;
return SpriteGroup::Resolve(group, object);
}
@@ -618,7 +618,7 @@ static const SpriteGroup *ResolveStation(StationResolverObject *object)
SpriteID GetCustomStationRelocation(const StationSpec *statspec, BaseStation *st, TileIndex tile, uint32 var10)
{
StationResolverObject object(statspec, st, tile, CBID_NO_CALLBACK, var10);
- const SpriteGroup *group = ResolveStation(&object);
+ const SpriteGroup *group = ResolveStation(object);
if (group == NULL || group->type != SGT_RESULT) return 0;
return group->GetResult() - 0x42D;
}
@@ -638,7 +638,7 @@ SpriteID GetCustomStationFoundationRelocation(const StationSpec *statspec, BaseS
StationResolverObject object(statspec, st, tile, CBID_NO_CALLBACK, 2, layout | (edge_info << 16));
ClearRegister(0x100);
- const SpriteGroup *group = ResolveStation(&object);
+ const SpriteGroup *group = ResolveStation(object);
if (group == NULL || group->type != SGT_RESULT) return 0;
return group->GetResult() + GetRegister(0x100);
}
@@ -647,7 +647,7 @@ SpriteID GetCustomStationFoundationRelocation(const StationSpec *statspec, BaseS
uint16 GetStationCallback(CallbackID callback, uint32 param1, uint32 param2, const StationSpec *statspec, BaseStation *st, TileIndex tile)
{
StationResolverObject object(statspec, st, tile, callback, param1, param2);
- const SpriteGroup *group = ResolveStation(&object);
+ const SpriteGroup *group = ResolveStation(object);
if (group == NULL) return CALLBACK_FAILED;
return group->GetCallbackResult();
}
@@ -672,7 +672,7 @@ CommandCost PerformStationTileSlopeCheck(TileIndex north_tile, TileIndex cur_til
(numtracks << 24) | (plat_len << 16) | (axis == AXIS_Y ? TileX(diff) << 8 | TileY(diff) : TileY(diff) << 8 | TileX(diff)));
object.station_scope.axis = axis;
- const SpriteGroup *group = ResolveStation(&object);
+ const SpriteGroup *group = ResolveStation(object);
uint16 cb_res = group != NULL ? group->GetCallbackResult() : CALLBACK_FAILED;
/* Failed callback means success. */
@@ -1023,7 +1023,7 @@ void TriggerStationRandomisation(Station *st, TileIndex tile, StationRandomTrigg
StationResolverObject object(ss, st, tile, CBID_RANDOM_TRIGGER, 0);
object.trigger = trigger_bit;
- const SpriteGroup *group = ResolveStation(&object);
+ const SpriteGroup *group = ResolveStation(object);
if (group == NULL) continue;
uint32 reseed = object.GetReseedSum();
diff --git a/src/newgrf_station.h b/src/newgrf_station.h
index 62bb940a4..ffb827cb3 100644
--- a/src/newgrf_station.h
+++ b/src/newgrf_station.h
@@ -30,7 +30,7 @@ struct StationScopeResolver : public ScopeResolver {
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);
+ StationScopeResolver(ResolverObject &ro, const StationSpec *statspec, BaseStation *st, TileIndex tile);
/* virtual */ uint32 GetRandomBits() const;
/* virtual */ uint32 GetTriggers() const;
diff --git a/src/newgrf_town.cpp b/src/newgrf_town.cpp
index 95cab9643..b6693d9ae 100644
--- a/src/newgrf_town.cpp
+++ b/src/newgrf_town.cpp
@@ -20,7 +20,7 @@
* @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)
+TownScopeResolver::TownScopeResolver(ResolverObject &ro, Town *t, bool readonly) : ScopeResolver(ro)
{
this->t = t;
this->readonly = readonly;
@@ -43,8 +43,8 @@ TownScopeResolver::TownScopeResolver(ResolverObject *ro, Town *t, bool readonly)
/* Check the persistent storage for the GrfID stored in register 100h. */
uint32 grfid = GetRegister(0x100);
if (grfid == 0xFFFFFFFF) {
- if (this->ro->grffile == NULL) return 0;
- grfid = this->ro->grffile->grfid;
+ if (this->ro.grffile == NULL) return 0;
+ grfid = this->ro.grffile->grfid;
}
std::list<PersistentStorage *>::iterator iter;
@@ -135,14 +135,14 @@ TownScopeResolver::TownScopeResolver(ResolverObject *ro, Town *t, bool readonly)
assert(this->t != NULL);
/* We can't store anything if the caller has no #GRFFile. */
- if (this->ro->grffile == NULL) return;
+ if (this->ro.grffile == NULL) return;
/* Check the persistent storage for the GrfID stored in register 100h. */
uint32 grfid = GetRegister(0x100);
/* A NewGRF can only write in the persistent storage associated to its own GRFID. */
- if (grfid == 0xFFFFFFFF) grfid = this->ro->grffile->grfid;
- if (grfid != this->ro->grffile->grfid) return;
+ if (grfid == 0xFFFFFFFF) grfid = this->ro.grffile->grfid;
+ if (grfid != this->ro.grffile->grfid) return;
/* Check if the storage exists. */
std::list<PersistentStorage *>::iterator iter;
@@ -167,7 +167,7 @@ TownScopeResolver::TownScopeResolver(ResolverObject *ro, Town *t, bool readonly)
* @param readonly Scope may change persistent storage of the town.
*/
TownResolverObject::TownResolverObject(const struct GRFFile *grffile, Town *t, bool readonly)
- : ResolverObject(grffile), town_scope(this, t, readonly)
+ : ResolverObject(grffile), town_scope(*this, t, readonly)
{
}
diff --git a/src/newgrf_town.h b/src/newgrf_town.h
index 3f6094cdb..145571e8a 100644
--- a/src/newgrf_town.h
+++ b/src/newgrf_town.h
@@ -25,7 +25,7 @@ struct TownScopeResolver : public ScopeResolver {
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);
+ TownScopeResolver(ResolverObject &ro, Town *t, bool readonly);
virtual uint32 GetVariable(byte variable, uint32 parameter, bool *available) const;
virtual void StorePSA(uint reg, int32 value);
diff --git a/src/station_base.h b/src/station_base.h
index 63a2ca5e5..c0bb96cd9 100644
--- a/src/station_base.h
+++ b/src/station_base.h
@@ -492,7 +492,7 @@ public:
return IsAirportTile(tile) && GetStationIndex(tile) == this->index;
}
- /* virtual */ uint32 GetNewGRFVariable(const ResolverObject *object, byte variable, byte parameter, bool *available) const;
+ /* virtual */ uint32 GetNewGRFVariable(const ResolverObject &object, byte variable, byte parameter, bool *available) const;
/* virtual */ void GetTileArea(TileArea *ta, StationType type) const;
};
diff --git a/src/waypoint_base.h b/src/waypoint_base.h
index c97c6089c..8d544a3b9 100644
--- a/src/waypoint_base.h
+++ b/src/waypoint_base.h
@@ -32,7 +32,7 @@ struct Waypoint FINAL : SpecializedStation<Waypoint, true> {
return IsRailWaypointTile(tile) && GetStationIndex(tile) == this->index;
}
- /* virtual */ uint32 GetNewGRFVariable(const struct ResolverObject *object, byte variable, byte parameter, bool *available) const;
+ /* virtual */ uint32 GetNewGRFVariable(const struct ResolverObject &object, byte variable, byte parameter, bool *available) const;
/* virtual */ void GetTileArea(TileArea *ta, StationType type) const;