summaryrefslogtreecommitdiff
path: root/src/newgrf_station.cpp
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 /src/newgrf_station.cpp
parent45a5aba8d55c68f54885c1de27684e8544e111d9 (diff)
downloadopenttd-db894b0b3fa13413cdb76989cfcd2bb789243b77.tar.xz
(svn r26085) -Codechange: Pass ResolverObjects as reference instead of pointer since they are never NULL.
Diffstat (limited to 'src/newgrf_station.cpp')
-rw-r--r--src/newgrf_station.cpp42
1 files changed, 21 insertions, 21 deletions
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();