diff --git a/src/openrct2/object/RideObject.cpp b/src/openrct2/object/RideObject.cpp index 2908acaec1..8fa29734e3 100644 --- a/src/openrct2/object/RideObject.cpp +++ b/src/openrct2/object/RideObject.cpp @@ -141,47 +141,11 @@ void RideObject::Load() rct_ride_entry_vehicle * vehicleEntry = &_legacyType.vehicles[i]; if (vehicleEntry->sprite_flags & VEHICLE_SPRITE_FLAG_FLAT) { - sint32 newVar03 = 1; - if (vehicleEntry->flags & VEHICLE_ENTRY_FLAG_SWINGING) - { - newVar03 = 13; - - if (!(vehicleEntry->flags & VEHICLE_ENTRY_FLAG_21) && !(vehicleEntry->flags & VEHICLE_ENTRY_FLAG_27)) - { - newVar03 = 5; - if (vehicleEntry->flags & VEHICLE_ENTRY_FLAG_25) - { - newVar03 = 3; - } - } - else if (!(vehicleEntry->flags & VEHICLE_ENTRY_FLAG_21) || !(vehicleEntry->flags & VEHICLE_ENTRY_FLAG_27)) - { - newVar03 = 7; - } - } - vehicleEntry->var_03 = newVar03; - // 0x6DE90B - sint32 newVar02 = 32; - if (!(vehicleEntry->flags & VEHICLE_ENTRY_FLAG_14)) - { - newVar02 = 1; - if (vehicleEntry->flags & VEHICLE_ENTRY_FLAG_23 && vehicleEntry->var_11 != 6) - { - newVar02 = 2; - if (!(vehicleEntry->flags & VEHICLE_ENTRY_FLAG_7)) - { - newVar02 = 4; - } - } - } - if (vehicleEntry->flags & VEHICLE_ENTRY_FLAG_HAS_SPECIAL_FRAMES) - { - newVar02 = vehicleEntry->special_frames; - } - vehicleEntry->var_02 = newVar02; + // RCT2 calculates var_02 and var_03 and overwrites these properties on the vehicle entry. + // Immediately afterwards, the two were multiplied in order to calculate var_16 and were never used again. + // This has been changed to use the calculation results directly - var_02 and var_03 are no longer set. // 0x6DE946 - - vehicleEntry->var_16 = vehicleEntry->var_02 * vehicleEntry->var_03; + vehicleEntry->var_16 = CalculateVar02(vehicleEntry) * CalculateVar03(vehicleEntry); vehicleEntry->base_image_id = cur_vehicle_images_offset; sint32 image_index = vehicleEntry->base_image_id; @@ -338,6 +302,76 @@ void RideObject::Load() } } +uint8 RideObject::CalculateVar02(rct_ride_entry_vehicle * vehicleEntry) +{ + // 0x6DE90B + uint8 newVar02; + if (vehicleEntry->flags & VEHICLE_ENTRY_FLAG_HAS_SPECIAL_FRAMES) + { + newVar02 = vehicleEntry->special_frames; + } + else + { + if (!(vehicleEntry->flags & VEHICLE_ENTRY_FLAG_14)) + { + if (vehicleEntry->flags & VEHICLE_ENTRY_FLAG_23 && vehicleEntry->var_11 != 6) + { + if (!(vehicleEntry->flags & VEHICLE_ENTRY_FLAG_7)) + { + newVar02 = 4; + } + else + { + newVar02 = 2; + } + } + else + { + newVar02 = 1; + } + } + else + { + newVar02 = 32; + } + } + + return newVar02; +} + +uint8 RideObject::CalculateVar03(rct_ride_entry_vehicle * vehicleEntry) +{ + uint8 newVar03; + if (vehicleEntry->flags & VEHICLE_ENTRY_FLAG_SWINGING) + { + if (!(vehicleEntry->flags & VEHICLE_ENTRY_FLAG_21) && !(vehicleEntry->flags & VEHICLE_ENTRY_FLAG_27)) + { + if (vehicleEntry->flags & VEHICLE_ENTRY_FLAG_25) + { + newVar03 = 3; + } + else + { + newVar03 = 5; + } + } + else if (!(vehicleEntry->flags & VEHICLE_ENTRY_FLAG_21) || !(vehicleEntry->flags & VEHICLE_ENTRY_FLAG_27)) + { + newVar03 = 7; + } + else + { + newVar03 = 13; + } + } + else + { + newVar03 = 1; + } + + return newVar03; +} + void RideObject::Unload() { language_free_object_string(_legacyType.name); diff --git a/src/openrct2/object/RideObject.h b/src/openrct2/object/RideObject.h index ef81d74684..f61e5328ab 100644 --- a/src/openrct2/object/RideObject.h +++ b/src/openrct2/object/RideObject.h @@ -39,6 +39,8 @@ public: void ReadLegacy(IReadObjectContext * context, IStream * stream) override; void Load() override; + uint8 CalculateVar02(rct_ride_entry_vehicle * vehicleEntry) override; + uint8 CalculateVar03(rct_ride_entry_vehicle * vehicleEntry) override; void Unload() override; void DrawPreview(rct_drawpixelinfo * dpi, sint32 width, sint32 height) const override; diff --git a/src/openrct2/ride/vehicle.h b/src/openrct2/ride/vehicle.h index 7b7aa772ee..0f96c0af91 100644 --- a/src/openrct2/ride/vehicle.h +++ b/src/openrct2/ride/vehicle.h @@ -34,8 +34,8 @@ assert_struct_size(rct_vehicle_colour, 2); */ typedef struct rct_ride_entry_vehicle { uint16 rotation_frame_mask; // 0x00 , 0x1A - uint8 var_02; // 0x02 , 0x1C - uint8 var_03; // 0x03 , 0x1D + uint8 var_02; // 0x02 , 0x1C, Appears to be unused, except as a temporary variable in RCT2 (not needed for OpenRCT2) + uint8 var_03; // 0x03 , 0x1D, Appears to be unused, except as a temporary variable in RCT2 (not needed for OpenRCT2) uint32 spacing; // 0x04 , 0x1E uint16 car_friction; // 0x08 , 0x22 sint8 tab_height; // 0x0A , 0x24