diff options
| author | notyourav <65437533+notyourav@users.noreply.github.com> | 2022-01-23 00:33:57 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-01-23 00:33:57 -0800 |
| commit | 3f793b24d94cff8a33367fcab974ea263170b30a (patch) | |
| tree | 68bce3fbd359b6822a592f90716b279a2882aa9e /src | |
| parent | c1f24f5b9129f328c28fa2d8643c4d1bbe36791a (diff) | |
| parent | d11a43df2511c60454fb50cd22f548d77e7ddacc (diff) | |
Merge pull request #75 from savage13/PlacementMap
Add PlacementMap, stubs: PlacementMapMgr and PlacementMapMgrMapArray
Diffstat (limited to 'src')
| -rw-r--r-- | src/KingSystem/Map/CMakeLists.txt | 4 | ||||
| -rw-r--r-- | src/KingSystem/Map/mapPlacementMap.cpp | 36 | ||||
| -rw-r--r-- | src/KingSystem/Map/mapPlacementMap.h | 131 | ||||
| -rw-r--r-- | src/KingSystem/Map/mapPlacementMapMgr.cpp | 3 | ||||
| -rw-r--r-- | src/KingSystem/Map/mapPlacementMapMgr.h | 58 | ||||
| -rw-r--r-- | src/KingSystem/Physics/StaticCompound/physStaticCompound.h | 3 |
6 files changed, 235 insertions, 0 deletions
diff --git a/src/KingSystem/Map/CMakeLists.txt b/src/KingSystem/Map/CMakeLists.txt index 9bf05203..4c612d59 100644 --- a/src/KingSystem/Map/CMakeLists.txt +++ b/src/KingSystem/Map/CMakeLists.txt @@ -14,6 +14,10 @@ target_sources(uking PRIVATE mapObjectLink.h mapPlacementActors.cpp mapPlacementActors.h + mapPlacementMap.cpp + mapPlacementMap.h + mapPlacementMapMgr.cpp + mapPlacementMapMgr.h mapPlacementMgr.cpp mapPlacementMgr.h mapPlacementTree.cpp diff --git a/src/KingSystem/Map/mapPlacementMap.cpp b/src/KingSystem/Map/mapPlacementMap.cpp new file mode 100644 index 00000000..ea3531d1 --- /dev/null +++ b/src/KingSystem/Map/mapPlacementMap.cpp @@ -0,0 +1,36 @@ +#include "KingSystem/Map/mapPlacementMap.h" + +namespace ksys::map { + +PlacementMap::PlacementMap() { + mInitStatus = InitStatus::None; + mParsedNumStaticObjs = 0xFFFFFFFF; + mStaticMapLoaded = StaticMap::None; + mNumStaticObjs = 0xFFFFFFFF; + mMat = sead::Matrix34f::ident; + mDistanceToCurrentMapUnit = 0; + mSkipLoadStaticMap = 0; + _38c = 0xFFFFFFFF; + mIdx = 0; + _388 = 0; + mCol = 0; + mRow = 0; + mNumRoutes = 0; + mP18 = 0; + mMgr = 0; + mPa = 0; + mDynamicGroupIdx = 0xFFFFFFFF; + mRes[0].mStatus = HkscRes::Status::_0; + mRes[1].mStatus = HkscRes::Status::_0; + mRes[2].mStatus = HkscRes::Status::_0; + mRes[3].mStatus = HkscRes::Status::_0; +} + +PlacementMap::~PlacementMap() { + mRoutes.freeBuffer(); + for (auto& r : mRes) { + r.cleanup(); + } +} + +} // namespace ksys::map diff --git a/src/KingSystem/Map/mapPlacementMap.h b/src/KingSystem/Map/mapPlacementMap.h new file mode 100644 index 00000000..91ae9013 --- /dev/null +++ b/src/KingSystem/Map/mapPlacementMap.h @@ -0,0 +1,131 @@ +#pragma once + +#include <basis/seadTypes.h> +#include <container/seadBuffer.h> +#include <container/seadPtrArray.h> +#include <container/seadSafeArray.h> +#include <heap/seadHeap.h> +#include <math/seadMatrix.h> +#include <prim/seadSafeString.h> +#include "KingSystem/Map/mapPlacementActors.h" +#include "KingSystem/Map/mapPlacementMapMgr.h" +#include "KingSystem/Physics/StaticCompound/physStaticCompound.h" +#include "KingSystem/Resource/resHandle.h" +#include "KingSystem/Utils/Types.h" + +namespace ksys::map { + +class PlacementMapMgr; + +class PlacementMap { + struct HkscRes { + public: + enum class Status : int { + _0 = 0, + _1 = 1, + _2 = 2, // Call cleanupHkscMaybe(), if ok, set to 3 + _3 = 3, + _4 = 4, // Call staticCompoundStuff, if ok, set to 5 + _5 = 5, + }; + + HkscRes() = default; + ~HkscRes() = default; + + void cleanup() { + auto* r = mRes.getResource(); + if (auto sc = sead::DynamicCast<phys::StaticCompound>(r)) { + if (sc->calledFromMapDtor()) { + sc->cleanUp(); + } + } + } + + res::Handle mRes; + Status mStatus; + }; + KSYS_CHECK_SIZE_NX150(HkscRes, 0x58); + + enum class StaticMap : u16 { None = 0, Loaded = 1 << 0, Parsed = 1 << 8 }; + enum class InitStatus : int { + None = 0, + StaticLoaded = 1, + DynamicLoadStarted = 2, + DynamicLoaded = 3, + _4 = 4, + _5 = 5, // x_9 takes initStatus from 4 to 5 in pmm->updateHkscLoadStatuesMaybe() + }; + KSYS_CHECK_SIZE_NX150(InitStatus, 4); + +public: + PlacementMap(); + ~PlacementMap(); + +private: + int loadStaticMap_(bool load); + void doLoadStaticMap_(bool load); + + bool parseStaticMap_(sead::Heap* heap, u8* data); + void parseMap_(sead::Heap* heap, u8* data, int group, u32 idx); + + bool loadDynamicMap(); + + int parseDynamicMap(); + + void resetDynamic(); + void unload(); + void unloadStaticMubin(); + int x_6(); + void x_5(); + int traverseStuff(sead::Vector3f* vec, PlacementActors* pa, int id); + + phys::BodyGroup* getFieldBodyGroup(u32 field_body_group_index); + void cleanupPhysics(); + bool loadStaticCompound(int index, bool is_auto_gen_mu, bool load_maybe); + int x_2(int id); + void x(int id, Object* obj); + void unloadHksc(int id); + int x_4(int id); + int x_1(int id); + bool staticCompoundStuff(int sc_id, bool cleanup); + int cleanHkscMaybe(int id); + bool sub_7100D43F18(const sead::Vector3f& pos); + void doDisableObjStaticCompound(Object* obj, bool disable); + void x_9(); + + void x_7(int idx, int unknown, char column, char row, const sead::SafeString& mubinPath, + const sead::SafeString& folderAndFile, int map_id_maybe, bool skip_load_static_map); + + u16 mSkipLoadStaticMap; + StaticMap mStaticMapLoaded; + u16 _04; + s16 _06; + sead::FixedSafeString<128> mMubinPath; + sead::FixedSafeString<128> mFolderAndFile; + u32 mIdx; + sead::SafeArray<HkscRes, 4> mRes; + res::Handle mStaticMubinRes; + res::Handle mDynamicMubinRes; + int mDynamicGroupIdx; + int mParsedNumStaticObjs; + int mNumStaticObjs; + InitStatus mInitStatus; + s8 mCol; + s8 mRow; + u16 _352; + sead::Matrix34f mMat; + int mDistanceToCurrentMapUnit; + u32 _388; // 388 check x_7() called .... + u32 _38c; // 38c ... from MapMgr::ctor (a8) + PlacementActors* mPa; + PlacementMapMgr* mMgr; + void* mP18; + sead::Buffer<void*> mRoutes; + int mNumRoutes; + int gap_38c; + sead::CriticalSection mCs; +}; + +KSYS_CHECK_SIZE_NX150(PlacementMap, 0x400); + +} // namespace ksys::map diff --git a/src/KingSystem/Map/mapPlacementMapMgr.cpp b/src/KingSystem/Map/mapPlacementMapMgr.cpp new file mode 100644 index 00000000..3ab81e10 --- /dev/null +++ b/src/KingSystem/Map/mapPlacementMapMgr.cpp @@ -0,0 +1,3 @@ +#include "KingSystem/Map/mapPlacementMapMgr.h" + +namespace ksys::map {} // namespace ksys::map diff --git a/src/KingSystem/Map/mapPlacementMapMgr.h b/src/KingSystem/Map/mapPlacementMapMgr.h new file mode 100644 index 00000000..ce86eceb --- /dev/null +++ b/src/KingSystem/Map/mapPlacementMapMgr.h @@ -0,0 +1,58 @@ +#pragma once + +#include <basis/seadTypes.h> +#include <container/seadBuffer.h> +#include <container/seadPtrArray.h> +#include <heap/seadDisposer.h> +#include "KingSystem/Map/mapPlacementMap.h" +#include "KingSystem/Resource/resHandle.h" +#include "KingSystem/Utils/Types.h" + +namespace ksys::map { + +class MapProperties; +class Placement18; +class FarActorMerge; + +class PlacementMap; + +/* NOT WORKING */ +class PlacementMapMgr { + /* NOT WORKING */ + class PlacementMapArray { + public: + PlacementMapArray() = default; + ~PlacementMapArray() = default; + + sead::PtrArray<PlacementMap> mMaps; + sead::PtrArray<PlacementMap> mPtrs; + PlacementActors* mPa; + s64 _28; + res::Handle mRes; + Placement18* mP18; + s32 _88; + s32 _8c; + void* _90; + }; + KSYS_CHECK_SIZE_NX150(PlacementMapArray, 0x98); + +public: + PlacementMapMgr() = default; + ~PlacementMapMgr() = default; + +private: + sead::Buffer<PlacementMap> mMaps; + MapProperties* mMapProps; + s32 _18; + s32 _1c; + PlacementMapArray mMapArray; + FarActorMerge* mFarActorMerge; + s32 mNeedLoadDynMap; + s32 mNeedLoadDynMapPhysics; + bool mIsShrineOrDivineBeast; + bool mIsShrine; +}; + +KSYS_CHECK_SIZE_NX150(PlacementMapMgr, 0xD0); + +} // namespace ksys::map diff --git a/src/KingSystem/Physics/StaticCompound/physStaticCompound.h b/src/KingSystem/Physics/StaticCompound/physStaticCompound.h index 397e55c8..c03d68eb 100644 --- a/src/KingSystem/Physics/StaticCompound/physStaticCompound.h +++ b/src/KingSystem/Physics/StaticCompound/physStaticCompound.h @@ -41,6 +41,9 @@ public: bool finishParsing_() override; bool m7_() override; + void cleanUp(); + bool calledFromMapDtor(); + private: enum class Flag { Initialised = 1 << 0, |
