Skip to content

Commit

Permalink
World: Encapsulate MapArchive
Browse files Browse the repository at this point in the history
Todo: There is no longer any benefit to separating the MapArchive
now that we have a World. MapArchive functionality should be merged
into World.
  • Loading branch information
danij-deng committed Jun 8, 2013
1 parent 8f7f40d commit 269bfe4
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 15 deletions.
4 changes: 0 additions & 4 deletions doomsday/client/include/dd_main.h
Expand Up @@ -34,7 +34,6 @@
#include "api_plugin.h"
#include "api_gameexport.h"
#include "Materials"
#include "resource/maparchive.h"
#include "resource/textures.h"
#include "filesys/sys_direc.h"
#include <de/c_wrapper.h>
Expand Down Expand Up @@ -192,9 +191,6 @@ de::Game &App_CurrentGame();
/// @return The application's global World.
de::World &App_World();

/// @return The application's global MapArchive.
de::MapArchive &App_MapArchive();

/// @return The application's global Material collection.
de::Materials &App_Materials();

Expand Down
7 changes: 7 additions & 0 deletions doomsday/client/include/world/world.h
Expand Up @@ -49,6 +49,11 @@ class World
*/
World();

/**
* To be called to register the cvars and ccmds for this module.
*/
static void consoleRegister();

bool hasMap() const;

Map &map() const;
Expand All @@ -60,6 +65,8 @@ class World
/// @todo Refactor away.
void clearMap();

void resetMapArchive();

private:
DENG2_PRIVATE(d)
};
Expand Down
10 changes: 1 addition & 9 deletions doomsday/client/src/dd_main.cpp
Expand Up @@ -170,9 +170,6 @@ static size_t numSessionResourceFileList;
extern GETGAMEAPI GetGameAPI;
#endif

// The app's MapArchive.
static MapArchive mapArchive;

// The app's global Material collection.
static Materials *materials;

Expand Down Expand Up @@ -551,11 +548,6 @@ void DD_CreateFileSystemSchemes()
}
}

MapArchive &App_MapArchive()
{
return mapArchive;
}

Textures &App_Textures()
{
if(!textures) throw Error("App_Textures", "Textures collection not yet initialized");
Expand Down Expand Up @@ -666,7 +658,7 @@ void DD_Register(void)
Materials::consoleRegister();
Textures::consoleRegister();
Net_Register();
MapArchive::consoleRegister();
World::consoleRegister();
MPE_Register();
FI_Register();
}
Expand Down
2 changes: 1 addition & 1 deletion doomsday/client/src/render/r_main.cpp
Expand Up @@ -599,7 +599,7 @@ void R_Update()
P_UpdateParticleGens(); // Defs might've changed.

// Reset the archived map cache (the available maps may have changed).
App_MapArchive().reset();
App_World().resetMapArchive();

for(uint i = 0; i < DDMAXPLAYERS; ++i)
{
Expand Down
16 changes: 15 additions & 1 deletion doomsday/client/src/world/world.cpp
Expand Up @@ -35,6 +35,7 @@

#include "audio/s_main.h"
#include "network/net_main.h"
#include "resource/maparchive.h"

#include "render/r_main.h" // R_ResetViewer

Expand Down Expand Up @@ -67,13 +68,21 @@ DENG2_PIMPL(World)
/// Current map.
Map *map;

/// The map archive.
MapArchive mapArchive;

Instance(Public *i) : Base(i), map(0)
{}
};

World::World() : d(new Instance(this))
{}

void World::consoleRegister() // static
{
MapArchive::consoleRegister();
}

bool World::hasMap() const
{
return d->map != 0;
Expand Down Expand Up @@ -110,7 +119,7 @@ bool World::loadMap(de::Uri const &uri)

Z_FreeTags(PU_MAP, PU_PURGELEVEL - 1);

if((d->map = App_MapArchive().loadMap(uri)))
if((d->map = d->mapArchive.loadMap(uri)))
{
LOG_INFO("Map elements: %d Vertexes, %d Lines, %d Sectors, %d BSP Nodes, %d BSP Leafs and %d Segments")
<< d->map->vertexCount() << d->map->lineCount() << d->map->sectorCount()
Expand Down Expand Up @@ -409,4 +418,9 @@ void World::clearMap()
d->map = 0;
}

void World::resetMapArchive()
{
d->mapArchive.reset();
}

} // namespace de

0 comments on commit 269bfe4

Please sign in to comment.