diff options
author | frosch <frosch@openttd.org> | 2011-11-08 17:22:49 +0000 |
---|---|---|
committer | frosch <frosch@openttd.org> | 2011-11-08 17:22:49 +0000 |
commit | f97fa89f1a649ae3dc8f6d0c5d9b70d69b0840d9 (patch) | |
tree | 882568e40297a0094297b5df5a16ef98c19a684f | |
parent | e08a227b535fe5ea2fe8d986c308519fcd8fbf86 (diff) | |
download | openttd-f97fa89f1a649ae3dc8f6d0c5d9b70d69b0840d9.tar.xz |
(svn r23137) -Change: [NewGRF v8] New result format for callback 16.
-rw-r--r-- | src/articulated_vehicles.cpp | 22 | ||||
-rw-r--r-- | src/newgrf_callbacks.h | 2 |
2 files changed, 19 insertions, 5 deletions
diff --git a/src/articulated_vehicles.cpp b/src/articulated_vehicles.cpp index 8d3932ce2..415937388 100644 --- a/src/articulated_vehicles.cpp +++ b/src/articulated_vehicles.cpp @@ -15,6 +15,7 @@ #include "vehicle_func.h" #include "engine_func.h" #include "company_func.h" +#include "newgrf.h" #include "table/strings.h" #include "table/sprites.h" @@ -33,12 +34,25 @@ static EngineID GetNextArticulatedPart(uint index, EngineID front_type, Vehicle { assert(front == NULL || front->engine_type == front_type); + const Engine *front_engine = Engine::Get(front_type); + uint16 callback = GetVehicleCallback(CBID_VEHICLE_ARTIC_ENGINE, index, 0, front_type, front); - if (callback == CALLBACK_FAILED || GB(callback, 0, 8) == 0xFF) return INVALID_ENGINE; + if (callback == CALLBACK_FAILED) return INVALID_ENGINE; + + if (front_engine->GetGRF()->grf_version < 8) { + /* 8 bits, bit 7 for mirroring */ + callback = GB(callback, 0, 8); + if (callback == 0xFF) return INVALID_ENGINE; + if (mirrored != NULL) *mirrored = HasBit(callback, 7); + callback = GB(callback, 0, 7); + } else { + /* 15 bits, bit 14 for mirroring */ + if (callback == 0x7FFF) return INVALID_ENGINE; + if (mirrored != NULL) *mirrored = HasBit(callback, 14); + callback = GB(callback, 0, 14); + } - if (mirrored != NULL) *mirrored = HasBit(callback, 7); - const Engine *front_engine = Engine::Get(front_type); - return GetNewEngineID(front_engine->GetGRF(), front_engine->type, GB(callback, 0, 7)); + return GetNewEngineID(front_engine->GetGRF(), front_engine->type, callback); } /** diff --git a/src/newgrf_callbacks.h b/src/newgrf_callbacks.h index 6c56f44b2..cce00151f 100644 --- a/src/newgrf_callbacks.h +++ b/src/newgrf_callbacks.h @@ -50,7 +50,7 @@ enum CallbackID { CBID_VEHICLE_REFIT_CAPACITY = 0x15, // 15 bit callback /** Builds articulated engines for trains and RVs. */ - CBID_VEHICLE_ARTIC_ENGINE = 0x16, // 8 bit callback + CBID_VEHICLE_ARTIC_ENGINE = 0x16, // 8 bit callback for grf version < 8 /** Determine whether the house can be built on the specified tile. */ CBID_HOUSE_ALLOW_CONSTRUCTION = 0x17, // 8 bit callback |