Skip to content

Commit

Permalink
Resources: Added cmd "inspectgame" for logging details of a registere…
Browse files Browse the repository at this point in the history
…d game

The 'inspectgame' command can be used to obtain detailed information
about a registered game. If no identity key is specified yet a game
is currently loaded the current game will be inspected by default.
  • Loading branch information
danij-deng committed Jan 4, 2014
1 parent e14a761 commit bf5bd20
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 3 deletions.
4 changes: 4 additions & 0 deletions doomsday/client/data/cphelp.txt
Expand Up @@ -161,6 +161,10 @@ desc = Execute a command if the condition is true.
[inc]
desc = Add 1 to a cvar.

[inspectgame]
desc = Print detailed information about a registered game to the console.
inf = Params: inspectgame (identityKey)\nFor example, 'inspectgame doom1-ultimate'.

[inspectmap]
desc = Print extended information about the current map to the console.

Expand Down
3 changes: 3 additions & 0 deletions doomsday/client/include/game.h
Expand Up @@ -168,6 +168,9 @@ class Game : public de::game::Game
*/
static void print(Game const &game, int flags);

/// Register the console commands, variables, etc..., of this module.
static void consoleRegister();

private:
DENG2_PRIVATE(d)
};
Expand Down
6 changes: 3 additions & 3 deletions doomsday/client/src/filesys/manifest.cpp
Expand Up @@ -64,8 +64,8 @@ DENG2_PIMPL(ResourceManifest)
{}
};

ResourceManifest::ResourceManifest(resourceclassid_t fClass, int fFlags, String *name)
: d(new Instance(this, fClass, fFlags))
ResourceManifest::ResourceManifest(resourceclassid_t resClass, int fFlags, String *name)
: d(new Instance(this, resClass, fFlags))
{
if(name) addName(*name);
}
Expand All @@ -78,7 +78,7 @@ void ResourceManifest::addName(String newName)
if(!d->names.contains(newName, Qt::CaseInsensitive))
{
d->names.prepend(newName);
}
}
}

void ResourceManifest::addIdentityKey(String newIdKey)
Expand Down
41 changes: 41 additions & 0 deletions doomsday/client/src/game.cpp
Expand Up @@ -21,7 +21,9 @@
#include "de_base.h"
#include "game.h"

#include "con_main.h"
#include "filesys/manifest.h"

#include <de/Error>
#include <de/Log>
#include <QtAlgorithms>
Expand Down Expand Up @@ -258,6 +260,45 @@ void Game::print(Game const &game, int flags)
}
}

D_CMD(InspectGame)
{
DENG2_UNUSED(src);

Game *game = 0;
if(argc < 2)
{
// No game identity key was specified - assume the current game.
if(!App_GameLoaded())
{
LOG_WARNING("No game is currently loaded.\nPlease specify the identity-key of the game to inspect.");
return false;
}
game = &App_CurrentGame();
}
else
{
String idKey = argv[1];
try
{
game = &App_Games().byIdentityKey(idKey);
}
catch(Games::NotFoundError const &)
{
LOG_WARNING("Unknown game '%s'.") << idKey;
return false;
}
}

Game::print(*game, PGF_EVERYTHING);
return true;
}

void Game::consoleRegister() //static
{
C_CMD("inspectgame", "", InspectGame);
C_CMD("inspectgame", "s", InspectGame);
}

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

Expand Down
2 changes: 2 additions & 0 deletions doomsday/client/src/games.cpp
Expand Up @@ -294,6 +294,8 @@ D_CMD(ListGames)
void Games::consoleRegister() //static
{
C_CMD("listgames", "", ListGames);

Game::consoleRegister();
}

} // namespace de
6 changes: 6 additions & 0 deletions doomsday/doc/engine/command/inspectgame.ame
@@ -0,0 +1,6 @@
@summary{
Print detailed information about a registered game to the console.
}
@description{
Params: inspectgame (identityKey) @cbr For example, 'inspectgame doom1-ultimate'.
}

0 comments on commit bf5bd20

Please sign in to comment.