From 6683eb5f581626b0ec4d81f6b2383ffc1c7a10be Mon Sep 17 00:00:00 2001 From: Karjala22 <78927981+Karjala22@users.noreply.github.com> Date: Wed, 9 Apr 2025 00:28:31 -0400 Subject: [PATCH 1/6] Fix for remaster darkpilo.cfg which is not located in the game folder. --- TheForceEngine/TFE_DarkForces/agent.cpp | 17 +++++++++++---- TheForceEngine/TFE_FileSystem/paths.cpp | 29 +++++++++++++++++++++++++ TheForceEngine/TFE_FileSystem/paths.h | 3 +++ TheForceEngine/main.cpp | 1 + 4 files changed, 46 insertions(+), 4 deletions(-) diff --git a/TheForceEngine/TFE_DarkForces/agent.cpp b/TheForceEngine/TFE_DarkForces/agent.cpp index 1a0a22396..58f7c268a 100644 --- a/TheForceEngine/TFE_DarkForces/agent.cpp +++ b/TheForceEngine/TFE_DarkForces/agent.cpp @@ -541,10 +541,19 @@ namespace TFE_DarkForces } else { - // Finally generate a new one. - TFE_System::logWrite(LOG_WARNING, "DarkForcesMain", "Cannot find 'DARKPILO.CFG' at '%s'. Creating a new file for save data.", sourcePath); -newpilo: - createDarkPilotConfig(documentsPath); + // Also check the remaster documents path. + TFE_Paths::appendPath(PATH_REMASTER_DOCS, "DARKPILO.CFG", sourcePath); + if (FileUtil::exists(sourcePath)) + { + FileUtil::copyFile(sourcePath, documentsPath); + } + else + { + // Finally generate a new one. + TFE_System::logWrite(LOG_WARNING, "DarkForcesMain", "Cannot find 'DARKPILO.CFG' at '%s'. Creating a new file for save data.", sourcePath); + newpilo: + createDarkPilotConfig(documentsPath); + } } } } diff --git a/TheForceEngine/TFE_FileSystem/paths.cpp b/TheForceEngine/TFE_FileSystem/paths.cpp index 2a688bcd7..774cac56c 100644 --- a/TheForceEngine/TFE_FileSystem/paths.cpp +++ b/TheForceEngine/TFE_FileSystem/paths.cpp @@ -123,6 +123,35 @@ namespace TFE_Paths return false; } + // This is the path to the Remaster documents folder. + bool setRemasterDocsPath(GameID game) + { + #ifdef _WIN32 + char path[TFE_MAX_PATH]; + + if (SUCCEEDED(SHGetFolderPath(NULL, CSIDL_PROFILE, NULL, 0, path))) + { + // Append product-specific path + if (game == Game_Dark_Forces) + { + PathAppend(path, "Saved Games\\Nightdive Studios\\Dark Forces Remaster"); + } + else if (game == Game_Outlaws) + { + PathAppend(path, "Saved Games\\Nightdive Studios\\Outlaws Remaster"); + } + else + { + return false; + } + s_paths[PATH_REMASTER_DOCS] = path; + s_paths[PATH_REMASTER_DOCS] += "\\"; + } + return !s_paths[PATH_REMASTER_DOCS].empty(); + #endif + return false; + } + bool setProgramPath() { char path[TFE_MAX_PATH]; diff --git a/TheForceEngine/TFE_FileSystem/paths.h b/TheForceEngine/TFE_FileSystem/paths.h index 786419d28..9eadc8384 100644 --- a/TheForceEngine/TFE_FileSystem/paths.h +++ b/TheForceEngine/TFE_FileSystem/paths.h @@ -1,6 +1,7 @@ #pragma once #include "fileutil.h" #include +#include enum TFE_PathType { @@ -10,6 +11,7 @@ enum TFE_PathType PATH_SOURCE_DATA, // This is the location of the source data, such as maps, textures, etc. PATH_EMULATOR, // Path to the dosbox exe (for the editor). PATH_MOD, // Use this to reference mods. + PATH_REMASTER_DOCS, // Path for Remaster Document Folder. PATH_COUNT }; @@ -34,6 +36,7 @@ namespace TFE_Paths bool setProgramDataPath(const char* append); bool setUserDocumentsPath(const char* append); // Platform specific executable path. + bool setRemasterDocsPath(GameID game); bool setProgramPath(); // find a relative path in a TFE system directory. true if mapping was done. bool mapSystemPath(char *path); diff --git a/TheForceEngine/main.cpp b/TheForceEngine/main.cpp index 1582757a3..b06e47ebe 100644 --- a/TheForceEngine/main.cpp +++ b/TheForceEngine/main.cpp @@ -547,6 +547,7 @@ int main(int argc, char* argv[]) const TFE_GameHeader* gameHeader = TFE_Settings::getGameHeader(game->game); TFE_Paths::setPath(PATH_SOURCE_DATA, gameHeader->sourcePath); TFE_Paths::setPath(PATH_EMULATOR, gameHeader->emulatorPath); + TFE_Paths::setRemasterDocsPath(game->id); // Validate the current game path. validatePath(); From 85b21947e6fcf5f8e35d1866185b66dcb51ae702 Mon Sep 17 00:00:00 2001 From: Karjala22 <78927981+Karjala22@users.noreply.github.com> Date: Wed, 9 Apr 2025 00:56:24 -0400 Subject: [PATCH 2/6] Add for linux compatibility --- TheForceEngine/TFE_FileSystem/paths-posix.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/TheForceEngine/TFE_FileSystem/paths-posix.cpp b/TheForceEngine/TFE_FileSystem/paths-posix.cpp index 02a79f8d6..1e8079199 100644 --- a/TheForceEngine/TFE_FileSystem/paths-posix.cpp +++ b/TheForceEngine/TFE_FileSystem/paths-posix.cpp @@ -130,6 +130,18 @@ namespace TFE_Paths return true; } + bool setRemasterDocsPath(GameID game) + { + if (isPortableInstall()) + { + s_paths[PATH_REMASTER_DOCS] = s_paths[PATH_PROGRAM]; + return true; + } + + // TO DO - find out where (if?) the remaster docs are available on Linux + return false; + } + bool setProgramPath(void) { char p[TFE_MAX_PATH]; From d3ed1cb152c97dc2edebc33e9a27cd615373a8d8 Mon Sep 17 00:00:00 2001 From: Karjala22 <78927981+Karjala22@users.noreply.github.com> Date: Wed, 9 Apr 2025 14:24:29 -0400 Subject: [PATCH 3/6] Update Linux pathing. --- TheForceEngine/TFE_FileSystem/paths-posix.cpp | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/TheForceEngine/TFE_FileSystem/paths-posix.cpp b/TheForceEngine/TFE_FileSystem/paths-posix.cpp index 1e8079199..a4906954a 100644 --- a/TheForceEngine/TFE_FileSystem/paths-posix.cpp +++ b/TheForceEngine/TFE_FileSystem/paths-posix.cpp @@ -3,6 +3,7 @@ #include "paths.h" #include "fileutil.h" #include "filestream.h" +#include #include #include #include @@ -130,6 +131,8 @@ namespace TFE_Paths return true; } + // There is no official remaster support on linux + // Lets approximate proton save locations. bool setRemasterDocsPath(GameID game) { if (isPortableInstall()) @@ -137,9 +140,23 @@ namespace TFE_Paths s_paths[PATH_REMASTER_DOCS] = s_paths[PATH_PROGRAM]; return true; } + + string id = to_string(c_steamRemasterProductId[game]); + string append = "steamapps/compatdata/" + id + "/pfx/drive_c/users/steamuser/Saved Games/Nightdive Studios"; - // TO DO - find out where (if?) the remaster docs are available on Linux - return false; + if (id == Game_Dark_Forces) + { + append += "/Dark Forces Remaster/"; + } + else if (id == Game_Outlaws) + { + append += "/Outlaws Remaster/"; + } + { + return false; + } + s_paths[PATH_REMASTER_DOCS] = append; + return !s_paths[PATH_REMASTER_DOCS].empty(); } bool setProgramPath(void) From 8241d5f5d150a23f3b686e8cc875e8dfceacb192 Mon Sep 17 00:00:00 2001 From: Karjala22 <78927981+Karjala22@users.noreply.github.com> Date: Wed, 9 Apr 2025 14:44:26 -0400 Subject: [PATCH 4/6] fix for nix paths --- TheForceEngine/TFE_FileSystem/paths-posix.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/TheForceEngine/TFE_FileSystem/paths-posix.cpp b/TheForceEngine/TFE_FileSystem/paths-posix.cpp index a4906954a..dfcabcfea 100644 --- a/TheForceEngine/TFE_FileSystem/paths-posix.cpp +++ b/TheForceEngine/TFE_FileSystem/paths-posix.cpp @@ -140,15 +140,14 @@ namespace TFE_Paths s_paths[PATH_REMASTER_DOCS] = s_paths[PATH_PROGRAM]; return true; } - - string id = to_string(c_steamRemasterProductId[game]); - string append = "steamapps/compatdata/" + id + "/pfx/drive_c/users/steamuser/Saved Games/Nightdive Studios"; + string strId = to_string((int)TFE_Settings::c_steamRemasterProductId[game]); + string append = "steamapps/compatdata/" + strId + "/pfx/drive_c/users/steamuser/Saved Games/Nightdive Studios"; - if (id == Game_Dark_Forces) + if (game == Game_Dark_Forces) { append += "/Dark Forces Remaster/"; } - else if (id == Game_Outlaws) + else if (game == Game_Outlaws) { append += "/Outlaws Remaster/"; } From 1babf9159ca44c51f76a96e821c81327476dac66 Mon Sep 17 00:00:00 2001 From: Karjala22 <78927981+Karjala22@users.noreply.github.com> Date: Wed, 9 Apr 2025 20:16:20 -0400 Subject: [PATCH 5/6] change the path path based on testing on proton. --- TheForceEngine/TFE_FileSystem/paths-posix.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/TheForceEngine/TFE_FileSystem/paths-posix.cpp b/TheForceEngine/TFE_FileSystem/paths-posix.cpp index dfcabcfea..1901010b9 100644 --- a/TheForceEngine/TFE_FileSystem/paths-posix.cpp +++ b/TheForceEngine/TFE_FileSystem/paths-posix.cpp @@ -141,7 +141,7 @@ namespace TFE_Paths return true; } string strId = to_string((int)TFE_Settings::c_steamRemasterProductId[game]); - string append = "steamapps/compatdata/" + strId + "/pfx/drive_c/users/steamuser/Saved Games/Nightdive Studios"; + string append = "~/.steam/steam/steamapps/compatdata/" + strId + "/pfx/drive_c/users/steamuser/Saved Games/Nightdive Studios"; if (game == Game_Dark_Forces) { @@ -151,6 +151,7 @@ namespace TFE_Paths { append += "/Outlaws Remaster/"; } + else { return false; } From 4a2977ec0e9699b92010195d74df5e1654ffa804 Mon Sep 17 00:00:00 2001 From: Karjala22 <78927981+Karjala22@users.noreply.github.com> Date: Sat, 21 Jun 2025 21:05:08 -0400 Subject: [PATCH 6/6] Fix filesave issue. Now you can delete save files without issue if some were deleted early breaking the index offsets. --- TheForceEngine/TFE_FrontEndUI/frontEndUi.cpp | 7 ++-- TheForceEngine/TFE_Game/saveSystem.cpp | 35 ++++++++++++++++++++ TheForceEngine/TFE_Game/saveSystem.h | 4 +-- 3 files changed, 41 insertions(+), 5 deletions(-) diff --git a/TheForceEngine/TFE_FrontEndUI/frontEndUi.cpp b/TheForceEngine/TFE_FrontEndUI/frontEndUi.cpp index 9212ae21c..1428e36aa 100644 --- a/TheForceEngine/TFE_FrontEndUI/frontEndUi.cpp +++ b/TheForceEngine/TFE_FrontEndUI/frontEndUi.cpp @@ -1711,8 +1711,8 @@ namespace TFE_FrontEndUI ImGui::PushStyleColor(ImGuiCol_FrameBg, ImVec4(0.0f, 0.0f, 0.0f, 0.0f)); char textBuffer[TFE_MAX_PATH]; - sprintf(textBuffer, "Game: Dark Forces\nTime: %s\nLevel: %s\nMods: %s\n", s_saveDir[s_selectedSave - listOffset].dateTime, - s_saveDir[s_selectedSave - listOffset].levelName, s_saveDir[s_selectedSave - listOffset].modNames); + sprintf(textBuffer, "Game: Dark Forces\nTime: %s\nLevel: %s\nMods: %s\nFileName: %s\n", s_saveDir[s_selectedSave - listOffset].dateTime, + s_saveDir[s_selectedSave - listOffset].levelName, s_saveDir[s_selectedSave - listOffset].modNames, s_saveDir[s_selectedSave - listOffset].fileName); ImGui::InputTextMultiline("##Info", textBuffer, strlen(textBuffer) + 1, size, ImGuiInputTextFlags_ReadOnly); ImGui::PopFont(); @@ -1775,12 +1775,13 @@ namespace TFE_FrontEndUI bool shouldExit = false; if (save) { + // New Save Created if (s_selectedSave == 0) { s_selectedSaveSlot = (s32)s_saveDir.size(); // If no quicksave exists, skip over it when generating the name. const s32 saveIndex = s_selectedSaveSlot + (s_hasQuicksave ? 0 : 1); - TFE_SaveSystem::getSaveFilenameFromIndex(saveIndex, s_fileName); + TFE_SaveSystem::getSaveFilename(s_fileName, saveIndex); s_newSaveName[0] = 0; openSaveNameEditPopup(s_newSaveName); diff --git a/TheForceEngine/TFE_Game/saveSystem.cpp b/TheForceEngine/TFE_Game/saveSystem.cpp index 2e59d1e76..e9ef8387e 100644 --- a/TheForceEngine/TFE_Game/saveSystem.cpp +++ b/TheForceEngine/TFE_Game/saveSystem.cpp @@ -27,6 +27,8 @@ namespace TFE_SaveSystem SVER_CUR = SVER_REPLAY }; + const int TFE_MAX_SAVES = 1024; + static SaveRequest s_req = SF_REQ_NONE; static char s_reqFilename[TFE_MAX_PATH]; static char s_reqSavename[TFE_MAX_PATH]; @@ -388,4 +390,37 @@ namespace TFE_SaveSystem lastState = 0; } } + + void getSaveFilename(char* filename, s32 index) + { + char saveFilePath[TFE_MAX_PATH]; + TFE_SaveSystem::getSaveFilenameFromIndex(index, filename); + sprintf(saveFilePath, "%s%s", s_gameSavePath, filename); + + // If the file doesn't exist or we are overwriting, use the saveFilePath - ex: save015.tfe + if (!FileUtil::exists(saveFilePath)) + { + filename = saveFilePath; + return; + } + else + { + // If the file already exists you must have deleted an older one so lets find the right index + // Ex: save000.tfe save001.tfe save003.tfe (skipped 2) or you have custom save names. + for (int i = 0; i < TFE_MAX_SAVES; i++) + { + TFE_SaveSystem::getSaveFilenameFromIndex(i, filename); + sprintf(saveFilePath, "%s%s", s_gameSavePath, filename); + + if (!FileUtil::exists(saveFilePath)) + { + filename = saveFilePath; + return; + } + } + } + + TFE_System::logWrite(LOG_MSG, "SaveSystem", "Unable to create a save file after %d attempts", TFE_MAX_SAVES); + assert(0); + } } \ No newline at end of file diff --git a/TheForceEngine/TFE_Game/saveSystem.h b/TheForceEngine/TFE_Game/saveSystem.h index 4a647fdcf..e890568e6 100644 --- a/TheForceEngine/TFE_Game/saveSystem.h +++ b/TheForceEngine/TFE_Game/saveSystem.h @@ -49,7 +49,7 @@ namespace TFE_SaveSystem const char* loadRequestFilename(); const char* saveRequestFilename(); - void getSaveFilenameFromIndex(s32 index, char* name); - + void getSaveFilename(char* filename, s32 index); void populateSaveDirectory(std::vector& dir); + } \ No newline at end of file