summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2010-10-08 21:07:54 +0000
committerrubidium <rubidium@openttd.org>2010-10-08 21:07:54 +0000
commit322e4ab86fe21c7522ae1501aba175a8f7fa1e5d (patch)
tree506672fdc91f9c091884fb335a067f7d63fd27c2 /src
parent969e3a9e45364d8c8d7a74ed1f84727bd272da33 (diff)
downloadopenttd-322e4ab86fe21c7522ae1501aba175a8f7fa1e5d.tar.xz
(svn r20908) -Fix [FS#4156]: assertion when the buy menu graphics callback accessed a variable that needs a tile index
Diffstat (limited to 'src')
-rw-r--r--src/newgrf_object.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/newgrf_object.cpp b/src/newgrf_object.cpp
index f6b2768c9..84d6187b2 100644
--- a/src/newgrf_object.cpp
+++ b/src/newgrf_object.cpp
@@ -241,6 +241,7 @@ static uint32 ObjectGetVariable(const ResolverObject *object, byte variable, byt
/* Allow these, but find the closest town. */
case 0x45:
case 0x46:
+ if (!IsValidTile(tile)) goto unhandled;
t = ClosestTownFromTile(tile, UINT_MAX);
break;
@@ -257,11 +258,11 @@ static uint32 ObjectGetVariable(const ResolverObject *object, byte variable, byt
* 0x63: Animation counter of nearby tile, see above.
*/
default:
- DEBUG(grf, 1, "Unhandled object property 0x%X", variable);
-
- *available = false;
- return UINT_MAX;
+ goto unhandled;
}
+
+ /* If there's an invalid tile, then we don't have enough information at all. */
+ if (!IsValidTile(tile)) goto unhandled;
} else {
t = o->town;
}
@@ -313,6 +314,7 @@ static uint32 ObjectGetVariable(const ResolverObject *object, byte variable, byt
case 0x64: return GetCountAndDistanceOfClosestInstance(parameter, object->grffile->grfid, tile, o);
}
+unhandled:
DEBUG(grf, 1, "Unhandled object property 0x%X", variable);
*available = false;