Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions BackEndLib/Files.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ WSTRING CFiles::wszDatPath;
WSTRING CFiles::wszResPath;
WSTRING CFiles::wCompanyName;
WSTRING CFiles::wGameName;
WSTRING CFiles::wGameConfName;
WSTRING CFiles::wGameVer;
WSTRING CFiles::wUniqueResFile;
UINT CFiles::dwRefCount = 0;
Expand Down Expand Up @@ -173,15 +174,16 @@ CFiles::CFiles(
const WCHAR *wszSetGameVer, //(in) game major version -- for finding resource files or paths
const bool bIsDemo, //(in) whether we should be looking for files for a demo version or not [default=false]
const bool confirm_resource_file,
const bool bIsRunningTests) //(in) set to true by test runner to ensure it uses its own dat files
const bool bIsRunningTests, //(in) set to true by test runner to ensure it uses its own dat files
const WCHAR *wszSetGameConfName) //(in) save folder name; NULL uses wszSetGameName
{
ASSERT(this->dwRefCount == 0);

ASSERT(wszSetAppPath != NULL);
ASSERT(wszSetGameName != NULL);
ASSERT(wszSetGameVer != NULL);

InitClass(wszSetAppPath, wszSetGameName, wszSetGameVer, bIsDemo, confirm_resource_file, bIsRunningTests);
InitClass(wszSetAppPath, wszSetGameName, wszSetGameVer, bIsDemo, confirm_resource_file, bIsRunningTests, wszSetGameConfName);

++this->dwRefCount;
}
Expand Down Expand Up @@ -411,7 +413,7 @@ const WSTRING CFiles::GetGameConfPathForName(const WCHAR *pwszGameName) {
}

const WSTRING CFiles::GetGameConfPath() {
return GetGameConfPathForName(CFiles::wGameName.c_str());
return GetGameConfPathForName(CFiles::wGameConfName.c_str());
}

#if defined(__APPLE__) && defined(STEAMBUILD) && !defined(STEAMBUILD_TSS_APP)
Expand Down Expand Up @@ -1070,7 +1072,8 @@ void CFiles::InitClass(
const WCHAR *wszSetGameVer, //(in)
const bool bIsDemo, //(in)
const bool confirm_resource_file,
const bool bIsRunningTests)
const bool bIsRunningTests,
const WCHAR *wszSetGameConfName) //(in) config subfolder name; NULL uses wszSetGameName
{
ASSERT(wszSetAppPath);
ASSERT(wszSetGameName);
Expand All @@ -1088,6 +1091,8 @@ void CFiles::InitClass(
//Get game name and version.
ASSERT(CFiles::wGameName.empty());
CFiles::wGameName = wszSetGameName;
ASSERT(CFiles::wGameConfName.empty());
CFiles::wGameConfName = wszSetGameConfName ? wszSetGameConfName : wszSetGameName;
ASSERT(this->wGameVer.empty());
CFiles::wGameVer = wszSetGameVer;

Expand Down Expand Up @@ -1362,6 +1367,7 @@ void CFiles::DeinitClass()
CFiles::wszResPath.resize(0);

CFiles::wGameName.resize(0);
CFiles::wGameConfName.resize(0);
CFiles::wGameVer.resize(0);
}

Expand Down
9 changes: 7 additions & 2 deletions BackEndLib/Files.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ class CFiles
CFiles(const WCHAR *wszSetAppPath,
const WCHAR *wszSetGameName, const WCHAR *wszSetGameVer,
const bool bIsDemo = false, const bool confirm_resource_file = true,
const bool bIsRunningTests = false);
const bool bIsRunningTests = false,
const WCHAR *wszSetGameConfName = NULL);
CFiles(); //may call this one after the class has been inited
~CFiles();

Expand Down Expand Up @@ -178,6 +179,9 @@ class CFiles
#endif

static WSTRING wCompanyName, wGameName, wGameVer, wUniqueResFile;
//Save-folder name; defaults to wGameName but can differ, so a build can use its
//own folder without changing the .dat/.ini/log names wGameName also determines.
static WSTRING wGameConfName;
static vector<string> datFiles, playerDataSubDirs;

static bool bad_data_path_file;
Expand Down Expand Up @@ -206,7 +210,8 @@ class CFiles
#endif
void InitClass(const WCHAR *pszSetAppPath,
const WCHAR *wszSetGameName, const WCHAR *wszSetGameVer, const bool bIsDemo,
const bool confirm_resource_file, const bool bIsRunningTests);
const bool confirm_resource_file, const bool bIsRunningTests,
const WCHAR *wszSetGameConfName = NULL);
static bool InitINI();
static void SetupHomePath();
static void SetupHomePathSubDirs();
Expand Down
10 changes: 6 additions & 4 deletions DROD/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,15 +291,17 @@ int main(int argc, char *argv[])
#endif

const WCHAR* gameName = wszDROD;
const WCHAR* gameConfName = NULL; //save folder; NULL means same as gameName
#ifdef STEAMBUILD_TSS_APP
const WCHAR wszDRODTSS[] = { We('d'),We('r'),We('o'),We('d'),We('-'),We('t'),We('s'),We('s'),We(0) };
gameName = wszDRODTSS;
#elif defined(__APPLE__) && defined(STEAMBUILD)
//The macOS Steam GatEB build uses a dedicated folder so it doesn't collide
//with the non-Steam TSS standalone build (both otherwise use "drod-5_0").
//Keep gameName "drod" (so it still loads drod5_0.dat) but give the macOS Steam
//GatEB build its own save folder, so it doesn't collide with the non-Steam TSS
//standalone build (both otherwise use "drod-5_0").
const WCHAR wszDRODGatEBSteam[] = { We('d'),We('r'),We('o'),We('d'),We('-'),
We('g'),We('a'),We('t'),We('e'),We('b'),We('-'),We('s'),We('t'),We('e'),We('a'),We('m'),We(0) };
gameName = wszDRODGatEBSteam;
gameConfName = wszDRODGatEBSteam;
#elif defined(KDD_STANDALONE)
const WCHAR wszDRODKDD[] = { We('d'),We('r'),We('o'),We('d'),We('-'),We('k'),We('d'),We('d'),We(0) };
gameName = wszDRODKDD;
Expand All @@ -313,7 +315,7 @@ int main(int argc, char *argv[])
const WCHAR wszDRODGatEB[] = { We('d'),We('r'),We('o'),We('d'),We('-'),We('g'),We('a'),We('t'),We('e'),We('b'),We(0) };
gameName = wszDRODGatEB;
#endif
m_pFiles = new CFiles(wstrPath.c_str(), gameName, wszDROD_VER, bIsDemo);
m_pFiles = new CFiles(wstrPath.c_str(), gameName, wszDROD_VER, bIsDemo, true, false, gameConfName);
if (CFiles::bad_data_path_file) {
DisplayInitErrorMessage(MID_DataPathDotTextFileIsInvalid);
}
Expand Down
Loading