1
0
mirror of https://github.com/OpenTTD/OpenTTD.git synced 2025-08-20 13:09:15 +00:00

(svn r23148) -Change: [NewGRF] Check the results of various callbacks for validness.

This commit is contained in:
frosch
2011-11-08 17:27:13 +00:00
parent 30874b5e81
commit 52774235eb
8 changed files with 44 additions and 5 deletions

View File

@@ -223,6 +223,10 @@ void Train::ConsistChanged(bool same_length)
uint16 veh_len = CALLBACK_FAILED;
if (HasBit(e_u->info.callback_mask, CBM_VEHICLE_LENGTH)) {
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);