Skip to content

Commit

Permalink
Add SavedGameDir option
Browse files Browse the repository at this point in the history
 spawn.ini->[Settings]->SavedGameDir=Saved Games
  • Loading branch information
Belonit committed Feb 17, 2024
1 parent daa4feb commit 06eda53
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/Misc/SavedGamesInSubdir.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}
}

Expand Down
1 change: 1 addition & 0 deletions src/Spawner/Spawner.Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/Spawner/Spawner.Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -158,6 +159,7 @@ class SpawnerConfig

// SaveGame
, LoadSaveGame { false }
, SavedGameDir { "Saved Games" }
, SaveGameName { "" }

// Scenario Options
Expand Down

0 comments on commit 06eda53

Please sign in to comment.