Skip to content

Commit 0250013

Browse files
TomBrouwsmrimer
authored andcommitted
macOS: decouple the save-folder name from the resource .dat name
gameName drives both the save folder and CDbBase::BaseResourceFilename(), so giving the Steam GatEB build a dedicated folder made the DB look for "drod-gateb-steam5_0.dat" instead of the bundled "drod5_0.dat" and fail to start (MID_DatMissing). Add CFiles::wGameConfName (defaults to wGameName, used only by GetGameConfPath) so a build can choose its save folder without changing the .dat/.ini/log names.
1 parent 5c0c047 commit 0250013

3 files changed

Lines changed: 23 additions & 10 deletions

File tree

BackEndLib/Files.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ WSTRING CFiles::wszDatPath;
8484
WSTRING CFiles::wszResPath;
8585
WSTRING CFiles::wCompanyName;
8686
WSTRING CFiles::wGameName;
87+
WSTRING CFiles::wGameConfName;
8788
WSTRING CFiles::wGameVer;
8889
WSTRING CFiles::wUniqueResFile;
8990
UINT CFiles::dwRefCount = 0;
@@ -173,15 +174,16 @@ CFiles::CFiles(
173174
const WCHAR *wszSetGameVer, //(in) game major version -- for finding resource files or paths
174175
const bool bIsDemo, //(in) whether we should be looking for files for a demo version or not [default=false]
175176
const bool confirm_resource_file,
176-
const bool bIsRunningTests) //(in) set to true by test runner to ensure it uses its own dat files
177+
const bool bIsRunningTests, //(in) set to true by test runner to ensure it uses its own dat files
178+
const WCHAR *wszSetGameConfName) //(in) save folder name; NULL uses wszSetGameName
177179
{
178180
ASSERT(this->dwRefCount == 0);
179181

180182
ASSERT(wszSetAppPath != NULL);
181183
ASSERT(wszSetGameName != NULL);
182184
ASSERT(wszSetGameVer != NULL);
183185

184-
InitClass(wszSetAppPath, wszSetGameName, wszSetGameVer, bIsDemo, confirm_resource_file, bIsRunningTests);
186+
InitClass(wszSetAppPath, wszSetGameName, wszSetGameVer, bIsDemo, confirm_resource_file, bIsRunningTests, wszSetGameConfName);
185187

186188
++this->dwRefCount;
187189
}
@@ -411,7 +413,7 @@ const WSTRING CFiles::GetGameConfPathForName(const WCHAR *pwszGameName) {
411413
}
412414

413415
const WSTRING CFiles::GetGameConfPath() {
414-
return GetGameConfPathForName(CFiles::wGameName.c_str());
416+
return GetGameConfPathForName(CFiles::wGameConfName.c_str());
415417
}
416418

417419
#if defined(__APPLE__) && defined(STEAMBUILD) && !defined(STEAMBUILD_TSS_APP)
@@ -1070,7 +1072,8 @@ void CFiles::InitClass(
10701072
const WCHAR *wszSetGameVer, //(in)
10711073
const bool bIsDemo, //(in)
10721074
const bool confirm_resource_file,
1073-
const bool bIsRunningTests)
1075+
const bool bIsRunningTests,
1076+
const WCHAR *wszSetGameConfName) //(in) config subfolder name; NULL uses wszSetGameName
10741077
{
10751078
ASSERT(wszSetAppPath);
10761079
ASSERT(wszSetGameName);
@@ -1088,6 +1091,8 @@ void CFiles::InitClass(
10881091
//Get game name and version.
10891092
ASSERT(CFiles::wGameName.empty());
10901093
CFiles::wGameName = wszSetGameName;
1094+
ASSERT(CFiles::wGameConfName.empty());
1095+
CFiles::wGameConfName = wszSetGameConfName ? wszSetGameConfName : wszSetGameName;
10911096
ASSERT(this->wGameVer.empty());
10921097
CFiles::wGameVer = wszSetGameVer;
10931098

@@ -1362,6 +1367,7 @@ void CFiles::DeinitClass()
13621367
CFiles::wszResPath.resize(0);
13631368

13641369
CFiles::wGameName.resize(0);
1370+
CFiles::wGameConfName.resize(0);
13651371
CFiles::wGameVer.resize(0);
13661372
}
13671373

BackEndLib/Files.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@ class CFiles
8989
CFiles(const WCHAR *wszSetAppPath,
9090
const WCHAR *wszSetGameName, const WCHAR *wszSetGameVer,
9191
const bool bIsDemo = false, const bool confirm_resource_file = true,
92-
const bool bIsRunningTests = false);
92+
const bool bIsRunningTests = false,
93+
const WCHAR *wszSetGameConfName = NULL);
9394
CFiles(); //may call this one after the class has been inited
9495
~CFiles();
9596

@@ -178,6 +179,9 @@ class CFiles
178179
#endif
179180

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

183187
static bool bad_data_path_file;
@@ -206,7 +210,8 @@ class CFiles
206210
#endif
207211
void InitClass(const WCHAR *pszSetAppPath,
208212
const WCHAR *wszSetGameName, const WCHAR *wszSetGameVer, const bool bIsDemo,
209-
const bool confirm_resource_file, const bool bIsRunningTests);
213+
const bool confirm_resource_file, const bool bIsRunningTests,
214+
const WCHAR *wszSetGameConfName = NULL);
210215
static bool InitINI();
211216
static void SetupHomePath();
212217
static void SetupHomePathSubDirs();

DROD/Main.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -291,15 +291,17 @@ int main(int argc, char *argv[])
291291
#endif
292292

293293
const WCHAR* gameName = wszDROD;
294+
const WCHAR* gameConfName = NULL; //save folder; NULL means same as gameName
294295
#ifdef STEAMBUILD_TSS_APP
295296
const WCHAR wszDRODTSS[] = { We('d'),We('r'),We('o'),We('d'),We('-'),We('t'),We('s'),We('s'),We(0) };
296297
gameName = wszDRODTSS;
297298
#elif defined(__APPLE__) && defined(STEAMBUILD)
298-
//The macOS Steam GatEB build uses a dedicated folder so it doesn't collide
299-
//with the non-Steam TSS standalone build (both otherwise use "drod-5_0").
299+
//Keep gameName "drod" (so it still loads drod5_0.dat) but give the macOS Steam
300+
//GatEB build its own save folder, so it doesn't collide with the non-Steam TSS
301+
//standalone build (both otherwise use "drod-5_0").
300302
const WCHAR wszDRODGatEBSteam[] = { We('d'),We('r'),We('o'),We('d'),We('-'),
301303
We('g'),We('a'),We('t'),We('e'),We('b'),We('-'),We('s'),We('t'),We('e'),We('a'),We('m'),We(0) };
302-
gameName = wszDRODGatEBSteam;
304+
gameConfName = wszDRODGatEBSteam;
303305
#elif defined(KDD_STANDALONE)
304306
const WCHAR wszDRODKDD[] = { We('d'),We('r'),We('o'),We('d'),We('-'),We('k'),We('d'),We('d'),We(0) };
305307
gameName = wszDRODKDD;
@@ -313,7 +315,7 @@ int main(int argc, char *argv[])
313315
const WCHAR wszDRODGatEB[] = { We('d'),We('r'),We('o'),We('d'),We('-'),We('g'),We('a'),We('t'),We('e'),We('b'),We(0) };
314316
gameName = wszDRODGatEB;
315317
#endif
316-
m_pFiles = new CFiles(wstrPath.c_str(), gameName, wszDROD_VER, bIsDemo);
318+
m_pFiles = new CFiles(wstrPath.c_str(), gameName, wszDROD_VER, bIsDemo, true, false, gameConfName);
317319
if (CFiles::bad_data_path_file) {
318320
DisplayInitErrorMessage(MID_DataPathDotTextFileIsInvalid);
319321
}

0 commit comments

Comments
 (0)