From d51e6fb7c43acb311838630a5fe38244942da0fc Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Sat, 3 Jul 2010 15:41:20 +0200 Subject: [PATCH] second part of refactoring --- CMakeLists.txt | 19 ++++++++++++------- apps/openmw/engine.cpp | 11 ++++++----- apps/openmw/engine.hpp | 15 +++++++++------ apps/openmw/mwrender/cellimp.cpp | 4 ++-- apps/openmw/mwrender/cellimp.hpp | 4 ++-- apps/openmw/mwrender/interior.hpp | 4 ++-- apps/openmw/mwscript/cellextensions.cpp | 2 +- apps/openmw/mwscript/interpretercontext.cpp | 6 +++--- apps/openmw/mwscript/interpretercontext.hpp | 8 ++++---- apps/openmw/mwsound/extensions.cpp | 2 +- apps/openmw/{ => mwworld}/refdata.hpp | 8 ++++---- apps/openmw/{ => mwworld}/world.cpp | 8 ++++---- apps/openmw/{ => mwworld}/world.hpp | 15 +++++++-------- 13 files changed, 57 insertions(+), 49 deletions(-) rename apps/openmw/{ => mwworld}/refdata.hpp (90%) rename apps/openmw/{ => mwworld}/world.cpp (93%) rename apps/openmw/{ => mwworld}/world.hpp (87%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2e40862778..ab7b531c2e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,12 +10,9 @@ set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/) set(GAME apps/openmw/main.cpp - apps/openmw/engine.cpp - apps/openmw/world.cpp) + apps/openmw/engine.cpp) set(GAME_HEADER - apps/openmw/engine.hpp - apps/openmw/world.hpp - apps/openmw/refdata.hpp) + apps/openmw/engine.hpp) source_group(game FILES ${GAME} ${GAME_HEADER}) set(GAMEREND @@ -60,9 +57,17 @@ set(GAMESOUND_HEADER apps/openmw/mwsound/extensions.hpp) source_group(apps\\openmw\\mwsound FILES ${GAMESOUND} ${GAMESOUND_HEADER}) -set(APPS ${GAME} ${GAMEREND} ${GAMEINPUT} ${GAMESCRIPT} ${GAMESOUND}) +set(GAMEWORLD + apps/openmw/mwworld/world.cpp) +set(GAMEWORLD_HEADER + apps/openmw/mwworld/refdata.hpp + apps/openmw/mwworld/world.hpp) +source_group(apps\\openmw\\mwworld FILES ${GAMEWORLD} ${GAMEWORLD_HEADER}) + + +set(APPS ${GAME} ${GAMEREND} ${GAMEINPUT} ${GAMESCRIPT} ${GAMESOUND} ${GAMEWORLD}) set(APPS_HEADER ${GAME_HEADER} ${GAMEREND_HEADER} ${GAMEINPUT_HEADER} ${GAMESCRIPT_HEADER} - ${GAMESOUND_HEADER}) + ${GAMESOUND_HEADER} ${GAMEWORLD_HEADER}) # source directory: components diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index 455ce5f4e5..f865bb54cb 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -4,10 +4,11 @@ #include -#include "components/misc/fileops.hpp" -#include "components/bsa/bsa_archive.hpp" +#include +#include #include "mwinput/inputmanager.hpp" + #include "mwscript/scriptmanager.hpp" #include "mwscript/compilercontextscript.hpp" #include "mwscript/interpretercontext.hpp" @@ -15,11 +16,11 @@ #include "mwsound/soundmanager.hpp" -#include "world.hpp" +#include "mwworld/world.hpp" void OMW::Engine::executeLocalScripts() { - for (World::ScriptList::const_iterator iter (mWorld->getLocalScripts().begin()); + for (MWWorld::World::ScriptList::const_iterator iter (mWorld->getLocalScripts().begin()); iter!=mWorld->getLocalScripts().end(); ++iter) { MWScript::InterpreterContext interpreterContext (*mWorld, *mSoundManager, iter->second); @@ -163,7 +164,7 @@ void OMW::Engine::go() loadBSA(); // Create the world - mWorld = new World (mOgre, mDataDir, mMaster, mCellName); + mWorld = new MWWorld::World (mOgre, mDataDir, mMaster, mCellName); mSoundManager = new MWSound::SoundManager; diff --git a/apps/openmw/engine.hpp b/apps/openmw/engine.hpp index 9217835a76..ab5fe5dc26 100644 --- a/apps/openmw/engine.hpp +++ b/apps/openmw/engine.hpp @@ -7,10 +7,10 @@ #include -#include "components/engine/ogre/renderer.hpp" -#include "components/misc/tsdeque.hpp" -#include "components/commandserver/server.hpp" -#include "components/commandserver/command.hpp" +#include +#include +#include +#include #include namespace Compiler @@ -28,10 +28,13 @@ namespace MWSound class SoundManager; } -namespace OMW +namespace MWWorld { class World; +} +namespace OMW +{ /// \brief Main engine class, that brings together all the components of OpenMW class Engine : private Ogre::FrameListener @@ -42,7 +45,7 @@ namespace OMW Render::OgreRenderer mOgre; std::string mCellName; std::string mMaster; - World *mWorld; + MWWorld::World *mWorld; bool mDebug; bool mVerboseScripts; diff --git a/apps/openmw/mwrender/cellimp.cpp b/apps/openmw/mwrender/cellimp.cpp index 24512702f9..7a8de957e3 100644 --- a/apps/openmw/mwrender/cellimp.cpp +++ b/apps/openmw/mwrender/cellimp.cpp @@ -18,7 +18,7 @@ void insertObj(CellRenderImp& cellRender, T& liveRef) } template<> -void insertObj(CellRenderImp& cellRender, ESMS::LiveCellRef& liveRef) +void insertObj(CellRenderImp& cellRender, ESMS::LiveCellRef& liveRef) { assert (liveRef.base != NULL); const std::string &model = liveRef.base->model; @@ -50,7 +50,7 @@ void insertCellRefList (CellRenderImp& cellRender, T& cellRefList) } } -void CellRenderImp::insertCell(ESMS::CellStore &cell) +void CellRenderImp::insertCell(ESMS::CellStore &cell) { // Loop through all references in the cell insertCellRefList (*this, cell.activators); diff --git a/apps/openmw/mwrender/cellimp.hpp b/apps/openmw/mwrender/cellimp.hpp index 9f3554bfd5..88406bb4f6 100644 --- a/apps/openmw/mwrender/cellimp.hpp +++ b/apps/openmw/mwrender/cellimp.hpp @@ -5,7 +5,7 @@ #include "components/esm_store/cell_store.hpp" -#include "../refdata.hpp" +#include "../mwworld/refdata.hpp" namespace ESM { @@ -35,7 +35,7 @@ namespace MWRender /// finish inserting a new reference and return a handle to it. virtual std::string insertEnd() = 0; - void insertCell(ESMS::CellStore &cell); + void insertCell(ESMS::CellStore &cell); }; } diff --git a/apps/openmw/mwrender/interior.hpp b/apps/openmw/mwrender/interior.hpp index f7ec786a3a..5eda4eccd0 100644 --- a/apps/openmw/mwrender/interior.hpp +++ b/apps/openmw/mwrender/interior.hpp @@ -42,7 +42,7 @@ namespace MWRender static bool lightOutQuadInLin; - ESMS::CellStore &cell; + ESMS::CellStore &cell; MWScene &scene; /// The scene node that contains all objects belonging to this @@ -78,7 +78,7 @@ namespace MWRender public: - InteriorCellRender(ESMS::CellStore &_cell, MWScene &_scene) + InteriorCellRender(ESMS::CellStore &_cell, MWScene &_scene) : cell(_cell), scene(_scene), base(NULL), insert(NULL), ambientMode (0) {} virtual ~InteriorCellRender() { destroy(); } diff --git a/apps/openmw/mwscript/cellextensions.cpp b/apps/openmw/mwscript/cellextensions.cpp index 0c74b11e0d..73e131a8de 100644 --- a/apps/openmw/mwscript/cellextensions.cpp +++ b/apps/openmw/mwscript/cellextensions.cpp @@ -7,7 +7,7 @@ #include #include -#include "../world.hpp" +#include "../mwworld/world.hpp" #include "interpretercontext.hpp" diff --git a/apps/openmw/mwscript/interpretercontext.cpp b/apps/openmw/mwscript/interpretercontext.cpp index 8edfbf5809..701c7083e5 100644 --- a/apps/openmw/mwscript/interpretercontext.cpp +++ b/apps/openmw/mwscript/interpretercontext.cpp @@ -5,11 +5,11 @@ #include #include "locals.hpp" -#include "../world.hpp" +#include "../mwworld/world.hpp" namespace MWScript { - InterpreterContext::InterpreterContext (OMW::World& world, + InterpreterContext::InterpreterContext (MWWorld::World& world, MWSound::SoundManager& soundManager, MWScript::Locals *locals) : mWorld (world), mSoundManager (soundManager), mLocals (locals) {} @@ -71,7 +71,7 @@ namespace MWScript std::cerr << "error: message box buttons not supported" << std::endl; } - OMW::World& InterpreterContext::getWorld() + MWWorld::World& InterpreterContext::getWorld() { return mWorld; } diff --git a/apps/openmw/mwscript/interpretercontext.hpp b/apps/openmw/mwscript/interpretercontext.hpp index ac5863f1a6..2087755540 100644 --- a/apps/openmw/mwscript/interpretercontext.hpp +++ b/apps/openmw/mwscript/interpretercontext.hpp @@ -3,7 +3,7 @@ #include -namespace OMW +namespace MWWorld { class World; } @@ -19,13 +19,13 @@ namespace MWScript class InterpreterContext : public Interpreter::Context { - OMW::World& mWorld; + MWWorld::World& mWorld; MWSound::SoundManager& mSoundManager; Locals *mLocals; public: - InterpreterContext (OMW::World& world, MWSound::SoundManager& soundManager, + InterpreterContext (MWWorld::World& world, MWSound::SoundManager& soundManager, MWScript::Locals *locals); ///< The ownership of \a locals is not transferred. 0-pointer allowed. @@ -44,7 +44,7 @@ namespace MWScript virtual void messageBox (const std::string& message, const std::vector& buttons); - OMW::World& getWorld(); + MWWorld::World& getWorld(); MWSound::SoundManager& getSoundManager(); }; diff --git a/apps/openmw/mwsound/extensions.cpp b/apps/openmw/mwsound/extensions.cpp index 83177b1023..9540da6376 100644 --- a/apps/openmw/mwsound/extensions.cpp +++ b/apps/openmw/mwsound/extensions.cpp @@ -9,7 +9,7 @@ #include "../mwscript/interpretercontext.hpp" -#include "../world.hpp" +#include "../mwworld/world.hpp" #include "soundmanager.hpp" diff --git a/apps/openmw/refdata.hpp b/apps/openmw/mwworld/refdata.hpp similarity index 90% rename from apps/openmw/refdata.hpp rename to apps/openmw/mwworld/refdata.hpp index f10c272980..a7e137b9dd 100644 --- a/apps/openmw/refdata.hpp +++ b/apps/openmw/mwworld/refdata.hpp @@ -1,16 +1,16 @@ -#ifndef REFDATA_H -#define REFDATA_H +#ifndef GAME_MWWORLD_REFDATA_H +#define GAME_MWWORLD_REFDATA_H #include -#include "mwscript/locals.hpp" +#include "../mwscript/locals.hpp" namespace ESM { class Script; } -namespace OMW +namespace MWWorld { class RefData { diff --git a/apps/openmw/world.cpp b/apps/openmw/mwworld/world.cpp similarity index 93% rename from apps/openmw/world.cpp rename to apps/openmw/mwworld/world.cpp index 59db2ea9a0..2ec6fd54be 100644 --- a/apps/openmw/world.cpp +++ b/apps/openmw/mwworld/world.cpp @@ -13,9 +13,9 @@ namespace { template void listCellScripts (const ESMS::ESMStore& store, - ESMS::CellRefList& cellRefList, OMW::World::ScriptList& scriptList) + ESMS::CellRefList& cellRefList, MWWorld::World::ScriptList& scriptList) { - for (typename ESMS::CellRefList::List::iterator iter ( + for (typename ESMS::CellRefList::List::iterator iter ( cellRefList.list.begin()); iter!=cellRefList.list.end(); ++iter) { @@ -33,9 +33,9 @@ namespace } } -namespace OMW +namespace MWWorld { - void World::insertInteriorScripts (ESMS::CellStore& cell) + void World::insertInteriorScripts (ESMS::CellStore& cell) { listCellScripts (mStore, cell.activators, mLocalScripts); listCellScripts (mStore, cell.potions, mLocalScripts); diff --git a/apps/openmw/world.hpp b/apps/openmw/mwworld/world.hpp similarity index 87% rename from apps/openmw/world.hpp rename to apps/openmw/mwworld/world.hpp index fc466cdc68..f81fb5c213 100644 --- a/apps/openmw/world.hpp +++ b/apps/openmw/mwworld/world.hpp @@ -1,16 +1,15 @@ -#ifndef WORLD_H -#define WORLD_H +#ifndef GAME_MWWORLD_WORLD_H +#define GAME_MWWORLD_WORLD_H #include #include #include -#include "components/esm_store/cell_store.hpp" - -#include "apps/openmw/mwrender/playerpos.hpp" -#include "apps/openmw/mwrender/mwscene.hpp" +#include +#include "../mwrender/playerpos.hpp" +#include "../mwrender/mwscene.hpp" #include "refdata.hpp" @@ -25,7 +24,7 @@ namespace MWRender class CellRender; } -namespace OMW +namespace MWWorld { /// \brief The game world and its visual representation @@ -54,7 +53,7 @@ namespace OMW World (const World&); World& operator= (const World&); - void insertInteriorScripts (ESMS::CellStore& cell); + void insertInteriorScripts (ESMS::CellStore& cell); public: