From 269bfe4f6119f2d2c88990b7f325bac68cb7dc6a Mon Sep 17 00:00:00 2001 From: danij Date: Sat, 8 Jun 2013 15:22:37 +0100 Subject: [PATCH] World: Encapsulate MapArchive Todo: There is no longer any benefit to separating the MapArchive now that we have a World. MapArchive functionality should be merged into World. --- doomsday/client/include/dd_main.h | 4 ---- doomsday/client/include/world/world.h | 7 +++++++ doomsday/client/src/dd_main.cpp | 10 +--------- doomsday/client/src/render/r_main.cpp | 2 +- doomsday/client/src/world/world.cpp | 16 +++++++++++++++- 5 files changed, 24 insertions(+), 15 deletions(-) diff --git a/doomsday/client/include/dd_main.h b/doomsday/client/include/dd_main.h index 9d05942d65..69d561f357 100644 --- a/doomsday/client/include/dd_main.h +++ b/doomsday/client/include/dd_main.h @@ -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 @@ -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(); diff --git a/doomsday/client/include/world/world.h b/doomsday/client/include/world/world.h index 262b456f75..47be216f7c 100644 --- a/doomsday/client/include/world/world.h +++ b/doomsday/client/include/world/world.h @@ -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; @@ -60,6 +65,8 @@ class World /// @todo Refactor away. void clearMap(); + void resetMapArchive(); + private: DENG2_PRIVATE(d) }; diff --git a/doomsday/client/src/dd_main.cpp b/doomsday/client/src/dd_main.cpp index 9021a932b1..bc011ffefb 100644 --- a/doomsday/client/src/dd_main.cpp +++ b/doomsday/client/src/dd_main.cpp @@ -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; @@ -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"); @@ -666,7 +658,7 @@ void DD_Register(void) Materials::consoleRegister(); Textures::consoleRegister(); Net_Register(); - MapArchive::consoleRegister(); + World::consoleRegister(); MPE_Register(); FI_Register(); } diff --git a/doomsday/client/src/render/r_main.cpp b/doomsday/client/src/render/r_main.cpp index a950a985e1..e3712d48cf 100644 --- a/doomsday/client/src/render/r_main.cpp +++ b/doomsday/client/src/render/r_main.cpp @@ -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) { diff --git a/doomsday/client/src/world/world.cpp b/doomsday/client/src/world/world.cpp index 44ad1ce8b3..a3efe4ce47 100644 --- a/doomsday/client/src/world/world.cpp +++ b/doomsday/client/src/world/world.cpp @@ -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 @@ -67,6 +68,9 @@ DENG2_PIMPL(World) /// Current map. Map *map; + /// The map archive. + MapArchive mapArchive; + Instance(Public *i) : Base(i), map(0) {} }; @@ -74,6 +78,11 @@ DENG2_PIMPL(World) World::World() : d(new Instance(this)) {} +void World::consoleRegister() // static +{ + MapArchive::consoleRegister(); +} + bool World::hasMap() const { return d->map != 0; @@ -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() @@ -409,4 +418,9 @@ void World::clearMap() d->map = 0; } +void World::resetMapArchive() +{ + d->mapArchive.reset(); +} + } // namespace de