From e954865b496cd4d4ae567fc3a89dae336bfc07f0 Mon Sep 17 00:00:00 2001 From: duncanspumpkin Date: Sun, 8 Apr 2018 13:56:21 +0100 Subject: [PATCH] Fix waypoints for json changes --- src/openrct2/object/RideObject.cpp | 35 ++++++++++++------------------ src/openrct2/peep/Peep.cpp | 2 +- src/openrct2/ride/Vehicle.h | 8 +------ 3 files changed, 16 insertions(+), 29 deletions(-) diff --git a/src/openrct2/object/RideObject.cpp b/src/openrct2/object/RideObject.cpp index 7c50ed3f17..98c3f85e61 100644 --- a/src/openrct2/object/RideObject.cpp +++ b/src/openrct2/object/RideObject.cpp @@ -104,7 +104,11 @@ void RideObject::ReadLegacy(IReadObjectContext * context, IStream * stream) if (_legacyType.vehicles[i].flags & VEHICLE_ENTRY_FLAG_LOADING_WAYPOINTS) { - _legacyType.vehicles[i].peep_loading_xy_type = stream->ReadValue() == 0 ? peep_loading_type::xy_1 : peep_loading_type::xy_2; + _legacyType.vehicles[i].peep_loading_waypoint_segments = stream->ReadValue() == 0 ? 0 : 4; + if (_legacyType.ride_type[0] == RIDE_TYPE_ENTERPRISE) + { + _legacyType.vehicles[i].peep_loading_waypoint_segments = 8; + } Guard::Assert(((numPeepLoadingPositions - 1) % 8) == 0, "Malformed peep loading positions"); @@ -124,7 +128,7 @@ void RideObject::ReadLegacy(IReadObjectContext * context, IStream * stream) } else { - _legacyType.vehicles[i].peep_loading_xy_type = peep_loading_type::normal; + _legacyType.vehicles[i].peep_loading_waypoint_segments = 0; auto data = stream->ReadArray(numPeepLoadingPositions); _peepLoadingPositions[i] = std::vector(data, data + numPeepLoadingPositions); @@ -764,25 +768,15 @@ rct_ride_entry_vehicle RideObject::ReadJsonCar(const json_t * jCar) } else { + auto& peepLoadingWaypoints = car.peep_loading_waypoints; auto jLoadingWaypoints = json_object_get(jCar, "loadingWaypoints"); if (json_is_array(jLoadingWaypoints)) { car.flags |= VEHICLE_ENTRY_FLAG_LOADING_WAYPOINTS; auto numSegments = ObjectJsonHelpers::GetInteger(jCar, "numSegments"); - if (numSegments == 8) - { - peepLoadingPositions.push_back(1); - } - else if (numSegments == 4) - { - peepLoadingPositions.push_back(1); - } - else - { - peepLoadingPositions.push_back(0); - } - + car.peep_loading_waypoint_segments = numSegments; + size_t i; json_t * route; json_array_foreach(jLoadingWaypoints, i, route) @@ -791,18 +785,17 @@ rct_ride_entry_vehicle RideObject::ReadJsonCar(const json_t * jCar) { size_t j; json_t * waypoint; + std::array entry; json_array_foreach(route, j, waypoint) { if (json_is_array(waypoint) && json_array_size(waypoint) >= 2) { - auto x = json_integer_value(json_array_get(waypoint, 0)); - auto y = json_integer_value(json_array_get(waypoint, 1)); - peepLoadingPositions.push_back(x); - peepLoadingPositions.push_back(y); + auto x = (sint8)json_integer_value(json_array_get(waypoint, 0)); + auto y = (sint8)json_integer_value(json_array_get(waypoint, 1)); + entry[j] = { x, y }; } } - peepLoadingPositions.push_back(0); - peepLoadingPositions.push_back(0); + peepLoadingWaypoints.push_back(entry); } } } diff --git a/src/openrct2/peep/Peep.cpp b/src/openrct2/peep/Peep.cpp index a30b6ebff2..c8c4c944d7 100644 --- a/src/openrct2/peep/Peep.cpp +++ b/src/openrct2/peep/Peep.cpp @@ -2946,7 +2946,7 @@ static uint8 peep_get_waypointed_seat_location(rct_peep * peep, Ride * ride, rct // Type 1 loading doesn't do segments and all peeps go to the same // location on the ride - if (vehicle_type->peep_loading_xy_type == peep_loading_type::xy_1) + if (vehicle_type->peep_loading_waypoint_segments == 0) { track_direction /= 2; seatLocationSegment = 0; diff --git a/src/openrct2/ride/Vehicle.h b/src/openrct2/ride/Vehicle.h index 5d6f64da96..e1632ed39e 100644 --- a/src/openrct2/ride/Vehicle.h +++ b/src/openrct2/ride/Vehicle.h @@ -28,12 +28,6 @@ struct rct_vehicle_colour { uint8 trim_colour; }; -enum class peep_loading_type { - normal, - xy_1, - xy_2 -}; - #ifdef __TESTPAINT__ #pragma pack(push, 1) #endif // __TESTPAINT__ @@ -90,7 +84,7 @@ struct rct_ride_entry_vehicle { uint8 pad_61[7]; // 0x61 , 0x7B std::vector > peep_loading_waypoints; std::vector peep_loading_positions; // previously 0x61 , 0x7B - peep_loading_type peep_loading_xy_type; + uint8 peep_loading_waypoint_segments; }; #ifdef __TESTPAINT__ #pragma pack(pop)