Changeset - r17769:40a7de7cde1c
[Not reviewed]
master
0 7 0
terkhen - 13 years ago 2011-06-12 20:40:21
terkhen@openttd.org
(svn r22564) -Codechange: Rename Get and Store persistent storage functions to GetValue and StoreValue.
7 files changed with 15 insertions and 15 deletions:
0 comments (0 inline, 0 general)
src/newgrf_airport.cpp
Show inline comments
 
@@ -146,13 +146,13 @@ uint32 AirportGetVariable(const Resolver
 
		*available = false;
 
		return UINT_MAX;
 
	}
 

	
 
	switch (variable) {
 
		/* Get a variable from the persistent storage */
 
		case 0x7C: return st->airport.psa.Get(parameter);
 
		case 0x7C: return st->airport.psa.GetValue(parameter);
 

	
 
		case 0xF0: return st->facilities;
 
		case 0xFA: return Clamp(st->build_date - DAYS_TILL_ORIGINAL_BASE_YEAR, 0, 65535);
 
	}
 

	
 
	return st->GetNewGRFVariable(object, variable, parameter, available);
 
@@ -191,13 +191,13 @@ static void AirportSetTriggers(const Res
 
 * @param value Value to store.
 
 */
 
void AirportStorePSA(ResolverObject *object, uint pos, int32 value)
 
{
 
	Station *st = object->u.airport.st;
 
	if (object->scope != VSG_SCOPE_SELF || st == NULL) return;
 
	st->airport.psa.Store(pos, value);
 
	st->airport.psa.StoreValue(pos, value);
 
}
 

	
 
static void NewAirportResolver(ResolverObject *res, TileIndex tile, Station *st, byte airport_id, byte layout)
 
{
 
	res->GetRandomBits = AirportGetRandomBits;
 
	res->GetTriggers   = AirportGetTriggers;
src/newgrf_industries.cpp
Show inline comments
 
@@ -280,13 +280,13 @@ uint32 IndustryGetVariable(const Resolve
 
				town_filter = HasBit(reg, 8);
 
			}
 
			return GetCountAndDistanceOfClosestInstance(parameter, layout_filter, town_filter, industry);
 
		}
 

	
 
		/* Get a variable from the persistent storage */
 
		case 0x7C: return industry->psa.Get(parameter);
 
		case 0x7C: return industry->psa.GetValue(parameter);
 

	
 
		/* Industry structure access*/
 
		case 0x80: return industry->location.tile;
 
		case 0x81: return GB(industry->location.tile, 8, 8);
 
		/* Pointer to the town the industry is associated with */
 
		case 0x82: return industry->town->index;
 
@@ -383,13 +383,13 @@ static void IndustrySetTriggers(const Re
 
 * @param value Value to store.
 
 */
 
void IndustryStorePSA(ResolverObject *object, uint pos, int32 value)
 
{
 
	Industry *ind = object->u.industry.ind;
 
	if (object->scope != VSG_SCOPE_SELF || ind->index == INVALID_INDUSTRY) return;
 
	ind->psa.Store(pos, value);
 
	ind->psa.StoreValue(pos, value);
 
}
 

	
 
static void NewIndustryResolver(ResolverObject *res, TileIndex tile, Industry *indus, IndustryType type)
 
{
 
	res->GetRandomBits = IndustryGetRandomBits;
 
	res->GetTriggers   = IndustryGetTriggers;
src/newgrf_industrytiles.cpp
Show inline comments
 
@@ -155,13 +155,13 @@ static void IndustryTileSetTriggers(cons
 
 * @param value Value to store.
 
 */
 
void IndustryTileStorePSA(ResolverObject *object, uint pos, int32 value)
 
{
 
	Industry *ind = object->u.industry.ind;
 
	if (object->scope != VSG_SCOPE_PARENT || ind->index == INVALID_INDUSTRY) return;
 
	ind->psa.Store(pos, value);
 
	ind->psa.StoreValue(pos, value);
 
}
 

	
 
static void NewIndustryTileResolver(ResolverObject *res, IndustryGfx gfx, TileIndex tile, Industry *indus)
 
{
 
	res->GetRandomBits = IndustryTileGetRandomBits;
 
	res->GetTriggers   = IndustryTileGetTriggers;
src/newgrf_spritegroup.cpp
Show inline comments
 
@@ -50,13 +50,13 @@ static inline uint32 GetVariable(const R
 
		case 0x10: return object->callback_param1;
 
		case 0x18: return object->callback_param2;
 
		case 0x1C: return object->last_value;
 

	
 
		case 0x5F: return (object->GetRandomBits(object) << 8) | object->GetTriggers(object);
 

	
 
		case 0x7D: return _temp_store.Get(parameter);
 
		case 0x7D: return _temp_store.GetValue(parameter);
 

	
 
		case 0x7F:
 
			if (object == NULL || object->grffile == NULL) return 0;
 
			return object->grffile->GetParam(parameter);
 

	
 
		/* Not a common variable, so evalute the feature specific variables */
 
@@ -108,13 +108,13 @@ static U EvalAdjustT(const Deterministic
 
		case DSGA_OP_UDIV: return value == 0 ? (U)last_value : (U)last_value / (U)value;
 
		case DSGA_OP_UMOD: return value == 0 ? (U)last_value : (U)last_value % (U)value;
 
		case DSGA_OP_MUL:  return last_value * value;
 
		case DSGA_OP_AND:  return last_value & value;
 
		case DSGA_OP_OR:   return last_value | value;
 
		case DSGA_OP_XOR:  return last_value ^ value;
 
		case DSGA_OP_STO:  _temp_store.Store((U)value, (S)last_value); return last_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: if (object->StorePSA != NULL) object->StorePSA(object, (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);
 
		case DSGA_OP_SHL:  return (U)last_value << ((U)value & 0x1F); // mask 'value' to 5 bits, which should behave the same on all architectures.
src/newgrf_spritegroup.h
Show inline comments
 
@@ -29,24 +29,24 @@
 
 * @pre i < 0x110
 
 * @return the value of the register
 
 */
 
static inline uint32 GetRegister(uint i)
 
{
 
	extern TemporaryStorageArray<int32, 0x110> _temp_store;
 
	return _temp_store.Get(i);
 
	return _temp_store.GetValue(i);
 
}
 

	
 
/**
 
 * Clears the value of a so-called newgrf "register".
 
 * @param i index of the register
 
 * @pre i < 0x110
 
 */
 
static inline void ClearRegister(uint i)
 
{
 
	extern TemporaryStorageArray<int32, 0x110> _temp_store;
 
	_temp_store.Store(i, 0);
 
	_temp_store.StoreValue(i, 0);
 
}
 

	
 
/* List of different sprite group types */
 
enum SpriteGroupType {
 
	SGT_REAL,
 
	SGT_DETERMINISTIC,
src/newgrf_storage.h
Show inline comments
 
@@ -33,13 +33,13 @@ struct BaseStorageArray
 

	
 
	/**
 
	 * Stores some value at a given position.
 
	 * @param pos   the position to write at
 
	 * @param value the value to write
 
	 */
 
	virtual void Store(uint pos, int32 value) = 0;
 
	virtual void StoreValue(uint pos, int32 value) = 0;
 
};
 

	
 
/**
 
 * Class for persistent storage of data.
 
 * On ClearChanges that data is either reverted or saved.
 
 * @param TYPE the type of variable to store.
 
@@ -72,13 +72,13 @@ struct PersistentStorageArray : BaseStor
 
	 * Stores some value at a given position.
 
	 * If there is no backup of the data that backup is made and then
 
	 * we write the data.
 
	 * @param pos   the position to write at
 
	 * @param value the value to write
 
	 */
 
	void Store(uint pos, int32 value)
 
	void StoreValue(uint pos, int32 value)
 
	{
 
		/* Out of the scope of the array */
 
		if (pos >= SIZE) return;
 

	
 
		/* The value hasn't changed, so we pretend nothing happened.
 
		 * Saves a few cycles and such and it's pretty easy to check. */
 
@@ -99,13 +99,13 @@ struct PersistentStorageArray : BaseStor
 

	
 
	/**
 
	 * Gets the value from a given position.
 
	 * @param pos the position to get the data from
 
	 * @return the data from that position
 
	 */
 
	TYPE Get(uint pos) const
 
	TYPE GetValue(uint pos) const
 
	{
 
		/* Out of the scope of the array */
 
		if (pos >= SIZE) return 0;
 

	
 
		return this->storage[pos];
 
	}
 
@@ -144,13 +144,13 @@ struct TemporaryStorageArray : BaseStora
 

	
 
	/**
 
	 * Stores some value at a given position.
 
	 * @param pos   the position to write at
 
	 * @param value the value to write
 
	 */
 
	void Store(uint pos, int32 value)
 
	void StoreValue(uint pos, int32 value)
 
	{
 
		/* Out of the scope of the array */
 
		if (pos >= SIZE) return;
 

	
 
		this->storage[pos] = value;
 
		AddChangedStorage(this);
 
@@ -158,13 +158,13 @@ struct TemporaryStorageArray : BaseStora
 

	
 
	/**
 
	 * Gets the value from a given position.
 
	 * @param pos the position to get the data from
 
	 * @return the data from that position
 
	 */
 
	TYPE Get(uint pos) const
 
	TYPE GetValue(uint pos) const
 
	{
 
		/* Out of the scope of the array */
 
		if (pos >= SIZE) return 0;
 

	
 
		return this->storage[pos];
 
	}
src/newgrf_text.cpp
Show inline comments
 
@@ -964,13 +964,13 @@ void PrepareTextRefStackUsage(byte numEn
 

	
 
	_newgrf_textrefstack->ResetStack();
 

	
 
	byte *p = _newgrf_textrefstack->stack;
 
	for (uint i = 0; i < numEntries; i++) {
 
		for (uint j = 0; j < 32; j += 8) {
 
			*p = GB(_temp_store.Get(0x100 + i), j, 8);
 
			*p = GB(_temp_store.GetValue(0x100 + i), j, 8);
 
			p++;
 
		}
 
	}
 
}
 

	
 
/** Stop using the TTDP compatible string code parsing */
0 comments (0 inline, 0 general)