summaryrefslogtreecommitdiff
path: root/src/newgrf_industries.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_industries.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_industries.cpp')
-rw-r--r--src/newgrf_industries.cpp22
1 files changed, 11 insertions, 11 deletions
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;