From 641dd1613a63b4cf976380ab96bf533966029b3f Mon Sep 17 00:00:00 2001 From: iTNTPiston Date: Fri, 29 Jan 2021 15:49:49 -0500 Subject: [PATCH] EventInfoData --- data/uking_functions.csv | 18 +++--- src/KingSystem/Event/CMakeLists.txt | 2 + src/KingSystem/Event/evtInfoData.cpp | 72 ++++++++++++++++++++++++ src/KingSystem/Event/evtInfoData.h | 34 +++++++++++ src/KingSystem/Resource/resLoadRequest.h | 4 +- 5 files changed, 120 insertions(+), 10 deletions(-) create mode 100644 src/KingSystem/Event/evtInfoData.cpp create mode 100644 src/KingSystem/Event/evtInfoData.h diff --git a/data/uking_functions.csv b/data/uking_functions.csv index 08b8dd4c..cfc31bfa 100644 --- a/data/uking_functions.csv +++ b/data/uking_functions.csv @@ -75495,15 +75495,15 @@ 0x0000007100daeba8,sub_7100DAEBA8,264, 0x0000007100daecb0,sub_7100DAECB0,112, 0x0000007100daed20,sub_7100DAED20,92, -0x0000007100daed7c,sub_7100DAED7C,100, -0x0000007100daede0,sub_7100DAEDE0,108, -0x0000007100daee4c,EventInfoData::createInstance,160, -0x0000007100daeeec,sub_7100DAEEEC,80, -0x0000007100daef3c,sub_7100DAEF3C,88, -0x0000007100daef94,sub_7100DAEF94,324, -0x0000007100daf0d8,EventInfoData::init,8, -0x0000007100daf0e0,EventInfoData::getEntry,292, -0x0000007100daf204,EventInfoData::getSceneChangeEventTraverseLimit,256, +0x0000007100daed7c,sub_7100DAED7C,100,_ZN4ksys3evt8InfoData18SingletonDisposer_D2Ev +0x0000007100daede0,sub_7100DAEDE0,108,_ZN4ksys3evt8InfoData18SingletonDisposer_D0Ev +0x0000007100daee4c,EventInfoData::createInstance,160,_ZN4ksys3evt8InfoData14createInstanceEPN4sead4HeapE +0x0000007100daeeec,sub_7100DAEEEC,80,_ZN4ksys3evt8InfoDataD1Ev +0x0000007100daef3c,sub_7100DAEF3C,88,_ZN4ksys3evt8InfoDataD0Ev +0x0000007100daef94,EventInfoData::doInit,324,_ZN4ksys3evt8InfoData6doInitEPN4sead4HeapEPNS_12OverlayArenaE +0x0000007100daf0d8,EventInfoData::init,8,_ZN4ksys3evt8InfoData4initEPN4sead4HeapE +0x0000007100daf0e0,EventInfoData::getEntry,292,_ZN4ksys3evt8InfoData8getEntryEPN2al9ByamlIterERKN4sead14SafeStringBaseIcEES9_ +0x0000007100daf204,EventInfoData::getSceneChangeEventTraverseLimit,256,_ZN4ksys3evt8InfoData32getSceneChangeEventTraverseLimitERKN4sead14SafeStringBaseIcEE 0x0000007100daf304,nullsub_3835,4, 0x0000007100daf308,sub_7100DAF308,100, 0x0000007100daf36c,sub_7100DAF36C,108, diff --git a/src/KingSystem/Event/CMakeLists.txt b/src/KingSystem/Event/CMakeLists.txt index cd1f47d5..0de91345 100644 --- a/src/KingSystem/Event/CMakeLists.txt +++ b/src/KingSystem/Event/CMakeLists.txt @@ -1,6 +1,8 @@ target_sources(uking PRIVATE evtEvent.cpp evtEvent.h + evtInfoData.cpp + evtInfoData.h evtManager.cpp evtManager.h ) diff --git a/src/KingSystem/Event/evtInfoData.cpp b/src/KingSystem/Event/evtInfoData.cpp new file mode 100644 index 00000000..03762193 --- /dev/null +++ b/src/KingSystem/Event/evtInfoData.cpp @@ -0,0 +1,72 @@ +#include "KingSystem/Event/evtInfoData.h" +#include +#include +#include +#include "KingSystem/Resource/resHandle.h" +#include "KingSystem/Resource/resLoadRequest.h" +#include "KingSystem/Utils/Byaml/Byaml.h" + +namespace ksys::evt { + +SEAD_SINGLETON_DISPOSER_IMPL(InfoData) + +InfoData::InfoData() = default; + +void InfoData::init(sead::Heap* heap) { + doInit(heap, nullptr); +} + +void InfoData::doInit(sead::Heap* heap, OverlayArena* arena) { + ksys::res::LoadRequest load_request; + + load_request.mRequester = "evt::InfoData"; + load_request._22 = true; + load_request.mArena = arena; + + mHandle.load("Event/EventInfo.product.byml", &load_request, nullptr); + auto* resource = sead::DynamicCast(mHandle.getResource()); + + if (mRootIter) + delete mRootIter; + + mRootIter = new (heap) al::ByamlIter(resource->getRawData()); +} + +InfoData::~InfoData() { + if (mRootIter) + delete mRootIter; + + if (_80) { + delete _80; + } +} + +bool InfoData::getEntry(al::ByamlIter* iter, const sead::SafeString& event_flow_name, + const sead::SafeString& entry_point) { + sead::FixedSafeString<256> formatted_key; + + if (entry_point.isEmpty()) { + formatted_key.format("%s<%s>", event_flow_name.cstr(), event_flow_name.cstr()); + } else { + formatted_key.format("%s<%s>", event_flow_name.cstr(), entry_point.cstr()); + } + + return mRootIter->tryGetIterByKey(iter, formatted_key.cstr()); +} + +bool InfoData::getSceneChangeEventTraverseLimit(const sead::SafeString& event_flow_name) { + if (event_flow_name != "ClearRemains") { + al::ByamlIter dict; + if (!getEntry(&dict, event_flow_name, "")) { + return false; + } + + f32 value{}; + if (!(dict.tryGetFloatByKey(&value, "traverse_limit") && value > 0.0)) { + return false; + } + } + return true; +} + +} // namespace ksys::evt diff --git a/src/KingSystem/Event/evtInfoData.h b/src/KingSystem/Event/evtInfoData.h new file mode 100644 index 00000000..21c8d1bf --- /dev/null +++ b/src/KingSystem/Event/evtInfoData.h @@ -0,0 +1,34 @@ +#pragma once + +#include +#include +#include "KingSystem/Resource/resHandle.h" +#include "KingSystem/Resource/resLoadRequest.h" +#include "KingSystem/Utils/Byaml/Byaml.h" + +namespace ksys::evt { + +class InfoDataUnknownType { +public: + virtual ~InfoDataUnknownType(); +}; + +class InfoData { + SEAD_SINGLETON_DISPOSER(InfoData) + InfoData(); + virtual ~InfoData(); + +public: + bool getEntry(al::ByamlIter* iter, const sead::SafeString& event_flow_name, + const sead::SafeString& entry_point); + bool getSceneChangeEventTraverseLimit(const sead::SafeString& event_flow_name); + void init(sead::Heap* heap); + +private: + void doInit(sead::Heap* heap, OverlayArena* arena); + al::ByamlIter* mRootIter = nullptr; + ksys::res::Handle mHandle; + InfoDataUnknownType* _80 = nullptr; +}; + +} // namespace ksys::evt diff --git a/src/KingSystem/Resource/resLoadRequest.h b/src/KingSystem/Resource/resLoadRequest.h index 048bc306..13892170 100644 --- a/src/KingSystem/Resource/resLoadRequest.h +++ b/src/KingSystem/Resource/resLoadRequest.h @@ -3,6 +3,7 @@ #include #include #include +#include #include "KingSystem/Utils/Types.h" namespace sead { @@ -15,9 +16,10 @@ class OverlayArena; namespace ksys::res { -class EntryFactoryBase; class Handle; +class EntryFactoryBase; + class ILoadRequest { SEAD_RTTI_BASE(ILoadRequest) public: