Changeset - r19740:cdfba1e51313
[Not reviewed]
master
0 4 0
frosch - 12 years ago 2012-11-11 12:57:27
frosch@openttd.org
(svn r24695) -Fix/Cleanup: Remove remaining (incorrect) usages of ResolverObject::scope and count.
4 files changed with 19 insertions and 27 deletions:
0 comments (0 inline, 0 general)
src/newgrf_engine.cpp
Show inline comments
 
@@ -1301,7 +1301,7 @@ void FillNewGRFVehicleCache(const Vehicl
 
		/* 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. */
src/newgrf_spritegroup.cpp
Show inline comments
 
@@ -174,7 +174,7 @@ static uint32 RotateRight(uint32 val, ui
 
/* 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 Deterministic
 
		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 *DeterministicSpriteGr
 
	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 *DeterministicSpriteGr
 
				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 *DeterministicSpriteGr
 
		}
 

	
 
		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 *DeterministicSpriteGr
 

	
 
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 */
src/newgrf_spritegroup.h
Show inline comments
 
@@ -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;
src/table/newgrf_debug_data.h
Show inline comments
 
@@ -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
0 comments (0 inline, 0 general)