diff options
author | frosch <frosch@openttd.org> | 2014-02-03 21:10:04 +0000 |
---|---|---|
committer | frosch <frosch@openttd.org> | 2014-02-03 21:10:04 +0000 |
commit | 9e5fc88499becfe5b5d86b5ed7093a63a2001267 (patch) | |
tree | 8e519140a6c717c0d25a5e44d530586f1af75542 | |
parent | 9ff5aa4b7bb1bf7239c76a85369dab7cb3c7ac91 (diff) | |
download | openttd-9e5fc88499becfe5b5d86b5ed7093a63a2001267.tar.xz |
(svn r26294) -Change: [NewGRF] Make vehicle variable 61 return 'not available' instead of zero when using it in invalid callback contexts.
-rw-r--r-- | src/newgrf_engine.cpp | 10 |
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 |