Skip to content

Commit bf3d3ca

Browse files
Fix for remaster darkpilo.cfg which is not located in the game folder. (#523)
* Fix for remaster darkpilo.cfg which is not located in the game folder. * Add for linux compatibility * Update Linux pathing. * fix for nix paths * change the path path based on testing on proton. --------- Co-authored-by: Karjala22 <78927981+Karjala22@users.noreply.github.com>
1 parent 5fb4480 commit bf3d3ca

File tree

5 files changed

+75
-4
lines changed

5 files changed

+75
-4
lines changed

TheForceEngine/TFE_DarkForces/agent.cpp

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -541,10 +541,19 @@ namespace TFE_DarkForces
541541
}
542542
else
543543
{
544-
// Finally generate a new one.
545-
TFE_System::logWrite(LOG_WARNING, "DarkForcesMain", "Cannot find 'DARKPILO.CFG' at '%s'. Creating a new file for save data.", sourcePath);
546-
newpilo:
547-
createDarkPilotConfig(documentsPath);
544+
// Also check the remaster documents path.
545+
TFE_Paths::appendPath(PATH_REMASTER_DOCS, "DARKPILO.CFG", sourcePath);
546+
if (FileUtil::exists(sourcePath))
547+
{
548+
FileUtil::copyFile(sourcePath, documentsPath);
549+
}
550+
else
551+
{
552+
// Finally generate a new one.
553+
TFE_System::logWrite(LOG_WARNING, "DarkForcesMain", "Cannot find 'DARKPILO.CFG' at '%s'. Creating a new file for save data.", sourcePath);
554+
newpilo:
555+
createDarkPilotConfig(documentsPath);
556+
}
548557
}
549558
}
550559
}

TheForceEngine/TFE_FileSystem/paths-posix.cpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include "paths.h"
44
#include "fileutil.h"
55
#include "filestream.h"
6+
#include <TFE_Settings/gameSourceData.h>
67
#include <TFE_System/system.h>
78
#include <TFE_Archive/archive.h>
89
#include <algorithm>
@@ -130,6 +131,34 @@ namespace TFE_Paths
130131
return true;
131132
}
132133

134+
// There is no official remaster support on linux
135+
// Lets approximate proton save locations.
136+
bool setRemasterDocsPath(GameID game)
137+
{
138+
if (isPortableInstall())
139+
{
140+
s_paths[PATH_REMASTER_DOCS] = s_paths[PATH_PROGRAM];
141+
return true;
142+
}
143+
string strId = to_string((int)TFE_Settings::c_steamRemasterProductId[game]);
144+
string append = "~/.steam/steam/steamapps/compatdata/" + strId + "/pfx/drive_c/users/steamuser/Saved Games/Nightdive Studios";
145+
146+
if (game == Game_Dark_Forces)
147+
{
148+
append += "/Dark Forces Remaster/";
149+
}
150+
else if (game == Game_Outlaws)
151+
{
152+
append += "/Outlaws Remaster/";
153+
}
154+
else
155+
{
156+
return false;
157+
}
158+
s_paths[PATH_REMASTER_DOCS] = append;
159+
return !s_paths[PATH_REMASTER_DOCS].empty();
160+
}
161+
133162
bool setProgramPath(void)
134163
{
135164
char p[TFE_MAX_PATH];

TheForceEngine/TFE_FileSystem/paths.cpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,35 @@ namespace TFE_Paths
123123
return false;
124124
}
125125

126+
// This is the path to the Remaster documents folder.
127+
bool setRemasterDocsPath(GameID game)
128+
{
129+
#ifdef _WIN32
130+
char path[TFE_MAX_PATH];
131+
132+
if (SUCCEEDED(SHGetFolderPath(NULL, CSIDL_PROFILE, NULL, 0, path)))
133+
{
134+
// Append product-specific path
135+
if (game == Game_Dark_Forces)
136+
{
137+
PathAppend(path, "Saved Games\\Nightdive Studios\\Dark Forces Remaster");
138+
}
139+
else if (game == Game_Outlaws)
140+
{
141+
PathAppend(path, "Saved Games\\Nightdive Studios\\Outlaws Remaster");
142+
}
143+
else
144+
{
145+
return false;
146+
}
147+
s_paths[PATH_REMASTER_DOCS] = path;
148+
s_paths[PATH_REMASTER_DOCS] += "\\";
149+
}
150+
return !s_paths[PATH_REMASTER_DOCS].empty();
151+
#endif
152+
return false;
153+
}
154+
126155
bool setProgramPath()
127156
{
128157
char path[TFE_MAX_PATH];

TheForceEngine/TFE_FileSystem/paths.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#pragma once
22
#include "fileutil.h"
33
#include <TFE_System/types.h>
4+
#include <TFE_Settings/gameSourceData.h>
45

56
enum TFE_PathType
67
{
@@ -10,6 +11,7 @@ enum TFE_PathType
1011
PATH_SOURCE_DATA, // This is the location of the source data, such as maps, textures, etc.
1112
PATH_EMULATOR, // Path to the dosbox exe (for the editor).
1213
PATH_MOD, // Use this to reference mods.
14+
PATH_REMASTER_DOCS, // Path for Remaster Document Folder.
1315
PATH_COUNT
1416
};
1517

@@ -34,6 +36,7 @@ namespace TFE_Paths
3436
bool setProgramDataPath(const char* append);
3537
bool setUserDocumentsPath(const char* append);
3638
// Platform specific executable path.
39+
bool setRemasterDocsPath(GameID game);
3740
bool setProgramPath();
3841
// find a relative path in a TFE system directory. true if mapping was done.
3942
bool mapSystemPath(char *path);

TheForceEngine/main.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,7 @@ int main(int argc, char* argv[])
547547
const TFE_GameHeader* gameHeader = TFE_Settings::getGameHeader(game->game);
548548
TFE_Paths::setPath(PATH_SOURCE_DATA, gameHeader->sourcePath);
549549
TFE_Paths::setPath(PATH_EMULATOR, gameHeader->emulatorPath);
550+
TFE_Paths::setRemasterDocsPath(game->id);
550551

551552
// Validate the current game path.
552553
validatePath();

0 commit comments

Comments
 (0)