Skip to content

Commit

Permalink
Refactor|libdoomsday: Moved Game and Games out of the "de" namespace
Browse files Browse the repository at this point in the history
The "de" namespace is reserved for SDK libraries. libdoomsday uses
either no namespace or a domain-specific one like "defn" or "res".

Also, added a stub for the Players class.
  • Loading branch information
skyjake committed Jul 23, 2015
1 parent 233877a commit eb6ed28
Show file tree
Hide file tree
Showing 15 changed files with 102 additions and 45 deletions.
6 changes: 3 additions & 3 deletions doomsday/apps/client/include/dd_main.h
Expand Up @@ -85,17 +85,17 @@ void DD_UpdateEngineState();
/**
* Switch to/activate the specified game.
*/
bool App_ChangeGame(de::Game &game, bool allowReload = false);
bool App_ChangeGame(Game &game, bool allowReload = false);

/**
* Returns the application's global Games (collection).
*/
de::Games &App_Games();
Games &App_Games();

/**
* Returns the current game from the application's global collection.
*/
de::Game &App_CurrentGame();
Game &App_CurrentGame();

/**
* Frees the info structures for all registered games.
Expand Down
2 changes: 1 addition & 1 deletion doomsday/apps/client/include/resource/mapdef.h
Expand Up @@ -52,7 +52,7 @@ class MapDef : public de::PathTree::Node, public de::Record
/**
* Returns the id used to uniquely reference the map in some (old) definitions.
*/
de::String composeUniqueId(de::Game const &currentGame) const;
de::String composeUniqueId(Game const &currentGame) const;

MapDef &setSourceFile(de::File1 *newSourceFile);

Expand Down
8 changes: 4 additions & 4 deletions doomsday/apps/client/src/dd_main.cpp
Expand Up @@ -1198,7 +1198,7 @@ static dint DD_ActivateGameWorker(void *context)
return 0;
}

de::Games &App_Games()
Games &App_Games()
{
if(App::appExists())
{
Expand All @@ -1218,7 +1218,7 @@ void App_ClearGames()
App::app().setGame(App_Games().nullGame());
}

static void populateGameInfo(GameInfo &info, de::Game &game)
static void populateGameInfo(GameInfo &info, Game &game)
{
info.identityKey = AutoStr_FromTextStd(game.identityKey().toUtf8().constData());
info.title = AutoStr_FromTextStd(game.title().toUtf8().constData());
Expand Down Expand Up @@ -1318,7 +1318,7 @@ gameid_t DD_GameIdForKey(char const *identityKey)
return 0; // Invalid id.
}

de::Game &App_CurrentGame()
Game &App_CurrentGame()
{
return DoomsdayApp::currentGame();
}
Expand Down Expand Up @@ -1811,7 +1811,7 @@ static void initialize()
// Attempt automatic game selection.
if(!CommandLine_Exists("-noautoselect") || isDedicated)
{
if(de::Game *game = DD_AutoselectGame())
if(Game *game = DD_AutoselectGame())
{
// An implicit game session profile has been defined.
// Add all resources specified using -file options on the command line
Expand Down
2 changes: 1 addition & 1 deletion doomsday/apps/client/src/def_main.cpp
Expand Up @@ -495,7 +495,7 @@ static void readAllDefinitions()

if(App_GameLoaded())
{
de::Game &game = App_CurrentGame();
Game &game = App_CurrentGame();

// Some games use definitions that are translated to DED.
QStringList mapInfoUrns = allMapInfoUrns();
Expand Down
2 changes: 1 addition & 1 deletion doomsday/apps/client/src/ui/widgets/taskbarwidget.cpp
Expand Up @@ -266,7 +266,7 @@ DENG_GUI_PIMPL(TaskBarWidget)

void showOrHideMenuItems()
{
de::Game &game = App_CurrentGame();
Game &game = App_CurrentGame();

itemWidget(mainMenu, POS_GAMES) .show(!game.isNull());
itemWidget(mainMenu, POS_UNLOAD) .show(!game.isNull());
Expand Down
7 changes: 5 additions & 2 deletions doomsday/apps/libdoomsday/include/doomsday/doomsdayapp.h
Expand Up @@ -24,6 +24,8 @@
#include "busymode.h"
#include "gameapi.h"

class Players;

/**
* Common application-level state and components.
*
Expand All @@ -46,8 +48,9 @@ class LIBDOOMSDAY_PUBLIC DoomsdayApp
public:
static DoomsdayApp &app();
static Plugins &plugins();
static de::Games &games();
static de::Game &currentGame();
static Games &games();
static Players &players();
static Game &currentGame();
static BusyMode &busyMode();

private:
Expand Down
31 changes: 13 additions & 18 deletions doomsday/apps/libdoomsday/include/doomsday/game.h
Expand Up @@ -65,10 +65,7 @@ typedef struct gamedef_s {
#include <QMultiMap>

class ResourceManifest;

namespace de {

class File1;
namespace de { class File1; }

/**
* Records top-level game configurations registered by the loaded game plugin(s).
Expand Down Expand Up @@ -97,12 +94,12 @@ class Game : public de::game::Game
* @param legacySavegameSubfoler Game-specific subdirectory of /home for legacy savegames.
* @param mapMapInfo Base relative path to the main MAPINFO definition data.
*/
Game(String const &identityKey, Path const &configDir,
String const &title = "Unnamed",
String const &author = "Unknown",
String const &legacySavegameNameExp = "",
String const &legacySavegameSubfolder = "",
String const &mainMapInfo = "");
Game(de::String const &identityKey, de::Path const &configDir,
de::String const &title = "Unnamed",
de::String const &author = "Unknown",
de::String const &legacySavegameNameExp = "",
de::String const &legacySavegameSubfolder = "",
de::String const &mainMapInfo = "");

virtual ~Game();

Expand All @@ -118,13 +115,13 @@ class Game : public de::game::Game
*
* @see status()
*/
String const &statusAsText() const;
de::String const &statusAsText() const;

/**
* Returns information about the game as styled text. Printed by "inspectgame",
* for instance.
*/
String description() const;
de::String description() const;

/**
* Returns the unique identifier of the plugin which registered the game.
Expand Down Expand Up @@ -175,15 +172,15 @@ class Game : public de::game::Game
/**
* Returns the regular expression used for locating legacy savegame files.
*/
String legacySavegameNameExp() const;
de::String legacySavegameNameExp() const;

/**
* Determine the absolute path to the legacy savegame folder for the 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.
*/
String legacySavegamePath() const;
de::String legacySavegamePath() const;

/**
* Add a new manifest to the list of manifests.
Expand Down Expand Up @@ -213,7 +210,7 @@ class Game : public de::game::Game
*
* @return @c true iff @a file is required by this game.
*/
bool isRequiredFile(File1 &file);
bool isRequiredFile(de::File1 &file);

public:
/**
Expand All @@ -239,7 +236,7 @@ class Game : public de::game::Game
* @param withStatus @c true to include the current availability/load status
* of each file.
*/
String filesAsText(int rflags, bool withStatus = true) const;
de::String filesAsText(int rflags, bool withStatus = true) const;

static void printFiles(Game const &game, int rflags, bool printStatus = true);

Expand Down Expand Up @@ -270,8 +267,6 @@ class NullGame : public Game
}
};

} // namespace de

#endif // __cplusplus

#endif /* LIBDOOMSDAY_GAME_H */
8 changes: 2 additions & 6 deletions doomsday/apps/libdoomsday/include/doomsday/games.h
Expand Up @@ -27,10 +27,8 @@
#include <de/Observers>
#include <QList>

namespace de {

/**
* Encapsulates a collection of de::Game instances and the logical operations
* Encapsulates a collection of Game instances and the logical operations
* which are performed upon it (such as searches and various index printing
* algorithms).
*
Expand Down Expand Up @@ -91,7 +89,7 @@ class Games
*
* @throws NotFoundError if no game is associated with @a identityKey.
*/
Game &byIdentityKey(String identityKey) const;
Game &byIdentityKey(de::String identityKey) const;

/**
* @return Game associated with @a gameId.
Expand Down Expand Up @@ -161,6 +159,4 @@ class Games
DENG2_PRIVATE(d)
};

} // namespace de

#endif // LIBDOOMSDAY_GAMES_H
38 changes: 38 additions & 0 deletions doomsday/apps/libdoomsday/include/doomsday/players.h
@@ -0,0 +1,38 @@
/** @file doomsday/players.h
*
* @authors Copyright (c) 2015 Jaakko Keränen <jaakko.keranen@iki.fi>
*
* @par License
* GPL: http://www.gnu.org/licenses/gpl.html
*
* <small>This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version. This program is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details. You should have received a copy of the GNU
* General Public License along with this program; if not, see:
* http://www.gnu.org/licenses</small>
*/

#ifndef LIBDOOMSDAY_PLAYERS_H
#define LIBDOOMSDAY_PLAYERS_H

#include "libdoomsday.h"

/**
* Base class for player state: common functionality shared by both the server
* and the client.
*/
class LIBDOOMSDAY_PUBLIC Players
{
public:
Players();

private:
DENG2_PRIVATE(d)
};

#endif // LIBDOOMSDAY_PLAYERS_H

2 changes: 1 addition & 1 deletion doomsday/apps/libdoomsday/src/doomsdayapp.cpp
Expand Up @@ -192,7 +192,7 @@ Games &DoomsdayApp::games()

Game &DoomsdayApp::currentGame()
{
return App::game().as<de::Game>();
return App::game().as<Game>();
}

BusyMode &DoomsdayApp::busyMode()
Expand Down
4 changes: 1 addition & 3 deletions doomsday/apps/libdoomsday/src/game.cpp
Expand Up @@ -32,7 +32,7 @@
#include <de/charsymbols.h>
#include <QtAlgorithms>

namespace de {
using namespace de;

DENG2_PIMPL(Game)
{
Expand Down Expand Up @@ -391,5 +391,3 @@ void Game::consoleRegister() //static

NullGame::NullGame() : Game("" /*null*/, "doomsday", "null-game", "null-game")
{}

} // namespace de
4 changes: 1 addition & 3 deletions doomsday/apps/libdoomsday/src/games.cpp
Expand Up @@ -32,7 +32,7 @@
#include <de/charsymbols.h>
#include <QtAlgorithms>

namespace de {
using namespace de;

DENG2_PIMPL(Games)
{
Expand Down Expand Up @@ -364,5 +364,3 @@ void Games::consoleRegister() //static

Game::consoleRegister();
}

} // namespace de
29 changes: 29 additions & 0 deletions doomsday/apps/libdoomsday/src/players.cpp
@@ -0,0 +1,29 @@
/** @file doomsday/players.cpp
*
* @authors Copyright (c) 2015 Jaakko Keränen <jaakko.keranen@iki.fi>
*
* @par License
* GPL: http://www.gnu.org/licenses/gpl.html
*
* <small>This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version. This program is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details. You should have received a copy of the GNU
* General Public License along with this program; if not, see:
* http://www.gnu.org/licenses</small>
*/

#include "doomsday/players.h"

using namespace de;

DENG2_PIMPL_NOREF(Players)
{

};

Players::Players() : d(new Instance)
{}
2 changes: 1 addition & 1 deletion doomsday/apps/server/src/shelluser.cpp
Expand Up @@ -96,7 +96,7 @@ void ShellUser::sendInitialUpdate()

void ShellUser::sendGameState()
{
de::Game &game = App_CurrentGame();
Game &game = App_CurrentGame();
String mode = (App_GameLoaded()? game.identityKey() : "");

/**
Expand Down
2 changes: 1 addition & 1 deletion doomsday/sdk/libcore/include/de/game/game.h
Expand Up @@ -35,7 +35,7 @@ namespace game {
* <pre>load doom2</pre>
*
* @todo The 'game' namespace can be removed once the client/server apps don't
* declare their own de::Game classes any more.
* declare their own Game classes any more.
*/
class DENG2_PUBLIC Game
{
Expand Down

0 comments on commit eb6ed28

Please sign in to comment.