From 1a9ef29ac53bc38b22ce0f9131c0f123eca3b6b9 Mon Sep 17 00:00:00 2001 From: Malkierian Date: Mon, 15 May 2023 17:32:49 -0700 Subject: [PATCH] Added function to get sectionID for a specified section name, returning -1 if section name not registered. --- soh/soh/SaveManager.cpp | 9 +++++++++ soh/soh/SaveManager.h | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/soh/soh/SaveManager.cpp b/soh/soh/SaveManager.cpp index 2f8c52759..97f09bd74 100644 --- a/soh/soh/SaveManager.cpp +++ b/soh/soh/SaveManager.cpp @@ -885,6 +885,15 @@ void SaveManager::AddPostFunction(const std::string& name, PostFunc func) { postHandlers[name] = func; } +// Returns -1 if section name not found +int SaveManager::GetSaveSectionID(std::string& sectionName) { + if (sectionRegistry.contains(sectionName)) { + return sectionRegistry.find(sectionName)->second; + } else { + return -1; + } +} + void SaveManager::CreateDefaultGlobal() { gSaveContext.audioSetting = 0; gSaveContext.zTargetSetting = 0; diff --git a/soh/soh/SaveManager.h b/soh/soh/SaveManager.h index 56c3692ba..e4c11b838 100644 --- a/soh/soh/SaveManager.h +++ b/soh/soh/SaveManager.h @@ -65,6 +65,7 @@ public: void InitFile(bool isDebug); void SaveFile(int fileNum); void SaveSection(int fileNum, int sectionID); + int GetSaveSectionID(std::string& name); void SaveGlobal(); void LoadFile(int fileNum); bool SaveFile_Exist(int fileNum); @@ -162,7 +163,7 @@ public: int sectionIndex = SECTION_ID_MAX; std::map coreSectionIDsByName; std::map sectionSaveHandlers; - std::set sectionRegistry; + std::map sectionRegistry; std::map postHandlers;