Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Refactor|Cleanup: Games belong in libdoomsday
Relocated all game-related classes from libcore to libdoomsday.
libcore is too low-level for this kind of functionality.

The game namespaces were removed as unnecessary.

SavedSession now provides an interpreter for .save files rather than
being bundled in ZipArchive's interpreter.

Removed de/c_wrapper.h from libdoomsday.h, which was polluting the
global namespace unnecessary.
  • Loading branch information
skyjake committed Jan 17, 2016
1 parent caa68b3 commit 7af8a41
Show file tree
Hide file tree
Showing 71 changed files with 385 additions and 354 deletions.
2 changes: 1 addition & 1 deletion doomsday/CMakeLists.txt
Expand Up @@ -7,8 +7,8 @@ project (Doomsday)
include (cmake/Config.cmake)

add_subdirectory (sdk)
add_subdirectory (apps)
if (DENG_ENABLE_TOOLS)
add_subdirectory (tools)
endif ()
add_subdirectory (apps)
add_subdirectory (tests)
2 changes: 1 addition & 1 deletion doomsday/apps/client/include/render/rend_main.h
Expand Up @@ -257,7 +257,7 @@ de::duint Rend_CollectAffectingLights(de::Vector3d const &point,
de::Vector3f const &ambientColor = de::Vector3f(1, 1, 1), ConvexSubspace *subspace = nullptr,
bool starkLight = false);

void Rend_DrawVectorLight(VectorLightData const &vlight, dfloat alpha);
void Rend_DrawVectorLight(VectorLightData const &vlight, de::dfloat alpha);

/**
* Returns the radius of the given @a sprite, as it would visually appear to be.
Expand Down
Expand Up @@ -21,7 +21,7 @@
#define DENG_CLIENT_SAVEDSESSIONMENUWIDGET_H

#include "sessionmenuwidget.h"
#include <de/game/SavedSession>
#include <doomsday/SavedSession>

/**
* Menu that populates itself with available saved game sessions.
Expand Down
9 changes: 5 additions & 4 deletions doomsday/apps/client/src/audio/system.cpp
Expand Up @@ -54,6 +54,7 @@
#endif
#include <de/App>
#include <de/timer.h>
#include <de/c_wrapper.h>
#ifdef __CLIENT__
# include <de/concurrency.h>
# include <de/memory.h>
Expand Down Expand Up @@ -188,7 +189,7 @@ static bool recognizeMus(de::File1 &file)

DENG2_PIMPL(System)
#ifdef __CLIENT__
, DENG2_OBSERVES(App, GameUnload)
, DENG2_OBSERVES(DoomsdayApp, GameUnload)
, DENG2_OBSERVES(SfxSampleCache, SampleRemove)
#endif
{
Expand Down Expand Up @@ -597,7 +598,7 @@ DENG2_PIMPL(System)
theAudioSystem = thisPublic;

#ifdef __CLIENT__
App::app().audienceForGameUnload() += this;
DoomsdayApp::app().audienceForGameUnload() += this;
sfxSampleCache.audienceForSampleRemove() += this;
#endif
}
Expand All @@ -607,7 +608,7 @@ DENG2_PIMPL(System)
sfxClearLogical();
#ifdef __CLIENT__
sfxSampleCache.audienceForSampleRemove() -= this;
App::app().audienceForGameUnload() -= this;
DoomsdayApp::app().audienceForGameUnload() -= this;
#endif

theAudioSystem = nullptr;
Expand Down Expand Up @@ -1379,7 +1380,7 @@ DENG2_PIMPL(System)
unloadSoundID(sample.id);
}

void aboutToUnloadGame(game::Game const &)
void aboutToUnloadGame(Game const &)
{
self.reset();
}
Expand Down
26 changes: 14 additions & 12 deletions doomsday/apps/client/src/dd_main.cpp
Expand Up @@ -45,12 +45,12 @@
#include <de/timer.h>
#include <de/ArrayValue>
#include <de/DictionaryValue>
#include <de/game/Session>
#include <de/Log>
#include <de/NativePath>
#ifdef __CLIENT__
# include <de/DisplayMode>
#endif
#include <doomsday/Session>
#include <doomsday/console/alias.h>
#include <doomsday/console/cmd.h>
#include <doomsday/console/exec.h>
Expand Down Expand Up @@ -1041,7 +1041,7 @@ static dint DD_LoadAddonResourcesWorker(void *context)
/**
* Phase 3: Add real files from the Auto directory.
*/
game::Session::Profile &prof = game::Session::profile();
Session::Profile &prof = Session::profile();

FS1::PathList found;
findAllGameDataPaths(found);
Expand Down Expand Up @@ -1221,7 +1221,7 @@ Games &App_Games()
void App_ClearGames()
{
App_Games().clear();
App::app().setGame(App_Games().nullGame());
DoomsdayApp::setGame(App_Games().nullGame());
}

static void populateGameInfo(GameInfo &info, Game &game)
Expand Down Expand Up @@ -1356,9 +1356,10 @@ bool App_ChangeGame(Game &game, bool allowReload)
}

// The current game will be gone very soon.
DENG2_FOR_EACH_OBSERVER(App::GameUnloadAudience, i, App::app().audienceForGameUnload())
DENG2_FOR_EACH_OBSERVER(DoomsdayApp::GameUnloadAudience, i,
DoomsdayApp::app().audienceForGameUnload())
{
i->aboutToUnloadGame(App::game());
i->aboutToUnloadGame(DoomsdayApp::game());
}

// Quit netGame if one is in progress.
Expand Down Expand Up @@ -1448,10 +1449,10 @@ bool App_ChangeGame(Game &game, bool allowReload)
}

// We do not want to load session resources specified on the command line again.
game::Session::profile().resourceFiles.clear();
Session::profile().resourceFiles.clear();

// The current game is now the special "null-game".
App::app().setGame(App_Games().nullGame());
DoomsdayApp::setGame(App_Games().nullGame());

Con_InitDatabases();
consoleRegister();
Expand Down Expand Up @@ -1517,8 +1518,8 @@ bool App_ChangeGame(Game &game, bool allowReload)
}

// This is now the current game.
App::app().setGame(game);
game::Session::profile().gameId = game.id();
DoomsdayApp::setGame(game);
Session::profile().gameId = game.id();

#ifdef __CLIENT__
ClientWindow::main().setWindowTitle(DD_ComposeMainWindowTitle());
Expand Down Expand Up @@ -1620,9 +1621,10 @@ bool App_ChangeGame(Game &game, bool allowReload)
#endif

// Game change is complete.
DENG2_FOR_EACH_OBSERVER(App::GameChangeAudience, i, App::app().audienceForGameChange())
DENG2_FOR_EACH_OBSERVER(DoomsdayApp::GameChangeAudience, i,
DoomsdayApp::app().audienceForGameChange())
{
i->currentGameChanged(App::game());
i->currentGameChanged(DoomsdayApp::game());
}

return true;
Expand Down Expand Up @@ -1820,7 +1822,7 @@ static void initialize()
// An implicit game session profile has been defined.
// Add all resources specified using -file options on the command line
// to the list for the session.
game::Session::Profile &prof = game::Session::profile();
Session::Profile &prof = Session::profile();

for(dint p = 0; p < CommandLine_Count(); ++p)
{
Expand Down
1 change: 1 addition & 0 deletions doomsday/apps/client/src/def_main.cpp
Expand Up @@ -28,6 +28,7 @@
#include <QMap>
#include <QTextStream>
#include <de/findfile.h>
#include <de/c_wrapper.h>
#include <de/App>
#include <de/NativePath>
#include <de/RecordValue>
Expand Down
2 changes: 2 additions & 0 deletions doomsday/apps/client/src/render/projectionlist.cpp
Expand Up @@ -20,6 +20,8 @@

#include <de/memoryzone.h>

using namespace de;

ProjectionList::Node *ProjectionList::firstNode = nullptr;
ProjectionList::Node *ProjectionList::cursorNode = nullptr;

Expand Down
8 changes: 4 additions & 4 deletions doomsday/apps/client/src/resource/resourcesystem.cpp
Expand Up @@ -30,8 +30,6 @@
#include <de/ArrayValue>
#include <de/ByteRefArray>
#include <de/DirectoryFeed>
#include <de/game/SavedSession>
#include <de/game/Session>
#include <de/Log>
#include <de/Loop>
#include <de/Module>
Expand All @@ -53,6 +51,8 @@
#include <doomsday/filesys/fs_main.h>
#include <doomsday/filesys/fs_util.h>
#include <doomsday/filesys/lumpindex.h>
#include <doomsday/SavedSession>
#include <doomsday/Session>

#ifdef __CLIENT__
# include "clientapp.h"
Expand Down Expand Up @@ -4409,10 +4409,10 @@ D_CMD(InspectSavegame)
// If a game is loaded assume the user is referring to those savegames if not specified.
if(savePath.fileNamePath().isEmpty() && App_GameLoaded())
{
savePath = game::Session::savePath() / savePath;
savePath = Session::savePath() / savePath;
}

if(game::SavedSession const *saved = App::rootFolder().tryLocate<game::SavedSession>(savePath))
if(SavedSession const *saved = App::rootFolder().tryLocate<SavedSession>(savePath))
{
LOG_SCR_MSG("%s") << saved->metadata().asStyledText();
LOG_SCR_MSG(_E(D) "Resource: " _E(.)_E(i) "\"%s\"") << saved->path();
Expand Down
20 changes: 11 additions & 9 deletions doomsday/apps/client/src/settingsregister.cpp
Expand Up @@ -21,14 +21,16 @@
#include "api_console.h"

#include <de/App>
#include <de/game/Game>
#include <de/Script>
#include <de/Process>
#include <de/RecordValue>
#include <de/NumberValue>
#include <de/ZipArchive>
#include <de/Info>

#include <doomsday/doomsdayapp.h>
#include <doomsday/Game>

#include <QMap>
#include <QList>
#include <QTextStream>
Expand All @@ -38,8 +40,8 @@ using namespace de;
static String const CUSTOM_PROFILE = "Custom";

DENG2_PIMPL(SettingsRegister),
DENG2_OBSERVES(App, GameUnload),
DENG2_OBSERVES(App, GameChange)
DENG2_OBSERVES(DoomsdayApp, GameUnload),
DENG2_OBSERVES(DoomsdayApp, GameChange)
{
struct Setting
{
Expand Down Expand Up @@ -106,16 +108,16 @@ DENG2_OBSERVES(App, GameChange)

Instance(Public *i) : Base(i), current(CUSTOM_PROFILE)
{
App::app().audienceForGameUnload() += this;
App::app().audienceForGameChange() += this;
DoomsdayApp::app().audienceForGameUnload() += this;
DoomsdayApp::app().audienceForGameChange() += this;

addProfile(current);
}

~Instance()
{
App::app().audienceForGameUnload() -= this;
App::app().audienceForGameChange() -= this;
DoomsdayApp::app().audienceForGameUnload() -= this;
DoomsdayApp::app().audienceForGameChange() -= this;

clearProfiles();
}
Expand Down Expand Up @@ -407,7 +409,7 @@ DENG2_OBSERVES(App, GameChange)
*
* @param newGame New current game.
*/
void currentGameChanged(game::Game const &newGame)
void currentGameChanged(Game const &newGame)
{
if(persistentName.isEmpty() || newGame.isNull()) return;

Expand Down Expand Up @@ -486,7 +488,7 @@ DENG2_OBSERVES(App, GameChange)
*
* @param gameBeingUnloaded Current game.
*/
void aboutToUnloadGame(game::Game const &gameBeingUnloaded)
void aboutToUnloadGame(Game const &gameBeingUnloaded)
{
if(persistentName.isEmpty() || gameBeingUnloaded.isNull()) return;

Expand Down
12 changes: 6 additions & 6 deletions doomsday/apps/client/src/ui/clientwindow.cpp
Expand Up @@ -71,11 +71,11 @@ static inline InputSystem &inputSys()
static ClientWindow *mainWindow = nullptr; // The main window, set after fully constructed.

DENG2_PIMPL(ClientWindow)
, DENG2_OBSERVES(MouseEventSource, MouseStateChange)
, DENG2_OBSERVES(Canvas, FocusChange)
, DENG2_OBSERVES(App, GameChange)
, DENG2_OBSERVES(App, StartupComplete)
, DENG2_OBSERVES(Games, Readiness)
, DENG2_OBSERVES(DoomsdayApp, GameChange)
, DENG2_OBSERVES(MouseEventSource, MouseStateChange)
, DENG2_OBSERVES(Canvas, FocusChange)
, DENG2_OBSERVES(Variable, Change)
{
bool needMainInit = true;
Expand Down Expand Up @@ -125,7 +125,7 @@ DENG2_PIMPL(ClientWindow)
/// @todo The decision whether to receive input notifications from the
/// canvas is really a concern for the input drivers.

App::app().audienceForGameChange() += this;
DoomsdayApp::app().audienceForGameChange() += this;
App::app().audienceForStartupComplete() += this;
App_Games().audienceForReadiness() += this;

Expand All @@ -145,7 +145,7 @@ DENG2_PIMPL(ClientWindow)
App::config(s).audienceForChange() -= this;
}

App::app().audienceForGameChange() -= this;
DoomsdayApp::app().audienceForGameChange() -= this;
App::app().audienceForStartupComplete() -= this;
App_Games().audienceForReadiness() -= this;

Expand Down Expand Up @@ -365,7 +365,7 @@ DENG2_PIMPL(ClientWindow)
}
}

void currentGameChanged(game::Game const &newGame)
void currentGameChanged(Game const &newGame)
{
if(newGame.isNull())
{
Expand Down
8 changes: 4 additions & 4 deletions doomsday/apps/client/src/ui/controllerpresets.cpp
Expand Up @@ -35,7 +35,7 @@ using namespace de;
static String VAR_CONTROLLER_PRESETS("controllerPresets");

DENG2_PIMPL_NOREF(ControllerPresets)
, DENG2_OBSERVES(App, GameChange)
, DENG2_OBSERVES(DoomsdayApp, GameChange)
{
Record &inputModule;
char const *presetCVarPath = nullptr;
Expand All @@ -45,12 +45,12 @@ DENG2_PIMPL_NOREF(ControllerPresets)
: inputModule(App::scriptSystem().nativeModule("Input"))
{
inputModule.addDictionary(VAR_CONTROLLER_PRESETS);
App::app().audienceForGameChange() += this;
DoomsdayApp::app().audienceForGameChange() += this;
}

~Instance()
{
App::app().audienceForGameChange() -= this;
DoomsdayApp::app().audienceForGameChange() -= this;
}

DictionaryValue const &presets() const
Expand Down Expand Up @@ -116,7 +116,7 @@ DENG2_PIMPL_NOREF(ControllerPresets)
return Con_FindVariable(presetCVarPath);
}

void currentGameChanged(game::Game const &newGame)
void currentGameChanged(Game const &newGame)
{
String const currentScheme = CVar_String(presetCVar());

Expand Down
Expand Up @@ -39,7 +39,7 @@ using namespace ui;

DENG_GUI_PIMPL(RendererAppearanceEditor),
DENG2_OBSERVES(SettingsRegister, ProfileChange),
DENG2_OBSERVES(App, GameChange),
DENG2_OBSERVES(DoomsdayApp, GameChange),
public VariableGroupEditor::IOwner
{
using Group = VariableGroupEditor;
Expand All @@ -64,7 +64,7 @@ public VariableGroupEditor::IOwner
, settings(ClientApp::renderSystem().appearanceSettings())
{
// The editor will close automatically when going to Ring Zero.
App::app().audienceForGameChange() += this;
DoomsdayApp::app().audienceForGameChange() += this;
settings.audienceForProfileChange += this;

GuiWidget *container = &self.containerWidget();
Expand Down Expand Up @@ -375,7 +375,7 @@ public VariableGroupEditor::IOwner

~Instance()
{
App::app().audienceForGameChange() -= this;
DoomsdayApp::app().audienceForGameChange() -= this;
settings.audienceForProfileChange -= this;
}

Expand All @@ -394,7 +394,7 @@ public VariableGroupEditor::IOwner
settings.resetSettingToDefaults(settingName);
}

void currentGameChanged(game::Game const &newGame)
void currentGameChanged(Game const &newGame)
{
if(newGame.isNull())
{
Expand Down

0 comments on commit 7af8a41

Please sign in to comment.