summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2012-11-12 20:13:02 +0000
committerfrosch <frosch@openttd.org>2012-11-12 20:13:02 +0000
commit0a4fe02a47a56fd9f6a906e08f08626c9ac7afd8 (patch)
tree85856f463cdd5f944291e04a851462942afbb004 /src
parent160aa435da76ef79686b3712d77e9f63c1d6d73e (diff)
downloadopenttd-0a4fe02a47a56fd9f6a906e08f08626c9ac7afd8.tar.xz
(svn r24713) -Fix [FS#5262]: [NewGRF] Tolerate old NewGRFs returning invalid values via CB 11.
Diffstat (limited to 'src')
-rw-r--r--src/roadveh_cmd.cpp2
-rw-r--r--src/train_cmd.cpp7
2 files changed, 5 insertions, 4 deletions
diff --git a/src/roadveh_cmd.cpp b/src/roadveh_cmd.cpp
index 62eb67915..11830973b 100644
--- a/src/roadveh_cmd.cpp
+++ b/src/roadveh_cmd.cpp
@@ -169,13 +169,13 @@ static uint GetRoadVehLength(const RoadVehicle *v)
if (e->GetGRF() != NULL && e->GetGRF()->grf_version >= 8) {
/* Use callback 36 */
veh_len = GetVehicleProperty(v, PROP_ROADVEH_SHORTEN_FACTOR, CALLBACK_FAILED);
+ if (veh_len != CALLBACK_FAILED && veh_len >= VEHICLE_LENGTH) ErrorUnknownCallbackResult(e->GetGRFID(), CBID_VEHICLE_LENGTH, veh_len);
} else {
/* Use callback 11 */
veh_len = GetVehicleCallback(CBID_VEHICLE_LENGTH, 0, 0, v->engine_type, v);
}
if (veh_len == CALLBACK_FAILED) veh_len = e->u.road.shorten_factor;
if (veh_len != 0) {
- if (veh_len >= VEHICLE_LENGTH) ErrorUnknownCallbackResult(e->GetGRFID(), CBID_VEHICLE_LENGTH, veh_len);
length -= Clamp(veh_len, 0, VEHICLE_LENGTH - 1);
}
diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp
index 34ac24cd8..c7bad3bf0 100644
--- a/src/train_cmd.cpp
+++ b/src/train_cmd.cpp
@@ -208,13 +208,14 @@ void Train::ConsistChanged(bool same_length)
if (e_u->GetGRF() != NULL && e_u->GetGRF()->grf_version >= 8) {
/* Use callback 36 */
veh_len = GetVehicleProperty(u, PROP_TRAIN_SHORTEN_FACTOR, CALLBACK_FAILED);
+
+ if (veh_len != CALLBACK_FAILED && veh_len >= VEHICLE_LENGTH) {
+ ErrorUnknownCallbackResult(e_u->GetGRFID(), CBID_VEHICLE_LENGTH, veh_len);
+ }
} else if (HasBit(e_u->info.callback_mask, CBM_VEHICLE_LENGTH)) {
/* Use callback 11 */
veh_len = GetVehicleCallback(CBID_VEHICLE_LENGTH, 0, 0, u->engine_type, u);
}
- if (veh_len != CALLBACK_FAILED && veh_len >= VEHICLE_LENGTH) {
- ErrorUnknownCallbackResult(e_u->GetGRFID(), CBID_VEHICLE_LENGTH, veh_len);
- }
if (veh_len == CALLBACK_FAILED) veh_len = rvi_u->shorten_factor;
veh_len = VEHICLE_LENGTH - Clamp(veh_len, 0, VEHICLE_LENGTH - 1);