Changeset - r18290:4e805de55757
[Not reviewed]
master
0 3 0
frosch - 13 years ago 2011-11-08 17:22:19
frosch@openttd.org
(svn r23136) -Change: [NewGRF v8] Deprecate old-style callback results 0xFF??.
3 files changed with 7 insertions and 6 deletions:
0 comments (0 inline, 0 general)
src/newgrf.cpp
Show inline comments
 
@@ -4237,13 +4237,13 @@ static void SkipAct1(ByteReader *buf)
 
/* Helper function to either create a callback or link to a previously
 
 * defined spritegroup. */
 
static const SpriteGroup *GetGroupFromGroupID(byte setid, byte type, uint16 groupid)
 
{
 
	if (HasBit(groupid, 15)) {
 
		assert(CallbackResultSpriteGroup::CanAllocateItem());
 
		return new CallbackResultSpriteGroup(groupid);
 
		return new CallbackResultSpriteGroup(groupid, _cur.grffile->grf_version >= 8);
 
	}
 

	
 
	if (groupid > MAX_SPRITEGROUP || _cur.spritegroups[groupid] == NULL) {
 
		grfmsg(1, "GetGroupFromGroupID(0x%02X:0x%02X): Groupid 0x%04X does not exist, leaving empty", setid, type, groupid);
 
		return NULL;
 
	}
 
@@ -4260,13 +4260,13 @@ static const SpriteGroup *GetGroupFromGr
 
 * @return Created spritegroup.
 
 */
 
static const SpriteGroup *CreateGroupFromGroupID(byte feature, byte setid, byte type, uint16 spriteid)
 
{
 
	if (HasBit(spriteid, 15)) {
 
		assert(CallbackResultSpriteGroup::CanAllocateItem());
 
		return new CallbackResultSpriteGroup(spriteid);
 
		return new CallbackResultSpriteGroup(spriteid, _cur.grffile->grf_version >= 8);
 
	}
 

	
 
	if (!_cur.IsValidSpriteSet(feature, spriteid)) {
 
		grfmsg(1, "CreateGroupFromGroupID(0x%02X:0x%02X): Sprite set %u invalid", setid, type, spriteid);
 
		return NULL;
 
	}
src/newgrf_spritegroup.cpp
Show inline comments
 
@@ -172,13 +172,13 @@ const SpriteGroup *DeterministicSpriteGr
 

	
 
	object->last_value = last_value;
 

	
 
	if (this->num_ranges == 0) {
 
		/* nvar == 0 is a special case -- we turn our value into a callback result */
 
		if (value != CALLBACK_FAILED) value = GB(value, 0, 15);
 
		static CallbackResultSpriteGroup nvarzero(0);
 
		static CallbackResultSpriteGroup nvarzero(0, true);
 
		nvarzero.result = value;
 
		return &nvarzero;
 
	}
 

	
 
	for (i = 0; i < this->num_ranges; i++) {
 
		if (this->ranges[i].low <= value && value <= this->ranges[i].high) {
src/newgrf_spritegroup.h
Show inline comments
 
@@ -237,20 +237,21 @@ protected:
 
/* This contains a callback result. A failed callback has a value of
 
 * CALLBACK_FAILED */
 
struct CallbackResultSpriteGroup : SpriteGroup {
 
	/**
 
	 * Creates a spritegroup representing a callback result
 
	 * @param value The value that was used to represent this callback result
 
	 * @param grf_version8 True, if we are dealing with a new NewGRF which uses GRF version >= 8.
 
	 */
 
	CallbackResultSpriteGroup(uint16 value) :
 
	CallbackResultSpriteGroup(uint16 value, bool grf_version8) :
 
		SpriteGroup(SGT_CALLBACK),
 
		result(value)
 
	{
 
		/* Old style callback results have the highest byte 0xFF so signify it is a callback result
 
		/* Old style callback results (only valid for version < 8) have the highest byte 0xFF so signify it is a callback result.
 
		 * New style ones only have the highest bit set (allows 15-bit results, instead of just 8) */
 
		if ((this->result >> 8) == 0xFF) {
 
		if (!grf_version8 && (this->result >> 8) == 0xFF) {
 
			this->result &= ~0xFF00;
 
		} else {
 
			this->result &= ~0x8000;
 
		}
 
	}
 

	
0 comments (0 inline, 0 general)