diff --git a/doomsday/client/include/game.h b/doomsday/client/include/game.h index c71ccc3300..89e9351130 100644 --- a/doomsday/client/include/game.h +++ b/doomsday/client/include/game.h @@ -124,6 +124,21 @@ class Game : public de::game::Game */ de::String logoImageId() const; + /** + * Returns the file extension used by legacy savegame files. + */ + String legacySavegameExtension() const; + + /** + * Determine the absolute path to the legacy savegame folder for the specified @a game. + * If there is no possibility of a legacy savegame existing (e.g., because the game is + * newer than the introduction of the modern, package-based .save format) then a zero + * length string is returned. + * + * @param game Game to return the legacy savegame folder path for. + */ + String legacySavegamePath() const; + /** * Add a new manifest to the list of manifests. * diff --git a/doomsday/client/include/resource/resourcesystem.h b/doomsday/client/include/resource/resourcesystem.h index c6661ab53f..f67a6694fd 100644 --- a/doomsday/client/include/resource/resourcesystem.h +++ b/doomsday/client/include/resource/resourcesystem.h @@ -870,6 +870,11 @@ class ResourceSystem : public de::System */ de::game::SavedSessionRepository &savedSessionRepository() const; + /** + * Returns the native path of the root of the saved session repository + */ + de::NativePath nativeSavePath(); + public: /// @todo Should be private: void initCompositeTextures(); void initFlatTextures(); diff --git a/doomsday/client/src/game.cpp b/doomsday/client/src/game.cpp index 5fbd74a305..ad4ac503c3 100644 --- a/doomsday/client/src/game.cpp +++ b/doomsday/client/src/game.cpp @@ -24,6 +24,7 @@ #include "con_main.h" #include "filesys/manifest.h" +#include #include #include #include @@ -169,6 +170,42 @@ String Game::logoImageId() const return "logo.game." + plugName; } +String Game::legacySavegameExtension() const +{ + String const idKey = identityKey(); + /// @todo Use GameDef to define these. + if(idKey.beginsWith("doom")) return ".dsg"; + if(idKey.beginsWith("heretic")) return ".hsg"; + if(idKey.beginsWith("hexen")) return ".hxs"; + if(idKey.beginsWith("chex")) return ".dsg"; + if(idKey.beginsWith("hacx")) return ".dsg"; + return ""; +} + +String Game::legacySavegamePath() const +{ + NativePath nativeSavePath = App_ResourceSystem().nativeSavePath(); + + if(nativeSavePath.isEmpty()) return ""; + if(isNull()) return ""; + + if(App::commandLine().has("-savedir")) + { + // A custom path. The savegames are in the root of this folder. + return nativeSavePath; + } + + // The default save path. The savegames are in a game-specific folder. + String const idKey = identityKey(); + if(idKey.beginsWith("doom")) return App::app().nativeHomePath() / "savegame" / idKey; + if(idKey.beginsWith("heretic")) return App::app().nativeHomePath() / "savegame" / idKey; + if(idKey.beginsWith("hexen")) return App::app().nativeHomePath() / "hexndata" / idKey; + if(idKey.beginsWith("chex")) return App::app().nativeHomePath() / "savegame" / idKey; + if(idKey.beginsWith("hacx")) return App::app().nativeHomePath() / "savegame" / idKey; + + return ""; +} + Path const &Game::mainConfig() const { return d->mainConfig; diff --git a/doomsday/client/src/resource/resourcesystem.cpp b/doomsday/client/src/resource/resourcesystem.cpp index c950ccc5dd..82c4f670d5 100644 --- a/doomsday/client/src/resource/resourcesystem.cpp +++ b/doomsday/client/src/resource/resourcesystem.cpp @@ -1915,51 +1915,6 @@ DENG2_PIMPL(ResourceSystem) #endif // __CLIENT__ - /// @todo Move to Game? - String legacySavegameExtension(Game const &game) - { - String const gameId = game.identityKey(); - if(gameId.beginsWith("doom")) return ".dsg"; - if(gameId.beginsWith("heretic")) return ".hsg"; - if(gameId.beginsWith("hexen")) return ".hxs"; - if(gameId.beginsWith("doom")) return ".dsg"; - if(gameId.beginsWith("chex")) return ".dsg"; - if(gameId.beginsWith("hacx")) return ".dsg"; - return ""; - } - - /** - * Determine the absolute path to the legacy savegame folder for the specified @a game. - * If there is no possibility of a legacy savegame existing (e.g., because the game is - * newer than the introduction of the modern, package-based .save format) then a zero - * length string is returned. - * - * @param game Game to return the legacy savegame folder path for. - * - * @todo Move to Game? - */ - String legacySavegamePath(Game const &game) - { - if(nativeSavePath.isEmpty()) return ""; - if(game.isNull()) return ""; - - if(App::commandLine().has("-savedir")) - { - // A custom path. The savegames are in the root of this folder. - return nativeSavePath; - } - - // The default save path. The savegames are in a game-specific folder. - String const gameId = game.identityKey(); - if(gameId.beginsWith("doom")) return App::app().nativeHomePath() / "savegame" / gameId; - if(gameId.beginsWith("heretic")) return App::app().nativeHomePath() / "savegame" / gameId; - if(gameId.beginsWith("hexen")) return App::app().nativeHomePath() / "hexndata" / gameId; - if(gameId.beginsWith("chex")) return App::app().nativeHomePath() / "savegame" / gameId; - if(gameId.beginsWith("hacx")) return App::app().nativeHomePath() / "savegame" / gameId; - - return ""; - } - /** * Insert/replace a SavedSession in the db. * @@ -2037,10 +1992,10 @@ DENG2_PIMPL(ResourceSystem) } // Perhaps there are legacy saved game sessions which need to be converted? - NativePath const oldSavePath = legacySavegamePath(game); + NativePath const oldSavePath = game.legacySavegamePath(); if(oldSavePath.exists() && oldSavePath.isReadable()) { - String const oldSaveExt = legacySavegameExtension(game); + String const oldSaveExt = game.legacySavegameExtension(); DENG2_ASSERT(!oldSaveExt.isEmpty()); Folder &sourceFolder = App::fileSystem().makeFolder("/oldsavegames"); @@ -3995,6 +3950,11 @@ game::SavedSessionRepository &ResourceSystem::savedSessionRepository() const return d->saveRepo; } +NativePath ResourceSystem::nativeSavePath() +{ + return d->nativeSavePath; +} + byte precacheMapMaterials = true; byte precacheSprites = true; byte texGammaLut[256];