summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2012-11-11 12:57:27 +0000
committerfrosch <frosch@openttd.org>2012-11-11 12:57:27 +0000
commitb65ece1ea930a42763916d4dbfbaf1c190f3d2a9 (patch)
tree5353265e0667ff57bbd5f63a1dd7025f6947cde9 /src
parent55cff8407ffd6ee63765b5c31863843e2c9fc4e9 (diff)
downloadopenttd-b65ece1ea930a42763916d4dbfbaf1c190f3d2a9.tar.xz
(svn r24695) -Fix/Cleanup: Remove remaining (incorrect) usages of ResolverObject::scope and count.
Diffstat (limited to 'src')
-rw-r--r--src/newgrf_engine.cpp2
-rw-r--r--src/newgrf_spritegroup.cpp23
-rw-r--r--src/newgrf_spritegroup.h3
-rw-r--r--src/table/newgrf_debug_data.h18
4 files changed, 19 insertions, 27 deletions
diff --git a/src/newgrf_engine.cpp b/src/newgrf_engine.cpp
index 05300c22b..c9d489e94 100644
--- a/src/newgrf_engine.cpp
+++ b/src/newgrf_engine.cpp
@@ -1301,7 +1301,7 @@ void FillNewGRFVehicleCache(const Vehicle *v)
/* Only resolve when the cache isn't valid. */
if (HasBit(v->grf_cache.cache_valid, cache_entries[i][1])) continue;
bool stub;
- ro.GetScope(ro.scope)->GetVariable(cache_entries[i][0], 0, &stub);
+ ro.GetScope(VSG_SCOPE_SELF)->GetVariable(cache_entries[i][0], 0, &stub);
}
/* Make sure really all bits are set. */
diff --git a/src/newgrf_spritegroup.cpp b/src/newgrf_spritegroup.cpp
index 81b66767b..0bbf467b5 100644
--- a/src/newgrf_spritegroup.cpp
+++ b/src/newgrf_spritegroup.cpp
@@ -174,7 +174,7 @@ static uint32 RotateRight(uint32 val, uint32 rot)
/* Evaluate an adjustment for a variable of the given size.
* U is the unsigned type and S is the signed type to use. */
template <typename U, typename S>
-static U EvalAdjustT(const DeterministicSpriteGroupAdjust *adjust, ResolverObject *object, U last_value, uint32 value)
+static U EvalAdjustT(const DeterministicSpriteGroupAdjust *adjust, ScopeResolver *scope, U last_value, uint32 value)
{
value >>= adjust->shift_num;
value &= adjust->and_mask;
@@ -204,7 +204,7 @@ static U EvalAdjustT(const DeterministicSpriteGroupAdjust *adjust, ResolverObjec
case DSGA_OP_XOR: return last_value ^ value;
case DSGA_OP_STO: _temp_store.StoreValue((U)value, (S)last_value); return last_value;
case DSGA_OP_RST: return value;
- case DSGA_OP_STOP: object->GetScope(object->scope)->StorePSA((U)value, (S)last_value); return last_value;
+ case DSGA_OP_STOP: scope->StorePSA((U)value, (S)last_value); return last_value;
case DSGA_OP_ROR: return RotateRight(last_value, value);
case DSGA_OP_SCMP: return ((S)last_value == (S)value) ? 1 : ((S)last_value < (S)value ? 0 : 2);
case DSGA_OP_UCMP: return ((U)last_value == (U)value) ? 1 : ((U)last_value < (U)value ? 0 : 2);
@@ -222,7 +222,7 @@ const SpriteGroup *DeterministicSpriteGroup::Resolve(ResolverObject *object) con
uint32 value = 0;
uint i;
- object->scope = this->var_scope;
+ ScopeResolver *scope = object->GetScope(this->var_scope);
for (i = 0; i < this->num_adjusts; i++) {
DeterministicSpriteGroupAdjust *adjust = &this->adjusts[i];
@@ -237,13 +237,11 @@ const SpriteGroup *DeterministicSpriteGroup::Resolve(ResolverObject *object) con
value = subgroup->GetCallbackResult();
}
- /* Reset values to current scope.
- * Note: 'last_value' and 'reseed' are shared between the main chain and the procedure */
- object->scope = this->var_scope;
+ /* Note: 'last_value' and 'reseed' are shared between the main chain and the procedure */
} else if (adjust->variable == 0x7B) {
- value = GetVariable(object, object->GetScope(this->var_scope), adjust->parameter, last_value, &available);
+ value = GetVariable(object, scope, adjust->parameter, last_value, &available);
} else {
- value = GetVariable(object, object->GetScope(this->var_scope), adjust->variable, adjust->parameter, &available);
+ value = GetVariable(object, scope, adjust->variable, adjust->parameter, &available);
}
if (!available) {
@@ -253,9 +251,9 @@ const SpriteGroup *DeterministicSpriteGroup::Resolve(ResolverObject *object) con
}
switch (this->size) {
- case DSG_SIZE_BYTE: value = EvalAdjustT<uint8, int8> (adjust, object, last_value, value); break;
- case DSG_SIZE_WORD: value = EvalAdjustT<uint16, int16>(adjust, object, last_value, value); break;
- case DSG_SIZE_DWORD: value = EvalAdjustT<uint32, int32>(adjust, object, last_value, value); break;
+ case DSG_SIZE_BYTE: value = EvalAdjustT<uint8, int8> (adjust, scope, last_value, value); break;
+ case DSG_SIZE_WORD: value = EvalAdjustT<uint16, int16>(adjust, scope, last_value, value); break;
+ case DSG_SIZE_DWORD: value = EvalAdjustT<uint32, int32>(adjust, scope, last_value, value); break;
default: NOT_REACHED();
}
last_value = value;
@@ -283,9 +281,6 @@ const SpriteGroup *DeterministicSpriteGroup::Resolve(ResolverObject *object) con
const SpriteGroup *RandomizedSpriteGroup::Resolve(ResolverObject *object) const
{
- object->scope = this->var_scope;
- object->count = this->count;
-
ScopeResolver *scope = object->GetScope(this->var_scope, this->count);
if (object->trigger != 0) {
/* Handle triggers */
diff --git a/src/newgrf_spritegroup.h b/src/newgrf_spritegroup.h
index 9b6d1fc0e..93e2e58dc 100644
--- a/src/newgrf_spritegroup.h
+++ b/src/newgrf_spritegroup.h
@@ -344,9 +344,6 @@ struct ResolverObject {
uint32 last_value; ///< Result of most recent DeterministicSpriteGroup (including procedure calls)
uint32 reseed[VSG_END]; ///< Collects bits to rerandomise while triggering triggers.
- VarSpriteGroupScope scope; ///< Scope of currently resolved DeterministicSpriteGroup resp. RandomizedSpriteGroup
- byte count; ///< Additional scope for RandomizedSpriteGroup
-
const GRFFile *grffile; ///< GRFFile the resolved SpriteGroup belongs to
virtual const SpriteGroup *ResolveReal(const RealSpriteGroup *group) const;
diff --git a/src/table/newgrf_debug_data.h b/src/table/newgrf_debug_data.h
index 4446d7605..2f02b1404 100644
--- a/src/table/newgrf_debug_data.h
+++ b/src/table/newgrf_debug_data.h
@@ -75,7 +75,7 @@ class NIHVehicle : public NIHelper {
{
Vehicle *v = Vehicle::Get(index);
VehicleResolverObject ro(v->engine_type, v);
- return ro.GetScope(ro.scope)->GetVariable(var, param, avail);
+ return ro.GetScope(VSG_SCOPE_SELF)->GetVariable(var, param, avail);
}
};
@@ -137,7 +137,7 @@ class NIHStation : public NIHelper {
/* virtual */ uint Resolve(uint index, uint var, uint param, bool *avail) const
{
StationResolverObject ro(GetStationSpec(index), Station::GetByTile(index), index);
- return ro.GetScope(ro.scope)->GetVariable(var, param, avail);
+ return ro.GetScope(VSG_SCOPE_SELF)->GetVariable(var, param, avail);
}
};
@@ -202,7 +202,7 @@ class NIHHouse : public NIHelper {
/* virtual */ uint Resolve(uint index, uint var, uint param, bool *avail) const
{
HouseResolverObject ro(GetHouseType(index), index, Town::GetByTile(index));
- return ro.GetScope(ro.scope)->GetVariable(var, param, avail);
+ return ro.GetScope(VSG_SCOPE_SELF)->GetVariable(var, param, avail);
}
};
@@ -252,7 +252,7 @@ class NIHIndustryTile : public NIHelper {
/* virtual */ uint Resolve(uint index, uint var, uint param, bool *avail) const
{
IndustryTileResolverObject ro(GetIndustryGfx(index), index, Industry::GetByTile(index));
- return ro.GetScope(ro.scope)->GetVariable(var, param, avail);
+ return ro.GetScope(VSG_SCOPE_SELF)->GetVariable(var, param, avail);
}
};
@@ -325,7 +325,7 @@ class NIHIndustry : public NIHelper {
{
Industry *i = Industry::Get(index);
IndustriesResolverObject ro(i->location.tile, i, i->type);
- return ro.GetScope(ro.scope)->GetVariable(var, param, avail);
+ return ro.GetScope(VSG_SCOPE_SELF)->GetVariable(var, param, avail);
}
uint GetPSASize(uint index, uint32 grfid) const { return cpp_lengthof(PersistentStorage, storage); }
@@ -389,7 +389,7 @@ class NIHObject : public NIHelper {
/* virtual */ uint Resolve(uint index, uint var, uint param, bool *avail) const
{
ObjectResolverObject ro(ObjectSpec::GetByTile(index), Object::GetByTile(index), index);
- return ro.GetScope(ro.scope)->GetVariable(var, param, avail);
+ return ro.GetScope(VSG_SCOPE_SELF)->GetVariable(var, param, avail);
}
};
@@ -423,7 +423,7 @@ class NIHRailType : public NIHelper {
/* There is no unique GRFFile for the tile. Multiple GRFs can define different parts of the railtype.
* However, currently the NewGRF Debug GUI does not display variables depending on the GRF (like 0x7F) anyway. */
RailTypeResolverObject ro(index, TCX_NORMAL, NULL);
- return ro.GetScope(ro.scope)->GetVariable(var, param, avail);
+ return ro.GetScope(VSG_SCOPE_SELF)->GetVariable(var, param, avail);
}
};
@@ -457,7 +457,7 @@ class NIHAirportTile : public NIHelper {
/* virtual */ uint Resolve(uint index, uint var, uint param, bool *avail) const
{
AirportTileResolverObject ro(AirportTileSpec::GetByTile(index), index, Station::GetByTile(index));
- return ro.GetScope(ro.scope)->GetVariable(var, param, avail);
+ return ro.GetScope(VSG_SCOPE_SELF)->GetVariable(var, param, avail);
}
};
@@ -497,7 +497,7 @@ class NIHTown : public NIHelper {
/* virtual */ uint Resolve(uint index, uint var, uint param, bool *avail) const
{
TownResolverObject ro(NULL, Town::Get(index), true);
- return ro.GetScope(ro.scope)->GetVariable(var, param, avail);
+ return ro.GetScope(VSG_SCOPE_SELF)->GetVariable(var, param, avail);
}
const int32 *GetPSAFirstPosition(uint index, uint32 grfid) const