From f7f744f59b6a1edc8836925639a8cebbdab7d843 Mon Sep 17 00:00:00 2001 From: Gymnasiast Date: Sat, 7 Jan 2017 00:01:13 +0100 Subject: [PATCH] Use a map to convert vehicle subentry and restore seat rotation --- src/openrct2/rct1.h | 7 + src/openrct2/rct1/S4Importer.cpp | 19 ++- src/openrct2/rct1/Tables.h | 1 + src/openrct2/rct1/tables.cpp | 264 +++++++++++++++++++++++++++++++ 4 files changed, 286 insertions(+), 5 deletions(-) diff --git a/src/openrct2/rct1.h b/src/openrct2/rct1.h index 19beb30001..33f8e0358d 100644 --- a/src/openrct2/rct1.h +++ b/src/openrct2/rct1.h @@ -1121,6 +1121,13 @@ enum { RCT1_PARK_FLAGS_LOCK_REAL_NAMES_OPTION = (1 << 15), }; +enum { + STEEL_RC_FRONT = 0, + STEEL_RC_CARRIAGE = 1, + MINE_TRAIN_FRONT = 35, + MINE_TRAIN_CARRIAGE = 36, +}; + #define RCT1_MAX_STATIONS 4 extern const uint8 gRideCategories[0x60]; diff --git a/src/openrct2/rct1/S4Importer.cpp b/src/openrct2/rct1/S4Importer.cpp index 91b91bbd64..cc92e6c02f 100644 --- a/src/openrct2/rct1/S4Importer.cpp +++ b/src/openrct2/rct1/S4Importer.cpp @@ -847,11 +847,16 @@ private: { // TODO perform vehicle type conversion // this will be whether the vehicle is the head of the train or a seat etc. - uint8 vehicleEntryIndex = 0; - if (src->vehicle_type == 36) - { - vehicleEntryIndex = 1; - } +// uint8 vehicleEntryIndex = 0; +// if (src->vehicle_type == 36) +// { +// vehicleEntryIndex = 1; +// } + char buf[64]; + sprintf(buf, "%d", src->vehicle_type); + log_error(buf); + + uint8 vehicleEntryIndex = RCT1::GetVehicleSubEntryIndex(src->vehicle_type); rct_ride * ride = get_ride(src->ride); rct_ride_entry * rideEntry = get_ride_entry_by_ride(ride); @@ -900,6 +905,10 @@ private: dst->vehicle_sprite_type = src->vehicle_sprite_type; dst->bank_rotation = src->bank_rotation; + // Seat rotation was not in RCT1 + dst->target_seat_rotation = 4; + dst->seat_rotation = 4; + // Vehicle links (indexes converted later) dst->prev_vehicle_on_ride = src->prev_vehicle_on_ride; dst->next_vehicle_on_ride = src->next_vehicle_on_ride; diff --git a/src/openrct2/rct1/Tables.h b/src/openrct2/rct1/Tables.h index bbe18cae15..5f859eb304 100644 --- a/src/openrct2/rct1/Tables.h +++ b/src/openrct2/rct1/Tables.h @@ -33,6 +33,7 @@ namespace RCT1 bool RideTypeUsesVehicles(uint8 rideType); bool PathIsQueue(uint8 pathType); uint8 NormalisePathAddition(uint8 pathAdditionType); + uint8 GetVehicleSubEntryIndex(uint8 vehicleSubEntry); const char * GetRideTypeObject(uint8 rideType); const char * GetVehicleObject(uint8 vehicleType); diff --git a/src/openrct2/rct1/tables.cpp b/src/openrct2/rct1/tables.cpp index 98234776fe..7bab63d51b 100644 --- a/src/openrct2/rct1/tables.cpp +++ b/src/openrct2/rct1/tables.cpp @@ -314,6 +314,270 @@ namespace RCT1 return pathAdditionType; } + uint8 GetVehicleSubEntryIndex(uint8 vehicleSubEntry) + { + static const uint8 map[] = + { + 0, // STEEL_RC_FRONT + 1, // STEEL_RC_CARRIAGE + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, //MINE_TRAIN_FRONT + 1, //MINE_TRAIN_CARRIAGE + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + }; + return map[vehicleSubEntry]; + } + const char * GetRideTypeObject(uint8 rideType) { static const char * map[] =