1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2025-12-10 09:32:29 +01:00

Fix waypoints for json changes

This commit is contained in:
duncanspumpkin
2018-04-08 13:56:21 +01:00
parent 765500adfa
commit e954865b49
3 changed files with 16 additions and 29 deletions

View File

@@ -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<sint8>() == 0 ? peep_loading_type::xy_1 : peep_loading_type::xy_2;
_legacyType.vehicles[i].peep_loading_waypoint_segments = stream->ReadValue<sint8>() == 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<sint8>(numPeepLoadingPositions);
_peepLoadingPositions[i] = std::vector<sint8>(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<sLocationXY8, 3> 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);
}
}
}

View File

@@ -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;

View File

@@ -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<std::array<sLocationXY8, 3> > peep_loading_waypoints;
std::vector<sint8> peep_loading_positions; // previously 0x61 , 0x7B
peep_loading_type peep_loading_xy_type;
uint8 peep_loading_waypoint_segments;
};
#ifdef __TESTPAINT__
#pragma pack(pop)