summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2011-11-08 17:22:19 +0000
committerfrosch <frosch@openttd.org>2011-11-08 17:22:19 +0000
commite08a227b535fe5ea2fe8d986c308519fcd8fbf86 (patch)
tree47de21dfd37fe284ce8a4909d0fb32c06542bbfd /src
parent7a3e362763d248c852663c49178f5f690b9782fc (diff)
downloadopenttd-e08a227b535fe5ea2fe8d986c308519fcd8fbf86.tar.xz
(svn r23136) -Change: [NewGRF v8] Deprecate old-style callback results 0xFF??.
Diffstat (limited to 'src')
-rw-r--r--src/newgrf.cpp4
-rw-r--r--src/newgrf_spritegroup.cpp2
-rw-r--r--src/newgrf_spritegroup.h7
3 files changed, 7 insertions, 6 deletions
diff --git a/src/newgrf.cpp b/src/newgrf.cpp
index 530eb5a9b..61815e705 100644
--- a/src/newgrf.cpp
+++ b/src/newgrf.cpp
@@ -4240,7 +4240,7 @@ static const SpriteGroup *GetGroupFromGroupID(byte setid, byte type, uint16 grou
{
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) {
@@ -4263,7 +4263,7 @@ static const SpriteGroup *CreateGroupFromGroupID(byte feature, byte setid, byte
{
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)) {
diff --git a/src/newgrf_spritegroup.cpp b/src/newgrf_spritegroup.cpp
index 6a42f9b4c..bfca86718 100644
--- a/src/newgrf_spritegroup.cpp
+++ b/src/newgrf_spritegroup.cpp
@@ -175,7 +175,7 @@ const SpriteGroup *DeterministicSpriteGroup::Resolve(ResolverObject *object) con
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;
}
diff --git a/src/newgrf_spritegroup.h b/src/newgrf_spritegroup.h
index 46d7a1bda..4395a3923 100644
--- a/src/newgrf_spritegroup.h
+++ b/src/newgrf_spritegroup.h
@@ -240,14 +240,15 @@ 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;