Added function to get sectionID for a specified section name, returning -1 if section name not registered.

This commit is contained in:
Malkierian 2023-05-15 17:32:49 -07:00
parent 50fbe5d00c
commit 1a9ef29ac5
2 changed files with 11 additions and 1 deletions

View File

@ -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;

View File

@ -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<std::string, int> coreSectionIDsByName;
std::map<int, SaveFuncInfo> sectionSaveHandlers;
std::set<std::string> sectionRegistry;
std::map<std::string, int> sectionRegistry;
std::map<std::string, PostFunc> postHandlers;