diff --git a/source/blood/src/demo.cpp b/source/blood/src/demo.cpp index e7e95f732..48725b4ba 100644 --- a/source/blood/src/demo.cpp +++ b/source/blood/src/demo.cpp @@ -42,7 +42,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "network.h" #include "player.h" #include "screen.h" -#include "i_specialpaths.h" #include "view.h" #include "gamecontrol.h" #include "menu/menu.h" @@ -127,7 +126,7 @@ bool CDemo::Create(const char *pzFile) { for (int i = 0; i < 8 && !vc; i++) { - snprintf(buffer, BMAX_PATH, "%s%s0%02d.dem", M_GetDemoPath().GetChars(), BloodIniPre, i); + snprintf(buffer, BMAX_PATH, "%s%s0%02d.dem", G_GetDemoPath().GetChars(), BloodIniPre, i); if (access(buffer, 0) != -1) vc = 1; } @@ -140,7 +139,7 @@ bool CDemo::Create(const char *pzFile) } else { - snprintf(buffer, BMAX_PATH, "%s%s", M_GetDemoPath().GetChars(), pzFile); + snprintf(buffer, BMAX_PATH, "%s%s", G_GetDemoPath().GetChars(), pzFile); hRFile = fopen(buffer, "wb"); if (hRFile == NULL) return false; @@ -401,7 +400,7 @@ void CDemo::LoadDemoInfo(void) auto pDemo = &pFirstDemo; at59ef = 0; char zFN[BMAX_PATH]; - snprintf(zFN, BMAX_PATH, "%s%s*.dem", M_GetDemoPath().GetChars(), BloodIniPre); + snprintf(zFN, BMAX_PATH, "%s%s*.dem", G_GetDemoPath().GetChars(), BloodIniPre); TArray demos; D_AddWildFile(demos, zFN); diff --git a/source/common/gamecontrol.cpp b/source/common/gamecontrol.cpp index fd38c2fdf..a7a6aff44 100644 --- a/source/common/gamecontrol.cpp +++ b/source/common/gamecontrol.cpp @@ -878,3 +878,13 @@ int CalcSmoothRatio(const ClockTicks &totalclk, const ClockTicks &ototalclk, int return clamp(xs_RoundToInt(ratio * 65536), 0, 65536); } + +FString G_GetDemoPath() +{ + FString path = M_GetDemoPath(); + + path << LumpFilter << '/'; + CreatePath(path); + + return path; +} diff --git a/source/common/gamecontrol.h b/source/common/gamecontrol.h index aeb25df8a..15fc39369 100644 --- a/source/common/gamecontrol.h +++ b/source/common/gamecontrol.h @@ -160,6 +160,8 @@ void G_HandleMemErr(int32_t lineNum, const char* fileName, const char* funcName) void G_FatalEngineError(void); int CalcSmoothRatio(const ClockTicks& totalclk, const ClockTicks& ototalclk, int realgameticspersec); +FString G_GetDemoPath(); + struct FStartupInfo { diff --git a/source/duke3d/src/demo.cpp b/source/duke3d/src/demo.cpp index dfb18e9f2..2a7175abe 100644 --- a/source/duke3d/src/demo.cpp +++ b/source/duke3d/src/demo.cpp @@ -28,7 +28,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "menus.h" #include "savegame.h" #include "screens.h" -#include "i_specialpaths.h" #include "printf.h" #include "menu/menu.h" @@ -152,7 +151,7 @@ void G_OpenDemoWrite(void) if (demonum == MAXDEMOS) return; - if (snprintf(demofn, sizeof(demofn), "%s" DEMOFN_FMT, M_GetDemoPath().GetChars(), demonum)) + if (snprintf(demofn, sizeof(demofn), "%s" DEMOFN_FMT, G_GetDemoPath().GetChars(), demonum)) { initprintf("Couldn't start demo writing: INTERNAL ERROR: file name too long\n"); goto error_wopen_demo; diff --git a/source/platform/posix/osx/i_specialpaths.mm b/source/platform/posix/osx/i_specialpaths.mm index 9ea2c4719..913aa215b 100644 --- a/source/platform/posix/osx/i_specialpaths.mm +++ b/source/platform/posix/osx/i_specialpaths.mm @@ -239,7 +239,7 @@ FString M_GetDemoPath() { path += "/" GAME_DIR "/Demos/"; } - CreatePath(path); + return path; } diff --git a/source/platform/win32/i_specialpaths.cpp b/source/platform/win32/i_specialpaths.cpp index 213d425a7..44167f20e 100644 --- a/source/platform/win32/i_specialpaths.cpp +++ b/source/platform/win32/i_specialpaths.cpp @@ -42,7 +42,6 @@ #include "printf.h" #include "cmdlib.h" #include "i_findfile.h" -#include "gamecontrol.h" #include "version.h" // for GAMENAME // Stuff that needs to be set up later. @@ -349,7 +348,7 @@ FString M_GetDemoPath() FStringf inipath("%s" GAMENAME "_portable.ini", progdir.GetChars()); if (FileExists(inipath) || !UseKnownFolders()) { - path << progdir << "Demos/" << LumpFilter << '/'; + path << progdir << "Demos/"; } else // Try defacto My Documents/My Games folder @@ -357,13 +356,13 @@ FString M_GetDemoPath() { // I assume since this isn't a standard folder, it doesn't have // a localized name either. - path << "/My Games/" GAMENAME "/" << LumpFilter << '/'; + path << "/My Games/" GAMENAME "/"; } else { - path << progdir << "Demos/" << LumpFilter << '/'; + path << progdir << "Demos/"; } - CreatePath(path); + return path; } diff --git a/source/rr/src/demo.cpp b/source/rr/src/demo.cpp index ab4df0cd0..ff7082f9f 100644 --- a/source/rr/src/demo.cpp +++ b/source/rr/src/demo.cpp @@ -28,7 +28,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "menus.h" #include "savegame.h" #include "screens.h" -#include "i_specialpaths.h" BEGIN_RR_NS @@ -151,7 +150,7 @@ void G_OpenDemoWrite(void) if (demonum == MAXDEMOS) return; - if (snprintf(demofn, sizeof(demofn), "%s" DEMOFN_FMT, M_GetDemoPath().GetChars(), demonum)) + if (snprintf(demofn, sizeof(demofn), "%s" DEMOFN_FMT, G_GetDemoPath().GetChars(), demonum)) { initprintf("Couldn't start demo writing: INTERNAL ERROR: file name too long\n"); goto error_wopen_demo;