From 06eda5305ff44835a478790d28af31d98f75c812 Mon Sep 17 00:00:00 2001 From: Belonit <54427022+Belonit@users.noreply.github.com> Date: Sat, 17 Feb 2024 09:26:51 +0300 Subject: [PATCH] Add SavedGameDir option spawn.ini->[Settings]->SavedGameDir=Saved Games --- src/Misc/SavedGamesInSubdir.cpp | 9 +++------ src/Spawner/Spawner.Config.cpp | 1 + src/Spawner/Spawner.Config.h | 2 ++ 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Misc/SavedGamesInSubdir.cpp b/src/Misc/SavedGamesInSubdir.cpp index 8652d990..1d179e54 100644 --- a/src/Misc/SavedGamesInSubdir.cpp +++ b/src/Misc/SavedGamesInSubdir.cpp @@ -26,15 +26,12 @@ namespace SavedGames { - constexpr auto DirName = "Saved Games"; // Nested paths are also supported, e.g. "Saved Games\\Yuri's Revenge" - constexpr auto FileNamePrefixFormat = "%s\\%s"; - inline bool CreateSubdir() { - if (!std::filesystem::exists(SavedGames::DirName)) + if (!std::filesystem::exists(Spawner::GetConfig()->SavedGameDir)) { Debug::Log("\n[Spawner] Folder Saved Games does not exist, creating...\n"); - if (!std::filesystem::create_directories(SavedGames::DirName)) + if (!std::filesystem::create_directories(Spawner::GetConfig()->SavedGameDir)) { Debug::Log("\tCannot create folder Saved Games!\n"); return false; @@ -46,7 +43,7 @@ namespace SavedGames inline void FormatPath(char* buffer, const char* pFileName) { - sprintf(buffer, SavedGames::FileNamePrefixFormat, SavedGames::DirName, pFileName); + sprintf(buffer, "%s\\%s", Spawner::GetConfig()->SavedGameDir, pFileName); } } diff --git a/src/Spawner/Spawner.Config.cpp b/src/Spawner/Spawner.Config.cpp index cf1188aa..eca1549a 100644 --- a/src/Spawner/Spawner.Config.cpp +++ b/src/Spawner/Spawner.Config.cpp @@ -53,6 +53,7 @@ void SpawnerConfig::LoadFromINIFile(CCINIClass* pINI) // SaveGame Options LoadSaveGame = pINI->ReadBool(pSettingsSection, "LoadSaveGame", LoadSaveGame); + /* SavedGameDir */ pINI->ReadString(pSettingsSection, "SavedGameDir", SavedGameDir, SavedGameDir, sizeof(SavedGameDir)); /* SaveGameName */ pINI->ReadString(pSettingsSection, "SaveGameName", SaveGameName, SaveGameName, sizeof(SaveGameName)); { // Scenario Options diff --git a/src/Spawner/Spawner.Config.h b/src/Spawner/Spawner.Config.h index e65ba726..73f5cceb 100644 --- a/src/Spawner/Spawner.Config.h +++ b/src/Spawner/Spawner.Config.h @@ -92,6 +92,7 @@ class SpawnerConfig // SaveGame Options bool LoadSaveGame; + char SavedGameDir[MAX_PATH]; // Nested paths are also supported, e.g. "Saved Games\\Yuri's Revenge" char SaveGameName[60]; // Scenario Options @@ -158,6 +159,7 @@ class SpawnerConfig // SaveGame , LoadSaveGame { false } + , SavedGameDir { "Saved Games" } , SaveGameName { "" } // Scenario Options