From fd58eef21e2e1b9fbda47a7358469ad5c5dbe2c7 Mon Sep 17 00:00:00 2001 From: Luis Michaelis Date: Tue, 5 Dec 2023 15:42:59 +0100 Subject: [PATCH] fix(Archive): add missing includes and remove `reinterpret_pointer_cast` ... since the NDK does not seem to support it :( --- include/zenkit/Archive.hh | 4 +++- src/vobs/VirtualObject.cc | 12 ++++++++---- src/world/VobTree.cc | 3 ++- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/include/zenkit/Archive.hh b/include/zenkit/Archive.hh index da1c06bb..c8519cb4 100644 --- a/include/zenkit/Archive.hh +++ b/include/zenkit/Archive.hh @@ -14,6 +14,7 @@ #include #include +#include #include namespace phoenix { @@ -153,7 +154,8 @@ namespace zenkit { throw ParserError {"ReadArchive", "Read unexcected object!"}; } - return std::reinterpret_pointer_cast(std::move(obj)); + // NOTE(lmichaelis): The NDK does not seem to support `reinterpret_pointer_cast`. + return std::shared_ptr(obj, reinterpret_cast(obj.get())); } std::shared_ptr read_object(GameVersion version); diff --git a/src/vobs/VirtualObject.cc b/src/vobs/VirtualObject.cc index 9b5fc491..49c7bd3e 100644 --- a/src/vobs/VirtualObject.cc +++ b/src/vobs/VirtualObject.cc @@ -150,13 +150,15 @@ namespace zenkit { this->visual->type = it->second; if (this->visual->type == VisualType::DECAL) { - this->visual_decal.emplace(*std::reinterpret_pointer_cast(this->visual)); + this->visual_decal.emplace(*reinterpret_cast(this->visual.get())); } } } if (has_ai_object) { - this->ai = std::reinterpret_pointer_cast(r.read_object(version)); + // NOTE(lmichaelis): The NDK does not seem to support `reinterpret_pointer_cast`. + auto obj = r.read_object(version); + this->ai = std::shared_ptr(obj, reinterpret_cast(obj.get())); } if (has_event_manager_object) { @@ -211,7 +213,9 @@ namespace zenkit { } void AiMove::load(ReadArchive& r, GameVersion version) { - vob = std::reinterpret_pointer_cast(r.read_object(version)); // vob - owner = r.read_object(version); // owner + // NOTE(lmichaelis): The NDK does not seem to support `reinterpret_pointer_cast`. + auto obj = r.read_object(version); + vob = std::shared_ptr(obj, reinterpret_cast(obj.get())); // vob + owner = r.read_object(version); // owner } } // namespace zenkit diff --git a/src/world/VobTree.cc b/src/world/VobTree.cc index e485358b..44478df0 100644 --- a/src/world/VobTree.cc +++ b/src/world/VobTree.cc @@ -9,7 +9,8 @@ namespace zenkit { auto obj = in.read_object(version); if (!is_vobject(obj->get_object_type())) return nullptr; - auto object = std::reinterpret_pointer_cast(obj); + // NOTE(lmichaelis): The NDK does not seem to support `reinterpret_pointer_cast`. + std::shared_ptr object {obj, reinterpret_cast(obj.get())}; auto child_count = static_cast(in.read_int()); if (object == nullptr) {