Skip to content

Commit

Permalink
Game API: GameDef now defines values used for legacy savegame conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
danij-deng committed Mar 21, 2014
1 parent 351099e commit f10a771
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 49 deletions.
8 changes: 7 additions & 1 deletion doomsday/api/api_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ typedef struct gamedef_s {
/// Default author. May be overridden later.
/// Used for (e.g.) the map author name if not specified in a Map Info definition.
char const *defaultAuthor;

/*
* Used when converting legacy savegames:
*/
char const *legacySavegameExtension;
char const *legacySavegameSubfolder;
} GameDef;

/**
Expand All @@ -66,7 +72,7 @@ typedef struct gameinfo_s {
/// @}

// The Base API.
DENG_API_TYPEDEF(Base) // v1
DENG_API_TYPEDEF(Base) // v2
{
de_api_t api;

Expand Down
8 changes: 7 additions & 1 deletion doomsday/client/include/game.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,15 @@ class Game : public de::game::Game
/**
* @param identityKey Unique game mode key/identifier, 16 chars max (e.g., "doom1-ultimate").
* @param configDir Name of the config directory.
*
* @param legacySavegameExtension File extension for legacy savegames.
* @param legacySavegameSubfoler Game-specific subdirectory of /home for legacy savegames.
*/
Game(String const &identityKey, Path const &configDir,
String const &title = "Unnamed", String const &author = "Unknown");
String const &title = "Unnamed",
String const &author = "Unknown",
String const &legacySavegameExtension = "",
String const &legacySavegameSubfolder = "");

virtual ~Game();

Expand Down
34 changes: 16 additions & 18 deletions doomsday/client/src/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ DENG2_PIMPL(Game)
Path mainConfig; ///< Config file name (e.g., "configs/doom/game.cfg").
Path bindingConfig; ///< Control binding file name (set automatically).

String legacySavegameExtension;
String legacySavegameSubfolder;

Instance(Public &a, String const &identityKey, Path const &configDir,
String const &title, String const &author)
: Base(a)
Expand All @@ -62,11 +65,14 @@ DENG2_PIMPL(Game)
}
};

Game::Game(String const &identityKey, Path const &configDir, String const &title,
String const &author)
Game::Game(String const &identityKey, Path const &configDir, String const &title, String const &author,
String const &legacySavegameExtension_, String const &legacySavegameSubfolder)
: game::Game(identityKey)
, d(new Instance(*this, identityKey, configDir, title, author))
{}
{
d->legacySavegameExtension = legacySavegameExtension_;
d->legacySavegameSubfolder = legacySavegameSubfolder;
}

Game::~Game()
{}
Expand Down Expand Up @@ -172,14 +178,7 @@ String Game::logoImageId() const

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 "";
return d->legacySavegameExtension;
}

String Game::legacySavegamePath() const
Expand All @@ -196,12 +195,10 @@ String Game::legacySavegamePath() const
}

// 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;
if(!d->legacySavegameSubfolder.isEmpty())
{
return App::app().nativeHomePath() / d->legacySavegameSubfolder / identityKey();
}

return "";
}
Expand Down Expand Up @@ -261,7 +258,8 @@ bool Game::isRequiredFile(File1 &file)
Game *Game::fromDef(GameDef const &def)
{
return new Game(def.identityKey, NativePath(def.configDir).expand().withSeparators('/'),
def.defaultTitle, def.defaultAuthor);
def.defaultTitle, def.defaultAuthor, def.legacySavegameExtension,
def.legacySavegameSubfolder);
}

void Game::printBanner(Game const &game)
Expand Down
8 changes: 0 additions & 8 deletions doomsday/plugins/common/include/p_savedef.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@
# define CONSISTENCY 0x2c
# define SAVEGAMENAME "DoomSav"
# define CLIENTSAVEGAMENAME "DoomCl"
# define SAVEGAMEEXTENSION "dsg"
# define SAVEGAME_DEFAULT_DIR "savegame"

# define NUMSAVESLOTS 8
//# define BASE_SLOT 8
Expand All @@ -42,8 +40,6 @@
# define CONSISTENCY 0x2c
# define SAVEGAMENAME "D64Sav"
# define CLIENTSAVEGAMENAME "D64Cl"
# define SAVEGAMEEXTENSION "6sg"
# define SAVEGAME_DEFAULT_DIR "savegame"

# define NUMSAVESLOTS 8
//# define BASE_SLOT 8
Expand All @@ -55,8 +51,6 @@
# define CONSISTENCY 0x9d
# define SAVEGAMENAME "HticSav"
# define CLIENTSAVEGAMENAME "HticCl"
# define SAVEGAMEEXTENSION "hsg"
# define SAVEGAME_DEFAULT_DIR "savegame"

# define NUMSAVESLOTS 8
//# define BASE_SLOT 8
Expand All @@ -67,8 +61,6 @@
# define MY_CLIENT_SAVE_MAGIC 0x2B17CC00
# define SAVEGAMENAME "hex"
# define CLIENTSAVEGAMENAME "hexencl"
# define SAVEGAMEEXTENSION "hxs"
# define SAVEGAME_DEFAULT_DIR "hexndata"

# define NUMSAVESLOTS 6
# define BASE_SLOT 6
Expand Down
26 changes: 18 additions & 8 deletions doomsday/plugins/doom/src/d_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,38 +66,48 @@ static __inline gameid_t toGameId(int gamemode)
int G_RegisterGames(int hookType, int param, void* data)
{
#define STARTUPPK3 PLUGIN_NAMETEXT2 ".pk3"
#define LEGACYSAVEGAMEEXTENSION ".dsg"
#define LEGACYSAVEGAMESUBFOLDER "savegame"

GameDef const hacxDef = {
"hacx", "hacx",
"HACX - Twitch 'n Kill", "Banjo Software"
"HACX - Twitch 'n Kill", "Banjo Software",
LEGACYSAVEGAMEEXTENSION, LEGACYSAVEGAMESUBFOLDER
};
GameDef const chexDef = {
"chex", "chex",
"Chex(R) Quest", "Digital Cafe"
"Chex(R) Quest", "Digital Cafe",
LEGACYSAVEGAMEEXTENSION, LEGACYSAVEGAMESUBFOLDER
};
GameDef const doom2TntDef = {
"doom2-tnt", "doom",
"Final DOOM: TNT: Evilution", "Team TNT"
"Final DOOM: TNT: Evilution", "Team TNT",
LEGACYSAVEGAMEEXTENSION, LEGACYSAVEGAMESUBFOLDER
};
GameDef const doom2PlutDef = {
"doom2-plut", "doom",
"Final DOOM: The Plutonia Experiment", "Dario Casali and Milo Casali"
"Final DOOM: The Plutonia Experiment", "Dario Casali and Milo Casali",
LEGACYSAVEGAMEEXTENSION, LEGACYSAVEGAMESUBFOLDER
};
GameDef const doom2Def = {
"doom2", "doom",
"DOOM 2: Hell on Earth", "id Software"
"DOOM 2: Hell on Earth", "id Software",
LEGACYSAVEGAMEEXTENSION, LEGACYSAVEGAMESUBFOLDER
};
GameDef const doomUltimateDef = {
"doom1-ultimate", "doom",
"Ultimate DOOM", "id Software"
"Ultimate DOOM", "id Software",
LEGACYSAVEGAMEEXTENSION, LEGACYSAVEGAMESUBFOLDER
};
GameDef const doomDef = {
"doom1", "doom",
"DOOM Registered", "id Software"
"DOOM Registered", "id Software",
LEGACYSAVEGAMEEXTENSION, LEGACYSAVEGAMESUBFOLDER
};
GameDef const doomShareDef = {
"doom1-share", "doom",
"DOOM Shareware", "id Software"
"DOOM Shareware", "id Software",
LEGACYSAVEGAMEEXTENSION, LEGACYSAVEGAMESUBFOLDER
};

DENG_UNUSED(hookType); DENG_UNUSED(param); DENG_UNUSED(data);
Expand Down
3 changes: 2 additions & 1 deletion doomsday/plugins/doom64/src/d_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ int G_RegisterGames(int hookType, int param, void* data)

GameDef const doom64Def = {
"doom64", CONFIGDIR,
"Doom 64", "Midway Software"
"Doom 64", "Midway Software",
"", ""
};

DENG_UNUSED(hookType); DENG_UNUSED(param); DENG_UNUSED(data);
Expand Down
15 changes: 10 additions & 5 deletions doomsday/plugins/heretic/src/h_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,20 +63,25 @@ static __inline gameid_t toGameId(int gamemode)
*/
int G_RegisterGames(int hookType, int param, void* data)
{
#define CONFIGDIR "heretic"
#define STARTUPPK3 PLUGIN_NAMETEXT2 ".pk3"
#define CONFIGDIR "heretic"
#define STARTUPPK3 PLUGIN_NAMETEXT2 ".pk3"
#define LEGACYSAVEGAMEEXTENSION ".hsg"
#define LEGACYSAVEGAMESUBFOLDER "savegame"

GameDef const hereticExtDef = {
"heretic-ext", CONFIGDIR,
"Heretic: Shadow of the Serpent Riders", "Raven Software"
"Heretic: Shadow of the Serpent Riders", "Raven Software",
LEGACYSAVEGAMEEXTENSION, LEGACYSAVEGAMESUBFOLDER
};
GameDef const hereticDef = {
"heretic", CONFIGDIR,
"Heretic Registered", "Raven Software"
"Heretic Registered", "Raven Software",
LEGACYSAVEGAMEEXTENSION, LEGACYSAVEGAMESUBFOLDER
};
GameDef const hereticShareDef = {
"heretic-share", CONFIGDIR,
"Heretic Shareware", "Raven Software"
"Heretic Shareware", "Raven Software",
LEGACYSAVEGAMEEXTENSION, LEGACYSAVEGAMESUBFOLDER
};

DENG_UNUSED(hookType); DENG_UNUSED(param); DENG_UNUSED(data);
Expand Down
21 changes: 14 additions & 7 deletions doomsday/plugins/hexen/src/x_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,28 +63,35 @@ static __inline gameid_t toGameId(int gamemode)
*/
int G_RegisterGames(int hookType, int param, void* data)
{
#define CONFIGDIR "hexen"
#define STARTUPPK3 PLUGIN_NAMETEXT2 ".pk3"
#define CONFIGDIR "hexen"
#define STARTUPPK3 PLUGIN_NAMETEXT2 ".pk3"
#define LEGACYSAVEGAMEEXTENSION ".hxs"
#define LEGACYSAVEGAMESUBFOLDER "hexndata"

GameDef const deathkingsDef = {
"hexen-dk", CONFIGDIR,
"Hexen: Deathkings of the Dark Citadel", "Raven Software"
"Hexen: Deathkings of the Dark Citadel", "Raven Software",
LEGACYSAVEGAMEEXTENSION, LEGACYSAVEGAMESUBFOLDER
};
GameDef const hexenDef = {
"hexen", CONFIGDIR,
"Hexen", "Raven Software"
"Hexen", "Raven Software",
LEGACYSAVEGAMEEXTENSION, LEGACYSAVEGAMESUBFOLDER
};
GameDef const hexenDemoDef = {
"hexen-demo", CONFIGDIR,
"Hexen 4-map Demo", "Raven Software"
"Hexen 4-map Demo", "Raven Software",
LEGACYSAVEGAMEEXTENSION, LEGACYSAVEGAMESUBFOLDER
};
GameDef const hexenBetaDemoDef = {
"hexen-betademo", CONFIGDIR,
"Hexen 4-map Beta Demo", "Raven Software"
"Hexen 4-map Beta Demo", "Raven Software",
LEGACYSAVEGAMEEXTENSION, LEGACYSAVEGAMESUBFOLDER
};
GameDef const hexenV10Def = {
"hexen-v10", CONFIGDIR,
"Hexen v1.0", "Raven Software"
"Hexen v1.0", "Raven Software",
LEGACYSAVEGAMEEXTENSION, LEGACYSAVEGAMESUBFOLDER
};

DENG_UNUSED(hookType); DENG_UNUSED(param); DENG_UNUSED(data);
Expand Down

0 comments on commit f10a771

Please sign in to comment.