Skip to content

Commit

Permalink
Update all paths to use the .modloader folder with failsafe
Browse files Browse the repository at this point in the history
  • Loading branch information
PiKeyAr committed Feb 13, 2025
1 parent c0b2011 commit a1fc32c
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions SADXModLoader/dllmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ using json = nlohmann::json;
#include "dpi.h"
#include "backend.h"

wstring borderimage = L"mods\\Border.png";
wstring borderimage = L"mods\\.modloader\\Border.png";
HINSTANCE g_hinstDll = nullptr;
wstring iconPathName;
wstring bassFolder;
Expand Down Expand Up @@ -881,7 +881,8 @@ static void __cdecl InitMods()
{
// Enable debug logging to a file.
// dbgFile will be nullptr if the file couldn't be opened.
dbgFile = _wfopen(L"mods\\SADXModLoader.log", L"a+");
bool dbgNew = DirectoryExists("mods\\.modloader");
dbgFile = _wfopen(dbgNew ? L"mods\\.modloader\\SADXModLoader.log" : L"mods\\SADXModLoader.log", L"a+");
}

// Is any debug method enabled?
Expand Down Expand Up @@ -1276,6 +1277,13 @@ static void __cdecl InitMods()

if (!loaderSettings.DisableBorderImage)
{
// Failsafe for the old path: Custom border
if (!FileExists(borderimage))
borderimage = L"mods\\Border.png";
// Default border
if (!FileExists(borderimage))
borderimage = L"mods\\.modloader\\Border_Default.png";
// Failsafe for the old path: Default border
if (!FileExists(borderimage))
borderimage = L"mods\\Border_Default.png";
SetBorderImage(borderimage);
Expand Down Expand Up @@ -1465,7 +1473,8 @@ static void __cdecl InitMods()
#endif

// Check for patch-type codes.
ifstream patches_str("mods\\Patches.dat", ifstream::binary);
bool patches_new = Exists("mods\\.modloader\\Patches.dat");
ifstream patches_str(patches_new ? "mods\\.modloader\\Patches.dat" : "mods\\Patches.dat", ifstream::binary);
if (patches_str.is_open())
{
CodeParser patchParser;
Expand Down Expand Up @@ -1506,7 +1515,8 @@ static void __cdecl InitMods()


// Check for codes.
ifstream codes_str("mods\\Codes.dat", ifstream::binary);
bool codes_new = Exists("mods\\.modloader\\Codes.dat");
ifstream codes_str(codes_new ? "mods\\.modloader\\Codes.dat" : "mods\\Codes.dat", ifstream::binary);

if (codes_str.is_open())
{
Expand Down

0 comments on commit a1fc32c

Please sign in to comment.