Skip to content

Commit

Permalink
Refactor: Renamed World as WorldSystem, derive from de::System
Browse files Browse the repository at this point in the history
  • Loading branch information
danij-deng committed Jan 12, 2014
1 parent 6543298 commit 5027182
Show file tree
Hide file tree
Showing 55 changed files with 347 additions and 339 deletions.
4 changes: 2 additions & 2 deletions doomsday/client/client.pro
Expand Up @@ -461,7 +461,7 @@ DENG_HEADERS += \
include/world/surface.h \
include/world/thinkers.h \
include/world/vertex.h \
include/world/world.h
include/world/worldsystem.h

INCLUDEPATH += \
$$DENG_INCLUDE_DIR \
Expand Down Expand Up @@ -780,7 +780,7 @@ SOURCES += \
src/world/surface.cpp \
src/world/thinkers.cpp \
src/world/vertex.cpp \
src/world/world.cpp
src/world/worldsystem.cpp

!deng_nosdlmixer:!deng_nosdl {
HEADERS += include/audio/sys_audiod_sdlmixer.h
Expand Down
4 changes: 2 additions & 2 deletions doomsday/client/include/clientapp.h
Expand Up @@ -31,7 +31,7 @@
#include "WidgetActions"
#include "updater.h"
#include "Games"
#include "world/world.h"
#include "world/worldsystem.h"

/**
* The client application.
Expand Down Expand Up @@ -73,7 +73,7 @@ class ClientApp : public de::BaseGuiApp
static ResourceSystem &resourceSystem();
static WidgetActions &widgetActions();
static de::Games &games();
static de::World &world();
static de::WorldSystem &worldSystem();

public slots:
void openHomepageInBrowser();
Expand Down
8 changes: 4 additions & 4 deletions doomsday/client/include/dd_main.h
Expand Up @@ -31,7 +31,7 @@
#include "dd_types.h"
#include "resource/resourcesystem.h"
#include "Games"
#include "world/world.h"
#include "world/worldsystem.h"
#include "api_plugin.h"
#include "api_gameexport.h"
#include "filesys/sys_direc.h"
Expand Down Expand Up @@ -146,6 +146,9 @@ de::String DD_MaterialSchemeNameForTextureScheme(de::String textureSchemeName);
/// @return The application's global ResourceSystem.
ResourceSystem &App_ResourceSystem();

/// @return The application's global WorldSystem.
de::WorldSystem &App_WorldSystem();

/**
* Convenient method of returning a resource class from the application's global
* resource system.
Expand All @@ -172,9 +175,6 @@ bool App_ChangeGame(de::Game &game, bool allowReload = false);
/// @return The application's global Games (collection).
de::Games &App_Games();

/// @return The application's global World.
de::World &App_World();

fontschemeid_t DD_ParseFontSchemeName(char const *str);

/// @return Symbolic name of the material scheme associated with @a textureSchemeName.
Expand Down
8 changes: 4 additions & 4 deletions doomsday/client/include/world/hand.h
Expand Up @@ -21,7 +21,7 @@
#define DENG_WORLD_HAND_H

#include "Grabbable"
#include "world/world.h"
#include "world/worldsystem.h"

#include <de/Observers>
#include <de/Vector>
Expand All @@ -46,7 +46,7 @@ namespace internal {
*
* @ingroup world
*/
class Hand : DENG2_OBSERVES(de::World, FrameEnd)
class Hand : DENG2_OBSERVES(de::WorldSystem, FrameEnd)
{
DENG2_NO_COPY (Hand)
DENG2_NO_ASSIGN(Hand)
Expand Down Expand Up @@ -163,8 +163,8 @@ class Hand : DENG2_OBSERVES(de::World, FrameEnd)

#ifdef __CLIENT__
protected:
/// Observes World FrameEnd
void worldFrameEnds(de::World &world);
/// Observes WorldSystem FrameEnd
void worldSystemFrameEnds();
#endif

private:
Expand Down
8 changes: 4 additions & 4 deletions doomsday/client/include/world/map.h
Expand Up @@ -31,7 +31,7 @@
# include "client/clplanemover.h"
# include "client/clpolymover.h"

# include "world/world.h"
# include "world/worldsystem.h"
# include "p_particle.h"

# include "BiasSource"
Expand Down Expand Up @@ -75,7 +75,7 @@ class Thinkers;
*/
class Map
#ifdef __CLIENT__
: DENG2_OBSERVES(World, FrameBegin)
: DENG2_OBSERVES(WorldSystem, FrameBegin)
#endif
{
DENG2_NO_COPY (Map)
Expand Down Expand Up @@ -716,8 +716,8 @@ class Map
void spreadAllContacts(AABoxd const &region);

protected:
/// Observes World FrameBegin
void worldFrameBegins(World &world, bool resetNextViewer);
/// Observes WorldSystem FrameBegin
void worldSystemFrameBegins(bool resetNextViewer);

#endif // __CLIENT__

Expand Down
@@ -1,4 +1,4 @@
/** @file world.h World.
/** @file worldsystem.h World subsystem.
*
* Ideas for improvement:
*
Expand Down Expand Up @@ -27,13 +27,14 @@
* 02110-1301 USA</small>
*/

#ifndef DENG_WORLD_H
#define DENG_WORLD_H
#ifndef DENG_WORLDSYSTEM_H
#define DENG_WORLDSYSTEM_H

#include "uri.hh"
#include <de/libdeng1.h>
#include <de/Error>
#include <de/Observers>
#include <de/System>

#ifdef __CLIENT__
class Hand;
Expand All @@ -45,34 +46,32 @@ class Map;

/**
* @ingroup world
*
* @todo Derive from de::System
*/
class World
class WorldSystem : public de::System
{
DENG2_NO_COPY (World)
DENG2_NO_ASSIGN(World)

public:
/// No map is currently loaded. @ingroup errors
DENG2_ERROR(MapError);

/// Notified whenever the "current" map changes.
DENG2_DEFINE_AUDIENCE(MapChange, void worldMapChanged(World &world))
DENG2_DEFINE_AUDIENCE(MapChange, void worldSystemMapChanged())

#ifdef __CLIENT__
/// Notified when a new frame begins.
DENG2_DEFINE_AUDIENCE(FrameBegin, void worldFrameBegins(World &world, bool resetNextViewer))
DENG2_DEFINE_AUDIENCE(FrameBegin, void worldSystemFrameBegins(bool resetNextViewer))

/// Notified when the "current" frame ends.
DENG2_DEFINE_AUDIENCE(FrameEnd, void worldFrameEnds(World &world))
DENG2_DEFINE_AUDIENCE(FrameEnd, void worldSystemFrameEnds())
#endif

public:
/**
* Construct a new world with no "current" map.
* Construct a new world system (no map is loaded by default).
*/
World();
WorldSystem();

// System.
void timeChanged(de::Clock const &);

/**
* To be called to register the commands and variables of this module.
Expand Down
12 changes: 6 additions & 6 deletions doomsday/client/src/client/cl_main.cpp
Expand Up @@ -95,18 +95,18 @@ void Cl_CleanUp()
clientPaused = false;
handshakeReceived = false;

if(App_World().hasMap())
if(App_WorldSystem().hasMap())
{
Cl_ResetFrame();
App_World().map().clearClMobjs();
App_WorldSystem().map().clearClMobjs();
}

Cl_InitPlayers();
Cl_ResetTransTables();

if(App_World().hasMap())
if(App_WorldSystem().hasMap())
{
App_World().map().clearClMovers();
App_WorldSystem().map().clearClMovers();
}

GL_SetFilter(false);
Expand Down Expand Up @@ -459,9 +459,9 @@ void Cl_Ticker(timespan_t ticLength)
#endif
}

if(App_World().hasMap())
if(App_WorldSystem().hasMap())
{
App_World().map().expireClMobjs();
App_WorldSystem().map().expireClMobjs();
}
}

Expand Down
6 changes: 3 additions & 3 deletions doomsday/client/src/client/cl_mobj.cpp
Expand Up @@ -326,7 +326,7 @@ static dd_bool ClMobj_IsStuckInsideLocalPlayer(mobj_t *mo)
void ClMobj_ReadDelta()
{
/// @todo Do not assume the CURRENT map.
Map &map = App_World().map();
Map &map = App_WorldSystem().map();

thid_t const id = Reader_ReadUInt16(msgReader); // Read the ID.
int const df = Reader_ReadUInt16(msgReader); // Flags.
Expand Down Expand Up @@ -575,7 +575,7 @@ void ClMobj_ReadNullDelta()
LOG_AS("ClMobj_ReadNullDelta");

/// @todo Do not assume the CURRENT map.
Map &map = App_World().map();
Map &map = App_WorldSystem().map();

// The delta only contains an ID.
thid_t id = Reader_ReadUInt16(msgReader);
Expand Down Expand Up @@ -618,7 +618,7 @@ void ClMobj_ReadNullDelta()
mobj_t *ClMobj_Find(thid_t id)
{
/// @todo Do not assume the CURRENT map.
return App_World().map().clMobjFor(id);
return App_WorldSystem().map().clMobjFor(id);
}

// cl_player.c
Expand Down
4 changes: 2 additions & 2 deletions doomsday/client/src/client/cl_player.cpp
Expand Up @@ -264,7 +264,7 @@ void ClPlayer_MoveLocal(coord_t dx, coord_t dy, coord_t z, bool onground)
Mobj_Link(mo, MLF_SECTOR | MLF_BLOCKMAP);
}

mo->_bspLeaf = &App_World().map().bspLeafAt_FixedPrecision(Mobj_Origin(*mo));
mo->_bspLeaf = &App_WorldSystem().map().bspLeafAt_FixedPrecision(Mobj_Origin(*mo));
mo->floorZ = Mobj_Sector(mo)->floor().height();
mo->ceilingZ = Mobj_Sector(mo)->ceiling().height();

Expand All @@ -285,7 +285,7 @@ void ClPlayer_ReadDelta()
LOG_AS("ClPlayer_ReadDelta2");

/// @todo Do not assume the CURRENT map.
Map &map = App_World().map();
Map &map = App_WorldSystem().map();

int df = 0;
ushort num;
Expand Down
4 changes: 2 additions & 2 deletions doomsday/client/src/client/cl_sound.cpp
Expand Up @@ -32,7 +32,7 @@ void Cl_ReadSoundDelta(deltatype_t type)
LOG_AS("Cl_ReadSoundDelta");

/// @todo Do not assume the CURRENT map.
Map &map = App_World().map();
Map &map = App_WorldSystem().map();

int sound = 0, soundFlags = 0;
mobj_t *cmo = 0;
Expand Down Expand Up @@ -231,7 +231,7 @@ void Cl_Sound()
LOG_AS("Cl_Sound");

/// @todo Do not assume the CURRENT map.
Map &map = App_World().map();
Map &map = App_WorldSystem().map();

byte const flags = Reader_ReadByte(msgReader);

Expand Down
6 changes: 3 additions & 3 deletions doomsday/client/src/client/cl_world.cpp
Expand Up @@ -152,7 +152,7 @@ int Cl_LocalMobjState(int serverMobjState)
void Cl_ReadSectorDelta(int /*deltaType*/)
{
/// @todo Do not assume the CURRENT map.
Map &map = App_World().map();
Map &map = App_WorldSystem().map();

#define PLN_FLOOR 0
#define PLN_CEILING 1
Expand Down Expand Up @@ -260,7 +260,7 @@ void Cl_ReadSectorDelta(int /*deltaType*/)
void Cl_ReadSideDelta(int /*deltaType*/)
{
/// @todo Do not assume the CURRENT map.
Map &map = App_World().map();
Map &map = App_WorldSystem().map();

int const index = Reader_ReadUInt16(msgReader);
int const df = Reader_ReadPackedUInt32(msgReader); // Flags.
Expand Down Expand Up @@ -350,7 +350,7 @@ void Cl_ReadSideDelta(int /*deltaType*/)
void Cl_ReadPolyDelta()
{
/// @todo Do not assume the CURRENT map.
Map &map = App_World().map();
Map &map = App_WorldSystem().map();

int const index = Reader_ReadPackedUInt16(msgReader);
int const df = Reader_ReadByte(msgReader); // Flags.
Expand Down
2 changes: 1 addition & 1 deletion doomsday/client/src/client/clpolymover.cpp
Expand Up @@ -86,6 +86,6 @@ void ClPolyMover_Thinker(ClPolyMover *mover)
if(!mover->move && !mover->rotate)
{
/// @todo Do not assume the move is from the CURRENT map.
App_World().map().deleteClPolyMover(mover);
App_WorldSystem().map().deleteClPolyMover(mover);
}
}
14 changes: 11 additions & 3 deletions doomsday/client/src/clientapp.cpp
Expand Up @@ -136,7 +136,7 @@ DENG2_PIMPL(ClientApp)
WindowSystem *winSys;
ServerLink *svLink;
Games games;
World world;
WorldSystem *worldSys;

/**
* Log entry sink that passes warning messages to the main window's alert
Expand Down Expand Up @@ -185,6 +185,7 @@ DENG2_PIMPL(ClientApp)
, renderSys(0)
, resourceSys(0)
, winSys(0)
, worldSys(0)
, svLink(0)
{
clientAppSingleton = thisPublic;
Expand All @@ -200,6 +201,7 @@ DENG2_PIMPL(ClientApp)
DD_Shutdown();

delete svLink;
delete worldSys;
delete winSys;
delete renderSys;
delete resourceSys;
Expand Down Expand Up @@ -391,6 +393,10 @@ void ClientApp::initialize()
addSystem(*d->inputSys);
d->widgetActions.reset(new WidgetActions);

// Create the world system.
d->worldSys = new WorldSystem;
addSystem(*d->worldSys);

// Finally, run the bootstrap script.
scriptSystem().importModule("bootstrap");

Expand Down Expand Up @@ -506,9 +512,11 @@ Games &ClientApp::games()
return app().d->games;
}

World &ClientApp::world()
WorldSystem &ClientApp::worldSystem()
{
return app().d->world;
ClientApp &a = ClientApp::app();
DENG2_ASSERT(a.d->worldSys != 0);
return *a.d->worldSys;
}

void ClientApp::openHomepageInBrowser()
Expand Down
2 changes: 1 addition & 1 deletion doomsday/client/src/dd_loop.cpp
Expand Up @@ -278,7 +278,7 @@ static void advanceTime(timespan_t delta)
}

// World time always advances unless a local game is paused on client-side.
App_World().advanceTime(delta);
App_WorldSystem().advanceTime(delta);
}
}

Expand Down

0 comments on commit 5027182

Please sign in to comment.