From 7d4568361c92bcf448859f47103a59c0735a4f99 Mon Sep 17 00:00:00 2001 From: frosch Date: Tue, 8 Nov 2011 17:28:05 +0000 Subject: (svn r23151) -Change: [NewGRF v8] Deprecate callback 12, and use callback 36 instead. --- src/economy.cpp | 11 +++++++++-- src/newgrf.cpp | 2 +- src/newgrf_properties.h | 2 ++ 3 files changed, 12 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/economy.cpp b/src/economy.cpp index 79d8a0b99..48cd28296 100644 --- a/src/economy.cpp +++ b/src/economy.cpp @@ -1207,8 +1207,15 @@ static void LoadUnloadVehicle(Vehicle *front, int *cargo_left) /* The default loadamount for mail is 1/4 of the load amount for passengers */ if (v->type == VEH_AIRCRAFT && !Aircraft::From(v)->IsNormalAircraft()) load_amount = CeilDiv(load_amount, 4); - if (_settings_game.order.gradual_loading && HasBit(e->info.callback_mask, CBM_VEHICLE_LOAD_AMOUNT)) { - uint16 cb_load_amount = GetVehicleCallback(CBID_VEHICLE_LOAD_AMOUNT, 0, 0, v->engine_type, v); + if (_settings_game.order.gradual_loading) { + uint16 cb_load_amount = CALLBACK_FAILED; + if (e->GetGRF() != NULL && e->GetGRF()->grf_version >= 8) { + /* Use callback 36 */ + cb_load_amount = GetVehicleProperty(v, PROP_VEHICLE_LOAD_AMOUNT, CALLBACK_FAILED); + } else if (HasBit(e->info.callback_mask, CBM_VEHICLE_LOAD_AMOUNT)) { + /* Use callback 12 */ + cb_load_amount = GetVehicleCallback(CBID_VEHICLE_LOAD_AMOUNT, 0, 0, v->engine_type, v); + } if (cb_load_amount != CALLBACK_FAILED) { if (e->GetGRF()->grf_version < 8) cb_load_amount = GB(cb_load_amount, 0, 8); if (cb_load_amount >= 0x100) { diff --git a/src/newgrf.cpp b/src/newgrf.cpp index 0904760c6..890b10034 100644 --- a/src/newgrf.cpp +++ b/src/newgrf.cpp @@ -888,7 +888,7 @@ static ChangeInfoResult CommonVehicleChangeInfo(EngineInfo *ei, int prop, ByteRe ei->climates = buf->ReadByte(); break; - case 0x07: // Loading speed + case PROP_VEHICLE_LOAD_AMOUNT: // 0x07 Loading speed /* Amount of cargo loaded during a vehicle's "loading tick" */ ei->load_amount = buf->ReadByte(); break; diff --git a/src/newgrf_properties.h b/src/newgrf_properties.h index 5b2ba055a..090ac1413 100644 --- a/src/newgrf_properties.h +++ b/src/newgrf_properties.h @@ -18,6 +18,8 @@ * @todo Currently the list only contains properties which are used more than once in the code. I.e. they are available for callback 0x36. */ enum PropertyID { + PROP_VEHICLE_LOAD_AMOUNT = 0x07, ///< Loading speed + PROP_TRAIN_SPEED = 0x09, ///< Max. speed: 1 unit = 1/1.6 mph = 1 km-ish/h PROP_TRAIN_POWER = 0x0B, ///< Power in hp (if dualheaded: sum of both vehicles) PROP_TRAIN_RUNNING_COST_FACTOR = 0x0D, ///< Yearly runningcost (if dualheaded: sum of both vehicles) -- cgit v1.2.3-70-g09d2