From ac080494721576bce440ef96810f459281080625 Mon Sep 17 00:00:00 2001 From: ZehMatt Date: Tue, 27 Jul 2021 20:40:19 +0300 Subject: [PATCH] Adapt SV6 import and export for peep path-finding data --- src/openrct2/rct2/S6Exporter.cpp | 21 +++++++++++++++++++-- src/openrct2/rct2/S6Importer.cpp | 26 ++++++++++++++++++++++++-- 2 files changed, 43 insertions(+), 4 deletions(-) diff --git a/src/openrct2/rct2/S6Exporter.cpp b/src/openrct2/rct2/S6Exporter.cpp index 9388d6e41b..984a8d8bd6 100644 --- a/src/openrct2/rct2/S6Exporter.cpp +++ b/src/openrct2/rct2/S6Exporter.cpp @@ -1343,10 +1343,27 @@ void S6Exporter::ExportEntityPeep(RCT2SpritePeep* dst, const Peep* src) dst->id = src->Id; dst->path_check_optimisation = src->PathCheckOptimisation; dst->peep_flags = src->PeepFlags; - dst->pathfind_goal = src->PathfindGoal; + if (src->PathfindGoal.isNull()) + { + dst->pathfind_goal = { 0xFF, 0xFF, 0xFF, INVALID_DIRECTION }; + } + else + { + dst->pathfind_goal = { static_cast(src->PathfindGoal.x), static_cast(src->PathfindGoal.y), + static_cast(src->PathfindGoal.z), src->PathfindGoal.direction }; + } for (size_t i = 0; i < std::size(src->PathfindHistory); i++) { - dst->pathfind_history[i] = src->PathfindHistory[i]; + if (src->PathfindHistory[i].isNull()) + { + dst->pathfind_history[i] = { 0xFF, 0xFF, 0xFF, INVALID_DIRECTION }; + } + else + { + dst->pathfind_history[i] = { static_cast(src->PathfindHistory[i].x), + static_cast(src->PathfindHistory[i].y), + static_cast(src->PathfindHistory[i].z), src->PathfindHistory[i].direction }; + } } dst->no_action_frame_num = src->WalkingFrameNum; } diff --git a/src/openrct2/rct2/S6Importer.cpp b/src/openrct2/rct2/S6Importer.cpp index f4763855b4..ee7525c4a5 100644 --- a/src/openrct2/rct2/S6Importer.cpp +++ b/src/openrct2/rct2/S6Importer.cpp @@ -1365,6 +1365,10 @@ public: void ImportEntityPeep(Peep* dst, const RCT2SpritePeep* src) { + const auto isNullLocation = [](const rct12_xyzd8& pos) { + return pos.x == 0xFF && pos.y == 0xFF && pos.z == 0xFF && pos.direction == INVALID_DIRECTION; + }; + ImportEntityCommonProperties(static_cast(dst), src); if (is_user_string_id(src->name_string_idx)) { @@ -1401,10 +1405,28 @@ public: dst->Id = src->id; dst->PathCheckOptimisation = src->path_check_optimisation; dst->PeepFlags = src->peep_flags; - dst->PathfindGoal = src->pathfind_goal; + if (isNullLocation(src->pathfind_goal)) + { + dst->PathfindGoal.setNull(); + dst->PathfindGoal.direction = INVALID_DIRECTION; + } + else + { + dst->PathfindGoal = { src->pathfind_goal.x, src->pathfind_goal.y, src->pathfind_goal.z, + src->pathfind_goal.direction }; + } for (size_t i = 0; i < std::size(src->pathfind_history); i++) { - dst->PathfindHistory[i] = src->pathfind_history[i]; + if (isNullLocation(src->pathfind_history[i])) + { + dst->PathfindHistory[i].setNull(); + dst->PathfindHistory[i].direction = INVALID_DIRECTION; + } + else + { + dst->PathfindHistory[i] = { src->pathfind_history[i].x, src->pathfind_history[i].y, src->pathfind_history[i].z, + src->pathfind_history[i].direction }; + } } dst->WalkingFrameNum = src->no_action_frame_num; }