summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2014-02-03 21:10:04 +0000
committerfrosch <frosch@openttd.org>2014-02-03 21:10:04 +0000
commit9e5fc88499becfe5b5d86b5ed7093a63a2001267 (patch)
tree8e519140a6c717c0d25a5e44d530586f1af75542 /src
parent9ff5aa4b7bb1bf7239c76a85369dab7cb3c7ac91 (diff)
downloadopenttd-9e5fc88499becfe5b5d86b5ed7093a63a2001267.tar.xz
(svn r26294) -Change: [NewGRF] Make vehicle variable 61 return 'not available' instead of zero when using it in invalid callback contexts.
Diffstat (limited to 'src')
-rw-r--r--src/newgrf_engine.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/newgrf_engine.cpp b/src/newgrf_engine.cpp
index 3b48aba83..309decb72 100644
--- a/src/newgrf_engine.cpp
+++ b/src/newgrf_engine.cpp
@@ -651,13 +651,16 @@ static uint32 VehicleGetVariable(Vehicle *v, const VehicleScopeResolver *object,
}
case 0x61: // Get variable of n-th vehicle in chain [signed number relative to vehicle]
- if (!v->IsGroundVehicle() || parameter == 0x61) return 0;
+ if (!v->IsGroundVehicle() || parameter == 0x61) {
+ /* Not available */
+ break;
+ }
/* Only allow callbacks that don't change properties to avoid circular dependencies. */
if (object->ro.callback == CBID_NO_CALLBACK || object->ro.callback == CBID_RANDOM_TRIGGER || object->ro.callback == CBID_TRAIN_ALLOW_WAGON_ATTACH ||
object->ro.callback == CBID_VEHICLE_START_STOP_CHECK || object->ro.callback == CBID_VEHICLE_32DAY_CALLBACK || object->ro.callback == CBID_VEHICLE_COLOUR_MAPPING) {
Vehicle *u = v->Move((int32)GetRegister(0x10F));
- if (u == NULL) return 0;
+ if (u == NULL) return 0; // available, but zero
if (parameter == 0x5F) {
/* This seems to be the only variable that makes sense to access via var 61, but is not handled by VehicleGetVariable */
@@ -666,7 +669,8 @@ static uint32 VehicleGetVariable(Vehicle *v, const VehicleScopeResolver *object,
return VehicleGetVariable(u, object, parameter, GetRegister(0x10E), available);
}
}
- return 0;
+ /* Not available */
+ break;
case 0x62: { // Curvature/position difference for n-th vehicle in chain [signed number relative to vehicle]
/* Format: zzyyxxFD