From 35f478071e8ea81bff6b2e06ca14970e796752c7 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Mon, 23 Apr 2012 15:27:03 +0200 Subject: [PATCH] Issue #255: deleted the old environment class and using the new one instead --- apps/openmw/CMakeLists.txt | 2 +- apps/openmw/engine.cpp | 120 +++++++++---------- apps/openmw/engine.hpp | 5 +- apps/openmw/mwbase/environment.cpp | 13 +- apps/openmw/mwbase/environment.hpp | 5 + apps/openmw/mwclass/activator.cpp | 4 +- apps/openmw/mwclass/activator.hpp | 2 +- apps/openmw/mwclass/apparatus.cpp | 9 +- apps/openmw/mwclass/apparatus.hpp | 4 +- apps/openmw/mwclass/armor.cpp | 26 ++-- apps/openmw/mwclass/armor.hpp | 11 +- apps/openmw/mwclass/book.cpp | 13 +- apps/openmw/mwclass/book.hpp | 8 +- apps/openmw/mwclass/clothing.cpp | 16 +-- apps/openmw/mwclass/clothing.hpp | 11 +- apps/openmw/mwclass/container.cpp | 11 +- apps/openmw/mwclass/container.hpp | 4 +- apps/openmw/mwclass/creature.cpp | 15 +-- apps/openmw/mwclass/creature.hpp | 8 +- apps/openmw/mwclass/door.cpp | 17 +-- apps/openmw/mwclass/door.hpp | 4 +- apps/openmw/mwclass/ingredient.cpp | 13 +- apps/openmw/mwclass/ingredient.hpp | 8 +- apps/openmw/mwclass/light.cpp | 17 +-- apps/openmw/mwclass/light.hpp | 10 +- apps/openmw/mwclass/lockpick.cpp | 13 +- apps/openmw/mwclass/lockpick.hpp | 8 +- apps/openmw/mwclass/misc.cpp | 13 +- apps/openmw/mwclass/misc.hpp | 8 +- apps/openmw/mwclass/npc.cpp | 21 ++-- apps/openmw/mwclass/npc.hpp | 8 +- apps/openmw/mwclass/potion.cpp | 13 +- apps/openmw/mwclass/potion.hpp | 8 +- apps/openmw/mwclass/probe.cpp | 13 +- apps/openmw/mwclass/probe.hpp | 8 +- apps/openmw/mwclass/repair.cpp | 13 +- apps/openmw/mwclass/repair.hpp | 8 +- apps/openmw/mwclass/static.cpp | 2 +- apps/openmw/mwclass/static.hpp | 2 +- apps/openmw/mwclass/weapon.cpp | 16 +-- apps/openmw/mwclass/weapon.hpp | 11 +- apps/openmw/mwdialogue/dialoguemanager.cpp | 56 ++++----- apps/openmw/mwdialogue/dialoguemanager.hpp | 11 +- apps/openmw/mwdialogue/journal.cpp | 17 ++- apps/openmw/mwdialogue/journal.hpp | 8 +- apps/openmw/mwgui/charactercreation.cpp | 27 +++-- apps/openmw/mwgui/charactercreation.hpp | 3 +- apps/openmw/mwgui/console.cpp | 21 ++-- apps/openmw/mwgui/console.hpp | 3 +- apps/openmw/mwgui/dialogue.cpp | 17 ++- apps/openmw/mwgui/dialogue.hpp | 9 +- apps/openmw/mwgui/journalwindow.cpp | 18 +-- apps/openmw/mwgui/window_manager.cpp | 24 ++-- apps/openmw/mwgui/window_manager.hpp | 6 +- apps/openmw/mwmechanics/actors.cpp | 4 +- apps/openmw/mwmechanics/actors.hpp | 8 +- apps/openmw/mwmechanics/mechanicsmanager.cpp | 67 ++++++----- apps/openmw/mwmechanics/mechanicsmanager.hpp | 8 +- apps/openmw/mwmechanics/spells.cpp | 7 +- apps/openmw/mwmechanics/spells.hpp | 7 +- apps/openmw/mwrender/actors.cpp | 8 +- apps/openmw/mwrender/actors.hpp | 4 +- apps/openmw/mwrender/animation.cpp | 5 +- apps/openmw/mwrender/animation.hpp | 20 ++-- apps/openmw/mwrender/creatureanimation.cpp | 2 +- apps/openmw/mwrender/creatureanimation.hpp | 9 +- apps/openmw/mwrender/debugging.cpp | 8 +- apps/openmw/mwrender/debugging.hpp | 4 +- apps/openmw/mwrender/localmap.cpp | 27 ++--- apps/openmw/mwrender/localmap.hpp | 8 +- apps/openmw/mwrender/npcanimation.cpp | 66 +++++----- apps/openmw/mwrender/npcanimation.hpp | 17 ++- apps/openmw/mwrender/renderingmanager.cpp | 13 +- apps/openmw/mwrender/renderingmanager.hpp | 2 +- apps/openmw/mwrender/sky.cpp | 19 ++- apps/openmw/mwrender/sky.hpp | 9 +- apps/openmw/mwrender/terrain.cpp | 14 ++- apps/openmw/mwrender/terrain.hpp | 3 +- apps/openmw/mwscript/animationextensions.cpp | 15 +-- apps/openmw/mwscript/cellextensions.cpp | 58 +++------ apps/openmw/mwscript/compilercontext.cpp | 58 ++++----- apps/openmw/mwscript/compilercontext.hpp | 30 ++--- apps/openmw/mwscript/containerextensions.cpp | 7 +- apps/openmw/mwscript/controlextensions.cpp | 4 +- apps/openmw/mwscript/dialogueextensions.cpp | 29 ++--- apps/openmw/mwscript/globalscripts.cpp | 29 +++-- apps/openmw/mwscript/globalscripts.hpp | 20 ++-- apps/openmw/mwscript/guiextensions.cpp | 19 +-- apps/openmw/mwscript/interpretercontext.cpp | 85 +++++-------- apps/openmw/mwscript/interpretercontext.hpp | 17 +-- apps/openmw/mwscript/miscextensions.cpp | 28 ++--- apps/openmw/mwscript/ref.hpp | 7 +- apps/openmw/mwscript/skyextensions.cpp | 48 +++----- apps/openmw/mwscript/soundextensions.cpp | 44 ++----- apps/openmw/mwscript/statsextensions.cpp | 30 ++--- apps/openmw/mwsound/soundmanager.cpp | 16 +-- apps/openmw/mwsound/soundmanager.hpp | 9 +- apps/openmw/mwworld/action.hpp | 4 +- apps/openmw/mwworld/actiontake.cpp | 9 +- apps/openmw/mwworld/actiontake.hpp | 2 +- apps/openmw/mwworld/actiontalk.cpp | 6 +- apps/openmw/mwworld/actiontalk.hpp | 2 +- apps/openmw/mwworld/actionteleport.cpp | 9 +- apps/openmw/mwworld/actionteleport.hpp | 2 +- apps/openmw/mwworld/class.cpp | 18 ++- apps/openmw/mwworld/class.hpp | 18 ++- apps/openmw/mwworld/environment.hpp | 63 ---------- apps/openmw/mwworld/inventorystore.cpp | 9 +- apps/openmw/mwworld/inventorystore.hpp | 4 +- apps/openmw/mwworld/nullaction.hpp | 2 +- apps/openmw/mwworld/scene.cpp | 77 ++++++------ apps/openmw/mwworld/scene.hpp | 6 +- apps/openmw/mwworld/weather.cpp | 63 +++++----- apps/openmw/mwworld/weather.hpp | 107 ++++++++--------- apps/openmw/mwworld/world.cpp | 23 ++-- apps/openmw/mwworld/world.hpp | 4 +- 116 files changed, 891 insertions(+), 1170 deletions(-) delete mode 100644 apps/openmw/mwworld/environment.hpp diff --git a/apps/openmw/CMakeLists.txt b/apps/openmw/CMakeLists.txt index a27d5ae751..fb0e1db694 100644 --- a/apps/openmw/CMakeLists.txt +++ b/apps/openmw/CMakeLists.txt @@ -44,7 +44,7 @@ add_openmw_dir (mwsound ) add_openmw_dir (mwworld - refdata world physicssystem scene environment globals class action nullaction actionteleport + refdata world physicssystem scene globals class action nullaction actionteleport containerstore actiontalk actiontake manualref player cellfunctors cells localscripts customdata weather inventorystore ptr ) diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index ef1497905e..4ae6ae747c 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -50,10 +50,12 @@ #include "mwmechanics/mechanicsmanager.hpp" +#include "mwbase/environment.hpp" + void OMW::Engine::executeLocalScripts() { - MWWorld::LocalScripts& localScripts = mEnvironment.mWorld->getLocalScripts(); + MWWorld::LocalScripts& localScripts = MWBase::Environment::get().getWorld()->getLocalScripts(); localScripts.startIteration(); @@ -61,11 +63,11 @@ void OMW::Engine::executeLocalScripts() { std::pair script = localScripts.getNext(); - MWScript::InterpreterContext interpreterContext (mEnvironment, + MWScript::InterpreterContext interpreterContext ( &script.second.getRefData().getLocals(), script.second); - mEnvironment.mScriptManager->run (script.first, interpreterContext); + MWBase::Environment::get().getScriptManager()->run (script.first, interpreterContext); - if (mEnvironment.mWorld->hasCellChanged()) + if (MWBase::Environment::get().getWorld()->hasCellChanged()) break; } @@ -81,7 +83,7 @@ void OMW::Engine::updateFocusReport (float duration) std::string name; - std::string handle = mEnvironment.mWorld->getFacedHandle(); + std::string handle = MWBase::Environment::get().getWorld()->getFacedHandle(); if (!handle.empty()) { @@ -90,7 +92,7 @@ void OMW::Engine::updateFocusReport (float duration) // therefore, we are catching the "Unknown Ogre handle" exception that occurs in this case try { - MWWorld::Ptr ptr = mEnvironment.mWorld->getPtrViaHandle (handle); + MWWorld::Ptr ptr = MWBase::Environment::get().getWorld()->getPtrViaHandle (handle); if (!ptr.isEmpty()){ name = MWWorld::Class::get (ptr).getName (ptr); @@ -124,27 +126,27 @@ bool OMW::Engine::frameRenderingQueued (const Ogre::FrameEvent& evt) { try { - mEnvironment.mFrameDuration = evt.timeSinceLastFrame; + mEnvironment.setFrameDuration (evt.timeSinceLastFrame); // update input - mEnvironment.mInputManager->update(); + MWBase::Environment::get().getInputManager()->update(); // sound if (mUseSound) - mEnvironment.mSoundManager->update (evt.timeSinceLastFrame); + MWBase::Environment::get().getSoundManager()->update (evt.timeSinceLastFrame); // update GUI Ogre::RenderWindow* window = mOgre->getWindow(); - mEnvironment.mWindowManager->wmUpdateFps(window->getLastFPS(), + MWBase::Environment::get().getWindowManager()->wmUpdateFps(window->getLastFPS(), window->getTriangleCount(), window->getBatchCount()); - mEnvironment.mWindowManager->onFrame(mEnvironment.mFrameDuration); + MWBase::Environment::get().getWindowManager()->onFrame(mEnvironment.getFrameDuration()); // global scripts - mEnvironment.mScriptManager->getGlobalScripts().run (mEnvironment); + MWBase::Environment::get().getScriptManager()->getGlobalScripts().run(); - bool changed = mEnvironment.mWorld->hasCellChanged(); + bool changed = MWBase::Environment::get().getWorld()->hasCellChanged(); // local scripts executeLocalScripts(); // This does not handle the case where a global script causes a cell @@ -152,28 +154,28 @@ bool OMW::Engine::frameRenderingQueued (const Ogre::FrameEvent& evt) // frame. // passing of time - if (mEnvironment.mWindowManager->getMode()==MWGui::GM_Game) - mEnvironment.mWorld->advanceTime ( - mEnvironment.mFrameDuration*mEnvironment.mWorld->getTimeScaleFactor()/3600); + if (MWBase::Environment::get().getWindowManager()->getMode()==MWGui::GM_Game) + MWBase::Environment::get().getWorld()->advanceTime ( + mEnvironment.getFrameDuration()*MWBase::Environment::get().getWorld()->getTimeScaleFactor()/3600); if (changed) // keep change flag for another frame, if cell changed happend in local script - mEnvironment.mWorld->markCellAsUnchanged(); + MWBase::Environment::get().getWorld()->markCellAsUnchanged(); // update actors std::vector > movement; - mEnvironment.mMechanicsManager->update (movement, mEnvironment.mFrameDuration, - mEnvironment.mWindowManager->getMode()!=MWGui::GM_Game); + MWBase::Environment::get().getMechanicsManager()->update (movement, mEnvironment.getFrameDuration(), + MWBase::Environment::get().getWindowManager()->getMode()!=MWGui::GM_Game); - if (mEnvironment.mWindowManager->getMode()==MWGui::GM_Game) - mEnvironment.mWorld->doPhysics (movement, mEnvironment.mFrameDuration); + if (MWBase::Environment::get().getWindowManager()->getMode()==MWGui::GM_Game) + MWBase::Environment::get().getWorld()->doPhysics (movement, mEnvironment.getFrameDuration()); // update world - mEnvironment.mWorld->update (evt.timeSinceLastFrame); + MWBase::Environment::get().getWorld()->update (evt.timeSinceLastFrame); // report focus object (for debugging) if (mReportFocus) - updateFocusReport (mEnvironment.mFrameDuration); + updateFocusReport (mEnvironment.getFrameDuration()); } catch (const std::exception& e) { @@ -203,12 +205,13 @@ OMW::Engine::Engine(Files::ConfigurationManager& configurationManager) OMW::Engine::~Engine() { - delete mEnvironment.mWorld; - delete mEnvironment.mSoundManager; - delete mEnvironment.mMechanicsManager; - delete mEnvironment.mDialogueManager; - delete mEnvironment.mJournal; - delete mEnvironment.mScriptManager; + delete MWBase::Environment::get().getInputManager(); + delete MWBase::Environment::get().getSoundManager(); + delete MWBase::Environment::get().getMechanicsManager(); + delete MWBase::Environment::get().getDialogueManager(); + delete MWBase::Environment::get().getJournal(); + delete MWBase::Environment::get().getScriptManager(); + delete MWBase::Environment::get().getWorld(); delete mScriptContext; delete mOgre; } @@ -312,7 +315,6 @@ void OMW::Engine::setReportFocus (bool report) void OMW::Engine::go() { mFocusTDiff = 0; - assert (!mEnvironment.mWorld); assert (!mCellName.empty()); assert (!mMaster.empty()); assert (!mOgre); @@ -381,66 +383,66 @@ void OMW::Engine::go() MWGui::CursorReplace replacer; // Create the world - mEnvironment.mWorld = new MWWorld::World (*mOgre, mFileCollections, mMaster, - mResDir, mNewGame, mEnvironment, mEncoding, mFallbackMap); + mEnvironment.setWorld (new MWWorld::World (*mOgre, mFileCollections, mMaster, + mResDir, mNewGame, mEncoding, mFallbackMap)); // Create window manager - this manages all the MW-specific GUI windows MWScript::registerExtensions (mExtensions); - mEnvironment.mWindowManager = new MWGui::WindowManager(mEnvironment, - mExtensions, mFpsLevel, mNewGame, mOgre, mCfgMgr.getLogPath().string() + std::string("/")); + mEnvironment.setWindowManager (new MWGui::WindowManager( + mExtensions, mFpsLevel, mNewGame, mOgre, mCfgMgr.getLogPath().string() + std::string("/"))); // Create sound system - mEnvironment.mSoundManager = new MWSound::SoundManager(mUseSound, mEnvironment); + mEnvironment.setSoundManager (new MWSound::SoundManager(mUseSound)); // Create script system - mScriptContext = new MWScript::CompilerContext (MWScript::CompilerContext::Type_Full, - mEnvironment); + mScriptContext = new MWScript::CompilerContext (MWScript::CompilerContext::Type_Full); mScriptContext->setExtensions (&mExtensions); - mEnvironment.mScriptManager = new MWScript::ScriptManager (mEnvironment.mWorld->getStore(), - mVerboseScripts, *mScriptContext); + mEnvironment.setScriptManager (new MWScript::ScriptManager (MWBase::Environment::get().getWorld()->getStore(), + mVerboseScripts, *mScriptContext)); // Create game mechanics system - mEnvironment.mMechanicsManager = new MWMechanics::MechanicsManager (mEnvironment); + mEnvironment.setMechanicsManager (new MWMechanics::MechanicsManager); // Create dialog system - mEnvironment.mJournal = new MWDialogue::Journal (mEnvironment); - mEnvironment.mDialogueManager = new MWDialogue::DialogueManager (mEnvironment,mExtensions); + mEnvironment.setJournal (new MWDialogue::Journal); + mEnvironment.setDialogueManager (new MWDialogue::DialogueManager (mExtensions)); // load cell ESM::Position pos; pos.rot[0] = pos.rot[1] = pos.rot[2] = 0; pos.pos[2] = 0; - if (const ESM::Cell *exterior = mEnvironment.mWorld->getExterior (mCellName)) + if (const ESM::Cell *exterior = MWBase::Environment::get().getWorld()->getExterior (mCellName)) { - mEnvironment.mWorld->indexToPosition (exterior->data.gridX, exterior->data.gridY, + MWBase::Environment::get().getWorld()->indexToPosition (exterior->data.gridX, exterior->data.gridY, pos.pos[0], pos.pos[1], true); - mEnvironment.mWorld->changeToExteriorCell (pos); + MWBase::Environment::get().getWorld()->changeToExteriorCell (pos); } else { pos.pos[0] = pos.pos[1] = 0; - mEnvironment.mWorld->changeToInteriorCell (mCellName, pos); + MWBase::Environment::get().getWorld()->changeToInteriorCell (mCellName, pos); } // Sets up the input system - MWInput::MWInputManager input(*mOgre, mEnvironment.mWorld->getPlayer(), - *mEnvironment.mWindowManager, mDebug, *this); - mEnvironment.mInputManager = &input; + + mEnvironment.setInputManager (new MWInput::MWInputManager (*mOgre, + MWBase::Environment::get().getWorld()->getPlayer(), + *MWBase::Environment::get().getWindowManager(), mDebug, *this)); std::cout << "\nPress Q/ESC or close window to exit.\n"; mOgre->getRoot()->addFrameListener (this); // Play some good 'ol tunes - mEnvironment.mSoundManager->playPlaylist(std::string("Explore")); + MWBase::Environment::get().getSoundManager()->playPlaylist(std::string("Explore")); // scripts if (mCompileAll) { - std::pair result = mEnvironment.mScriptManager->compileAll(); + std::pair result = MWBase::Environment::get().getScriptManager()->compileAll(); if (result.first) std::cout @@ -461,10 +463,10 @@ void OMW::Engine::go() void OMW::Engine::activate() { - if (mEnvironment.mWindowManager->getMode()!=MWGui::GM_Game) + if (MWBase::Environment::get().getWindowManager()->getMode()!=MWGui::GM_Game) return; - std::string handle = mEnvironment.mWorld->getFacedHandle(); + std::string handle = MWBase::Environment::get().getWorld()->getFacedHandle(); if (handle.empty()) return; @@ -475,7 +477,7 @@ void OMW::Engine::activate() MWWorld::Ptr ptr; try { - ptr = mEnvironment.mWorld->getPtrViaHandle (handle); + ptr = MWBase::Environment::get().getWorld()->getPtrViaHandle (handle); if (ptr.isEmpty()) return; @@ -485,12 +487,10 @@ void OMW::Engine::activate() return; } - MWScript::InterpreterContext interpreterContext (mEnvironment, - &ptr.getRefData().getLocals(), ptr); + MWScript::InterpreterContext interpreterContext (&ptr.getRefData().getLocals(), ptr); boost::shared_ptr action = - MWWorld::Class::get (ptr).activate (ptr, mEnvironment.mWorld->getPlayer().getPlayer(), - mEnvironment); + MWWorld::Class::get (ptr).activate (ptr, MWBase::Environment::get().getWorld()->getPlayer().getPlayer()); interpreterContext.activate (ptr, action); @@ -498,8 +498,8 @@ void OMW::Engine::activate() if (!script.empty()) { - mEnvironment.mWorld->getLocalScripts().setIgnore (ptr); - mEnvironment.mScriptManager->run (script, interpreterContext); + MWBase::Environment::get().getWorld()->getLocalScripts().setIgnore (ptr); + MWBase::Environment::get().getScriptManager()->run (script, interpreterContext); } if (!interpreterContext.hasActivationBeenHandled()) diff --git a/apps/openmw/engine.hpp b/apps/openmw/engine.hpp index 6eae20cc0f..ccd7314cbc 100644 --- a/apps/openmw/engine.hpp +++ b/apps/openmw/engine.hpp @@ -10,7 +10,8 @@ #include #include -#include "mwworld/environment.hpp" +#include "mwbase/environment.hpp" + #include "mwworld/ptr.hpp" namespace Compiler @@ -78,7 +79,7 @@ namespace OMW std::string mFocusName; std::map mFallbackMap; - MWWorld::Environment mEnvironment; + MWBase::Environment mEnvironment; Compiler::Extensions mExtensions; Compiler::Context *mScriptContext; diff --git a/apps/openmw/mwbase/environment.cpp b/apps/openmw/mwbase/environment.cpp index 0845051711..8e9a9cfce3 100644 --- a/apps/openmw/mwbase/environment.cpp +++ b/apps/openmw/mwbase/environment.cpp @@ -7,7 +7,7 @@ MWBase::Environment *MWBase::Environment::sThis = 0; MWBase::Environment::Environment() : mWorld (0), mSoundManager (0), mScriptManager (0), mWindowManager (0), - mMechanicsManager (0), mDialogueManager (0), mJournal (0), mFrameDuration (0) + mMechanicsManager (0), mDialogueManager (0), mJournal (0), mInputManager (0), mFrameDuration (0) { assert (!sThis); sThis = this; @@ -53,6 +53,11 @@ void MWBase::Environment::setJournal (MWDialogue::Journal *journal) mJournal = journal; } +void MWBase::Environment::setInputManager (MWInput::MWInputManager *inputManager) +{ + mInputManager = inputManager; +} + void MWBase::Environment::setFrameDuration (float duration) { mFrameDuration = duration; @@ -100,6 +105,12 @@ MWDialogue::Journal *MWBase::Environment::getJournal() const return mJournal; } +MWInput::MWInputManager *MWBase::Environment::getInputManager() const +{ + assert (mInputManager); + return mInputManager; +} + float MWBase::Environment::getFrameDuration() const { return mFrameDuration; diff --git a/apps/openmw/mwbase/environment.hpp b/apps/openmw/mwbase/environment.hpp index 1b1ace0c73..a010e7faa0 100644 --- a/apps/openmw/mwbase/environment.hpp +++ b/apps/openmw/mwbase/environment.hpp @@ -56,6 +56,7 @@ namespace MWBase MWMechanics::MechanicsManager *mMechanicsManager; MWDialogue::DialogueManager *mDialogueManager; MWDialogue::Journal *mJournal; + MWInput::MWInputManager *mInputManager; float mFrameDuration; Environment (const Environment&); @@ -84,6 +85,8 @@ namespace MWBase void setJournal (MWDialogue::Journal *journal); + void setInputManager (MWInput::MWInputManager *inputManager); + void setFrameDuration (float duration); ///< Set length of current frame in seconds. @@ -101,6 +104,8 @@ namespace MWBase MWDialogue::Journal *getJournal() const; + MWInput::MWInputManager *getInputManager() const; + float getFrameDuration() const; static const Environment& get(); diff --git a/apps/openmw/mwclass/activator.cpp b/apps/openmw/mwclass/activator.cpp index 6749a2bfd1..5b5028f1ca 100644 --- a/apps/openmw/mwclass/activator.cpp +++ b/apps/openmw/mwclass/activator.cpp @@ -18,7 +18,7 @@ namespace MWClass assert (ref->base != NULL); const std::string &model = ref->base->model; - + if (!model.empty()) { MWRender::Objects& objects = renderingInterface.getObjects(); @@ -27,7 +27,7 @@ namespace MWClass } } - void Activator::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const + void Activator::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const { ESMS::LiveCellRef *ref = ptr.get(); diff --git a/apps/openmw/mwclass/activator.hpp b/apps/openmw/mwclass/activator.hpp index 08be8a5ff1..d0b1f25e06 100644 --- a/apps/openmw/mwclass/activator.hpp +++ b/apps/openmw/mwclass/activator.hpp @@ -12,7 +12,7 @@ namespace MWClass virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const; ///< Add reference into a cell for rendering - virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const; + virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const; virtual std::string getName (const MWWorld::Ptr& ptr) const; ///< \return name (the one that is to be presented to the user; not the internal one); diff --git a/apps/openmw/mwclass/apparatus.cpp b/apps/openmw/mwclass/apparatus.cpp index 90db40b5ae..e7c208d4a2 100644 --- a/apps/openmw/mwclass/apparatus.cpp +++ b/apps/openmw/mwclass/apparatus.cpp @@ -5,9 +5,10 @@ #include +#include "../mwbase/environment.hpp" + #include "../mwworld/ptr.hpp" #include "../mwworld/actiontake.hpp" -#include "../mwworld/environment.hpp" #include "../mwrender/objects.hpp" @@ -31,7 +32,7 @@ namespace MWClass } } - void Apparatus::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const + void Apparatus::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const { ESMS::LiveCellRef *ref = ptr.get(); @@ -54,9 +55,9 @@ namespace MWClass } boost::shared_ptr Apparatus::activate (const MWWorld::Ptr& ptr, - const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const + const MWWorld::Ptr& actor) const { - environment.mSoundManager->playSound3D (ptr, getUpSoundId(ptr), 1.0, 1.0, MWSound::Play_NoTrack); + MWBase::Environment::get().getSoundManager()->playSound3D (ptr, getUpSoundId(ptr), 1.0, 1.0, MWSound::Play_NoTrack); return boost::shared_ptr ( new MWWorld::ActionTake (ptr)); diff --git a/apps/openmw/mwclass/apparatus.hpp b/apps/openmw/mwclass/apparatus.hpp index 861610f6cc..9015aedb85 100644 --- a/apps/openmw/mwclass/apparatus.hpp +++ b/apps/openmw/mwclass/apparatus.hpp @@ -12,14 +12,14 @@ namespace MWClass virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const; ///< Add reference into a cell for rendering - virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const; + virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const; virtual std::string getName (const MWWorld::Ptr& ptr) const; ///< \return name (the one that is to be presented to the user; not the internal one); /// can return an empty string. virtual boost::shared_ptr activate (const MWWorld::Ptr& ptr, - const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const; + const MWWorld::Ptr& actor) const; ///< Generate action for activation virtual std::string getScript (const MWWorld::Ptr& ptr) const; diff --git a/apps/openmw/mwclass/armor.cpp b/apps/openmw/mwclass/armor.cpp index 8e1f81136b..3a34032611 100644 --- a/apps/openmw/mwclass/armor.cpp +++ b/apps/openmw/mwclass/armor.cpp @@ -9,11 +9,11 @@ #include "../mwworld/ptr.hpp" #include "../mwworld/actiontake.hpp" - #include "../mwworld/inventorystore.hpp" -#include "../mwworld/environment.hpp" #include "../mwworld/world.hpp" +#include "../mwbase/environment.hpp" + #include "../mwrender/objects.hpp" #include "../mwsound/soundmanager.hpp" @@ -36,7 +36,7 @@ namespace MWClass } } - void Armor::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const + void Armor::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const { ESMS::LiveCellRef *ref = ptr.get(); @@ -58,9 +58,9 @@ namespace MWClass } boost::shared_ptr Armor::activate (const MWWorld::Ptr& ptr, - const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const + const MWWorld::Ptr& actor) const { - environment.mSoundManager->playSound3D (ptr, getUpSoundId(ptr, environment), 1.0, 1.0, MWSound::Play_NoTrack); + MWBase::Environment::get().getSoundManager()->playSound3D (ptr, getUpSoundId(ptr), 1.0, 1.0, MWSound::Play_NoTrack); return boost::shared_ptr ( new MWWorld::ActionTake (ptr)); @@ -121,7 +121,7 @@ namespace MWClass return std::make_pair (slots, false); } - int Armor::getEquipmentSkill (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const + int Armor::getEquipmentSkill (const MWWorld::Ptr& ptr) const { ESMS::LiveCellRef *ref = ptr.get(); @@ -147,13 +147,13 @@ namespace MWClass if (typeGmst.empty()) return -1; - float iWeight = environment.mWorld->getStore().gameSettings.find (typeGmst)->i; + float iWeight = MWBase::Environment::get().getWorld()->getStore().gameSettings.find (typeGmst)->i; - if (iWeight * environment.mWorld->getStore().gameSettings.find ("fLightMaxMod")->f>= + if (iWeight * MWBase::Environment::get().getWorld()->getStore().gameSettings.find ("fLightMaxMod")->f>= ref->base->data.weight) return ESM::Skill::LightArmor; - if (iWeight * environment.mWorld->getStore().gameSettings.find ("fMedMaxMod")->f>= + if (iWeight * MWBase::Environment::get().getWorld()->getStore().gameSettings.find ("fMedMaxMod")->f>= ref->base->data.weight) return ESM::Skill::MediumArmor; @@ -175,9 +175,9 @@ namespace MWClass registerClass (typeid (ESM::Armor).name(), instance); } - std::string Armor::getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const + std::string Armor::getUpSoundId (const MWWorld::Ptr& ptr) const { - int es = getEquipmentSkill(ptr, environment); + int es = getEquipmentSkill(ptr); if (es == ESM::Skill::LightArmor) return std::string("Item Armor Light Up"); else if (es == ESM::Skill::MediumArmor) @@ -186,9 +186,9 @@ namespace MWClass return std::string("Item Armor Heavy Up"); } - std::string Armor::getDownSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const + std::string Armor::getDownSoundId (const MWWorld::Ptr& ptr) const { - int es = getEquipmentSkill(ptr, environment); + int es = getEquipmentSkill(ptr); if (es == ESM::Skill::LightArmor) return std::string("Item Armor Light Down"); else if (es == ESM::Skill::MediumArmor) diff --git a/apps/openmw/mwclass/armor.hpp b/apps/openmw/mwclass/armor.hpp index de5ca39835..6cba077264 100644 --- a/apps/openmw/mwclass/armor.hpp +++ b/apps/openmw/mwclass/armor.hpp @@ -12,14 +12,14 @@ namespace MWClass virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const; ///< Add reference into a cell for rendering - virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const; + virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const; virtual std::string getName (const MWWorld::Ptr& ptr) const; ///< \return name (the one that is to be presented to the user; not the internal one); /// can return an empty string. virtual boost::shared_ptr activate (const MWWorld::Ptr& ptr, - const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const; + const MWWorld::Ptr& actor) const; ///< Generate action for activation virtual bool hasItemHealth (const MWWorld::Ptr& ptr) const; @@ -35,8 +35,7 @@ namespace MWClass ///< \return first: Return IDs of the slot this object can be equipped in; second: can object /// stay stacked when equipped? - virtual int getEquipmentSkill (const MWWorld::Ptr& ptr, - const MWWorld::Environment& environment) const; + virtual int getEquipmentSkill (const MWWorld::Ptr& ptr) const; /// Return the index of the skill this item corresponds to when equiopped or -1, if there is /// no such skill. @@ -45,10 +44,10 @@ namespace MWClass static void registerSelf(); - virtual std::string getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const; + virtual std::string getUpSoundId (const MWWorld::Ptr& ptr) const; ///< Return the pick up sound Id - virtual std::string getDownSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const; + virtual std::string getDownSoundId (const MWWorld::Ptr& ptr) const; ///< Return the put down sound Id }; } diff --git a/apps/openmw/mwclass/book.cpp b/apps/openmw/mwclass/book.cpp index 9069d94765..b3b71104b6 100644 --- a/apps/openmw/mwclass/book.cpp +++ b/apps/openmw/mwclass/book.cpp @@ -5,9 +5,10 @@ #include +#include "../mwbase/environment.hpp" + #include "../mwworld/ptr.hpp" #include "../mwworld/actiontake.hpp" -#include "../mwworld/environment.hpp" #include "../mwrender/objects.hpp" @@ -31,7 +32,7 @@ namespace MWClass } } - void Book::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const + void Book::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const { ESMS::LiveCellRef *ref = ptr.get(); @@ -54,11 +55,11 @@ namespace MWClass } boost::shared_ptr Book::activate (const MWWorld::Ptr& ptr, - const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const + const MWWorld::Ptr& actor) const { // TODO implement reading - environment.mSoundManager->playSound3D (ptr, getUpSoundId(ptr, environment), 1.0, 1.0, MWSound::Play_NoTrack); + MWBase::Environment::get().getSoundManager()->playSound3D (ptr, getUpSoundId(ptr), 1.0, 1.0, MWSound::Play_NoTrack); return boost::shared_ptr ( new MWWorld::ActionTake (ptr)); @@ -87,12 +88,12 @@ namespace MWClass registerClass (typeid (ESM::Book).name(), instance); } - std::string Book::getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const + std::string Book::getUpSoundId (const MWWorld::Ptr& ptr) const { return std::string("Item Book Up"); } - std::string Book::getDownSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const + std::string Book::getDownSoundId (const MWWorld::Ptr& ptr) const { return std::string("Item Book Down"); } diff --git a/apps/openmw/mwclass/book.hpp b/apps/openmw/mwclass/book.hpp index 4738187cd6..975cdf12b3 100644 --- a/apps/openmw/mwclass/book.hpp +++ b/apps/openmw/mwclass/book.hpp @@ -12,14 +12,14 @@ namespace MWClass virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const; ///< Add reference into a cell for rendering - virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const; + virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const; virtual std::string getName (const MWWorld::Ptr& ptr) const; ///< \return name (the one that is to be presented to the user; not the internal one); /// can return an empty string. virtual boost::shared_ptr activate (const MWWorld::Ptr& ptr, - const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const; + const MWWorld::Ptr& actor) const; ///< Generate action for activation virtual std::string getScript (const MWWorld::Ptr& ptr) const; @@ -30,10 +30,10 @@ namespace MWClass static void registerSelf(); - virtual std::string getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const; + virtual std::string getUpSoundId (const MWWorld::Ptr& ptr) const; ///< Return the pick up sound Id - virtual std::string getDownSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const; + virtual std::string getDownSoundId (const MWWorld::Ptr& ptr) const; ///< Return the put down sound Id }; } diff --git a/apps/openmw/mwclass/clothing.cpp b/apps/openmw/mwclass/clothing.cpp index 672a2b60a0..15f00bb053 100644 --- a/apps/openmw/mwclass/clothing.cpp +++ b/apps/openmw/mwclass/clothing.cpp @@ -5,9 +5,10 @@ #include +#include "../mwbase/environment.hpp" + #include "../mwworld/ptr.hpp" #include "../mwworld/actiontake.hpp" -#include "../mwworld/environment.hpp" #include "../mwworld/inventorystore.hpp" #include "../mwrender/objects.hpp" @@ -32,7 +33,7 @@ namespace MWClass } } - void Clothing::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const + void Clothing::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const { ESMS::LiveCellRef *ref = ptr.get(); @@ -55,9 +56,9 @@ namespace MWClass } boost::shared_ptr Clothing::activate (const MWWorld::Ptr& ptr, - const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const + const MWWorld::Ptr& actor) const { - environment.mSoundManager->playSound3D (ptr, getUpSoundId(ptr, environment), 1.0, 1.0, MWSound::Play_NoTrack); + MWBase::Environment::get().getSoundManager()->playSound3D (ptr, getUpSoundId(ptr), 1.0, 1.0, MWSound::Play_NoTrack); return boost::shared_ptr ( new MWWorld::ActionTake (ptr)); @@ -111,8 +112,7 @@ namespace MWClass return std::make_pair (slots, false); } - int Clothing::getEquipmentSkill (const MWWorld::Ptr& ptr, - const MWWorld::Environment& environment) const + int Clothing::getEquipmentSkill (const MWWorld::Ptr& ptr) const { ESMS::LiveCellRef *ref = ptr.get(); @@ -138,7 +138,7 @@ namespace MWClass registerClass (typeid (ESM::Clothing).name(), instance); } - std::string Clothing::getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const + std::string Clothing::getUpSoundId (const MWWorld::Ptr& ptr) const { ESMS::LiveCellRef *ref = ptr.get(); @@ -150,7 +150,7 @@ namespace MWClass return std::string("Item Clothes Up"); } - std::string Clothing::getDownSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const + std::string Clothing::getDownSoundId (const MWWorld::Ptr& ptr) const { ESMS::LiveCellRef *ref = ptr.get(); diff --git a/apps/openmw/mwclass/clothing.hpp b/apps/openmw/mwclass/clothing.hpp index 97e09012d5..7fc05bef35 100644 --- a/apps/openmw/mwclass/clothing.hpp +++ b/apps/openmw/mwclass/clothing.hpp @@ -12,14 +12,14 @@ namespace MWClass virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const; ///< Add reference into a cell for rendering - virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const; + virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const; virtual std::string getName (const MWWorld::Ptr& ptr) const; ///< \return name (the one that is to be presented to the user; not the internal one); /// can return an empty string. virtual boost::shared_ptr activate (const MWWorld::Ptr& ptr, - const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const; + const MWWorld::Ptr& actor) const; ///< Generate action for activation virtual std::string getScript (const MWWorld::Ptr& ptr) const; @@ -29,8 +29,7 @@ namespace MWClass ///< \return first: Return IDs of the slot this object can be equipped in; second: can object /// stay stacked when equipped? - virtual int getEquipmentSkill (const MWWorld::Ptr& ptr, - const MWWorld::Environment& environment) const; + virtual int getEquipmentSkill (const MWWorld::Ptr& ptr) const; /// Return the index of the skill this item corresponds to when equiopped or -1, if there is /// no such skill. @@ -39,10 +38,10 @@ namespace MWClass static void registerSelf(); - virtual std::string getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const; + virtual std::string getUpSoundId (const MWWorld::Ptr& ptr) const; ///< Return the pick up sound Id - virtual std::string getDownSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const; + virtual std::string getDownSoundId (const MWWorld::Ptr& ptr) const; ///< Return the put down sound Id }; } diff --git a/apps/openmw/mwclass/container.cpp b/apps/openmw/mwclass/container.cpp index 29b3331ba9..a229cbe9b0 100644 --- a/apps/openmw/mwclass/container.cpp +++ b/apps/openmw/mwclass/container.cpp @@ -5,11 +5,12 @@ #include +#include "../mwbase/environment.hpp" + #include "../mwworld/ptr.hpp" #include "../mwworld/nullaction.hpp" #include "../mwworld/containerstore.hpp" #include "../mwworld/customdata.hpp" -#include "../mwworld/environment.hpp" #include "../mwrender/objects.hpp" @@ -61,7 +62,7 @@ namespace MWClass } } - void Container::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const + void Container::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const { ESMS::LiveCellRef *ref = ptr.get(); @@ -76,7 +77,7 @@ namespace MWClass } boost::shared_ptr Container::activate (const MWWorld::Ptr& ptr, - const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const + const MWWorld::Ptr& actor) const { const std::string lockedSound = "LockedChest"; const std::string trapActivationSound = "Disarm Trap Fail"; @@ -85,7 +86,7 @@ namespace MWClass { // TODO check for key std::cout << "Locked container" << std::endl; - environment.mSoundManager->playSound3D (ptr, lockedSound, 1.0, 1.0); + MWBase::Environment::get().getSoundManager()->playSound3D (ptr, lockedSound, 1.0, 1.0); return boost::shared_ptr (new MWWorld::NullAction); } else @@ -100,7 +101,7 @@ namespace MWClass { // Trap activation goes here std::cout << "Activated trap: " << ptr.getCellRef().trap << std::endl; - environment.mSoundManager->playSound3D (ptr, trapActivationSound, 1.0, 1.0); + MWBase::Environment::get().getSoundManager()->playSound3D (ptr, trapActivationSound, 1.0, 1.0); ptr.getCellRef().trap = ""; return boost::shared_ptr (new MWWorld::NullAction); } diff --git a/apps/openmw/mwclass/container.hpp b/apps/openmw/mwclass/container.hpp index 387714176b..c371e8898d 100644 --- a/apps/openmw/mwclass/container.hpp +++ b/apps/openmw/mwclass/container.hpp @@ -14,14 +14,14 @@ namespace MWClass virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const; ///< Add reference into a cell for rendering - virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const; + virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const; virtual std::string getName (const MWWorld::Ptr& ptr) const; ///< \return name (the one that is to be presented to the user; not the internal one); /// can return an empty string. virtual boost::shared_ptr activate (const MWWorld::Ptr& ptr, - const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const; + const MWWorld::Ptr& actor) const; ///< Generate action for activation virtual MWWorld::ContainerStore& getContainerStore (const MWWorld::Ptr& ptr) const; diff --git a/apps/openmw/mwclass/creature.cpp b/apps/openmw/mwclass/creature.cpp index 7270fd22b9..b5a17b2b52 100644 --- a/apps/openmw/mwclass/creature.cpp +++ b/apps/openmw/mwclass/creature.cpp @@ -6,9 +6,10 @@ #include "../mwmechanics/creaturestats.hpp" #include "../mwmechanics/mechanicsmanager.hpp" +#include "../mwbase/environment.hpp" + #include "../mwworld/ptr.hpp" #include "../mwworld/actiontalk.hpp" -#include "../mwworld/environment.hpp" #include "../mwworld/customdata.hpp" #include "../mwworld/containerstore.hpp" @@ -74,7 +75,7 @@ namespace MWClass actors.insertCreature(ptr); } - void Creature::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const + void Creature::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const { ESMS::LiveCellRef *ref = ptr.get(); @@ -87,14 +88,14 @@ namespace MWClass } } - void Creature::enable (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const + void Creature::enable (const MWWorld::Ptr& ptr) const { - environment.mMechanicsManager->addActor (ptr); + MWBase::Environment::get().getMechanicsManager()->addActor (ptr); } - void Creature::disable (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const + void Creature::disable (const MWWorld::Ptr& ptr) const { - environment.mMechanicsManager->removeActor (ptr); + MWBase::Environment::get().getMechanicsManager()->removeActor (ptr); } std::string Creature::getName (const MWWorld::Ptr& ptr) const @@ -113,7 +114,7 @@ namespace MWClass } boost::shared_ptr Creature::activate (const MWWorld::Ptr& ptr, - const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const + const MWWorld::Ptr& actor) const { return boost::shared_ptr (new MWWorld::ActionTalk (ptr)); } diff --git a/apps/openmw/mwclass/creature.hpp b/apps/openmw/mwclass/creature.hpp index 8eb45e8381..fa07f9625a 100644 --- a/apps/openmw/mwclass/creature.hpp +++ b/apps/openmw/mwclass/creature.hpp @@ -20,12 +20,12 @@ namespace MWClass virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const; ///< Add reference into a cell for rendering - virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const; + virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const; - virtual void enable (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const; + virtual void enable (const MWWorld::Ptr& ptr) const; ///< Enable reference; only does the non-rendering part - virtual void disable (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const; + virtual void disable (const MWWorld::Ptr& ptr) const; ///< Enable reference; only does the non-rendering part virtual std::string getName (const MWWorld::Ptr& ptr) const; @@ -36,7 +36,7 @@ namespace MWClass ///< Return creature stats virtual boost::shared_ptr activate (const MWWorld::Ptr& ptr, - const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const; + const MWWorld::Ptr& actor) const; ///< Generate action for activation virtual MWWorld::ContainerStore& getContainerStore ( diff --git a/apps/openmw/mwclass/door.cpp b/apps/openmw/mwclass/door.cpp index 9d6c6a78dc..003beaa304 100644 --- a/apps/openmw/mwclass/door.cpp +++ b/apps/openmw/mwclass/door.cpp @@ -5,11 +5,12 @@ #include +#include "../mwbase/environment.hpp" + #include "../mwworld/player.hpp" #include "../mwworld/ptr.hpp" #include "../mwworld/nullaction.hpp" #include "../mwworld/actionteleport.hpp" -#include "../mwworld/environment.hpp" #include "../mwworld/world.hpp" #include "../mwrender/objects.hpp" @@ -34,7 +35,7 @@ namespace MWClass } } - void Door::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const + void Door::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const { ESMS::LiveCellRef *ref = ptr.get(); @@ -58,7 +59,7 @@ namespace MWClass } boost::shared_ptr Door::activate (const MWWorld::Ptr& ptr, - const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const + const MWWorld::Ptr& actor) const { ESMS::LiveCellRef *ref = ptr.get(); @@ -73,7 +74,7 @@ namespace MWClass // TODO check for key // TODO report failure to player (message, sound?). Look up behaviour of original MW. std::cout << "Locked!" << std::endl; - environment.mSoundManager->playSound3D (ptr, lockedSound, 1.0, 1.0); + MWBase::Environment::get().getSoundManager()->playSound3D (ptr, lockedSound, 1.0, 1.0); return boost::shared_ptr (new MWWorld::NullAction); } @@ -81,7 +82,7 @@ namespace MWClass { // Trap activation std::cout << "Activated trap: " << ptr.getCellRef().trap << std::endl; - environment.mSoundManager->playSound3D(ptr, trapActivationSound, 1.0, 1.0); + MWBase::Environment::get().getSoundManager()->playSound3D(ptr, trapActivationSound, 1.0, 1.0); ptr.getCellRef().trap = ""; return boost::shared_ptr (new MWWorld::NullAction); } @@ -89,11 +90,11 @@ namespace MWClass if (ref->ref.teleport) { // teleport door - if (environment.mWorld->getPlayer().getPlayer()==actor) + if (MWBase::Environment::get().getWorld()->getPlayer().getPlayer()==actor) { // the player is using the door // The reason this is not 3D is that it would get interrupted when you teleport - environment.mSoundManager->playSound(openSound, 1.0, 1.0); + MWBase::Environment::get().getSoundManager()->playSound(openSound, 1.0, 1.0); return boost::shared_ptr ( new MWWorld::ActionTeleportPlayer (ref->ref.destCell, ref->ref.doorDest)); } @@ -110,7 +111,7 @@ namespace MWClass // TODO return action for rotating the door // This is a little pointless, but helps with testing - environment.mSoundManager->playSound3D (ptr, openSound, 1.0, 1.0); + MWBase::Environment::get().getSoundManager()->playSound3D (ptr, openSound, 1.0, 1.0); return boost::shared_ptr (new MWWorld::NullAction); } } diff --git a/apps/openmw/mwclass/door.hpp b/apps/openmw/mwclass/door.hpp index aecb4224cc..4779ed174a 100644 --- a/apps/openmw/mwclass/door.hpp +++ b/apps/openmw/mwclass/door.hpp @@ -12,14 +12,14 @@ namespace MWClass virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const; ///< Add reference into a cell for rendering - virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const; + virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const; virtual std::string getName (const MWWorld::Ptr& ptr) const; ///< \return name (the one that is to be presented to the user; not the internal one); /// can return an empty string. virtual boost::shared_ptr activate (const MWWorld::Ptr& ptr, - const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const; + const MWWorld::Ptr& actor) const; ///< Generate action for activation virtual void lock (const MWWorld::Ptr& ptr, int lockLevel) const; diff --git a/apps/openmw/mwclass/ingredient.cpp b/apps/openmw/mwclass/ingredient.cpp index 9707e79a8f..79b1bb92f3 100644 --- a/apps/openmw/mwclass/ingredient.cpp +++ b/apps/openmw/mwclass/ingredient.cpp @@ -5,9 +5,10 @@ #include +#include "../mwbase/environment.hpp" + #include "../mwworld/ptr.hpp" #include "../mwworld/actiontake.hpp" -#include "../mwworld/environment.hpp" #include "../mwrender/objects.hpp" @@ -31,7 +32,7 @@ namespace MWClass } } - void Ingredient::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const + void Ingredient::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const { ESMS::LiveCellRef *ref = ptr.get(); @@ -52,9 +53,9 @@ namespace MWClass } boost::shared_ptr Ingredient::activate (const MWWorld::Ptr& ptr, - const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const + const MWWorld::Ptr& actor) const { - environment.mSoundManager->playSound3D (ptr, getUpSoundId(ptr, environment), 1.0, 1.0, MWSound::Play_NoTrack); + MWBase::Environment::get().getSoundManager()->playSound3D (ptr, getUpSoundId(ptr), 1.0, 1.0, MWSound::Play_NoTrack); return boost::shared_ptr ( new MWWorld::ActionTake (ptr)); @@ -83,12 +84,12 @@ namespace MWClass registerClass (typeid (ESM::Ingredient).name(), instance); } - std::string Ingredient::getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const + std::string Ingredient::getUpSoundId (const MWWorld::Ptr& ptr) const { return std::string("Item Ingredient Up"); } - std::string Ingredient::getDownSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const + std::string Ingredient::getDownSoundId (const MWWorld::Ptr& ptr) const { return std::string("Item Ingredient Down"); } diff --git a/apps/openmw/mwclass/ingredient.hpp b/apps/openmw/mwclass/ingredient.hpp index 2d77176727..d8190c8fc2 100644 --- a/apps/openmw/mwclass/ingredient.hpp +++ b/apps/openmw/mwclass/ingredient.hpp @@ -12,14 +12,14 @@ namespace MWClass virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const; ///< Add reference into a cell for rendering - virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const; + virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const; virtual std::string getName (const MWWorld::Ptr& ptr) const; ///< \return name (the one that is to be presented to the user; not the internal one); /// can return an empty string. virtual boost::shared_ptr activate (const MWWorld::Ptr& ptr, - const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const; + const MWWorld::Ptr& actor) const; ///< Generate action for activation virtual std::string getScript (const MWWorld::Ptr& ptr) const; @@ -30,10 +30,10 @@ namespace MWClass static void registerSelf(); - virtual std::string getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const; + virtual std::string getUpSoundId (const MWWorld::Ptr& ptr) const; ///< Return the pick up sound Id - virtual std::string getDownSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const; + virtual std::string getDownSoundId (const MWWorld::Ptr& ptr) const; ///< Return the put down sound Id }; } diff --git a/apps/openmw/mwclass/light.cpp b/apps/openmw/mwclass/light.cpp index f67dd4cf05..deb8c25671 100644 --- a/apps/openmw/mwclass/light.cpp +++ b/apps/openmw/mwclass/light.cpp @@ -5,10 +5,11 @@ #include +#include "../mwbase/environment.hpp" + #include "../mwworld/ptr.hpp" #include "../mwworld/actiontake.hpp" #include "../mwworld/nullaction.hpp" -#include "../mwworld/environment.hpp" #include "../mwworld/inventorystore.hpp" #include "../mwsound/soundmanager.hpp" @@ -39,7 +40,7 @@ namespace MWClass objects.insertLight (ptr, r, g, b, radius); } - void Light::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const + void Light::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const { ESMS::LiveCellRef *ref = ptr.get(); @@ -52,14 +53,14 @@ namespace MWClass } } - void Light::enable (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const + void Light::enable (const MWWorld::Ptr& ptr) const { ESMS::LiveCellRef *ref = ptr.get(); if (!ref->base->sound.empty()) { - environment.mSoundManager->playSound3D (ptr, ref->base->sound, 1.0, 1.0, MWSound::Play_Loop); + MWBase::Environment::get().getSoundManager()->playSound3D (ptr, ref->base->sound, 1.0, 1.0, MWSound::Play_Loop); } } @@ -75,7 +76,7 @@ namespace MWClass } boost::shared_ptr Light::activate (const MWWorld::Ptr& ptr, - const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const + const MWWorld::Ptr& actor) const { ESMS::LiveCellRef *ref = ptr.get(); @@ -83,7 +84,7 @@ namespace MWClass if (!(ref->base->data.flags & ESM::Light::Carry)) return boost::shared_ptr (new MWWorld::NullAction); - environment.mSoundManager->playSound3D (ptr, getUpSoundId(ptr, environment), 1.0, 1.0, MWSound::Play_NoTrack); + MWBase::Environment::get().getSoundManager()->playSound3D (ptr, getUpSoundId(ptr), 1.0, 1.0, MWSound::Play_NoTrack); return boost::shared_ptr ( new MWWorld::ActionTake (ptr)); @@ -125,12 +126,12 @@ namespace MWClass registerClass (typeid (ESM::Light).name(), instance); } - std::string Light::getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const + std::string Light::getUpSoundId (const MWWorld::Ptr& ptr) const { return std::string("Item Misc Up"); } - std::string Light::getDownSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const + std::string Light::getDownSoundId (const MWWorld::Ptr& ptr) const { return std::string("Item Misc Down"); } diff --git a/apps/openmw/mwclass/light.hpp b/apps/openmw/mwclass/light.hpp index bde252c289..5d139cb8fd 100644 --- a/apps/openmw/mwclass/light.hpp +++ b/apps/openmw/mwclass/light.hpp @@ -12,9 +12,9 @@ namespace MWClass virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const; ///< Add reference into a cell for rendering - virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const; + virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const; - virtual void enable (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const; + virtual void enable (const MWWorld::Ptr& ptr) const; ///< Enable reference; only does the non-rendering part /// \attention This is not the same as the script instruction with the same name. References /// should only be enabled while in an active cell. @@ -24,7 +24,7 @@ namespace MWClass /// can return an empty string. virtual boost::shared_ptr activate (const MWWorld::Ptr& ptr, - const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const; + const MWWorld::Ptr& actor) const; ///< Generate action for activation virtual std::string getScript (const MWWorld::Ptr& ptr) const; @@ -39,10 +39,10 @@ namespace MWClass static void registerSelf(); - virtual std::string getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const; + virtual std::string getUpSoundId (const MWWorld::Ptr& ptr) const; ///< Return the pick up sound Id - virtual std::string getDownSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const; + virtual std::string getDownSoundId (const MWWorld::Ptr& ptr) const; ///< Return the put down sound Id }; } diff --git a/apps/openmw/mwclass/lockpick.cpp b/apps/openmw/mwclass/lockpick.cpp index 76bc3948f6..d682538eac 100644 --- a/apps/openmw/mwclass/lockpick.cpp +++ b/apps/openmw/mwclass/lockpick.cpp @@ -5,9 +5,10 @@ #include +#include "../mwbase/environment.hpp" + #include "../mwworld/ptr.hpp" #include "../mwworld/actiontake.hpp" -#include "../mwworld/environment.hpp" #include "../mwworld/inventorystore.hpp" #include "../mwrender/objects.hpp" @@ -32,7 +33,7 @@ namespace MWClass } } - void Lockpick::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const + void Lockpick::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const { ESMS::LiveCellRef *ref = ptr.get(); @@ -56,9 +57,9 @@ namespace MWClass } boost::shared_ptr Lockpick::activate (const MWWorld::Ptr& ptr, - const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const + const MWWorld::Ptr& actor) const { - environment.mSoundManager->playSound3D (ptr, getUpSoundId(ptr, environment), 1.0, 1.0, MWSound::Play_NoTrack); + MWBase::Environment::get().getSoundManager()->playSound3D (ptr, getUpSoundId(ptr), 1.0, 1.0, MWSound::Play_NoTrack); return boost::shared_ptr ( new MWWorld::ActionTake (ptr)); @@ -96,12 +97,12 @@ namespace MWClass registerClass (typeid (ESM::Tool).name(), instance); } - std::string Lockpick::getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const + std::string Lockpick::getUpSoundId (const MWWorld::Ptr& ptr) const { return std::string("Item Lockpick Up"); } - std::string Lockpick::getDownSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const + std::string Lockpick::getDownSoundId (const MWWorld::Ptr& ptr) const { return std::string("Item Lockpick Down"); } diff --git a/apps/openmw/mwclass/lockpick.hpp b/apps/openmw/mwclass/lockpick.hpp index 1b56234af1..042c726e44 100644 --- a/apps/openmw/mwclass/lockpick.hpp +++ b/apps/openmw/mwclass/lockpick.hpp @@ -12,14 +12,14 @@ namespace MWClass virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const; ///< Add reference into a cell for rendering - virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const; + virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const; virtual std::string getName (const MWWorld::Ptr& ptr) const; ///< \return name (the one that is to be presented to the user; not the internal one); /// can return an empty string. virtual boost::shared_ptr activate (const MWWorld::Ptr& ptr, - const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const; + const MWWorld::Ptr& actor) const; ///< Generate action for activation virtual std::string getScript (const MWWorld::Ptr& ptr) const; @@ -34,10 +34,10 @@ namespace MWClass static void registerSelf(); - virtual std::string getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const; + virtual std::string getUpSoundId (const MWWorld::Ptr& ptr) const; ///< Return the pick up sound Id - virtual std::string getDownSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const; + virtual std::string getDownSoundId (const MWWorld::Ptr& ptr) const; ///< Return the put down sound Id }; } diff --git a/apps/openmw/mwclass/misc.cpp b/apps/openmw/mwclass/misc.cpp index 84099caaaf..bcbf268708 100644 --- a/apps/openmw/mwclass/misc.cpp +++ b/apps/openmw/mwclass/misc.cpp @@ -5,9 +5,10 @@ #include +#include "../mwbase/environment.hpp" + #include "../mwworld/ptr.hpp" #include "../mwworld/actiontake.hpp" -#include "../mwworld/environment.hpp" #include "../mwrender/objects.hpp" @@ -31,7 +32,7 @@ namespace MWClass } } - void Miscellaneous::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const + void Miscellaneous::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const { ESMS::LiveCellRef *ref = ptr.get(); @@ -54,9 +55,9 @@ namespace MWClass } boost::shared_ptr Miscellaneous::activate (const MWWorld::Ptr& ptr, - const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const + const MWWorld::Ptr& actor) const { - environment.mSoundManager->playSound3D (ptr, getUpSoundId(ptr, environment), 1.0, 1.0, MWSound::Play_NoTrack); + MWBase::Environment::get().getSoundManager()->playSound3D (ptr, getUpSoundId(ptr), 1.0, 1.0, MWSound::Play_NoTrack); return boost::shared_ptr ( new MWWorld::ActionTake (ptr)); @@ -85,7 +86,7 @@ namespace MWClass registerClass (typeid (ESM::Miscellaneous).name(), instance); } - std::string Miscellaneous::getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const + std::string Miscellaneous::getUpSoundId (const MWWorld::Ptr& ptr) const { ESMS::LiveCellRef *ref = ptr.get(); @@ -97,7 +98,7 @@ namespace MWClass return std::string("Item Misc Up"); } - std::string Miscellaneous::getDownSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const + std::string Miscellaneous::getDownSoundId (const MWWorld::Ptr& ptr) const { ESMS::LiveCellRef *ref = ptr.get(); diff --git a/apps/openmw/mwclass/misc.hpp b/apps/openmw/mwclass/misc.hpp index fc002280cf..bc05169c0e 100644 --- a/apps/openmw/mwclass/misc.hpp +++ b/apps/openmw/mwclass/misc.hpp @@ -12,14 +12,14 @@ namespace MWClass virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const; ///< Add reference into a cell for rendering - virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const; + virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const; virtual std::string getName (const MWWorld::Ptr& ptr) const; ///< \return name (the one that is to be presented to the user; not the internal one); /// can return an empty string. virtual boost::shared_ptr activate (const MWWorld::Ptr& ptr, - const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const; + const MWWorld::Ptr& actor) const; ///< Generate action for activation virtual std::string getScript (const MWWorld::Ptr& ptr) const; @@ -30,10 +30,10 @@ namespace MWClass static void registerSelf(); - virtual std::string getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const; + virtual std::string getUpSoundId (const MWWorld::Ptr& ptr) const; ///< Return the pick up sound Id - virtual std::string getDownSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const; + virtual std::string getDownSoundId (const MWWorld::Ptr& ptr) const; ///< Return the put down sound Id }; } diff --git a/apps/openmw/mwclass/npc.cpp b/apps/openmw/mwclass/npc.cpp index c053ad1306..aaa239d474 100644 --- a/apps/openmw/mwclass/npc.cpp +++ b/apps/openmw/mwclass/npc.cpp @@ -14,11 +14,12 @@ #include "../mwworld/ptr.hpp" #include "../mwworld/actiontalk.hpp" -#include "../mwworld/environment.hpp" #include "../mwworld/world.hpp" #include "../mwworld/inventorystore.hpp" #include "../mwworld/customdata.hpp" +#include "../mwbase/environment.hpp" + namespace { const Ogre::Radian kOgrePi (Ogre::Math::PI); @@ -105,13 +106,13 @@ namespace MWClass void Npc::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const { - - + + renderingInterface.getActors().insertNPC(ptr, getInventoryStore(ptr)); - + } - void Npc::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const + void Npc::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const { @@ -133,14 +134,14 @@ namespace MWClass } - void Npc::enable (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const + void Npc::enable (const MWWorld::Ptr& ptr) const { - environment.mMechanicsManager->addActor (ptr); + MWBase::Environment::get().getMechanicsManager()->addActor (ptr); } - void Npc::disable (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const + void Npc::disable (const MWWorld::Ptr& ptr) const { - environment.mMechanicsManager->removeActor (ptr); + MWBase::Environment::get().getMechanicsManager()->removeActor (ptr); } std::string Npc::getName (const MWWorld::Ptr& ptr) const @@ -166,7 +167,7 @@ namespace MWClass } boost::shared_ptr Npc::activate (const MWWorld::Ptr& ptr, - const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const + const MWWorld::Ptr& actor) const { return boost::shared_ptr (new MWWorld::ActionTalk (ptr)); } diff --git a/apps/openmw/mwclass/npc.hpp b/apps/openmw/mwclass/npc.hpp index f210eda5f0..1ef77bd1b2 100644 --- a/apps/openmw/mwclass/npc.hpp +++ b/apps/openmw/mwclass/npc.hpp @@ -17,12 +17,12 @@ namespace MWClass virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const; ///< Add reference into a cell for rendering - virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const; + virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const; - virtual void enable (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const; + virtual void enable (const MWWorld::Ptr& ptr) const; ///< Enable reference; only does the non-rendering part - virtual void disable (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const; + virtual void disable (const MWWorld::Ptr& ptr) const; ///< Enable reference; only does the non-rendering part virtual std::string getName (const MWWorld::Ptr& ptr) const; @@ -42,7 +42,7 @@ namespace MWClass ///< Return inventory store virtual boost::shared_ptr activate (const MWWorld::Ptr& ptr, - const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const; + const MWWorld::Ptr& actor) const; ///< Generate action for activation virtual std::string getScript (const MWWorld::Ptr& ptr) const; diff --git a/apps/openmw/mwclass/potion.cpp b/apps/openmw/mwclass/potion.cpp index 642211df3c..790b4d13ef 100644 --- a/apps/openmw/mwclass/potion.cpp +++ b/apps/openmw/mwclass/potion.cpp @@ -5,9 +5,10 @@ #include +#include "../mwbase/environment.hpp" + #include "../mwworld/ptr.hpp" #include "../mwworld/actiontake.hpp" -#include "../mwworld/environment.hpp" #include "../mwrender/objects.hpp" @@ -31,7 +32,7 @@ namespace MWClass } } - void Potion::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const + void Potion::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const { ESMS::LiveCellRef *ref = ptr.get(); @@ -54,9 +55,9 @@ namespace MWClass } boost::shared_ptr Potion::activate (const MWWorld::Ptr& ptr, - const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const + const MWWorld::Ptr& actor) const { - environment.mSoundManager->playSound3D (ptr, getUpSoundId(ptr, environment), 1.0, 1.0, MWSound::Play_NoTrack); + MWBase::Environment::get().getSoundManager()->playSound3D (ptr, getUpSoundId(ptr), 1.0, 1.0, MWSound::Play_NoTrack); return boost::shared_ptr ( new MWWorld::ActionTake (ptr)); @@ -85,12 +86,12 @@ namespace MWClass registerClass (typeid (ESM::Potion).name(), instance); } - std::string Potion::getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const + std::string Potion::getUpSoundId (const MWWorld::Ptr& ptr) const { return std::string("Item Potion Up"); } - std::string Potion::getDownSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const + std::string Potion::getDownSoundId (const MWWorld::Ptr& ptr) const { return std::string("Item Potion Down"); } diff --git a/apps/openmw/mwclass/potion.hpp b/apps/openmw/mwclass/potion.hpp index 7d30179376..f9137766b1 100644 --- a/apps/openmw/mwclass/potion.hpp +++ b/apps/openmw/mwclass/potion.hpp @@ -12,14 +12,14 @@ namespace MWClass virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const; ///< Add reference into a cell for rendering - virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const; + virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const; virtual std::string getName (const MWWorld::Ptr& ptr) const; ///< \return name (the one that is to be presented to the user; not the internal one); /// can return an empty string. virtual boost::shared_ptr activate (const MWWorld::Ptr& ptr, - const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const; + const MWWorld::Ptr& actor) const; ///< Generate action for activation virtual std::string getScript (const MWWorld::Ptr& ptr) const; @@ -30,10 +30,10 @@ namespace MWClass static void registerSelf(); - virtual std::string getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const; + virtual std::string getUpSoundId (const MWWorld::Ptr& ptr) const; ///< Return the pick up sound Id - virtual std::string getDownSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const; + virtual std::string getDownSoundId (const MWWorld::Ptr& ptr) const; ///< Return the put down sound Id }; } diff --git a/apps/openmw/mwclass/probe.cpp b/apps/openmw/mwclass/probe.cpp index 923c29ee69..bfb1d29510 100644 --- a/apps/openmw/mwclass/probe.cpp +++ b/apps/openmw/mwclass/probe.cpp @@ -5,9 +5,10 @@ #include +#include "../mwbase/environment.hpp" + #include "../mwworld/ptr.hpp" #include "../mwworld/actiontake.hpp" -#include "../mwworld/environment.hpp" #include "../mwworld/inventorystore.hpp" #include "../mwrender/objects.hpp" @@ -32,7 +33,7 @@ namespace MWClass } } - void Probe::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const + void Probe::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const { ESMS::LiveCellRef *ref = ptr.get(); @@ -55,9 +56,9 @@ namespace MWClass return ref->base->name; } boost::shared_ptr Probe::activate (const MWWorld::Ptr& ptr, - const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const + const MWWorld::Ptr& actor) const { - environment.mSoundManager->playSound3D (ptr, getUpSoundId(ptr, environment), 1.0, 1.0, MWSound::Play_NoTrack); + MWBase::Environment::get().getSoundManager()->playSound3D (ptr, getUpSoundId(ptr), 1.0, 1.0, MWSound::Play_NoTrack); return boost::shared_ptr ( new MWWorld::ActionTake (ptr)); @@ -95,12 +96,12 @@ namespace MWClass registerClass (typeid (ESM::Probe).name(), instance); } - std::string Probe::getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const + std::string Probe::getUpSoundId (const MWWorld::Ptr& ptr) const { return std::string("Item Probe Up"); } - std::string Probe::getDownSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const + std::string Probe::getDownSoundId (const MWWorld::Ptr& ptr) const { return std::string("Item Probe Down"); } diff --git a/apps/openmw/mwclass/probe.hpp b/apps/openmw/mwclass/probe.hpp index 232b523645..543fa3f391 100644 --- a/apps/openmw/mwclass/probe.hpp +++ b/apps/openmw/mwclass/probe.hpp @@ -12,14 +12,14 @@ namespace MWClass virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const; ///< Add reference into a cell for rendering - virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const; + virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const; virtual std::string getName (const MWWorld::Ptr& ptr) const; ///< \return name (the one that is to be presented to the user; not the internal one); /// can return an empty string. virtual boost::shared_ptr activate (const MWWorld::Ptr& ptr, - const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const; + const MWWorld::Ptr& actor) const; ///< Generate action for activation virtual std::string getScript (const MWWorld::Ptr& ptr) const; @@ -34,10 +34,10 @@ namespace MWClass static void registerSelf(); - virtual std::string getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const; + virtual std::string getUpSoundId (const MWWorld::Ptr& ptr) const; ///< Return the pick up sound Id - virtual std::string getDownSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const; + virtual std::string getDownSoundId (const MWWorld::Ptr& ptr) const; ///< Return the put down sound Id }; } diff --git a/apps/openmw/mwclass/repair.cpp b/apps/openmw/mwclass/repair.cpp index d6433f5df5..8bae71e194 100644 --- a/apps/openmw/mwclass/repair.cpp +++ b/apps/openmw/mwclass/repair.cpp @@ -5,9 +5,10 @@ #include +#include "../mwbase/environment.hpp" + #include "../mwworld/ptr.hpp" #include "../mwworld/actiontake.hpp" -#include "../mwworld/environment.hpp" #include "../mwrender/objects.hpp" @@ -31,7 +32,7 @@ namespace MWClass } } - void Repair::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const + void Repair::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const { ESMS::LiveCellRef *ref = ptr.get(); @@ -54,9 +55,9 @@ namespace MWClass } boost::shared_ptr Repair::activate (const MWWorld::Ptr& ptr, - const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const + const MWWorld::Ptr& actor) const { - environment.mSoundManager->playSound3D (ptr, getUpSoundId(ptr, environment), 1.0, 1.0, MWSound::Play_NoTrack); + MWBase::Environment::get().getSoundManager()->playSound3D (ptr, getUpSoundId(ptr), 1.0, 1.0, MWSound::Play_NoTrack); return boost::shared_ptr ( new MWWorld::ActionTake (ptr)); @@ -85,12 +86,12 @@ namespace MWClass registerClass (typeid (ESM::Repair).name(), instance); } - std::string Repair::getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const + std::string Repair::getUpSoundId (const MWWorld::Ptr& ptr) const { return std::string("Item Repair Up"); } - std::string Repair::getDownSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const + std::string Repair::getDownSoundId (const MWWorld::Ptr& ptr) const { return std::string("Item Repair Down"); } diff --git a/apps/openmw/mwclass/repair.hpp b/apps/openmw/mwclass/repair.hpp index 0a9d9c2535..446ab325da 100644 --- a/apps/openmw/mwclass/repair.hpp +++ b/apps/openmw/mwclass/repair.hpp @@ -12,14 +12,14 @@ namespace MWClass virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const; ///< Add reference into a cell for rendering - virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const; + virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const; virtual std::string getName (const MWWorld::Ptr& ptr) const; ///< \return name (the one that is to be presented to the user; not the internal one); /// can return an empty string. virtual boost::shared_ptr activate (const MWWorld::Ptr& ptr, - const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const; + const MWWorld::Ptr& actor) const; ///< Generate action for activation virtual std::string getScript (const MWWorld::Ptr& ptr) const; @@ -30,10 +30,10 @@ namespace MWClass static void registerSelf(); - virtual std::string getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const; + virtual std::string getUpSoundId (const MWWorld::Ptr& ptr) const; ///< Return the pick up sound Id - virtual std::string getDownSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const; + virtual std::string getDownSoundId (const MWWorld::Ptr& ptr) const; ///< Return the put down sound Id }; } diff --git a/apps/openmw/mwclass/static.cpp b/apps/openmw/mwclass/static.cpp index 48750dd019..4a4136816e 100644 --- a/apps/openmw/mwclass/static.cpp +++ b/apps/openmw/mwclass/static.cpp @@ -25,7 +25,7 @@ namespace MWClass } } - void Static::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const + void Static::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const { ESMS::LiveCellRef *ref = ptr.get(); diff --git a/apps/openmw/mwclass/static.hpp b/apps/openmw/mwclass/static.hpp index a4b1d8c547..cd1626c197 100644 --- a/apps/openmw/mwclass/static.hpp +++ b/apps/openmw/mwclass/static.hpp @@ -12,7 +12,7 @@ namespace MWClass virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const; ///< Add reference into a cell for rendering - virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const; + virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const; virtual std::string getName (const MWWorld::Ptr& ptr) const; ///< \return name (the one that is to be presented to the user; not the internal one); diff --git a/apps/openmw/mwclass/weapon.cpp b/apps/openmw/mwclass/weapon.cpp index 7790e6a80b..22745f82d5 100644 --- a/apps/openmw/mwclass/weapon.cpp +++ b/apps/openmw/mwclass/weapon.cpp @@ -5,9 +5,10 @@ #include +#include "../mwbase/environment.hpp" + #include "../mwworld/ptr.hpp" #include "../mwworld/actiontake.hpp" -#include "../mwworld/environment.hpp" #include "../mwworld/inventorystore.hpp" #include "../mwrender/objects.hpp" @@ -32,7 +33,7 @@ namespace MWClass } } - void Weapon::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const + void Weapon::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const { ESMS::LiveCellRef *ref = ptr.get(); @@ -55,9 +56,9 @@ namespace MWClass } boost::shared_ptr Weapon::activate (const MWWorld::Ptr& ptr, - const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const + const MWWorld::Ptr& actor) const { - environment.mSoundManager->playSound3D (ptr, getUpSoundId(ptr, environment), 1.0, 1.0, MWSound::Play_NoTrack); + MWBase::Environment::get().getSoundManager()->playSound3D (ptr, getUpSoundId(ptr), 1.0, 1.0, MWSound::Play_NoTrack); return boost::shared_ptr ( new MWWorld::ActionTake (ptr)); @@ -108,8 +109,7 @@ namespace MWClass return std::make_pair (slots, stack); } - int Weapon::getEquipmentSkill (const MWWorld::Ptr& ptr, - const MWWorld::Environment& environment) const + int Weapon::getEquipmentSkill (const MWWorld::Ptr& ptr) const { ESMS::LiveCellRef *ref = ptr.get(); @@ -154,7 +154,7 @@ namespace MWClass registerClass (typeid (ESM::Weapon).name(), instance); } - std::string Weapon::getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const + std::string Weapon::getUpSoundId (const MWWorld::Ptr& ptr) const { ESMS::LiveCellRef *ref = ptr.get(); @@ -200,7 +200,7 @@ namespace MWClass return std::string("Item Misc Up"); } - std::string Weapon::getDownSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const + std::string Weapon::getDownSoundId (const MWWorld::Ptr& ptr) const { ESMS::LiveCellRef *ref = ptr.get(); diff --git a/apps/openmw/mwclass/weapon.hpp b/apps/openmw/mwclass/weapon.hpp index 505c45645f..204d327ade 100644 --- a/apps/openmw/mwclass/weapon.hpp +++ b/apps/openmw/mwclass/weapon.hpp @@ -12,14 +12,14 @@ namespace MWClass virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const; ///< Add reference into a cell for rendering - virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const; + virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const; virtual std::string getName (const MWWorld::Ptr& ptr) const; ///< \return name (the one that is to be presented to the user; not the internal one); /// can return an empty string. virtual boost::shared_ptr activate (const MWWorld::Ptr& ptr, - const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const; + const MWWorld::Ptr& actor) const; ///< Generate action for activation virtual bool hasItemHealth (const MWWorld::Ptr& ptr) const; @@ -35,8 +35,7 @@ namespace MWClass ///< \return first: Return IDs of the slot this object can be equipped in; second: can object /// stay stacked when equipped? - virtual int getEquipmentSkill (const MWWorld::Ptr& ptr, - const MWWorld::Environment& environment) const; + virtual int getEquipmentSkill (const MWWorld::Ptr& ptr) const; /// Return the index of the skill this item corresponds to when equiopped or -1, if there is /// no such skill. @@ -45,10 +44,10 @@ namespace MWClass static void registerSelf(); - virtual std::string getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const; + virtual std::string getUpSoundId (const MWWorld::Ptr& ptr) const; ///< Return the pick up sound Id - virtual std::string getDownSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const; + virtual std::string getDownSoundId (const MWWorld::Ptr& ptr) const; ///< Return the put down sound Id }; } diff --git a/apps/openmw/mwdialogue/dialoguemanager.cpp b/apps/openmw/mwdialogue/dialoguemanager.cpp index 3188136b30..f753e936ee 100644 --- a/apps/openmw/mwdialogue/dialoguemanager.cpp +++ b/apps/openmw/mwdialogue/dialoguemanager.cpp @@ -9,9 +9,9 @@ #include +#include "../mwbase/environment.hpp" #include "../mwworld/class.hpp" -#include "../mwworld/environment.hpp" #include "../mwworld/world.hpp" #include "../mwworld/refdata.hpp" #include "../mwworld/player.hpp" @@ -181,7 +181,7 @@ namespace MWDialogue case 46://Same faction { - MWMechanics::NpcStats PCstats = MWWorld::Class::get(mEnvironment.mWorld->getPlayer().getPlayer()).getNpcStats(mEnvironment.mWorld->getPlayer().getPlayer()); + MWMechanics::NpcStats PCstats = MWWorld::Class::get(MWBase::Environment::get().getWorld()->getPlayer().getPlayer()).getNpcStats(MWBase::Environment::get().getWorld()->getPlayer().getPlayer()); MWMechanics::NpcStats NPCstats = MWWorld::Class::get(actor).getNpcStats(actor); int sameFaction = 0; if(!NPCstats.mFactionRank.empty()) @@ -288,12 +288,12 @@ namespace MWDialogue if (select.type==ESM::VT_Short || select.type==ESM::VT_Int || select.type==ESM::VT_Long) { - if (!checkGlobal (comp, toLower (name), select.i, *mEnvironment.mWorld)) + if (!checkGlobal (comp, toLower (name), select.i, *MWBase::Environment::get().getWorld())) return false; } else if (select.type==ESM::VT_Float) { - if (!checkGlobal (comp, toLower (name), select.f, *mEnvironment.mWorld)) + if (!checkGlobal (comp, toLower (name), select.f, *MWBase::Environment::get().getWorld())) return false; } else @@ -308,13 +308,13 @@ namespace MWDialogue select.type==ESM::VT_Long) { if (!checkLocal (comp, toLower (name), select.i, actor, - mEnvironment.mWorld->getStore())) + MWBase::Environment::get().getWorld()->getStore())) return false; } else if (select.type==ESM::VT_Float) { if (!checkLocal (comp, toLower (name), select.f, actor, - mEnvironment.mWorld->getStore())) + MWBase::Environment::get().getWorld()->getStore())) return false; } else @@ -326,7 +326,7 @@ namespace MWDialogue case '4'://journal if(select.type==ESM::VT_Int) { - if(!selectCompare(comp,mEnvironment.mJournal->getJournalIndex(toLower(name)),select.i)) return false; + if(!selectCompare(comp,MWBase::Environment::get().getJournal()->getJournalIndex(toLower(name)),select.i)) return false; } else throw std::runtime_error ( @@ -336,7 +336,7 @@ namespace MWDialogue case '5'://item { - MWWorld::Ptr player = mEnvironment.mWorld->getPlayer().getPlayer(); + MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer(); MWWorld::ContainerStore& store = MWWorld::Class::get (player).getContainerStore (player); int sum = 0; @@ -424,13 +424,13 @@ namespace MWDialogue select.type==ESM::VT_Long) { if (checkLocal (comp, toLower (name), select.i, actor, - mEnvironment.mWorld->getStore())) + MWBase::Environment::get().getWorld()->getStore())) return false; } else if (select.type==ESM::VT_Float) { if (checkLocal (comp, toLower (name), select.f, actor, - mEnvironment.mWorld->getStore())) + MWBase::Environment::get().getWorld()->getStore())) return false; } else @@ -500,7 +500,7 @@ namespace MWDialogue // TODO check player faction if(!info.pcFaction.empty()) { - MWMechanics::NpcStats stats = MWWorld::Class::get(mEnvironment.mWorld->getPlayer().getPlayer()).getNpcStats(mEnvironment.mWorld->getPlayer().getPlayer()); + MWMechanics::NpcStats stats = MWWorld::Class::get(MWBase::Environment::get().getWorld()->getPlayer().getPlayer()).getNpcStats(MWBase::Environment::get().getWorld()->getPlayer().getPlayer()); std::map::iterator it = stats.mFactionRank.find(info.pcFaction); if(it!=stats.mFactionRank.end()) { @@ -528,7 +528,7 @@ namespace MWDialogue // check cell if (!info.cell.empty()) - if (mEnvironment.mWorld->getPlayer().getPlayer().getCell()->cell->name != info.cell) + if (MWBase::Environment::get().getWorld()->getPlayer().getPlayer().getCell()->cell->name != info.cell) return false; // TODO check DATAstruct @@ -540,8 +540,8 @@ namespace MWDialogue return true; } - DialogueManager::DialogueManager (MWWorld::Environment& environment,const Compiler::Extensions& extensions) : - mEnvironment (environment),mCompilerContext (MWScript::CompilerContext::Type_Dialgoue, environment), + DialogueManager::DialogueManager (const Compiler::Extensions& extensions) : + mCompilerContext (MWScript::CompilerContext::Type_Dialgoue), mErrorStream(std::cout.rdbuf()),mErrorHandler(mErrorStream) { mChoice = -1; @@ -549,7 +549,7 @@ namespace MWDialogue mCompilerContext.setExtensions (&extensions); mDialogueMap.clear(); actorKnownTopics.clear(); - ESMS::RecListCaseT::MapType dialogueList = mEnvironment.mWorld->getStore().dialogs.list; + ESMS::RecListCaseT::MapType dialogueList = MWBase::Environment::get().getWorld()->getStore().dialogs.list; for(ESMS::RecListCaseT::MapType::iterator it = dialogueList.begin(); it!=dialogueList.end();it++) { mDialogueMap[toLower(it->first)] = it->second; @@ -592,8 +592,8 @@ namespace MWDialogue actorKnownTopics.clear(); //initialise the GUI - mEnvironment.mInputManager->setGuiMode(MWGui::GM_Dialogue); - MWGui::DialogueWindow* win = mEnvironment.mWindowManager->getDialogueWindow(); + MWBase::Environment::get().getInputManager()->setGuiMode(MWGui::GM_Dialogue); + MWGui::DialogueWindow* win = MWBase::Environment::get().getWindowManager()->getDialogueWindow(); win->startDialogue(MWWorld::Class::get (actor).getName (actor)); //setup the list of topics known by the actor. Topics who are also on the knownTopics list will be added to the GUI @@ -601,8 +601,8 @@ namespace MWDialogue //greeting bool greetingFound = false; - //ESMS::RecListT::MapType dialogueList = mEnvironment.mWorld->getStore().dialogs.list; - ESMS::RecListCaseT::MapType dialogueList = mEnvironment.mWorld->getStore().dialogs.list; + //ESMS::RecListT::MapType dialogueList = MWBase::Environment::get().getWorld()->getStore().dialogs.list; + ESMS::RecListCaseT::MapType dialogueList = MWBase::Environment::get().getWorld()->getStore().dialogs.list; for(ESMS::RecListCaseT::MapType::iterator it = dialogueList.begin(); it!=dialogueList.end();it++) { ESM::Dialogue ndialogue = it->second; @@ -650,7 +650,7 @@ namespace MWDialogue if (!actorScript.empty()) { // grab local variables from actor's script, if available. - locals = mEnvironment.mScriptManager->getLocals (actorScript); + locals = MWBase::Environment::get().getScriptManager()->getLocals (actorScript); } Compiler::ScriptParser parser(mErrorHandler,mCompilerContext, locals, false); @@ -683,7 +683,7 @@ namespace MWDialogue { try { - MWScript::InterpreterContext interpreterContext(mEnvironment,&mActor.getRefData().getLocals(),mActor); + MWScript::InterpreterContext interpreterContext(&mActor.getRefData().getLocals(),mActor); Interpreter::Interpreter interpreter; MWScript::installOpcodes (interpreter); interpreter.run (&code[0], code.size(), interpreterContext); @@ -701,8 +701,8 @@ namespace MWDialogue int choice = mChoice; mChoice = -1; actorKnownTopics.clear(); - MWGui::DialogueWindow* win = mEnvironment.mWindowManager->getDialogueWindow(); - ESMS::RecListCaseT::MapType dialogueList = mEnvironment.mWorld->getStore().dialogs.list; + MWGui::DialogueWindow* win = MWBase::Environment::get().getWindowManager()->getDialogueWindow(); + ESMS::RecListCaseT::MapType dialogueList = MWBase::Environment::get().getWorld()->getStore().dialogs.list; for(ESMS::RecListCaseT::MapType::iterator it = dialogueList.begin(); it!=dialogueList.end();it++) { ESM::Dialogue ndialogue = it->second; @@ -747,7 +747,7 @@ namespace MWDialogue parseText(text); - MWGui::DialogueWindow* win = mEnvironment.mWindowManager->getDialogueWindow(); + MWGui::DialogueWindow* win = MWBase::Environment::get().getWindowManager()->getDialogueWindow(); win->addTitle(keyword); win->addText(iter->response); @@ -767,7 +767,7 @@ namespace MWDialogue void DialogueManager::goodbyeSelected() { - mEnvironment.mInputManager->setGuiMode(MWGui::GM_Game); + MWBase::Environment::get().getInputManager()->setGuiMode(MWGui::GM_Game); } void DialogueManager::questionAnswered(std::string answere) @@ -790,7 +790,7 @@ namespace MWDialogue mChoiceMap.clear(); mChoice = -1; mIsInChoice = false; - MWGui::DialogueWindow* win = mEnvironment.mWindowManager->getDialogueWindow(); + MWGui::DialogueWindow* win = MWBase::Environment::get().getWindowManager()->getDialogueWindow(); std::string text = iter->response; parseText(text); win->addText(text); @@ -808,13 +808,13 @@ namespace MWDialogue void DialogueManager::printError(std::string error) { - MWGui::DialogueWindow* win = mEnvironment.mWindowManager->getDialogueWindow(); + MWGui::DialogueWindow* win = MWBase::Environment::get().getWindowManager()->getDialogueWindow(); win->addText(error); } void DialogueManager::askQuestion(std::string question, int choice) { - MWGui::DialogueWindow* win = mEnvironment.mWindowManager->getDialogueWindow(); + MWGui::DialogueWindow* win = MWBase::Environment::get().getWindowManager()->getDialogueWindow(); win->askQuestion(question); mChoiceMap[question] = choice; mIsInChoice = true; diff --git a/apps/openmw/mwdialogue/dialoguemanager.hpp b/apps/openmw/mwdialogue/dialoguemanager.hpp index d0380fa717..a3e37987db 100644 --- a/apps/openmw/mwdialogue/dialoguemanager.hpp +++ b/apps/openmw/mwdialogue/dialoguemanager.hpp @@ -11,17 +11,10 @@ #include "../mwworld/ptr.hpp" #include -namespace MWWorld -{ - class Environment; -} - namespace MWDialogue { class DialogueManager { - MWWorld::Environment& mEnvironment; - bool isMatching (const MWWorld::Ptr& actor, const ESM::DialInfo::SelectStruct& select) const; bool isMatching (const MWWorld::Ptr& actor, const ESM::DialInfo& info) const; @@ -39,7 +32,7 @@ namespace MWDialogue MWScript::CompilerContext mCompilerContext; std::ostream mErrorStream; Compiler::StreamErrorHandler mErrorHandler; - + bool compile (const std::string& cmd,std::vector& code); void executeScript(std::string script); @@ -55,7 +48,7 @@ namespace MWDialogue public: - DialogueManager (MWWorld::Environment& environment,const Compiler::Extensions& extensions); + DialogueManager (const Compiler::Extensions& extensions); void startDialogue (const MWWorld::Ptr& actor); diff --git a/apps/openmw/mwdialogue/journal.cpp b/apps/openmw/mwdialogue/journal.cpp index 0715214ebd..e0245406ef 100644 --- a/apps/openmw/mwdialogue/journal.cpp +++ b/apps/openmw/mwdialogue/journal.cpp @@ -1,7 +1,7 @@ #include "journal.hpp" -#include "../mwworld/environment.hpp" +#include "../mwbase/environment.hpp" #include "../mwgui/window_manager.hpp" #include "../mwgui/messagebox.hpp" @@ -23,31 +23,30 @@ namespace MWDialogue return iter->second; } - Journal::Journal (MWWorld::Environment& environment) - : mEnvironment (environment) + Journal::Journal() {} void Journal::addEntry (const std::string& id, int index) { StampedJournalEntry entry = - StampedJournalEntry::makeFromQuest (id, index, *mEnvironment.mWorld); + StampedJournalEntry::makeFromQuest (id, index, *MWBase::Environment::get().getWorld()); mJournal.push_back (entry); Quest& quest = getQuest (id); - quest.addEntry (entry, *mEnvironment.mWorld); // we are doing slicing on purpose here - + quest.addEntry (entry, *MWBase::Environment::get().getWorld()); // we are doing slicing on purpose here + std::vector empty; std::string notification = "Your Journal has been updated."; - mEnvironment.mWindowManager->messageBox (notification, empty); + MWBase::Environment::get().getWindowManager()->messageBox (notification, empty); } void Journal::setJournalIndex (const std::string& id, int index) { Quest& quest = getQuest (id); - quest.setIndex (index, *mEnvironment.mWorld); + quest.setIndex (index, *MWBase::Environment::get().getWorld()); } void Journal::addTopic (const std::string& topicId, const std::string& infoId) @@ -62,7 +61,7 @@ namespace MWDialogue iter = result.first; } - iter->second.addEntry (JournalEntry (topicId, infoId), *mEnvironment.mWorld); + iter->second.addEntry (JournalEntry (topicId, infoId), *MWBase::Environment::get().getWorld()); } int Journal::getJournalIndex (const std::string& id) const diff --git a/apps/openmw/mwdialogue/journal.hpp b/apps/openmw/mwdialogue/journal.hpp index ff1343945d..62b9f4bed9 100644 --- a/apps/openmw/mwdialogue/journal.hpp +++ b/apps/openmw/mwdialogue/journal.hpp @@ -8,11 +8,6 @@ #include "journalentry.hpp" #include "quest.hpp" -namespace MWWorld -{ - struct Environment; -} - namespace MWDialogue { /// \brief The player's journal @@ -29,7 +24,6 @@ namespace MWDialogue private: - MWWorld::Environment& mEnvironment; TEntryContainer mJournal; TQuestContainer mQuests; TTopicContainer mTopics; @@ -38,7 +32,7 @@ namespace MWDialogue public: - Journal (MWWorld::Environment& environment); + Journal(); void addEntry (const std::string& id, int index); ///< Add a journal entry. diff --git a/apps/openmw/mwgui/charactercreation.cpp b/apps/openmw/mwgui/charactercreation.cpp index ce5e744ccb..9a23758558 100644 --- a/apps/openmw/mwgui/charactercreation.cpp +++ b/apps/openmw/mwgui/charactercreation.cpp @@ -8,6 +8,8 @@ #include "dialogue.hpp" #include "mode.hpp" +#include "../mwbase/environment.hpp" + namespace { struct Step @@ -93,7 +95,7 @@ namespace using namespace MWGui; -CharacterCreation::CharacterCreation(WindowManager* _wm, MWWorld::Environment* _environment) +CharacterCreation::CharacterCreation(WindowManager* _wm) : mNameDialog(0) , mRaceDialog(0) , mDialogueWindow(0) @@ -105,7 +107,6 @@ CharacterCreation::CharacterCreation(WindowManager* _wm, MWWorld::Environment* _ , mBirthSignDialog(0) , mReviewDialog(0) , mWM(_wm) - , mEnvironment(_environment) { mCreationStage = CSE_NotStarted; } @@ -279,8 +280,8 @@ void CharacterCreation::onPickClassDialogDone(WindowBase* parWindow) { const std::string &classId = mPickClassDialog->getClassId(); if (!classId.empty()) - mEnvironment->mMechanicsManager->setPlayerClass(classId); - const ESM::Class *klass = mEnvironment->mWorld->getStore().classes.find(classId); + MWBase::Environment::get().getMechanicsManager()->setPlayerClass(classId); + const ESM::Class *klass = MWBase::Environment::get().getWorld()->getStore().classes.find(classId); if (klass) { mPlayerClass = *klass; @@ -307,7 +308,7 @@ void CharacterCreation::onPickClassDialogBack() { const std::string classId = mPickClassDialog->getClassId(); if (!classId.empty()) - mEnvironment->mMechanicsManager->setPlayerClass(classId); + MWBase::Environment::get().getMechanicsManager()->setPlayerClass(classId); mWM->removeDialog(mPickClassDialog); } @@ -345,7 +346,7 @@ void CharacterCreation::onNameDialogDone(WindowBase* parWindow) { mPlayerName = mNameDialog->getTextInput(); mWM->setValue("name", mPlayerName); - mEnvironment->mMechanicsManager->setPlayerName(mPlayerName); + MWBase::Environment::get().getMechanicsManager()->setPlayerName(mPlayerName); mWM->removeDialog(mNameDialog); } @@ -366,7 +367,7 @@ void CharacterCreation::onRaceDialogBack() { mPlayerRaceId = mRaceDialog->getRaceId(); if (!mPlayerRaceId.empty()) - mEnvironment->mMechanicsManager->setPlayerRace(mPlayerRaceId, mRaceDialog->getGender() == RaceDialog::GM_Male); + MWBase::Environment::get().getMechanicsManager()->setPlayerRace(mPlayerRaceId, mRaceDialog->getGender() == RaceDialog::GM_Male); mWM->removeDialog(mRaceDialog); } @@ -380,7 +381,7 @@ void CharacterCreation::onRaceDialogDone(WindowBase* parWindow) mPlayerRaceId = mRaceDialog->getRaceId(); mWM->setValue("race", mPlayerRaceId); if (!mPlayerRaceId.empty()) - mEnvironment->mMechanicsManager->setPlayerRace(mPlayerRaceId, mRaceDialog->getGender() == RaceDialog::GM_Male); + MWBase::Environment::get().getMechanicsManager()->setPlayerRace(mPlayerRaceId, mRaceDialog->getGender() == RaceDialog::GM_Male); mWM->removeDialog(mRaceDialog); } @@ -402,7 +403,7 @@ void CharacterCreation::onBirthSignDialogDone(WindowBase* parWindow) mPlayerBirthSignId = mBirthSignDialog->getBirthId(); mWM->setBirthSign(mPlayerBirthSignId); if (!mPlayerBirthSignId.empty()) - mEnvironment->mMechanicsManager->setPlayerBirthsign(mPlayerBirthSignId); + MWBase::Environment::get().getMechanicsManager()->setPlayerBirthsign(mPlayerBirthSignId); mWM->removeDialog(mBirthSignDialog); } @@ -419,7 +420,7 @@ void CharacterCreation::onBirthSignDialogBack() { if (mBirthSignDialog) { - mEnvironment->mMechanicsManager->setPlayerBirthsign(mBirthSignDialog->getBirthId()); + MWBase::Environment::get().getMechanicsManager()->setPlayerBirthsign(mBirthSignDialog->getBirthId()); mWM->removeDialog(mBirthSignDialog); } @@ -450,7 +451,7 @@ void CharacterCreation::onCreateClassDialogDone(WindowBase* parWindow) klass.data.skills[i][1] = majorSkills[i]; klass.data.skills[i][0] = minorSkills[i]; } - mEnvironment->mMechanicsManager->setPlayerClass(klass); + MWBase::Environment::get().getMechanicsManager()->setPlayerClass(klass); mPlayerClass = klass; mWM->setPlayerClass(klass); @@ -592,7 +593,7 @@ void CharacterCreation::onGenerateClassBack() if (mGenerateClassResultDialog) mWM->removeDialog(mGenerateClassResultDialog); - mEnvironment->mMechanicsManager->setPlayerClass(mGenerateClass); + MWBase::Environment::get().getMechanicsManager()->setPlayerClass(mGenerateClass); mWM->setGuiMode(GM_Class); } @@ -601,7 +602,7 @@ void CharacterCreation::onGenerateClassDone(WindowBase* parWindow) { if (mGenerateClassResultDialog) mWM->removeDialog(mGenerateClassResultDialog); - mEnvironment->mMechanicsManager->setPlayerClass(mGenerateClass); + MWBase::Environment::get().getMechanicsManager()->setPlayerClass(mGenerateClass); if (mCreationStage == CSE_ReviewNext) mWM->setGuiMode(GM_Review); diff --git a/apps/openmw/mwgui/charactercreation.hpp b/apps/openmw/mwgui/charactercreation.hpp index b01e754d9d..222754cdc3 100644 --- a/apps/openmw/mwgui/charactercreation.hpp +++ b/apps/openmw/mwgui/charactercreation.hpp @@ -30,7 +30,7 @@ namespace MWGui public: typedef std::vector SkillList; - CharacterCreation(WindowManager* _wm, MWWorld::Environment* _environment); + CharacterCreation(WindowManager* _wm); ~CharacterCreation(); //Show a dialog @@ -56,7 +56,6 @@ namespace MWGui ReviewDialog* mReviewDialog; WindowManager* mWM; - MWWorld::Environment* mEnvironment; //Player data std::string mPlayerName; diff --git a/apps/openmw/mwgui/console.cpp b/apps/openmw/mwgui/console.cpp index ac4f4a82a9..8e15abddd6 100644 --- a/apps/openmw/mwgui/console.cpp +++ b/apps/openmw/mwgui/console.cpp @@ -7,6 +7,8 @@ #include "../mwscript/extensions.hpp" +#include "../mwbase/environment.hpp" + namespace MWGui { class ConsoleInterpreterContext : public MWScript::InterpreterContext @@ -15,15 +17,14 @@ namespace MWGui public: - ConsoleInterpreterContext (Console& console, MWWorld::Environment& environment, - MWWorld::Ptr reference); + ConsoleInterpreterContext (Console& console, MWWorld::Ptr reference); virtual void report (const std::string& message); }; ConsoleInterpreterContext::ConsoleInterpreterContext (Console& console, - MWWorld::Environment& environment, MWWorld::Ptr reference) - : MWScript::InterpreterContext (environment, + MWWorld::Ptr reference) + : MWScript::InterpreterContext ( reference.isEmpty() ? 0 : &reference.getRefData().getLocals(), reference), mConsole (console) {} @@ -88,7 +89,7 @@ namespace MWGui scanner.listKeywords (mNames); // identifier - const ESMS::ESMStore& store = mEnvironment.mWorld->getStore(); + const ESMS::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); for (ESMS::RecListList::const_iterator iter (store.recLists.begin()); iter!=store.recLists.end(); ++iter) @@ -101,11 +102,9 @@ namespace MWGui } } - Console::Console(int w, int h, MWWorld::Environment& environment, - const Compiler::Extensions& extensions) + Console::Console(int w, int h, const Compiler::Extensions& extensions) : Layout("openmw_console_layout.xml"), - mCompilerContext (MWScript::CompilerContext::Type_Console, environment), - mEnvironment (environment) + mCompilerContext (MWScript::CompilerContext::Type_Console) { setCoord(10,10, w-10, h/2); @@ -139,7 +138,7 @@ namespace MWGui void Console::disable() { setVisible(false); - // Remove keyboard focus from the console input whenever the + // Remove keyboard focus from the console input whenever the // console is turned off MyGUI::InputManager::getInstance().setKeyFocusWidget(NULL); } @@ -241,7 +240,7 @@ namespace MWGui { try { - ConsoleInterpreterContext interpreterContext (*this, mEnvironment, MWWorld::Ptr()); + ConsoleInterpreterContext interpreterContext (*this, MWWorld::Ptr()); Interpreter::Interpreter interpreter; MWScript::installOpcodes (interpreter); std::vector code; diff --git a/apps/openmw/mwgui/console.hpp b/apps/openmw/mwgui/console.hpp index eaf4299be0..6974d83330 100644 --- a/apps/openmw/mwgui/console.hpp +++ b/apps/openmw/mwgui/console.hpp @@ -23,7 +23,6 @@ namespace MWGui private: MWScript::CompilerContext mCompilerContext; - MWWorld::Environment& mEnvironment; std::vector mNames; bool compile (const std::string& cmd, Compiler::Output& output); @@ -51,7 +50,7 @@ namespace MWGui StringList::iterator current; std::string editString; - Console(int w, int h, MWWorld::Environment& environment, const Compiler::Extensions& extensions); + Console(int w, int h, const Compiler::Extensions& extensions); void enable(); diff --git a/apps/openmw/mwgui/dialogue.cpp b/apps/openmw/mwgui/dialogue.cpp index fc7a363829..2386cf9a32 100644 --- a/apps/openmw/mwgui/dialogue.cpp +++ b/apps/openmw/mwgui/dialogue.cpp @@ -3,7 +3,7 @@ #include "window_manager.hpp" #include "widgets.hpp" #include "components/esm_store/store.hpp" -#include "../mwworld/environment.hpp" +#include "../mwbase/environment.hpp" #include "../mwdialogue/dialoguemanager.hpp" #include @@ -36,9 +36,8 @@ std::string::size_type find_str_ci(const std::string& str, const std::string& su } -DialogueWindow::DialogueWindow(WindowManager& parWindowManager,MWWorld::Environment& environment) - : WindowBase("openmw_dialogue_window_layout.xml", parWindowManager), - mEnvironment(environment) +DialogueWindow::DialogueWindow(WindowManager& parWindowManager) + : WindowBase("openmw_dialogue_window_layout.xml", parWindowManager) { // Centre dialog center(); @@ -54,7 +53,7 @@ DialogueWindow::DialogueWindow(WindowManager& parWindowManager,MWWorld::Environm /// \todo scrolling the dialogue history with the mouse wheel doesn't work using this solution getWidget(eventbox, "EventBox"); eventbox->eventMouseButtonClick += MyGUI::newDelegate(this, &DialogueWindow::onHistoryClicked); - + //Topics list getWidget(topicsList, "TopicsList"); topicsList->setScrollVisible(true); @@ -83,9 +82,9 @@ void DialogueWindow::onHistoryClicked(MyGUI::Widget* _sender) if(color != "#B29154") { UString key = history->getColorTextAt(cursorPosition); - if(color == "#686EBA") mEnvironment.mDialogueManager->keywordSelected(lower_string(key)); + if(color == "#686EBA") MWBase::Environment::get().getDialogueManager()->keywordSelected(lower_string(key)); - if(color == "#572D21") mEnvironment.mDialogueManager->questionAnswered(key); + if(color == "#572D21") MWBase::Environment::get().getDialogueManager()->questionAnswered(key); } } @@ -100,7 +99,7 @@ void DialogueWindow::open() void DialogueWindow::onByeClicked(MyGUI::Widget* _sender) { - mEnvironment.mDialogueManager->goodbyeSelected(); + MWBase::Environment::get().getDialogueManager()->goodbyeSelected(); } void DialogueWindow::onSelectTopic(MyGUI::ListBox* _sender, size_t _index) @@ -108,7 +107,7 @@ void DialogueWindow::onSelectTopic(MyGUI::ListBox* _sender, size_t _index) if (_index == MyGUI::ITEM_NONE) return; std::string topic = _sender->getItemNameAt(_index); - mEnvironment.mDialogueManager->keywordSelected(lower_string(topic)); + MWBase::Environment::get().getDialogueManager()->keywordSelected(lower_string(topic)); } void DialogueWindow::startDialogue(std::string npcName) diff --git a/apps/openmw/mwgui/dialogue.hpp b/apps/openmw/mwgui/dialogue.hpp index b80a016cbe..5b84397582 100644 --- a/apps/openmw/mwgui/dialogue.hpp +++ b/apps/openmw/mwgui/dialogue.hpp @@ -9,11 +9,6 @@ namespace MWGui class WindowManager; } -namespace MWWorld -{ - class Environment; -} - /* This file contains the dialouge window Layout is defined by resources/mygui/openmw_dialogue_window_layout.xml. @@ -28,7 +23,7 @@ namespace MWGui class DialogueWindow: public WindowBase { public: - DialogueWindow(WindowManager& parWindowManager,MWWorld::Environment& environment); + DialogueWindow(WindowManager& parWindowManager); void open(); @@ -65,8 +60,6 @@ namespace MWGui MyGUI::ProgressPtr pDispositionBar; MyGUI::EditPtr pDispositionText; std::map pTopicsText;// this map links keyword and "real" text. - - MWWorld::Environment& mEnvironment; }; } #endif diff --git a/apps/openmw/mwgui/journalwindow.cpp b/apps/openmw/mwgui/journalwindow.cpp index 644bcbc04f..e67eda7771 100644 --- a/apps/openmw/mwgui/journalwindow.cpp +++ b/apps/openmw/mwgui/journalwindow.cpp @@ -1,7 +1,7 @@ #include "journalwindow.hpp" #include "window_manager.hpp" #include "../mwdialogue/journal.hpp" -#include "../mwworld/environment.hpp" +#include "../mwbase/environment.hpp" #include "../mwworld/world.hpp" #include "../mwsound/soundmanager.hpp" @@ -118,20 +118,20 @@ void MWGui::JournalWindow::open() { mPageNumber = 0; std::string journalOpenSound = "book open"; - mWindowManager.getEnvironment().mSoundManager->playSound (journalOpenSound, 1.0, 1.0); - if(mWindowManager.getEnvironment().mJournal->begin()!=mWindowManager.getEnvironment().mJournal->end()) + MWBase::Environment::get().getSoundManager()->playSound (journalOpenSound, 1.0, 1.0); + if(MWBase::Environment::get().getJournal()->begin()!=MWBase::Environment::get().getJournal()->end()) { book journal; journal.endLine = 0; - for(std::deque::const_iterator it = mWindowManager.getEnvironment().mJournal->begin();it!=mWindowManager.getEnvironment().mJournal->end();it++) + for(std::deque::const_iterator it = MWBase::Environment::get().getJournal()->begin();it!=MWBase::Environment::get().getJournal()->end();it++) { - std::string a = it->getText(mWindowManager.getEnvironment().mWorld->getStore()); + std::string a = it->getText(MWBase::Environment::get().getWorld()->getStore()); journal = formatText(a,journal,10,17); journal.endLine = journal.endLine +1; journal.pages.back() = journal.pages.back() + std::string("\n"); } - //std::string a = mWindowManager.getEnvironment().mJournal->begin()->getText(mWindowManager.getEnvironment().mWorld->getStore()); + //std::string a = MWBase::Environment::get().getJournal()->begin()->getText(MWBase::Environment::get().getWorld()->getStore()); //std::list journal = formatText(a,10,20,1); bool left = true; for(std::list::iterator it = journal.pages.begin(); it != journal.pages.end();it++) @@ -155,7 +155,7 @@ void MWGui::JournalWindow::open() } else { - //std::cout << mWindowManager.getEnvironment().mJournal->begin()->getText(mWindowManager.getEnvironment().mWorld->getStore()); + //std::cout << MWBase::Environment::get().getJournal()->begin()->getText(MWBase::Environment::get().getWorld()->getStore()); } } @@ -181,7 +181,7 @@ void MWGui::JournalWindow::notifyNextPage(MyGUI::WidgetPtr _sender) if(mPageNumber < int(leftPages.size())-1) { std::string nextSound = "book page2"; - mWindowManager.getEnvironment().mSoundManager->playSound (nextSound, 1.0, 1.0); + MWBase::Environment::get().getSoundManager()->playSound (nextSound, 1.0, 1.0); mPageNumber = mPageNumber + 1; displayLeftText(leftPages[mPageNumber]); displayRightText(rightPages[mPageNumber]); @@ -193,7 +193,7 @@ void MWGui::JournalWindow::notifyPrevPage(MyGUI::WidgetPtr _sender) if(mPageNumber > 0) { std::string prevSound = "book page"; - mWindowManager.getEnvironment().mSoundManager->playSound (prevSound, 1.0, 1.0); + MWBase::Environment::get().getSoundManager()->playSound (prevSound, 1.0, 1.0); mPageNumber = mPageNumber - 1; displayLeftText(leftPages[mPageNumber]); displayRightText(rightPages[mPageNumber]); diff --git a/apps/openmw/mwgui/window_manager.cpp b/apps/openmw/mwgui/window_manager.cpp index 34d62ba080..0792b0fcb7 100644 --- a/apps/openmw/mwgui/window_manager.cpp +++ b/apps/openmw/mwgui/window_manager.cpp @@ -11,6 +11,8 @@ #include "../mwmechanics/mechanicsmanager.hpp" #include "../mwinput/inputmanager.hpp" +#include "../mwbase/environment.hpp" + #include "console.hpp" #include "journalwindow.hpp" #include "charactercreation.hpp" @@ -23,10 +25,9 @@ using namespace MWGui; -WindowManager::WindowManager(MWWorld::Environment& environment, +WindowManager::WindowManager( const Compiler::Extensions& extensions, int fpsLevel, bool newGame, OEngine::Render::OgreRenderer *mOgre, const std::string logpath) : mGuiManager(NULL) - , environment(environment) , hud(NULL) , map(NULL) , menu(NULL) @@ -76,15 +77,15 @@ WindowManager::WindowManager(MWWorld::Environment& environment, menu = new MainMenu(w,h); map = new MapWindow(*this); stats = new StatsWindow(*this); - console = new Console(w,h, environment, extensions); + console = new Console(w,h, extensions); mJournal = new JournalWindow(*this); mMessageBoxManager = new MessageBoxManager(this); - dialogueWindow = new DialogueWindow(*this,environment); + dialogueWindow = new DialogueWindow(*this); // The HUD is always on hud->setVisible(true); - mCharGen = new CharacterCreation(this, &environment); + mCharGen = new CharacterCreation(this); // Setup player stats for (int i = 0; i < ESM::Attribute::Length; ++i) @@ -143,7 +144,7 @@ void WindowManager::update() if (needModeChange) { needModeChange = false; - environment.mInputManager->setGuiMode(nextMode); + MWBase::Environment::get().getInputManager()->setGuiMode(nextMode); nextMode = GM_Game; } if (showFPSLevel > 0) @@ -154,11 +155,6 @@ void WindowManager::update() } } -MWWorld::Environment& WindowManager::getEnvironment() -{ - return environment; -} - void WindowManager::setNextMode(GuiMode newMode) { nextMode = newMode; @@ -167,7 +163,7 @@ void WindowManager::setNextMode(GuiMode newMode) void WindowManager::setGuiMode(GuiMode newMode) { - environment.mInputManager->setGuiMode(newMode); + MWBase::Environment::get().getInputManager()->setGuiMode(newMode); } void WindowManager::updateVisible() @@ -388,7 +384,7 @@ int WindowManager::readPressedButton () const std::string &WindowManager::getGameSettingString(const std::string &id, const std::string &default_) { - const ESM::GameSetting *setting = environment.mWorld->getStore().gameSettings.search(id); + const ESM::GameSetting *setting = MWBase::Environment::get().getWorld()->getStore().gameSettings.search(id); if (setting && setting->type == ESM::VT_String) return setting->str; return default_; @@ -412,7 +408,7 @@ void WindowManager::onFrame (float frameDuration) const ESMS::ESMStore& WindowManager::getStore() const { - return environment.mWorld->getStore(); + return MWBase::Environment::get().getWorld()->getStore(); } void WindowManager::changeCell(MWWorld::Ptr::CellStore* cell) diff --git a/apps/openmw/mwgui/window_manager.hpp b/apps/openmw/mwgui/window_manager.hpp index 2b53560baf..6e446387e0 100644 --- a/apps/openmw/mwgui/window_manager.hpp +++ b/apps/openmw/mwgui/window_manager.hpp @@ -34,7 +34,6 @@ namespace Compiler namespace MWWorld { - class Environment; class World; } @@ -83,7 +82,7 @@ namespace MWGui typedef std::vector FactionList; typedef std::vector SkillList; - WindowManager(MWWorld::Environment& environment, const Compiler::Extensions& extensions, int fpsLevel, bool newGame, OEngine::Render::OgreRenderer *mOgre, const std::string logpath); + WindowManager(const Compiler::Extensions& extensions, int fpsLevel, bool newGame, OEngine::Render::OgreRenderer *mOgre, const std::string logpath); virtual ~WindowManager(); void setGuiMode(GuiMode newMode); @@ -95,8 +94,6 @@ namespace MWGui */ void update(); - MWWorld::Environment& getEnvironment(); - void setMode(GuiMode newMode) { if (newMode==GM_Inventory && allowed==GW_None) @@ -192,7 +189,6 @@ namespace MWGui private: OEngine::GUI::MyGUIManager *mGuiManager; - MWWorld::Environment& environment; HUD *hud; MapWindow *map; MainMenu *menu; diff --git a/apps/openmw/mwmechanics/actors.cpp b/apps/openmw/mwmechanics/actors.cpp index 7d9f748d4a..849ab8ea4c 100644 --- a/apps/openmw/mwmechanics/actors.cpp +++ b/apps/openmw/mwmechanics/actors.cpp @@ -19,10 +19,10 @@ namespace MWMechanics { if (!paused && ptr.getRefData().getHandle()!="player") MWWorld::Class::get (ptr).getInventoryStore (ptr).autoEquip ( - MWWorld::Class::get (ptr).getNpcStats (ptr), mEnvironment); + MWWorld::Class::get (ptr).getNpcStats (ptr)); } - Actors::Actors (MWWorld::Environment& environment) : mEnvironment (environment), mDuration (0) {} + Actors::Actors() : mDuration (0) {} void Actors::addActor (const MWWorld::Ptr& ptr) { diff --git a/apps/openmw/mwmechanics/actors.hpp b/apps/openmw/mwmechanics/actors.hpp index 7ff33b63bd..ae93fb52ee 100644 --- a/apps/openmw/mwmechanics/actors.hpp +++ b/apps/openmw/mwmechanics/actors.hpp @@ -12,16 +12,10 @@ namespace Ogre class Vector3; } -namespace MWWorld -{ - class Environment; -} - namespace MWMechanics { class Actors { - MWWorld::Environment& mEnvironment; std::set mActors; float mDuration; @@ -31,7 +25,7 @@ namespace MWMechanics public: - Actors (MWWorld::Environment& environment); + Actors(); void addActor (const MWWorld::Ptr& ptr); ///< Register an actor for stats management diff --git a/apps/openmw/mwmechanics/mechanicsmanager.cpp b/apps/openmw/mwmechanics/mechanicsmanager.cpp index f5711e78e6..8bc408be6f 100644 --- a/apps/openmw/mwmechanics/mechanicsmanager.cpp +++ b/apps/openmw/mwmechanics/mechanicsmanager.cpp @@ -5,8 +5,9 @@ #include "../mwgui/window_manager.hpp" +#include "../mwbase/environment.hpp" + #include "../mwworld/class.hpp" -#include "../mwworld/environment.hpp" #include "../mwworld/world.hpp" #include "../mwworld/player.hpp" @@ -14,7 +15,7 @@ namespace MWMechanics { void MechanicsManager::buildPlayer() { - MWWorld::Ptr ptr = mEnvironment.mWorld->getPlayer().getPlayer(); + MWWorld::Ptr ptr = MWBase::Environment::get().getWorld()->getPlayer().getPlayer(); MWMechanics::CreatureStats& creatureStats = MWWorld::Class::get (ptr).getCreatureStats (ptr); MWMechanics::NpcStats& npcStats = MWWorld::Class::get (ptr).getNpcStats (ptr); @@ -33,10 +34,10 @@ namespace MWMechanics if (mRaceSelected) { const ESM::Race *race = - mEnvironment.mWorld->getStore().races.find ( - mEnvironment.mWorld->getPlayer().getRace()); + MWBase::Environment::get().getWorld()->getStore().races.find ( + MWBase::Environment::get().getWorld()->getPlayer().getRace()); - bool male = mEnvironment.mWorld->getPlayer().isMale(); + bool male = MWBase::Environment::get().getWorld()->getPlayer().isMale(); for (int i=0; i<8; ++i) { @@ -76,11 +77,11 @@ namespace MWMechanics } // birthsign - if (!mEnvironment.mWorld->getPlayer().getBirthsign().empty()) + if (!MWBase::Environment::get().getWorld()->getPlayer().getBirthsign().empty()) { const ESM::BirthSign *sign = - mEnvironment.mWorld->getStore().birthSigns.find ( - mEnvironment.mWorld->getPlayer().getBirthsign()); + MWBase::Environment::get().getWorld()->getStore().birthSigns.find ( + MWBase::Environment::get().getWorld()->getPlayer().getBirthsign()); for (std::vector::const_iterator iter (sign->powers.list.begin()); iter!=sign->powers.list.end(); ++iter) @@ -92,7 +93,7 @@ namespace MWMechanics // class if (mClassSelected) { - const ESM::Class& class_ = mEnvironment.mWorld->getPlayer().getClass(); + const ESM::Class& class_ = MWBase::Environment::get().getWorld()->getPlayer().getClass(); for (int i=0; i<2; ++i) { @@ -121,7 +122,7 @@ namespace MWMechanics } typedef ESMS::IndexListT::MapType ContainerType; - const ContainerType& skills = mEnvironment.mWorld->getStore().skills.list; + const ContainerType& skills = MWBase::Environment::get().getWorld()->getStore().skills.list; for (ContainerType::const_iterator iter (skills.begin()); iter!=skills.end(); ++iter) { @@ -164,7 +165,7 @@ namespace MWMechanics MWMechanics::CreatureStats& creatureStats = MWWorld::Class::get (creature).getCreatureStats (creature); - MagicEffects now = creatureStats.mSpells.getMagicEffects (mEnvironment); + MagicEffects now = creatureStats.mSpells.getMagicEffects(); /// \todo add effects from active spells and equipment @@ -175,9 +176,9 @@ namespace MWMechanics // TODO apply diff to other stats } - MechanicsManager::MechanicsManager (MWWorld::Environment& environment) - : mEnvironment (environment), mUpdatePlayer (true), mClassSelected (false), - mRaceSelected (false), mActors (environment) + MechanicsManager::MechanicsManager() + : mUpdatePlayer (true), mClassSelected (false), + mRaceSelected (false) { buildPlayer(); } @@ -236,7 +237,7 @@ namespace MWMechanics { mWatchedCreature.mAttributes[i] = stats.mAttributes[i]; - mEnvironment.mWindowManager->setValue (attributeNames[i], stats.mAttributes[i]); + MWBase::Environment::get().getWindowManager()->setValue (attributeNames[i], stats.mAttributes[i]); } } @@ -246,7 +247,7 @@ namespace MWMechanics { mWatchedCreature.mDynamic[i] = stats.mDynamic[i]; - mEnvironment.mWindowManager->setValue (dynamicNames[i], stats.mDynamic[i]); + MWBase::Environment::get().getWindowManager()->setValue (dynamicNames[i], stats.mDynamic[i]); } } @@ -259,25 +260,25 @@ namespace MWMechanics { update = true; mWatchedNpc.mSkill[i] = npcStats.mSkill[i]; - mEnvironment.mWindowManager->setValue((ESM::Skill::SkillEnum)i, npcStats.mSkill[i]); + MWBase::Environment::get().getWindowManager()->setValue((ESM::Skill::SkillEnum)i, npcStats.mSkill[i]); } } if (update) - mEnvironment.mWindowManager->updateSkillArea(); + MWBase::Environment::get().getWindowManager()->updateSkillArea(); - mEnvironment.mWindowManager->setValue ("level", stats.mLevel); + MWBase::Environment::get().getWindowManager()->setValue ("level", stats.mLevel); } if (mUpdatePlayer) { // basic player profile; should not change anymore after the creation phase is finished. - mEnvironment.mWindowManager->setValue ("name", mEnvironment.mWorld->getPlayer().getName()); - mEnvironment.mWindowManager->setValue ("race", - mEnvironment.mWorld->getStore().races.find (mEnvironment.mWorld->getPlayer(). + MWBase::Environment::get().getWindowManager()->setValue ("name", MWBase::Environment::get().getWorld()->getPlayer().getName()); + MWBase::Environment::get().getWindowManager()->setValue ("race", + MWBase::Environment::get().getWorld()->getStore().races.find (MWBase::Environment::get().getWorld()->getPlayer(). getRace())->name); - mEnvironment.mWindowManager->setValue ("class", - mEnvironment.mWorld->getPlayer().getClass().name); + MWBase::Environment::get().getWindowManager()->setValue ("class", + MWBase::Environment::get().getWorld()->getPlayer().getClass().name); mUpdatePlayer = false; MWGui::WindowManager::SkillList majorSkills (5); @@ -285,11 +286,11 @@ namespace MWMechanics for (int i=0; i<5; ++i) { - minorSkills[i] = mEnvironment.mWorld->getPlayer().getClass().data.skills[i][0]; - majorSkills[i] = mEnvironment.mWorld->getPlayer().getClass().data.skills[i][1]; + minorSkills[i] = MWBase::Environment::get().getWorld()->getPlayer().getClass().data.skills[i][0]; + majorSkills[i] = MWBase::Environment::get().getWorld()->getPlayer().getClass().data.skills[i][1]; } - mEnvironment.mWindowManager->configureSkills (majorSkills, minorSkills); + MWBase::Environment::get().getWindowManager()->configureSkills (majorSkills, minorSkills); } mActors.update (movement, duration, paused); @@ -297,14 +298,14 @@ namespace MWMechanics void MechanicsManager::setPlayerName (const std::string& name) { - mEnvironment.mWorld->getPlayer().setName (name); + MWBase::Environment::get().getWorld()->getPlayer().setName (name); mUpdatePlayer = true; } void MechanicsManager::setPlayerRace (const std::string& race, bool male) { - mEnvironment.mWorld->getPlayer().setGender (male); - mEnvironment.mWorld->getPlayer().setRace (race); + MWBase::Environment::get().getWorld()->getPlayer().setGender (male); + MWBase::Environment::get().getWorld()->getPlayer().setRace (race); mRaceSelected = true; buildPlayer(); mUpdatePlayer = true; @@ -312,14 +313,14 @@ namespace MWMechanics void MechanicsManager::setPlayerBirthsign (const std::string& id) { - mEnvironment.mWorld->getPlayer().setBirthsign (id); + MWBase::Environment::get().getWorld()->getPlayer().setBirthsign (id); buildPlayer(); mUpdatePlayer = true; } void MechanicsManager::setPlayerClass (const std::string& id) { - mEnvironment.mWorld->getPlayer().setClass (*mEnvironment.mWorld->getStore().classes.find (id)); + MWBase::Environment::get().getWorld()->getPlayer().setClass (*MWBase::Environment::get().getWorld()->getStore().classes.find (id)); mClassSelected = true; buildPlayer(); mUpdatePlayer = true; @@ -327,7 +328,7 @@ namespace MWMechanics void MechanicsManager::setPlayerClass (const ESM::Class& class_) { - mEnvironment.mWorld->getPlayer().setClass (class_); + MWBase::Environment::get().getWorld()->getPlayer().setClass (class_); mClassSelected = true; buildPlayer(); mUpdatePlayer = true; diff --git a/apps/openmw/mwmechanics/mechanicsmanager.hpp b/apps/openmw/mwmechanics/mechanicsmanager.hpp index a121507ce1..a26fb98cd9 100644 --- a/apps/openmw/mwmechanics/mechanicsmanager.hpp +++ b/apps/openmw/mwmechanics/mechanicsmanager.hpp @@ -15,16 +15,10 @@ namespace Ogre class Vector3; } -namespace MWWorld -{ - class Environment; -} - namespace MWMechanics { class MechanicsManager { - MWWorld::Environment& mEnvironment; MWWorld::Ptr mWatched; CreatureStats mWatchedCreature; NpcStats mWatchedNpc; @@ -41,7 +35,7 @@ namespace MWMechanics public: - MechanicsManager (MWWorld::Environment& environment); + MechanicsManager (); void configureGUI(); diff --git a/apps/openmw/mwmechanics/spells.cpp b/apps/openmw/mwmechanics/spells.cpp index 916239a840..a53c75dc22 100644 --- a/apps/openmw/mwmechanics/spells.cpp +++ b/apps/openmw/mwmechanics/spells.cpp @@ -3,7 +3,8 @@ #include -#include "../mwworld/environment.hpp" +#include "../mwbase/environment.hpp" + #include "../mwworld/world.hpp" #include "magiceffects.hpp" @@ -48,13 +49,13 @@ namespace MWMechanics mSelectedSpell.clear(); } - MagicEffects Spells::getMagicEffects (const MWWorld::Environment& environment) const + MagicEffects Spells::getMagicEffects() const { MagicEffects effects; for (TIterator iter = mSpells.begin(); iter!=mSpells.end(); ++iter) { - const ESM::Spell *spell = environment.mWorld->getStore().spells.find (*iter); + const ESM::Spell *spell = MWBase::Environment::get().getWorld()->getStore().spells.find (*iter); if (spell->data.type==ESM::Spell::ST_Ability || spell->data.type==ESM::Spell::ST_Blight || spell->data.type==ESM::Spell::ST_Disease || spell->data.type==ESM::Spell::ST_Curse) diff --git a/apps/openmw/mwmechanics/spells.hpp b/apps/openmw/mwmechanics/spells.hpp index f7606c4ac2..d90f5b502d 100644 --- a/apps/openmw/mwmechanics/spells.hpp +++ b/apps/openmw/mwmechanics/spells.hpp @@ -9,11 +9,6 @@ namespace ESM struct Spell; } -namespace MWWorld -{ - struct Environment; -} - namespace MWMechanics { class MagicEffects; @@ -49,7 +44,7 @@ namespace MWMechanics ///< If the spell to be removed is the selected spell, the selected spell will be changed to /// no spell (empty string). - MagicEffects getMagicEffects (const MWWorld::Environment& environment) const; + MagicEffects getMagicEffects() const; ///< Return sum of magic effects resulting from abilities, blights, deseases and curses. void clear(); diff --git a/apps/openmw/mwrender/actors.cpp b/apps/openmw/mwrender/actors.cpp index 5034e72b32..152cf32770 100644 --- a/apps/openmw/mwrender/actors.cpp +++ b/apps/openmw/mwrender/actors.cpp @@ -22,10 +22,10 @@ void Actors::setMwRoot(Ogre::SceneNode* root){ } void Actors::insertNPC(const MWWorld::Ptr& ptr, MWWorld::InventoryStore& inv){ - insertBegin(ptr, true, true); - NpcAnimation* anim = new MWRender::NpcAnimation(ptr, mEnvironment, mRend, inv); + insertBegin(ptr, true, true); + NpcAnimation* anim = new MWRender::NpcAnimation(ptr, mRend, inv); - mAllActors[ptr] = anim; + mAllActors[ptr] = anim; } void Actors::insertBegin (const MWWorld::Ptr& ptr, bool enabled, bool static_){ Ogre::SceneNode* cellnode; @@ -68,7 +68,7 @@ void Actors::insertBegin (const MWWorld::Ptr& ptr, bool enabled, bool static_){ void Actors::insertCreature (const MWWorld::Ptr& ptr){ insertBegin(ptr, true, true); - CreatureAnimation* anim = new MWRender::CreatureAnimation(ptr, mEnvironment, mRend); + CreatureAnimation* anim = new MWRender::CreatureAnimation(ptr, mRend); //mAllActors.insert(std::pair(ptr,anim)); delete mAllActors[ptr]; mAllActors[ptr] = anim; diff --git a/apps/openmw/mwrender/actors.hpp b/apps/openmw/mwrender/actors.hpp index 66c98c541c..432bcc2972 100644 --- a/apps/openmw/mwrender/actors.hpp +++ b/apps/openmw/mwrender/actors.hpp @@ -13,7 +13,6 @@ #include "../mwworld/refdata.hpp" #include "../mwworld/ptr.hpp" #include "../mwworld/actiontalk.hpp" -#include "../mwworld/environment.hpp" #include "npcanimation.hpp" #include "creatureanimation.hpp" #include @@ -23,13 +22,12 @@ namespace MWRender{ OEngine::Render::OgreRenderer &mRend; std::map mCellSceneNodes; Ogre::SceneNode* mMwRoot; - MWWorld::Environment& mEnvironment; std::map mAllActors; public: - Actors(OEngine::Render::OgreRenderer& _rend, MWWorld::Environment& _env): mRend(_rend), mEnvironment(_env){} + Actors(OEngine::Render::OgreRenderer& _rend): mRend(_rend) {} ~Actors(); void setMwRoot(Ogre::SceneNode* root); void insertBegin (const MWWorld::Ptr& ptr, bool enabled, bool static_); diff --git a/apps/openmw/mwrender/animation.cpp b/apps/openmw/mwrender/animation.cpp index 5755418e2d..fc62582082 100644 --- a/apps/openmw/mwrender/animation.cpp +++ b/apps/openmw/mwrender/animation.cpp @@ -4,10 +4,9 @@ namespace MWRender{ std::map Animation::mUniqueIDs; - Animation::Animation(MWWorld::Environment& _env, OEngine::Render::OgreRenderer& _rend) + Animation::Animation(OEngine::Render::OgreRenderer& _rend) : insert(NULL) , mRend(_rend) - , mEnvironment(_env) , vecRotPos() , time(0.0f) , startTime(0.0f) @@ -428,7 +427,7 @@ namespace MWRender{ //base->_updateAnimation(); //base->_notifyMoved(); - + std::vector::iterator iter; diff --git a/apps/openmw/mwrender/animation.hpp b/apps/openmw/mwrender/animation.hpp index 98f0e74879..4ab60cff4b 100644 --- a/apps/openmw/mwrender/animation.hpp +++ b/apps/openmw/mwrender/animation.hpp @@ -5,7 +5,6 @@ #include "../mwworld/refdata.hpp" #include "../mwworld/ptr.hpp" #include "../mwworld/actiontalk.hpp" -#include "../mwworld/environment.hpp" #include #include #include @@ -21,16 +20,15 @@ struct PosAndRot{ }; class Animation{ - + protected: Ogre::SceneNode* insert; OEngine::Render::OgreRenderer &mRend; - MWWorld::Environment& mEnvironment; std::map vecRotPos; static std::map mUniqueIDs; - - - + + + float time; @@ -41,14 +39,14 @@ class Animation{ std::vectorrindexI; //Represents a translation index for each bone std::vectortindexI; - + //Only shapes with morphing data will use a shape number int shapeNumber; std::vector > shapeIndexI; //Ogre::SkeletonInstance* skel; std::vector* shapes; //All the NiTriShapeData for a creature - + std::vector* transformations; @@ -58,16 +56,16 @@ class Animation{ void handleAnimationTransforms(); bool timeIndex( float time, const std::vector & times, int & i, int & j, float & x ); std::string getUniqueID(std::string mesh); - + public: - Animation(MWWorld::Environment& _env, OEngine::Render::OgreRenderer& _rend); + Animation(OEngine::Render::OgreRenderer& _rend); virtual void runAnimation(float timepassed) = 0; void startScript(std::string groupname, int mode, int loops); void stopScript(); virtual ~Animation(); - + }; } #endif diff --git a/apps/openmw/mwrender/creatureanimation.cpp b/apps/openmw/mwrender/creatureanimation.cpp index e0eb5ccc20..9ca3ed7319 100644 --- a/apps/openmw/mwrender/creatureanimation.cpp +++ b/apps/openmw/mwrender/creatureanimation.cpp @@ -10,7 +10,7 @@ namespace MWRender{ CreatureAnimation::~CreatureAnimation(){ } -CreatureAnimation::CreatureAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env,OEngine::Render::OgreRenderer& _rend): Animation(_env,_rend){ +CreatureAnimation::CreatureAnimation(const MWWorld::Ptr& ptr, OEngine::Render::OgreRenderer& _rend): Animation(_rend){ insert = ptr.getRefData().getBaseNode(); ESMS::LiveCellRef *ref = ptr.get(); diff --git a/apps/openmw/mwrender/creatureanimation.hpp b/apps/openmw/mwrender/creatureanimation.hpp index 2229eeec98..f50b7904b7 100644 --- a/apps/openmw/mwrender/creatureanimation.hpp +++ b/apps/openmw/mwrender/creatureanimation.hpp @@ -7,20 +7,19 @@ #include "../mwworld/refdata.hpp" #include "../mwworld/ptr.hpp" -#include "../mwworld/environment.hpp" #include "components/nifogre/ogre_nif_loader.hpp" namespace MWRender{ class CreatureAnimation: public Animation{ - + public: virtual ~CreatureAnimation(); - CreatureAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env, OEngine::Render::OgreRenderer& _rend); + CreatureAnimation(const MWWorld::Ptr& ptr, OEngine::Render::OgreRenderer& _rend); virtual void runAnimation(float timepassed); - + }; } -#endif \ No newline at end of file +#endif diff --git a/apps/openmw/mwrender/debugging.cpp b/apps/openmw/mwrender/debugging.cpp index d426721795..be8afbae65 100644 --- a/apps/openmw/mwrender/debugging.cpp +++ b/apps/openmw/mwrender/debugging.cpp @@ -8,7 +8,7 @@ #include #include "../mwworld/world.hpp" // these includes can be removed once the static-hack is gone -#include "../mwworld/environment.hpp" +#include "../mwbase/environment.hpp" #include "../mwworld/ptr.hpp" #include #include @@ -138,8 +138,8 @@ ManualObject *Debugging::createPathgridPoints(const ESM::Pathgrid *pathgrid) return result; } -Debugging::Debugging(SceneNode *mwRoot, MWWorld::Environment &env, OEngine::Physic::PhysicEngine *engine) : - mMwRoot(mwRoot), mEnvironment(env), mEngine(engine), +Debugging::Debugging(SceneNode *mwRoot, OEngine::Physic::PhysicEngine *engine) : + mMwRoot(mwRoot), mEngine(engine), mSceneMgr(mwRoot->getCreator()), mPathgridEnabled(false), mInteriorPathgridNode(NULL), mPathGridRoot(NULL), @@ -218,7 +218,7 @@ void Debugging::togglePathgrid() void Debugging::enableCellPathgrid(MWWorld::Ptr::CellStore *store) { - ESM::Pathgrid *pathgrid = mEnvironment.mWorld->getStore().pathgrids.search(*store->cell); + ESM::Pathgrid *pathgrid = MWBase::Environment::get().getWorld()->getStore().pathgrids.search(*store->cell); if (!pathgrid) return; Vector3 cellPathGridPos(0, 0, 0); diff --git a/apps/openmw/mwrender/debugging.hpp b/apps/openmw/mwrender/debugging.hpp index ebf3884dcc..e12c0647c6 100644 --- a/apps/openmw/mwrender/debugging.hpp +++ b/apps/openmw/mwrender/debugging.hpp @@ -23,7 +23,6 @@ namespace Ogre namespace MWWorld { class World; - class Environment; } namespace MWRender @@ -34,7 +33,6 @@ namespace MWRender { OEngine::Physic::PhysicEngine* mEngine; Ogre::SceneManager *mSceneMgr; - MWWorld::Environment& mEnvironment; // Path grid stuff bool mPathgridEnabled; @@ -68,7 +66,7 @@ namespace MWRender Ogre::ManualObject *createPathgridLines(const ESM::Pathgrid *pathgrid); Ogre::ManualObject *createPathgridPoints(const ESM::Pathgrid *pathgrid); public: - Debugging(Ogre::SceneNode* mwRoot, MWWorld::Environment &env, OEngine::Physic::PhysicEngine *engine); + Debugging(Ogre::SceneNode* mwRoot, OEngine::Physic::PhysicEngine *engine); ~Debugging(); bool toggleRenderMode (int mode); diff --git a/apps/openmw/mwrender/localmap.cpp b/apps/openmw/mwrender/localmap.cpp index 2cc233a011..ea89024433 100644 --- a/apps/openmw/mwrender/localmap.cpp +++ b/apps/openmw/mwrender/localmap.cpp @@ -1,7 +1,7 @@ #include "localmap.hpp" #include "renderingmanager.hpp" -#include "../mwworld/environment.hpp" +#include "../mwbase/environment.hpp" #include "../mwworld/world.hpp" #include "../mwgui/window_manager.hpp" #include "renderconst.hpp" @@ -12,12 +12,11 @@ using namespace MWRender; using namespace Ogre; -LocalMap::LocalMap(OEngine::Render::OgreRenderer* rend, MWRender::RenderingManager* rendering, MWWorld::Environment* env) : +LocalMap::LocalMap(OEngine::Render::OgreRenderer* rend, MWRender::RenderingManager* rendering) : mInterior(false), mCellX(0), mCellY(0) { mRendering = rend; mRenderingManager = rendering; - mEnvironment = env; mCameraPosNode = mRendering->getScene()->getRootSceneNode()->createChildSceneNode(); mCameraRotNode = mCameraPosNode->createChildSceneNode(); @@ -54,12 +53,12 @@ void LocalMap::saveTexture(const std::string& texname, const std::string& filena if (tex.isNull()) return; HardwarePixelBufferSharedPtr readbuffer = tex->getBuffer(); readbuffer->lock(HardwareBuffer::HBL_NORMAL ); - const PixelBox &readrefpb = readbuffer->getCurrentLock(); - uchar *readrefdata = static_cast(readrefpb.data); + const PixelBox &readrefpb = readbuffer->getCurrentLock(); + uchar *readrefdata = static_cast(readrefpb.data); Image img; img = img.loadDynamicImage (readrefdata, tex->getWidth(), - tex->getHeight(), tex->getFormat()); + tex->getHeight(), tex->getFormat()); img.save("./" + filename); readbuffer->unlock(); @@ -82,7 +81,7 @@ void LocalMap::saveFogOfWar(MWWorld::Ptr::CellStore* cell) Vector2 min(mBounds.getMinimum().x, mBounds.getMinimum().z); Vector2 max(mBounds.getMaximum().x, mBounds.getMaximum().z); Vector2 length = max-min; - + // divide into segments const int segsX = std::ceil( length.x / sSize ); const int segsY = std::ceil( length.y / sSize ); @@ -123,7 +122,7 @@ void LocalMap::requestMap(MWWorld::Ptr::CellStore* cell, Vector2 z(mBounds.getMaximum().y, mBounds.getMinimum().y); - const Vector2& north = mEnvironment->mWorld->getNorthVector(cell); + const Vector2& north = MWBase::Environment::get().getWorld()->getNorthVector(cell); Radian angle(std::atan2(-north.x, -north.y)); mAngle = angle.valueRadians(); mCameraRotNode->setOrientation(Quaternion(Math::Cos(angle/2.f), 0, Math::Sin(angle/2.f), 0)); @@ -213,7 +212,7 @@ void LocalMap::render(const float x, const float y, texture, ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, TEX_TYPE_2D, - xw*sMapResolution/sSize, yw*sMapResolution/sSize, + xw*sMapResolution/sSize, yw*sMapResolution/sSize, 0, PF_R8G8B8, TU_RENDERTARGET); @@ -236,7 +235,7 @@ void LocalMap::render(const float x, const float y, texture + "_fog", ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, TEX_TYPE_2D, - xw*sFogOfWarResolution/sSize, yw*sFogOfWarResolution/sSize, + xw*sFogOfWarResolution/sSize, yw*sFogOfWarResolution/sSize, 0, PF_A8R8G8B8, TU_DYNAMIC_WRITE_ONLY_DISCARDABLE); @@ -276,7 +275,7 @@ void LocalMap::updatePlayer (const Ogre::Vector3& position, const Ogre::Quaterni return; } - // retrieve the x,y grid coordinates the player is in + // retrieve the x,y grid coordinates the player is in int x,y; Vector3 _pos(position.x, 0, position.z); Vector2 pos(_pos.x, _pos.z); @@ -303,7 +302,7 @@ void LocalMap::updatePlayer (const Ogre::Vector3& position, const Ogre::Quaterni x = std::ceil((pos.x - min.x)/sSize)-1; y = std::ceil((pos.y - min.y)/sSize)-1; - mEnvironment->mWindowManager->setInteriorMapTexture(x,y); + MWBase::Environment::get().getWindowManager()->setInteriorMapTexture(x,y); } // convert from world coordinates to texture UV coordinates @@ -323,8 +322,8 @@ void LocalMap::updatePlayer (const Ogre::Vector3& position, const Ogre::Quaterni texName = mInteriorName + "_" + coordStr(x,y); } - mEnvironment->mWindowManager->setPlayerPos(u, v); - mEnvironment->mWindowManager->setPlayerDir(playerdirection.x, -playerdirection.z); + MWBase::Environment::get().getWindowManager()->setPlayerPos(u, v); + MWBase::Environment::get().getWindowManager()->setPlayerDir(playerdirection.x, -playerdirection.z); // explore radius (squared) const float sqrExploreRadius = 0.01 * sFogOfWarResolution*sFogOfWarResolution; diff --git a/apps/openmw/mwrender/localmap.hpp b/apps/openmw/mwrender/localmap.hpp index 95685167c3..9e03988f38 100644 --- a/apps/openmw/mwrender/localmap.hpp +++ b/apps/openmw/mwrender/localmap.hpp @@ -5,11 +5,6 @@ #include -namespace MWWorld -{ - class Environment; -} - namespace MWRender { class RenderingManager; @@ -20,7 +15,7 @@ namespace MWRender class LocalMap { public: - LocalMap(OEngine::Render::OgreRenderer*, MWRender::RenderingManager* rendering, MWWorld::Environment* env); + LocalMap(OEngine::Render::OgreRenderer*, MWRender::RenderingManager* rendering); ~LocalMap(); /** @@ -61,7 +56,6 @@ namespace MWRender private: OEngine::Render::OgreRenderer* mRendering; MWRender::RenderingManager* mRenderingManager; - MWWorld::Environment* mEnvironment; // 1024*1024 pixels for a cell static const int sMapResolution = 1024; diff --git a/apps/openmw/mwrender/npcanimation.cpp b/apps/openmw/mwrender/npcanimation.cpp index 751a075481..94a7469891 100644 --- a/apps/openmw/mwrender/npcanimation.cpp +++ b/apps/openmw/mwrender/npcanimation.cpp @@ -2,7 +2,7 @@ #include "../mwworld/world.hpp" #include "renderconst.hpp" - +#include "../mwbase/environment.hpp" using namespace Ogre; using namespace NifOgre; @@ -12,7 +12,7 @@ NpcAnimation::~NpcAnimation(){ } -NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env,OEngine::Render::OgreRenderer& _rend, MWWorld::InventoryStore& _inv): Animation(_env,_rend), mStateID(-1), inv(_inv), timeToChange(0), +NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, OEngine::Render::OgreRenderer& _rend, MWWorld::InventoryStore& _inv): Animation(_rend), mStateID(-1), inv(_inv), timeToChange(0), robe(inv.end()), helmet(inv.end()), shirt(inv.end()), cuirass(inv.end()), greaves(inv.end()), leftpauldron(inv.end()), rightpauldron(inv.end()), @@ -77,14 +77,14 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env,O std::string hairID = ref->base->hair; std::string headID = ref->base->head; headModel = "meshes\\" + - mEnvironment.mWorld->getStore().bodyParts.find(headID)->model; + MWBase::Environment::get().getWorld()->getStore().bodyParts.find(headID)->model; hairModel = "meshes\\" + - mEnvironment.mWorld->getStore().bodyParts.find(hairID)->model; + MWBase::Environment::get().getWorld()->getStore().bodyParts.find(hairID)->model; npcName = ref->base->name; //ESMStore::Races r = - const ESM::Race* race = mEnvironment.mWorld->getStore().races.find(ref->base->race); + const ESM::Race* race = MWBase::Environment::get().getWorld()->getStore().races.find(ref->base->race); bodyRaceID = headID.substr(0, headID.find_last_of("head_") - 4); @@ -370,116 +370,116 @@ void NpcAnimation::updateParts(){ addOrReplaceIndividualPart(ESM::PRT_Hair, -1,1,hairModel); } if(partpriorities[ESM::PRT_Neck] < 1){ - const ESM::BodyPart *neckPart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "neck"); + const ESM::BodyPart *neckPart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "neck"); if(neckPart) addOrReplaceIndividualPart(ESM::PRT_Neck, -1,1,"meshes\\" + neckPart->model); } if(partpriorities[ESM::PRT_Cuirass] < 1){ - const ESM::BodyPart *chestPart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "chest"); + const ESM::BodyPart *chestPart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "chest"); if(chestPart) addOrReplaceIndividualPart(ESM::PRT_Cuirass, -1,1,"meshes\\" + chestPart->model); } if(partpriorities[ESM::PRT_Groin] < 1){ - const ESM::BodyPart *groinPart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "groin"); + const ESM::BodyPart *groinPart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "groin"); if(groinPart) addOrReplaceIndividualPart(ESM::PRT_Groin, -1,1,"meshes\\" + groinPart->model); } if(partpriorities[ESM::PRT_RHand] < 1){ - const ESM::BodyPart *handPart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "hand"); + const ESM::BodyPart *handPart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "hand"); if(!handPart) - handPart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "hands"); + handPart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "hands"); if(handPart) addOrReplaceIndividualPart(ESM::PRT_RHand, -1,1,"meshes\\" + handPart->model); } if(partpriorities[ESM::PRT_LHand] < 1){ - const ESM::BodyPart *handPart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "hand"); + const ESM::BodyPart *handPart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "hand"); if(!handPart) - handPart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "hands"); + handPart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "hands"); if(handPart) addOrReplaceIndividualPart(ESM::PRT_LHand, -1,1,"meshes\\" + handPart->model); } if(partpriorities[ESM::PRT_RWrist] < 1){ - const ESM::BodyPart *wristPart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "wrist"); + const ESM::BodyPart *wristPart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "wrist"); if(wristPart) addOrReplaceIndividualPart(ESM::PRT_RWrist, -1,1,"meshes\\" + wristPart->model); } if(partpriorities[ESM::PRT_LWrist] < 1){ - const ESM::BodyPart *wristPart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "wrist"); + const ESM::BodyPart *wristPart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "wrist"); if(wristPart) addOrReplaceIndividualPart(ESM::PRT_LWrist, -1,1,"meshes\\" + wristPart->model); } if(partpriorities[ESM::PRT_RForearm] < 1){ - const ESM::BodyPart *forearmPart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "forearm"); + const ESM::BodyPart *forearmPart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "forearm"); if(bodyRaceID == "b_n_argonian_f_") - forearmPart = mEnvironment.mWorld->getStore().bodyParts.search ("b_n_argonian_m_forearm"); + forearmPart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search ("b_n_argonian_m_forearm"); if(forearmPart) addOrReplaceIndividualPart(ESM::PRT_RForearm, -1,1,"meshes\\" + forearmPart->model); } if(partpriorities[ESM::PRT_LForearm] < 1){ - const ESM::BodyPart *forearmPart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "forearm"); + const ESM::BodyPart *forearmPart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "forearm"); if(bodyRaceID == "b_n_argonian_f_") - forearmPart = mEnvironment.mWorld->getStore().bodyParts.search ("b_n_argonian_m_forearm"); + forearmPart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search ("b_n_argonian_m_forearm"); if(forearmPart) addOrReplaceIndividualPart(ESM::PRT_LForearm, -1,1,"meshes\\" + forearmPart->model); } if(partpriorities[ESM::PRT_RUpperarm] < 1){ - const ESM::BodyPart *armPart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "upper arm"); + const ESM::BodyPart *armPart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "upper arm"); if(armPart) addOrReplaceIndividualPart(ESM::PRT_RUpperarm, -1,1,"meshes\\" + armPart->model); } if(partpriorities[ESM::PRT_LUpperarm] < 1){ - const ESM::BodyPart *armPart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "upper arm"); + const ESM::BodyPart *armPart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "upper arm"); if(armPart) addOrReplaceIndividualPart(ESM::PRT_LUpperarm, -1,1,"meshes\\" + armPart->model); } if(partpriorities[ESM::PRT_RFoot] < 1){ - const ESM::BodyPart *footPart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "foot"); + const ESM::BodyPart *footPart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "foot"); if(isBeast && !footPart) - footPart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "feet"); + footPart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "feet"); if(footPart) addOrReplaceIndividualPart(ESM::PRT_RFoot, -1,1,"meshes\\" + footPart->model); } if(partpriorities[ESM::PRT_LFoot] < 1){ - const ESM::BodyPart *footPart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "foot"); + const ESM::BodyPart *footPart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "foot"); if(isBeast && !footPart) - footPart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "feet"); + footPart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "feet"); if(footPart) addOrReplaceIndividualPart(ESM::PRT_LFoot, -1,1,"meshes\\" + footPart->model); } if(partpriorities[ESM::PRT_RAnkle] < 1){ - const ESM::BodyPart *anklePart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "ankle"); + const ESM::BodyPart *anklePart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "ankle"); if(anklePart) addOrReplaceIndividualPart(ESM::PRT_RAnkle, -1,1,"meshes\\" + anklePart->model); } if(partpriorities[ESM::PRT_LAnkle] < 1){ - const ESM::BodyPart *anklePart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "ankle"); + const ESM::BodyPart *anklePart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "ankle"); if(anklePart) addOrReplaceIndividualPart(ESM::PRT_LAnkle, -1,1,"meshes\\" + anklePart->model); } if(partpriorities[ESM::PRT_RKnee] < 1){ - const ESM::BodyPart *kneePart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "knee"); + const ESM::BodyPart *kneePart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "knee"); if(kneePart) addOrReplaceIndividualPart(ESM::PRT_RKnee, -1,1,"meshes\\" + kneePart->model); } if(partpriorities[ESM::PRT_LKnee] < 1){ - const ESM::BodyPart *kneePart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "knee"); + const ESM::BodyPart *kneePart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "knee"); if(kneePart) addOrReplaceIndividualPart(ESM::PRT_LKnee, -1,1,"meshes\\" + kneePart->model); } if(partpriorities[ESM::PRT_RLeg] < 1){ - const ESM::BodyPart *legPart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "upper leg"); + const ESM::BodyPart *legPart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "upper leg"); if(legPart) addOrReplaceIndividualPart(ESM::PRT_RLeg, -1,1,"meshes\\" + legPart->model); } if(partpriorities[ESM::PRT_LLeg] < 1){ - const ESM::BodyPart *legPart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "upper leg"); + const ESM::BodyPart *legPart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "upper leg"); if(legPart) addOrReplaceIndividualPart(ESM::PRT_LLeg, -1,1,"meshes\\" + legPart->model); } if(partpriorities[ESM::PRT_Tail] < 1){ - const ESM::BodyPart *tailPart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "tail"); + const ESM::BodyPart *tailPart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "tail"); if(tailPart) addOrReplaceIndividualPart(ESM::PRT_Tail, -1,1,"meshes\\" + tailPart->model); } @@ -848,9 +848,9 @@ void NpcAnimation::removeIndividualPart(int type){ const ESM::BodyPart *bodypart = 0; if(isFemale) - bodypart = mEnvironment.mWorld->getStore().bodyParts.search (part.female); + bodypart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (part.female); if(!bodypart) - bodypart = mEnvironment.mWorld->getStore().bodyParts.search (part.male); + bodypart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (part.male); if(bodypart){ addOrReplaceIndividualPart(part.part, group,priority,"meshes\\" + bodypart->model); } diff --git a/apps/openmw/mwrender/npcanimation.hpp b/apps/openmw/mwrender/npcanimation.hpp index 352b54beca..a37becc26d 100644 --- a/apps/openmw/mwrender/npcanimation.hpp +++ b/apps/openmw/mwrender/npcanimation.hpp @@ -10,7 +10,6 @@ #include "../mwworld/refdata.hpp" #include "../mwworld/ptr.hpp" -#include "../mwworld/environment.hpp" #include "components/nifogre/ogre_nif_loader.hpp" #include "../mwworld/inventorystore.hpp" #include "../mwclass/npc.hpp" @@ -36,8 +35,8 @@ private: int partpriorities[27]; std::pair*> zero; - - + + //Bounded Parts Ogre::Entity* lclavicle; Ogre::Entity* rclavicle; @@ -59,7 +58,7 @@ private: Ogre::Entity* rfoot; Ogre::Entity* hair; Ogre::Entity* head; - + Ogre::SceneNode* insert; bool isBeast; bool isFemale; @@ -80,9 +79,9 @@ private: MWWorld::ContainerStoreIterator leftglove; MWWorld::ContainerStoreIterator rightglove; MWWorld::ContainerStoreIterator skirtiter; - + public: - NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env, OEngine::Render::OgreRenderer& _rend, MWWorld::InventoryStore& _inv); + NpcAnimation(const MWWorld::Ptr& ptr, OEngine::Render::OgreRenderer& _rend, MWWorld::InventoryStore& _inv); virtual ~NpcAnimation(); Ogre::Entity* insertBoundedPart(const std::string &mesh, std::string bonename); std::pair*> insertFreePart(const std::string &mesh, const std::string suffix); @@ -91,12 +90,12 @@ private: void updateParts(); void removeIndividualPart(int type); void reserveIndividualPart(int type, int group, int priority); - + bool addOrReplaceIndividualPart(int type, int group, int priority, const std::string &mesh); void removePartGroup(int group); void addPartGroup(int group, int priority, std::vector& parts); - + }; } -#endif \ No newline at end of file +#endif diff --git a/apps/openmw/mwrender/renderingmanager.cpp b/apps/openmw/mwrender/renderingmanager.cpp index c1462807fc..266fbfb62a 100644 --- a/apps/openmw/mwrender/renderingmanager.cpp +++ b/apps/openmw/mwrender/renderingmanager.cpp @@ -24,8 +24,8 @@ using namespace Ogre; namespace MWRender { -RenderingManager::RenderingManager (OEngine::Render::OgreRenderer& _rend, const boost::filesystem::path& resDir, OEngine::Physic::PhysicEngine* engine, MWWorld::Environment& environment) - :mRendering(_rend), mObjects(mRendering), mActors(mRendering, environment), mAmbientMode(0), mSunEnabled(0) +RenderingManager::RenderingManager (OEngine::Render::OgreRenderer& _rend, const boost::filesystem::path& resDir, OEngine::Physic::PhysicEngine* engine) + :mRendering(_rend), mObjects(mRendering), mActors(mRendering), mAmbientMode(0), mSunEnabled(0) { mRendering.createScene("PlayerCam", Settings::Manager::getFloat("field of view", "General"), 5); @@ -93,19 +93,18 @@ RenderingManager::RenderingManager (OEngine::Render::OgreRenderer& _rend, const mShadows = new Shadows(&mRendering); mShaderHelper = new ShaderHelper(this); - mTerrainManager = new TerrainManager(mRendering.getScene(), this, - environment); + mTerrainManager = new TerrainManager(mRendering.getScene(), this); //mSkyManager = 0; - mSkyManager = new SkyManager(mMwRoot, mRendering.getCamera(), &environment); + mSkyManager = new SkyManager(mMwRoot, mRendering.getCamera()); mOcclusionQuery = new OcclusionQuery(&mRendering, mSkyManager->getSunNode()); mPlayer = new MWRender::Player (mRendering.getCamera(), playerNode); mSun = 0; - mDebugging = new Debugging(mMwRoot, environment, engine); - mLocalMap = new MWRender::LocalMap(&mRendering, this, &environment); + mDebugging = new Debugging(mMwRoot, engine); + mLocalMap = new MWRender::LocalMap(&mRendering, this); } RenderingManager::~RenderingManager () diff --git a/apps/openmw/mwrender/renderingmanager.hpp b/apps/openmw/mwrender/renderingmanager.hpp index a563d78c6a..c4134eeded 100644 --- a/apps/openmw/mwrender/renderingmanager.hpp +++ b/apps/openmw/mwrender/renderingmanager.hpp @@ -57,7 +57,7 @@ class RenderingManager: private RenderingInterface { virtual MWRender::Actors& getActors(); public: - RenderingManager(OEngine::Render::OgreRenderer& _rend, const boost::filesystem::path& resDir, OEngine::Physic::PhysicEngine* engine, MWWorld::Environment& environment); + RenderingManager(OEngine::Render::OgreRenderer& _rend, const boost::filesystem::path& resDir, OEngine::Physic::PhysicEngine* engine); virtual ~RenderingManager(); diff --git a/apps/openmw/mwrender/sky.cpp b/apps/openmw/mwrender/sky.cpp index 859da2dc11..da2e7446ab 100644 --- a/apps/openmw/mwrender/sky.cpp +++ b/apps/openmw/mwrender/sky.cpp @@ -10,7 +10,7 @@ #include -#include "../mwworld/environment.hpp" +#include "../mwbase/environment.hpp" #include "../mwworld/world.hpp" #include "renderconst.hpp" #include "renderingmanager.hpp" @@ -271,10 +271,10 @@ void Moon::setPhase(const Moon::Phase& phase) { // Colour texture Ogre::String textureName = "textures\\tx_"; - + if (mType == Moon::Type_Secunda) textureName += "secunda_"; else textureName += "masser_"; - + if (phase == Moon::Phase_New) textureName += "new"; else if (phase == Moon::Phase_WaxingCrescent) textureName += "one_wax"; else if (phase == Moon::Phase_WaxingHalf) textureName += "half_wax"; @@ -283,9 +283,9 @@ void Moon::setPhase(const Moon::Phase& phase) else if (phase == Moon::Phase_WaningHalf) textureName += "half_wan"; else if (phase == Moon::Phase_WaningGibbous) textureName += "three_wan"; else if (phase == Moon::Phase_Full) textureName += "full"; - + textureName += ".dds"; - + mMaterial->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setTextureName(textureName); mPhase = phase; @@ -365,9 +365,8 @@ void SkyManager::ModVertexAlpha(Entity* ent, unsigned int meshType) ent->getMesh()->getSubMesh(0)->vertexData->vertexBufferBinding->getBuffer(ves_diffuse->getSource())->unlock(); } -SkyManager::SkyManager (SceneNode* pMwRoot, Camera* pCamera, MWWorld::Environment* env) - : mEnvironment(env) - , mHour(0.0f) +SkyManager::SkyManager (SceneNode* pMwRoot, Camera* pCamera) + : mHour(0.0f) , mDay(0) , mMonth(0) , mSun(NULL) @@ -713,7 +712,7 @@ void SkyManager::update(float duration) if (!mEnabled) return; // UV Scroll the clouds - mCloudMaterial->getTechnique(0)->getPass(0)->getFragmentProgramParameters()->setNamedConstantFromTime("time", mEnvironment->mWorld->getTimeScaleFactor()/30.f); + mCloudMaterial->getTechnique(0)->getPass(0)->getFragmentProgramParameters()->setNamedConstantFromTime("time", MWBase::Environment::get().getWorld()->getTimeScaleFactor()/30.f); /// \todo improve this mMasser->setPhase( static_cast( (int) ((mDay % 32)/4.f)) ); @@ -752,7 +751,7 @@ void SkyManager::update(float duration) mSecunda->setVisible(mSecundaEnabled); // rotate the stars by 360 degrees every 4 days - mAtmosphereNight->roll(Degree(mEnvironment->mWorld->getTimeScaleFactor()*duration*360 / (3600*96.f))); + mAtmosphereNight->roll(Degree(MWBase::Environment::get().getWorld()->getTimeScaleFactor()*duration*360 / (3600*96.f))); } void SkyManager::enable() diff --git a/apps/openmw/mwrender/sky.hpp b/apps/openmw/mwrender/sky.hpp index 64d5c16a03..da89d0eb04 100644 --- a/apps/openmw/mwrender/sky.hpp +++ b/apps/openmw/mwrender/sky.hpp @@ -59,8 +59,8 @@ namespace MWRender Ogre::MaterialPtr mMaterial; Ogre::BillboardSet* mBBSet; }; - - + + /* * The moons need a seperate class because of their shader (which allows them to be partially transparent) */ @@ -104,11 +104,11 @@ namespace MWRender Type mType; Phase mPhase; }; - + class SkyManager { public: - SkyManager(Ogre::SceneNode* pMwRoot, Ogre::Camera* pCamera, MWWorld::Environment* env); + SkyManager(Ogre::SceneNode* pMwRoot, Ogre::Camera* pCamera); ~SkyManager(); void update(float duration); @@ -176,7 +176,6 @@ namespace MWRender private: bool mCreated; - MWWorld::Environment* mEnvironment; float mHour; int mDay; int mMonth; diff --git a/apps/openmw/mwrender/terrain.cpp b/apps/openmw/mwrender/terrain.cpp index f9b43655b7..90d853f752 100644 --- a/apps/openmw/mwrender/terrain.cpp +++ b/apps/openmw/mwrender/terrain.cpp @@ -4,6 +4,8 @@ #include "../mwworld/world.hpp" +#include "../mwbase/environment.hpp" + #include "terrainmaterial.hpp" #include "terrain.hpp" #include "renderconst.hpp" @@ -17,8 +19,8 @@ namespace MWRender //---------------------------------------------------------------------------------------------- - TerrainManager::TerrainManager(Ogre::SceneManager* mgr, RenderingManager* rend, const MWWorld::Environment& evn) : - mEnvironment(evn), mTerrainGroup(TerrainGroup(mgr, Terrain::ALIGN_X_Z, mLandSize, mWorldSize)), mRendering(rend) + TerrainManager::TerrainManager(Ogre::SceneManager* mgr, RenderingManager* rend) : + mTerrainGroup(TerrainGroup(mgr, Terrain::ALIGN_X_Z, mLandSize, mWorldSize)), mRendering(rend) { TerrainMaterialGeneratorPtr matGen; @@ -107,7 +109,7 @@ namespace MWRender const int cellX = store->cell->getGridX(); const int cellY = store->cell->getGridY(); - ESM::Land* land = mEnvironment.mWorld->getStore().lands.search(cellX, cellY); + ESM::Land* land = MWBase::Environment::get().getWorld()->getStore().lands.search(cellX, cellY); if ( land != NULL ) { if (!land->dataLoaded) @@ -268,7 +270,7 @@ namespace MWRender { //NB: All vtex ids are +1 compared to the ltex ids - assert( (int)mEnvironment.mWorld->getStore().landTexts.getSize() >= (int)ltexIndex - 1 && + assert( (int)MWBase::Environment::get().getWorld()->getStore().landTexts.getSize() >= (int)ltexIndex - 1 && "LAND.VTEX must be within the bounds of the LTEX array"); std::string texture; @@ -278,7 +280,7 @@ namespace MWRender } else { - texture = mEnvironment.mWorld->getStore().landTexts.search(ltexIndex-1)->texture; + texture = MWBase::Environment::get().getWorld()->getStore().landTexts.search(ltexIndex-1)->texture; //TODO this is needed due to MWs messed up texture handling texture = texture.substr(0, texture.rfind(".")) + ".dds"; } @@ -434,7 +436,7 @@ namespace MWRender } - ESM::Land* land = mEnvironment.mWorld->getStore().lands.search(cellX, cellY); + ESM::Land* land = MWBase::Environment::get().getWorld()->getStore().lands.search(cellX, cellY); if ( land != NULL ) { if (!land->dataLoaded) diff --git a/apps/openmw/mwrender/terrain.hpp b/apps/openmw/mwrender/terrain.hpp index dc4a2388ce..c4ff053a6f 100644 --- a/apps/openmw/mwrender/terrain.hpp +++ b/apps/openmw/mwrender/terrain.hpp @@ -24,7 +24,7 @@ namespace MWRender{ */ class TerrainManager{ public: - TerrainManager(Ogre::SceneManager* mgr, RenderingManager* rend, const MWWorld::Environment& env); + TerrainManager(Ogre::SceneManager* mgr, RenderingManager* rend); virtual ~TerrainManager(); void setDiffuse(const Ogre::ColourValue& diffuse); @@ -36,7 +36,6 @@ namespace MWRender{ Ogre::TerrainGlobalOptions mTerrainGlobals; Ogre::TerrainGroup mTerrainGroup; - const MWWorld::Environment& mEnvironment; RenderingManager* mRendering; Ogre::TerrainMaterialGeneratorB::SM2Profile* mActiveProfile; diff --git a/apps/openmw/mwscript/animationextensions.cpp b/apps/openmw/mwscript/animationextensions.cpp index 184be83db4..864a2bf1d1 100644 --- a/apps/openmw/mwscript/animationextensions.cpp +++ b/apps/openmw/mwscript/animationextensions.cpp @@ -27,10 +27,7 @@ namespace MWScript { MWWorld::Ptr ptr = R()(runtime); - InterpreterContext& context = - static_cast (runtime.getContext()); - - context.getWorld().skipAnimation (ptr); + MWBase::Environment::get().getWorld()->skipAnimation (ptr); } }; @@ -43,9 +40,6 @@ namespace MWScript { MWWorld::Ptr ptr = R()(runtime); - InterpreterContext& context = - static_cast (runtime.getContext()); - std::string group = runtime.getStringLiteral (runtime[0].mInteger); runtime.pop(); @@ -60,7 +54,7 @@ namespace MWScript throw std::runtime_error ("animation mode out of range"); } - context.getWorld().playAnimationGroup (ptr, group, mode, 1); + MWBase::Environment::get().getWorld()->playAnimationGroup (ptr, group, mode, 1); } }; @@ -73,9 +67,6 @@ namespace MWScript { MWWorld::Ptr ptr = R()(runtime); - InterpreterContext& context = - static_cast (runtime.getContext()); - std::string group = runtime.getStringLiteral (runtime[0].mInteger); runtime.pop(); @@ -96,7 +87,7 @@ namespace MWScript throw std::runtime_error ("animation mode out of range"); } - context.getWorld().playAnimationGroup (ptr, group, mode, loops); + MWBase::Environment::get().getWorld()->playAnimationGroup (ptr, group, mode, loops); } }; diff --git a/apps/openmw/mwscript/cellextensions.cpp b/apps/openmw/mwscript/cellextensions.cpp index d69c42ab34..a5db5fd5f9 100644 --- a/apps/openmw/mwscript/cellextensions.cpp +++ b/apps/openmw/mwscript/cellextensions.cpp @@ -7,6 +7,8 @@ #include #include +#include "../mwbase/environment.hpp" + #include "../mwworld/world.hpp" #include "../mwworld/player.hpp" @@ -22,10 +24,7 @@ namespace MWScript virtual void execute (Interpreter::Runtime& runtime) { - InterpreterContext& context - = static_cast (runtime.getContext()); - - runtime.push (context.getWorld().hasCellChanged() ? 1 : 0); + runtime.push (MWBase::Environment::get().getWorld()->hasCellChanged() ? 1 : 0); } }; @@ -35,9 +34,6 @@ namespace MWScript virtual void execute (Interpreter::Runtime& runtime) { - InterpreterContext& context - = static_cast (runtime.getContext()); - std::string cell = runtime.getStringLiteral (runtime[0].mInteger); runtime.pop(); @@ -45,16 +41,16 @@ namespace MWScript pos.rot[0] = pos.rot[1] = pos.rot[2] = 0; pos.pos[2] = 0; - if (const ESM::Cell *exterior = context.getWorld().getExterior (cell)) + if (const ESM::Cell *exterior = MWBase::Environment::get().getWorld()->getExterior (cell)) { - context.getWorld().indexToPosition (exterior->data.gridX, exterior->data.gridY, + MWBase::Environment::get().getWorld()->indexToPosition (exterior->data.gridX, exterior->data.gridY, pos.pos[0], pos.pos[1], true); - context.getWorld().changeToExteriorCell (pos); + MWBase::Environment::get().getWorld()->changeToExteriorCell (pos); } else { pos.pos[0] = pos.pos[1] = 0; - context.getWorld().changeToInteriorCell (cell, pos); + MWBase::Environment::get().getWorld()->changeToInteriorCell (cell, pos); } } }; @@ -65,9 +61,6 @@ namespace MWScript virtual void execute (Interpreter::Runtime& runtime) { - InterpreterContext& context - = static_cast (runtime.getContext()); - Interpreter::Type_Integer x = runtime[0].mInteger; runtime.pop(); @@ -76,12 +69,12 @@ namespace MWScript ESM::Position pos; - context.getWorld().indexToPosition (x, y, pos.pos[0], pos.pos[1], true); + MWBase::Environment::get().getWorld()->indexToPosition (x, y, pos.pos[0], pos.pos[1], true); pos.pos[2] = 0; pos.rot[0] = pos.rot[1] = pos.rot[2] = 0; - context.getWorld().changeToExteriorCell (pos); + MWBase::Environment::get().getWorld()->changeToExteriorCell (pos); } }; @@ -91,11 +84,8 @@ namespace MWScript virtual void execute (Interpreter::Runtime& runtime) { - InterpreterContext& context - = static_cast (runtime.getContext()); - bool interior = - context.getWorld().getPlayer().getPlayer().getCell()->cell->data.flags & + MWBase::Environment::get().getWorld()->getPlayer().getPlayer().getCell()->cell->data.flags & ESM::Cell::Interior; runtime.push (interior ? 1 : 0); @@ -108,20 +98,17 @@ namespace MWScript virtual void execute (Interpreter::Runtime& runtime) { - InterpreterContext& context - = static_cast (runtime.getContext()); - std::string name = runtime.getStringLiteral (runtime[0].mInteger); runtime.pop(); - const ESM::Cell *cell = context.getWorld().getPlayer().getPlayer().getCell()->cell; + const ESM::Cell *cell = MWBase::Environment::get().getWorld()->getPlayer().getPlayer().getCell()->cell; std::string current = cell->name; if (!(cell->data.flags & ESM::Cell::Interior) && current.empty()) { const ESM::Region *region = - context.getWorld().getStore().regions.find (cell->region); + MWBase::Environment::get().getWorld()->getStore().regions.find (cell->region); current = region->name; } @@ -139,10 +126,7 @@ namespace MWScript virtual void execute (Interpreter::Runtime& runtime) { - InterpreterContext& context - = static_cast (runtime.getContext()); - - MWWorld::Ptr::CellStore *cell = context.getWorld().getPlayer().getPlayer().getCell(); + MWWorld::Ptr::CellStore *cell = MWBase::Environment::get().getWorld()->getPlayer().getPlayer().getCell(); runtime.push (cell->mWaterLevel); } }; @@ -153,18 +137,15 @@ namespace MWScript virtual void execute (Interpreter::Runtime& runtime) { - InterpreterContext& context - = static_cast (runtime.getContext()); - Interpreter::Type_Float level = runtime[0].mFloat; - MWWorld::Ptr::CellStore *cell = context.getWorld().getPlayer().getPlayer().getCell(); + MWWorld::Ptr::CellStore *cell = MWBase::Environment::get().getWorld()->getPlayer().getPlayer().getCell(); if (!(cell->cell->data.flags & ESM::Cell::Interior)) throw std::runtime_error("Can't set water level in exterior cell"); cell->mWaterLevel = level; - context.getEnvironment().mWorld->setWaterHeight(cell->mWaterLevel); + MWBase::Environment::get().getWorld()->setWaterHeight(cell->mWaterLevel); } }; @@ -174,18 +155,15 @@ namespace MWScript virtual void execute (Interpreter::Runtime& runtime) { - InterpreterContext& context - = static_cast (runtime.getContext()); - Interpreter::Type_Float level = runtime[0].mFloat; - MWWorld::Ptr::CellStore *cell = context.getWorld().getPlayer().getPlayer().getCell(); + MWWorld::Ptr::CellStore *cell = MWBase::Environment::get().getWorld()->getPlayer().getPlayer().getCell(); if (!(cell->cell->data.flags & ESM::Cell::Interior)) throw std::runtime_error("Can't set water level in exterior cell"); - + cell->mWaterLevel +=level; - context.getEnvironment().mWorld->setWaterHeight(cell->mWaterLevel); + MWBase::Environment::get().getWorld()->setWaterHeight(cell->mWaterLevel); } }; diff --git a/apps/openmw/mwscript/compilercontext.cpp b/apps/openmw/mwscript/compilercontext.cpp index 15cc599a7f..078d0da5e7 100644 --- a/apps/openmw/mwscript/compilercontext.cpp +++ b/apps/openmw/mwscript/compilercontext.cpp @@ -1,48 +1,48 @@ #include "compilercontext.hpp" -#include "../mwworld/environment.hpp" +#include "../mwbase/environment.hpp" + #include "../mwworld/world.hpp" namespace MWScript { - CompilerContext::CompilerContext (Type type, const MWWorld::Environment& environment) - : mType (type), mEnvironment (environment) + CompilerContext::CompilerContext (Type type) + : mType (type) {} bool CompilerContext::canDeclareLocals() const { return mType==Type_Full; - } - + } + char CompilerContext::getGlobalType (const std::string& name) const { - return mEnvironment.mWorld->getGlobalVariableType (name); - } - + return MWBase::Environment::get().getWorld()->getGlobalVariableType (name); + } + bool CompilerContext::isId (const std::string& name) const { return - mEnvironment.mWorld->getStore().activators.search (name) || - mEnvironment.mWorld->getStore().potions.search (name) || - mEnvironment.mWorld->getStore().appas.search (name) || - mEnvironment.mWorld->getStore().armors.search (name) || - mEnvironment.mWorld->getStore().books.search (name) || - mEnvironment.mWorld->getStore().clothes.search (name) || - mEnvironment.mWorld->getStore().containers.search (name) || - mEnvironment.mWorld->getStore().creatures.search (name) || - mEnvironment.mWorld->getStore().doors.search (name) || - mEnvironment.mWorld->getStore().ingreds.search (name) || - mEnvironment.mWorld->getStore().creatureLists.search (name) || - mEnvironment.mWorld->getStore().itemLists.search (name) || - mEnvironment.mWorld->getStore().lights.search (name) || - mEnvironment.mWorld->getStore().lockpicks.search (name) || - mEnvironment.mWorld->getStore().miscItems.search (name) || - mEnvironment.mWorld->getStore().npcs.search (name) || - mEnvironment.mWorld->getStore().probes.search (name) || - mEnvironment.mWorld->getStore().repairs.search (name) || - mEnvironment.mWorld->getStore().statics.search (name) || - mEnvironment.mWorld->getStore().weapons.search (name); + MWBase::Environment::get().getWorld()->getStore().activators.search (name) || + MWBase::Environment::get().getWorld()->getStore().potions.search (name) || + MWBase::Environment::get().getWorld()->getStore().appas.search (name) || + MWBase::Environment::get().getWorld()->getStore().armors.search (name) || + MWBase::Environment::get().getWorld()->getStore().books.search (name) || + MWBase::Environment::get().getWorld()->getStore().clothes.search (name) || + MWBase::Environment::get().getWorld()->getStore().containers.search (name) || + MWBase::Environment::get().getWorld()->getStore().creatures.search (name) || + MWBase::Environment::get().getWorld()->getStore().doors.search (name) || + MWBase::Environment::get().getWorld()->getStore().ingreds.search (name) || + MWBase::Environment::get().getWorld()->getStore().creatureLists.search (name) || + MWBase::Environment::get().getWorld()->getStore().itemLists.search (name) || + MWBase::Environment::get().getWorld()->getStore().lights.search (name) || + MWBase::Environment::get().getWorld()->getStore().lockpicks.search (name) || + MWBase::Environment::get().getWorld()->getStore().miscItems.search (name) || + MWBase::Environment::get().getWorld()->getStore().npcs.search (name) || + MWBase::Environment::get().getWorld()->getStore().probes.search (name) || + MWBase::Environment::get().getWorld()->getStore().repairs.search (name) || + MWBase::Environment::get().getWorld()->getStore().statics.search (name) || + MWBase::Environment::get().getWorld()->getStore().weapons.search (name); } } - diff --git a/apps/openmw/mwscript/compilercontext.hpp b/apps/openmw/mwscript/compilercontext.hpp index 7a3411bba7..32b2f1881c 100644 --- a/apps/openmw/mwscript/compilercontext.hpp +++ b/apps/openmw/mwscript/compilercontext.hpp @@ -3,44 +3,36 @@ #include -namespace MWWorld -{ - class Environment; -} - namespace MWScript { class CompilerContext : public Compiler::Context { public: - + enum Type { Type_Full, // global, local, targetted Type_Dialgoue, Type_Console }; - + private: - + Type mType; - const MWWorld::Environment& mEnvironment; - + public: - - CompilerContext (Type type, const MWWorld::Environment& environment); - + + CompilerContext (Type type); + /// Is the compiler allowed to declare local variables? - virtual bool canDeclareLocals() const; - - /// 'l: long, 's': short, 'f': float, ' ': does not exist. + virtual bool canDeclareLocals() const; + + /// 'l: long, 's': short, 'f': float, ' ': does not exist. virtual char getGlobalType (const std::string& name) const; virtual bool isId (const std::string& name) const; - ///< Does \a name match an ID, that can be referenced? + ///< Does \a name match an ID, that can be referenced? }; } #endif - - diff --git a/apps/openmw/mwscript/containerextensions.cpp b/apps/openmw/mwscript/containerextensions.cpp index a0aba5db9a..3e8658bf85 100644 --- a/apps/openmw/mwscript/containerextensions.cpp +++ b/apps/openmw/mwscript/containerextensions.cpp @@ -9,6 +9,8 @@ #include #include +#include "../mwbase/environment.hpp" + #include "../mwworld/manualref.hpp" #include "../mwworld/class.hpp" #include "../mwworld/containerstore.hpp" @@ -29,9 +31,6 @@ namespace MWScript { MWWorld::Ptr ptr = R()(runtime); - MWScript::InterpreterContext& context - = static_cast (runtime.getContext()); - std::string item = runtime.getStringLiteral (runtime[0].mInteger); runtime.pop(); @@ -41,7 +40,7 @@ namespace MWScript if (count<0) throw std::runtime_error ("second argument for AddItem must be non-negative"); - MWWorld::ManualRef ref (context.getWorld().getStore(), item); + MWWorld::ManualRef ref (MWBase::Environment::get().getWorld()->getStore(), item); ref.getPtr().getRefData().setCount (count); diff --git a/apps/openmw/mwscript/controlextensions.cpp b/apps/openmw/mwscript/controlextensions.cpp index 384e13e450..363a09b6bd 100644 --- a/apps/openmw/mwscript/controlextensions.cpp +++ b/apps/openmw/mwscript/controlextensions.cpp @@ -7,6 +7,8 @@ #include #include +#include "../mwbase/environment.hpp" + #include "../mwworld/player.hpp" #include "interpretercontext.hpp" @@ -46,7 +48,7 @@ namespace MWScript InterpreterContext& context = static_cast (runtime.getContext()); - bool enabled = context.getWorld().toggleCollisionMode(); + bool enabled = MWBase::Environment::get().getWorld()->toggleCollisionMode(); context.report (enabled ? "Collision -> On" : "Collision -> Off"); } diff --git a/apps/openmw/mwscript/dialogueextensions.cpp b/apps/openmw/mwscript/dialogueextensions.cpp index fec539d3e3..b99d55999c 100644 --- a/apps/openmw/mwscript/dialogueextensions.cpp +++ b/apps/openmw/mwscript/dialogueextensions.cpp @@ -23,16 +23,13 @@ namespace MWScript virtual void execute (Interpreter::Runtime& runtime) { - MWScript::InterpreterContext& context - = static_cast (runtime.getContext()); - std::string quest = runtime.getStringLiteral (runtime[0].mInteger); runtime.pop(); Interpreter::Type_Integer index = runtime[0].mInteger; runtime.pop(); - context.getEnvironment().mJournal->addEntry (quest, index); + MWBase::Environment::get().getJournal()->addEntry (quest, index); } }; @@ -42,16 +39,13 @@ namespace MWScript virtual void execute (Interpreter::Runtime& runtime) { - MWScript::InterpreterContext& context - = static_cast (runtime.getContext()); - std::string quest = runtime.getStringLiteral (runtime[0].mInteger); runtime.pop(); Interpreter::Type_Integer index = runtime[0].mInteger; runtime.pop(); - context.getEnvironment().mJournal->setJournalIndex (quest, index); + MWBase::Environment::get().getJournal()->setJournalIndex (quest, index); } }; @@ -61,13 +55,10 @@ namespace MWScript virtual void execute (Interpreter::Runtime& runtime) { - MWScript::InterpreterContext& context - = static_cast (runtime.getContext()); - std::string quest = runtime.getStringLiteral (runtime[0].mInteger); runtime.pop(); - int index = context.getEnvironment().mJournal->getJournalIndex (quest); + int index = MWBase::Environment::get().getJournal()->getJournalIndex (quest); runtime.push (index); @@ -80,13 +71,10 @@ namespace MWScript virtual void execute (Interpreter::Runtime& runtime) { - MWScript::InterpreterContext& context - = static_cast (runtime.getContext()); - std::string topic = runtime.getStringLiteral (runtime[0].mInteger); runtime.pop(); - context.getEnvironment().mDialogueManager->addTopic(topic); + MWBase::Environment::get().getDialogueManager()->addTopic(topic); } }; @@ -96,9 +84,7 @@ namespace MWScript virtual void execute (Interpreter::Runtime& runtime, unsigned int arg0) { - MWScript::InterpreterContext& context - = static_cast (runtime.getContext()); - MWDialogue::DialogueManager* dialogue = context.getEnvironment().mDialogueManager; + MWDialogue::DialogueManager* dialogue = MWBase::Environment::get().getDialogueManager(); while(arg0>0) { std::string question = runtime.getStringLiteral (runtime[0].mInteger); @@ -124,9 +110,8 @@ namespace MWScript virtual void execute (Interpreter::Runtime& runtime) { MWWorld::Ptr ptr = R()(runtime); - MWScript::InterpreterContext& context - = static_cast (runtime.getContext()); - context.getEnvironment().mDialogueManager->startDialogue (ptr); + + MWBase::Environment::get().getDialogueManager()->startDialogue (ptr); } }; diff --git a/apps/openmw/mwscript/globalscripts.cpp b/apps/openmw/mwscript/globalscripts.cpp index 14930b8280..eb96ba5e2b 100644 --- a/apps/openmw/mwscript/globalscripts.cpp +++ b/apps/openmw/mwscript/globalscripts.cpp @@ -12,9 +12,9 @@ namespace MWScript : mStore (store), mScriptManager (scriptManager) { addScript ("Main"); - - for (ESMS::RecListT::MapType::const_iterator iter - (store.startScripts.list.begin()); + + for (ESMS::RecListT::MapType::const_iterator iter + (store.startScripts.list.begin()); iter != store.startScripts.list.end(); ++iter) addScript (iter->second.script); } @@ -23,15 +23,15 @@ namespace MWScript { if (mScripts.find (name)==mScripts.end()) if (const ESM::Script *script = mStore.scripts.find (name)) - { + { Locals locals; - + locals.configure (*script); - mScripts.insert (std::make_pair (name, std::make_pair (true, locals))); + mScripts.insert (std::make_pair (name, std::make_pair (true, locals))); } } - + void GlobalScripts::removeScript (const std::string& name) { std::map >::iterator iter = mScripts.find (name); @@ -39,31 +39,30 @@ namespace MWScript if (iter!=mScripts.end()) iter->second.first = false; } - + bool GlobalScripts::isRunning (const std::string& name) const { std::map >::const_iterator iter = mScripts.find (name); - + if (iter==mScripts.end()) return false; - + return iter->second.first; } - - void GlobalScripts::run (MWWorld::Environment& environment) + + void GlobalScripts::run() { for (std::map >::iterator iter (mScripts.begin()); iter!=mScripts.end(); ++iter) { if (iter->second.first) { - MWScript::InterpreterContext interpreterContext (environment, + MWScript::InterpreterContext interpreterContext ( &iter->second.second, MWWorld::Ptr()); - mScriptManager.run (iter->first, interpreterContext); + mScriptManager.run (iter->first, interpreterContext); } } } } - diff --git a/apps/openmw/mwscript/globalscripts.hpp b/apps/openmw/mwscript/globalscripts.hpp index 741968fcdc..3d62e4d7a0 100644 --- a/apps/openmw/mwscript/globalscripts.hpp +++ b/apps/openmw/mwscript/globalscripts.hpp @@ -11,11 +11,6 @@ namespace ESMS struct ESMStore; } -namespace MWWorld -{ - class Environment; -} - namespace MWScript { class ScriptManager; @@ -25,21 +20,20 @@ namespace MWScript const ESMS::ESMStore& mStore; ScriptManager& mScriptManager; std::map > mScripts; // running, local variables - + public: - + GlobalScripts (const ESMS::ESMStore& store, ScriptManager& scriptManager); - + void addScript (const std::string& name); - + void removeScript (const std::string& name); - + bool isRunning (const std::string& name) const; - - void run (MWWorld::Environment& environment); + + void run(); ///< run all active global scripts }; } #endif - diff --git a/apps/openmw/mwscript/guiextensions.cpp b/apps/openmw/mwscript/guiextensions.cpp index 426378efca..a37595ea82 100644 --- a/apps/openmw/mwscript/guiextensions.cpp +++ b/apps/openmw/mwscript/guiextensions.cpp @@ -7,6 +7,8 @@ #include #include +#include "../mwbase/environment.hpp" + #include "../mwgui/window_manager.hpp" #include "../mwinput/inputmanager.hpp" @@ -26,10 +28,7 @@ namespace MWScript virtual void execute (Interpreter::Runtime& runtime) { - InterpreterContext& context = - static_cast (runtime.getContext()); - - context.getWindowManager().allow (mWindow); + MWBase::Environment::get().getWindowManager()->allow (mWindow); } }; @@ -45,10 +44,7 @@ namespace MWScript virtual void execute (Interpreter::Runtime& runtime) { - InterpreterContext& context = - static_cast (runtime.getContext()); - - context.getInputManager().setGuiMode(mDialogue); + MWBase::Environment::get().getInputManager()->setGuiMode(mDialogue); } }; @@ -63,7 +59,7 @@ namespace MWScript MWWorld::Ptr ptr = context.getReference(); - runtime.push (context.getWindowManager().readPressedButton()); + runtime.push (MWBase::Environment::get().getWindowManager()->readPressedButton()); } }; @@ -73,10 +69,7 @@ namespace MWScript virtual void execute (Interpreter::Runtime& runtime) { - InterpreterContext& context = - static_cast (runtime.getContext()); - - context.getEnvironment().mWindowManager->toggleFogOfWar(); + MWBase::Environment::get().getWindowManager()->toggleFogOfWar(); } }; diff --git a/apps/openmw/mwscript/interpretercontext.cpp b/apps/openmw/mwscript/interpretercontext.cpp index acd1d957d6..a369486faf 100644 --- a/apps/openmw/mwscript/interpretercontext.cpp +++ b/apps/openmw/mwscript/interpretercontext.cpp @@ -7,6 +7,8 @@ #include +#include "../mwbase/environment.hpp" + #include "../mwworld/world.hpp" #include "../mwgui/window_manager.hpp" @@ -24,7 +26,7 @@ namespace MWScript { if (!id.empty()) { - return mEnvironment.mWorld->getPtr (id, activeOnly); + return MWBase::Environment::get().getWorld()->getPtr (id, activeOnly); } else { @@ -40,7 +42,7 @@ namespace MWScript { if (!id.empty()) { - return mEnvironment.mWorld->getPtr (id, activeOnly); + return MWBase::Environment::get().getWorld()->getPtr (id, activeOnly); } else { @@ -51,9 +53,9 @@ namespace MWScript } } - InterpreterContext::InterpreterContext (MWWorld::Environment& environment, + InterpreterContext::InterpreterContext ( MWScript::Locals *locals, MWWorld::Ptr reference) - : mEnvironment (environment), mLocals (locals), mReference (reference), + : mLocals (locals), mReference (reference), mActivationHandled (false) {} @@ -108,7 +110,7 @@ namespace MWScript void InterpreterContext::messageBox (const std::string& message, const std::vector& buttons) { - mEnvironment.mWindowManager->messageBox (message, buttons); + MWBase::Environment::get().getWindowManager()->messageBox (message, buttons); } void InterpreterContext::report (const std::string& message) @@ -118,74 +120,74 @@ namespace MWScript bool InterpreterContext::menuMode() { - return mEnvironment.mWindowManager->isGuiMode(); + return MWBase::Environment::get().getWindowManager()->isGuiMode(); } int InterpreterContext::getGlobalShort (const std::string& name) const { - return mEnvironment.mWorld->getGlobalVariable (name).mShort; + return MWBase::Environment::get().getWorld()->getGlobalVariable (name).mShort; } int InterpreterContext::getGlobalLong (const std::string& name) const { // a global long is internally a float. - return mEnvironment.mWorld->getGlobalVariable (name).mLong; + return MWBase::Environment::get().getWorld()->getGlobalVariable (name).mLong; } float InterpreterContext::getGlobalFloat (const std::string& name) const { - return mEnvironment.mWorld->getGlobalVariable (name).mFloat; + return MWBase::Environment::get().getWorld()->getGlobalVariable (name).mFloat; } void InterpreterContext::setGlobalShort (const std::string& name, int value) { if (name=="gamehour") - mEnvironment.mWorld->setHour (value); + MWBase::Environment::get().getWorld()->setHour (value); else if (name=="day") - mEnvironment.mWorld->setDay (value); + MWBase::Environment::get().getWorld()->setDay (value); else if (name=="month") - mEnvironment.mWorld->setMonth (value); + MWBase::Environment::get().getWorld()->setMonth (value); else - mEnvironment.mWorld->getGlobalVariable (name).mShort = value; + MWBase::Environment::get().getWorld()->getGlobalVariable (name).mShort = value; } void InterpreterContext::setGlobalLong (const std::string& name, int value) { if (name=="gamehour") - mEnvironment.mWorld->setHour (value); + MWBase::Environment::get().getWorld()->setHour (value); else if (name=="day") - mEnvironment.mWorld->setDay (value); + MWBase::Environment::get().getWorld()->setDay (value); else if (name=="month") - mEnvironment.mWorld->setMonth (value); + MWBase::Environment::get().getWorld()->setMonth (value); else - mEnvironment.mWorld->getGlobalVariable (name).mLong = value; + MWBase::Environment::get().getWorld()->getGlobalVariable (name).mLong = value; } void InterpreterContext::setGlobalFloat (const std::string& name, float value) { if (name=="gamehour") - mEnvironment.mWorld->setHour (value); + MWBase::Environment::get().getWorld()->setHour (value); else if (name=="day") - mEnvironment.mWorld->setDay (value); + MWBase::Environment::get().getWorld()->setDay (value); else if (name=="month") - mEnvironment.mWorld->setMonth (value); + MWBase::Environment::get().getWorld()->setMonth (value); else - mEnvironment.mWorld->getGlobalVariable (name).mFloat = value; + MWBase::Environment::get().getWorld()->getGlobalVariable (name).mFloat = value; } bool InterpreterContext::isScriptRunning (const std::string& name) const { - return mEnvironment.mScriptManager->getGlobalScripts().isRunning (name); + return MWBase::Environment::get().getScriptManager()->getGlobalScripts().isRunning (name); } void InterpreterContext::startScript (const std::string& name) { - mEnvironment.mScriptManager->getGlobalScripts().addScript (name); + MWBase::Environment::get().getScriptManager()->getGlobalScripts().addScript (name); } void InterpreterContext::stopScript (const std::string& name) { - mEnvironment.mScriptManager->getGlobalScripts().removeScript (name); + MWBase::Environment::get().getScriptManager()->getGlobalScripts().removeScript (name); } float InterpreterContext::getDistance (const std::string& name, const std::string& id) const @@ -193,7 +195,7 @@ namespace MWScript // TODO handle exterior cells (when ref and ref2 are located in different cells) const MWWorld::Ptr ref2 = getReference (id, false); - const MWWorld::Ptr ref = mEnvironment.mWorld->getPtr (name, true); + const MWWorld::Ptr ref = MWBase::Environment::get().getWorld()->getPtr (name, true); double diff[3]; @@ -234,7 +236,7 @@ namespace MWScript if (!mAction.get()) throw std::runtime_error ("activation failed, because no action to perform"); - mAction->execute (mEnvironment); + mAction->execute(); mActivationHandled = true; } @@ -247,7 +249,7 @@ namespace MWScript float InterpreterContext::getSecondsPassed() const { - return mEnvironment.mFrameDuration; + return MWBase::Environment::get().getFrameDuration(); } bool InterpreterContext::isDisabled (const std::string& id) const @@ -259,38 +261,13 @@ namespace MWScript void InterpreterContext::enable (const std::string& id) { MWWorld::Ptr ref = getReference (id, false); - mEnvironment.mWorld->enable (ref); + MWBase::Environment::get().getWorld()->enable (ref); } void InterpreterContext::disable (const std::string& id) { MWWorld::Ptr ref = getReference (id, false); - mEnvironment.mWorld->disable (ref); - } - - MWWorld::Environment& InterpreterContext::getEnvironment() - { - return mEnvironment; - } - - MWGui::WindowManager& InterpreterContext::getWindowManager() - { - return *mEnvironment.mWindowManager; - } - - MWInput::MWInputManager& InterpreterContext::getInputManager() - { - return *mEnvironment.mInputManager; - } - - MWWorld::World& InterpreterContext::getWorld() - { - return *mEnvironment.mWorld; - } - - MWSound::SoundManager& InterpreterContext::getSoundManager() - { - return *mEnvironment.mSoundManager; + MWBase::Environment::get().getWorld()->disable (ref); } MWWorld::Ptr InterpreterContext::getReference() diff --git a/apps/openmw/mwscript/interpretercontext.hpp b/apps/openmw/mwscript/interpretercontext.hpp index 35b4a169d2..40f53337db 100644 --- a/apps/openmw/mwscript/interpretercontext.hpp +++ b/apps/openmw/mwscript/interpretercontext.hpp @@ -6,7 +6,6 @@ #include #include "../mwworld/ptr.hpp" -#include "../mwworld/environment.hpp" #include "../mwworld/world.hpp" #include "../mwworld/action.hpp" @@ -26,7 +25,6 @@ namespace MWScript class InterpreterContext : public Interpreter::Context { - MWWorld::Environment& mEnvironment; Locals *mLocals; MWWorld::Ptr mReference; @@ -40,8 +38,7 @@ namespace MWScript public: - InterpreterContext (MWWorld::Environment& environment, - MWScript::Locals *locals, MWWorld::Ptr reference); + InterpreterContext (MWScript::Locals *locals, MWWorld::Ptr reference); ///< The ownership of \a locals is not transferred. 0-pointer allowed. virtual int getLocalShort (int index) const; @@ -110,18 +107,6 @@ namespace MWScript virtual void disable (const std::string& id = ""); - MWWorld::Environment& getEnvironment(); - - /// \todo remove the following functions (extentions should use getEnvironment instead) - - MWWorld::World& getWorld(); - - MWSound::SoundManager& getSoundManager(); - - MWGui::WindowManager& getWindowManager(); - - MWInput::MWInputManager& getInputManager(); - MWWorld::Ptr getReference(); ///< Reference, that the script is running from (can be empty) }; diff --git a/apps/openmw/mwscript/miscextensions.cpp b/apps/openmw/mwscript/miscextensions.cpp index a0770b9a88..4ba523937c 100644 --- a/apps/openmw/mwscript/miscextensions.cpp +++ b/apps/openmw/mwscript/miscextensions.cpp @@ -7,6 +7,8 @@ #include #include +#include "../mwbase/environment.hpp" + #include "../mwworld/class.hpp" #include "interpretercontext.hpp" @@ -100,7 +102,7 @@ namespace MWScript static_cast (runtime.getContext()); bool enabled = - context.getWorld().toggleRenderMode (MWWorld::World::Render_CollisionDebug); + MWBase::Environment::get().getWorld()->toggleRenderMode (MWWorld::World::Render_CollisionDebug); context.report (enabled ? "Collision Mesh Rendering -> On" : "Collision Mesh Rendering -> Off"); @@ -117,7 +119,7 @@ namespace MWScript static_cast (runtime.getContext()); bool enabled = - context.getWorld().toggleRenderMode (MWWorld::World::Render_Wireframe); + MWBase::Environment::get().getWorld()->toggleRenderMode (MWWorld::World::Render_Wireframe); context.report (enabled ? "Wireframe Rendering -> On" : "Wireframe Rendering -> Off"); @@ -133,7 +135,7 @@ namespace MWScript static_cast (runtime.getContext()); bool enabled = - context.getWorld().toggleRenderMode (MWWorld::World::Render_Pathgrid); + MWBase::Environment::get().getWorld()->toggleRenderMode (MWWorld::World::Render_Pathgrid); context.report (enabled ? "Path Grid rendering -> On" : "Path Grid Rendering -> Off"); @@ -146,13 +148,10 @@ namespace MWScript virtual void execute (Interpreter::Runtime& runtime) { - InterpreterContext& context = - static_cast (runtime.getContext()); - Interpreter::Type_Float time = runtime[0].mFloat; runtime.pop(); - context.getWorld().getFader()->fadeIn(time); + MWBase::Environment::get().getWorld()->getFader()->fadeIn(time); } }; @@ -162,13 +161,10 @@ namespace MWScript virtual void execute (Interpreter::Runtime& runtime) { - InterpreterContext& context = - static_cast (runtime.getContext()); - Interpreter::Type_Float time = runtime[0].mFloat; runtime.pop(); - context.getWorld().getFader()->fadeOut(time); + MWBase::Environment::get().getWorld()->getFader()->fadeOut(time); } }; @@ -178,16 +174,13 @@ namespace MWScript virtual void execute (Interpreter::Runtime& runtime) { - InterpreterContext& context = - static_cast (runtime.getContext()); - Interpreter::Type_Float alpha = runtime[0].mFloat; runtime.pop(); Interpreter::Type_Float time = runtime[0].mFloat; runtime.pop(); - context.getWorld().getFader()->fadeTo(alpha, time); + MWBase::Environment::get().getWorld()->getFader()->fadeTo(alpha, time); } }; @@ -197,10 +190,7 @@ namespace MWScript virtual void execute (Interpreter::Runtime& runtime) { - InterpreterContext& context = - static_cast (runtime.getContext()); - - context.getWorld().toggleWater(); + MWBase::Environment::get().getWorld()->toggleWater(); } }; diff --git a/apps/openmw/mwscript/ref.hpp b/apps/openmw/mwscript/ref.hpp index 5ca1ea4d62..28093c4e56 100644 --- a/apps/openmw/mwscript/ref.hpp +++ b/apps/openmw/mwscript/ref.hpp @@ -5,6 +5,8 @@ #include +#include "../mwbase/environment.hpp" + #include "../mwworld/ptr.hpp" #include "../mwworld/world.hpp" @@ -16,13 +18,10 @@ namespace MWScript { MWWorld::Ptr operator() (Interpreter::Runtime& runtime) const { - MWScript::InterpreterContext& context - = static_cast (runtime.getContext()); - std::string id = runtime.getStringLiteral (runtime[0].mInteger); runtime.pop(); - return context.getWorld().getPtr (id, false); + return MWBase::Environment::get().getWorld()->getPtr (id, false); } }; diff --git a/apps/openmw/mwscript/skyextensions.cpp b/apps/openmw/mwscript/skyextensions.cpp index a5cc9e2138..e16c2ec233 100644 --- a/apps/openmw/mwscript/skyextensions.cpp +++ b/apps/openmw/mwscript/skyextensions.cpp @@ -7,6 +7,8 @@ #include #include +#include "../mwbase/environment.hpp" + #include "interpretercontext.hpp" namespace MWScript @@ -19,11 +21,11 @@ namespace MWScript virtual void execute (Interpreter::Runtime& runtime) { + bool enabled = MWBase::Environment::get().getWorld()->toggleSky(); + InterpreterContext& context = static_cast (runtime.getContext()); - bool enabled = context.getWorld().toggleSky(); - context.report (enabled ? "Sky -> On" : "Sky -> Off"); } }; @@ -34,10 +36,7 @@ namespace MWScript virtual void execute (Interpreter::Runtime& runtime) { - InterpreterContext& context = - static_cast (runtime.getContext()); - - context.getWorld().setMoonColour (false); + MWBase::Environment::get().getWorld()->setMoonColour (false); } }; @@ -47,10 +46,7 @@ namespace MWScript virtual void execute (Interpreter::Runtime& runtime) { - InterpreterContext& context = - static_cast (runtime.getContext()); - - context.getWorld().setMoonColour (true); + MWBase::Environment::get().getWorld()->setMoonColour (true); } }; @@ -60,10 +56,7 @@ namespace MWScript virtual void execute (Interpreter::Runtime& runtime) { - InterpreterContext& context = - static_cast (runtime.getContext()); - - runtime.push (context.getWorld().getMasserPhase()); + runtime.push (MWBase::Environment::get().getWorld()->getMasserPhase()); } }; @@ -73,42 +66,33 @@ namespace MWScript virtual void execute (Interpreter::Runtime& runtime) { - InterpreterContext& context = - static_cast (runtime.getContext()); - - runtime.push (context.getWorld().getSecundaPhase()); + runtime.push (MWBase::Environment::get().getWorld()->getSecundaPhase()); } }; - + class OpGetCurrentWeather : public Interpreter::Opcode0 { public: - + virtual void execute (Interpreter::Runtime& runtime) { - InterpreterContext& context = - static_cast (runtime.getContext()); - - runtime.push (context.getWorld().getCurrentWeather()); + runtime.push (MWBase::Environment::get().getWorld()->getCurrentWeather()); } }; - + class OpChangeWeather : public Interpreter::Opcode0 { public: - + virtual void execute (Interpreter::Runtime& runtime) { - InterpreterContext& context = - static_cast (runtime.getContext()); - std::string region = runtime.getStringLiteral (runtime[0].mInteger); runtime.pop(); - + Interpreter::Type_Integer id = runtime[0].mInteger; runtime.pop(); - - context.getWorld().changeWeather(region, id); + + MWBase::Environment::get().getWorld()->changeWeather(region, id); } }; diff --git a/apps/openmw/mwscript/soundextensions.cpp b/apps/openmw/mwscript/soundextensions.cpp index b4386a8a0d..c2b45641a3 100644 --- a/apps/openmw/mwscript/soundextensions.cpp +++ b/apps/openmw/mwscript/soundextensions.cpp @@ -7,6 +7,8 @@ #include #include +#include "../mwbase/environment.hpp" + #include "../mwworld/world.hpp" #include "../mwsound/soundmanager.hpp" @@ -36,7 +38,7 @@ namespace MWScript std::string text = runtime.getStringLiteral (runtime[0].mInteger); runtime.pop(); - context.getSoundManager().say (ptr, file); + MWBase::Environment::get().getSoundManager()->say (ptr, file); context.messageBox (text); } }; @@ -50,10 +52,7 @@ namespace MWScript { MWWorld::Ptr ptr = R()(runtime); - MWScript::InterpreterContext& context - = static_cast (runtime.getContext()); - - runtime.push (context.getSoundManager().sayDone (ptr)); + runtime.push (MWBase::Environment::get().getSoundManager()->sayDone (ptr)); } }; @@ -63,13 +62,10 @@ namespace MWScript virtual void execute (Interpreter::Runtime& runtime) { - MWScript::InterpreterContext& context - = static_cast (runtime.getContext()); - std::string sound = runtime.getStringLiteral (runtime[0].mInteger); runtime.pop(); - context.getSoundManager().streamMusic (sound); + MWBase::Environment::get().getSoundManager()->streamMusic (sound); } }; @@ -79,13 +75,10 @@ namespace MWScript virtual void execute (Interpreter::Runtime& runtime) { - MWScript::InterpreterContext& context - = static_cast (runtime.getContext()); - std::string sound = runtime.getStringLiteral (runtime[0].mInteger); runtime.pop(); - context.getSoundManager().playSound (sound, 1.0, 1.0); + MWBase::Environment::get().getSoundManager()->playSound (sound, 1.0, 1.0); } }; @@ -95,9 +88,6 @@ namespace MWScript virtual void execute (Interpreter::Runtime& runtime) { - MWScript::InterpreterContext& context - = static_cast (runtime.getContext()); - std::string sound = runtime.getStringLiteral (runtime[0].mInteger); runtime.pop(); @@ -107,7 +97,7 @@ namespace MWScript Interpreter::Type_Float pitch = runtime[0].mFloat; runtime.pop(); - context.getSoundManager().playSound (sound, volume, pitch); + MWBase::Environment::get().getSoundManager()->playSound (sound, volume, pitch); } }; @@ -124,13 +114,10 @@ namespace MWScript { MWWorld::Ptr ptr = R()(runtime); - MWScript::InterpreterContext& context - = static_cast (runtime.getContext()); - std::string sound = runtime.getStringLiteral (runtime[0].mInteger); runtime.pop(); - context.getSoundManager().playSound3D (ptr, sound, 1.0, 1.0, mLoop ? MWSound::Play_Loop : 0); + MWBase::Environment::get().getSoundManager()->playSound3D (ptr, sound, 1.0, 1.0, mLoop ? MWSound::Play_Loop : 0); } }; @@ -147,9 +134,6 @@ namespace MWScript { MWWorld::Ptr ptr = R()(runtime); - MWScript::InterpreterContext& context - = static_cast (runtime.getContext()); - std::string sound = runtime.getStringLiteral (runtime[0].mInteger); runtime.pop(); @@ -159,7 +143,7 @@ namespace MWScript Interpreter::Type_Float pitch = runtime[0].mFloat; runtime.pop(); - context.getSoundManager().playSound3D (ptr, sound, volume, pitch, mLoop ? MWSound::Play_Loop : 0); + MWBase::Environment::get().getSoundManager()->playSound3D (ptr, sound, volume, pitch, mLoop ? MWSound::Play_Loop : 0); } }; @@ -173,13 +157,10 @@ namespace MWScript { MWWorld::Ptr ptr = R()(runtime); - MWScript::InterpreterContext& context - = static_cast (runtime.getContext()); - std::string sound = runtime.getStringLiteral (runtime[0].mInteger); runtime.pop(); - context.getSoundManager().stopSound3D (ptr, sound); + MWBase::Environment::get().getSoundManager()->stopSound3D (ptr, sound); } }; @@ -192,13 +173,10 @@ namespace MWScript { MWWorld::Ptr ptr = R()(runtime); - MWScript::InterpreterContext& context - = static_cast (runtime.getContext()); - int index = runtime[0].mInteger; runtime.pop(); - runtime.push (context.getSoundManager().getSoundPlaying ( + runtime.push (MWBase::Environment::get().getSoundManager()->getSoundPlaying ( ptr, runtime.getStringLiteral (index))); } }; diff --git a/apps/openmw/mwscript/statsextensions.cpp b/apps/openmw/mwscript/statsextensions.cpp index 239f8d7682..cad52e5930 100644 --- a/apps/openmw/mwscript/statsextensions.cpp +++ b/apps/openmw/mwscript/statsextensions.cpp @@ -7,8 +7,9 @@ #include #include +#include "../mwbase/environment.hpp" + #include "../mwworld/class.hpp" -#include "../mwworld/environment.hpp" #include "../mwworld/player.hpp" #include "../mwmechanics/creaturestats.hpp" @@ -351,11 +352,10 @@ namespace MWScript virtual void execute (Interpreter::Runtime& runtime, unsigned int arg0) { std::string factionID = ""; - MWScript::InterpreterContext& context - = static_cast (runtime.getContext()); + if(arg0==0) { - factionID = context.getEnvironment().mDialogueManager->getFaction(); + factionID = MWBase::Environment::get().getDialogueManager()->getFaction(); } else { @@ -364,7 +364,7 @@ namespace MWScript } if(factionID != "") { - MWWorld::Ptr player = context.getEnvironment().mWorld->getPlayer().getPlayer(); + MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer(); if(MWWorld::Class::get(player).getNpcStats(player).mFactionRank.find(factionID) == MWWorld::Class::get(player).getNpcStats(player).mFactionRank.end()) { MWWorld::Class::get(player).getNpcStats(player).mFactionRank[factionID] = 0; @@ -380,11 +380,10 @@ namespace MWScript virtual void execute (Interpreter::Runtime& runtime, unsigned int arg0) { std::string factionID = ""; - MWScript::InterpreterContext& context - = static_cast (runtime.getContext()); + if(arg0==0) { - factionID = context.getEnvironment().mDialogueManager->getFaction(); + factionID = MWBase::Environment::get().getDialogueManager()->getFaction(); } else { @@ -393,7 +392,7 @@ namespace MWScript } if(factionID != "") { - MWWorld::Ptr player = context.getEnvironment().mWorld->getPlayer().getPlayer(); + MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer(); if(MWWorld::Class::get(player).getNpcStats(player).mFactionRank.find(factionID) == MWWorld::Class::get(player).getNpcStats(player).mFactionRank.end()) { MWWorld::Class::get(player).getNpcStats(player).mFactionRank[factionID] = 0; @@ -413,11 +412,10 @@ namespace MWScript virtual void execute (Interpreter::Runtime& runtime, unsigned int arg0) { std::string factionID = ""; - MWScript::InterpreterContext& context - = static_cast (runtime.getContext()); + if(arg0==0) { - factionID = context.getEnvironment().mDialogueManager->getFaction(); + factionID = MWBase::Environment::get().getDialogueManager()->getFaction(); } else { @@ -426,7 +424,7 @@ namespace MWScript } if(factionID != "") { - MWWorld::Ptr player = context.getEnvironment().mWorld->getPlayer().getPlayer(); + MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer(); if(MWWorld::Class::get(player).getNpcStats(player).mFactionRank.find(factionID) != MWWorld::Class::get(player).getNpcStats(player).mFactionRank.end()) { MWWorld::Class::get(player).getNpcStats(player).mFactionRank[factionID] = MWWorld::Class::get(player).getNpcStats(player).mFactionRank[factionID] -1; @@ -461,9 +459,7 @@ namespace MWScript factionID = MWWorld::Class::get(ptr).getNpcStats(ptr).mFactionRank.begin()->first; } } - MWScript::InterpreterContext& context - = static_cast (runtime.getContext()); - MWWorld::Ptr player = context.getEnvironment().mWorld->getPlayer().getPlayer(); + MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer(); if(factionID!="") { if(MWWorld::Class::get(player).getNpcStats(player).mFactionRank.find(factionID) != MWWorld::Class::get(player).getNpcStats(player).mFactionRank.end()) @@ -481,7 +477,7 @@ namespace MWScript } } }; - + template class OpModDisposition : public Interpreter::Opcode0 { diff --git a/apps/openmw/mwsound/soundmanager.cpp b/apps/openmw/mwsound/soundmanager.cpp index 730d9d9b21..4656efb6ed 100644 --- a/apps/openmw/mwsound/soundmanager.cpp +++ b/apps/openmw/mwsound/soundmanager.cpp @@ -9,7 +9,8 @@ #include #include -#include "../mwworld/environment.hpp" +#include "../mwbase/environment.hpp" + #include "../mwworld/world.hpp" #include "../mwworld/player.hpp" @@ -46,9 +47,8 @@ namespace MWSound { - SoundManager::SoundManager(bool useSound, MWWorld::Environment& environment) + SoundManager::SoundManager(bool useSound) : mResourceMgr(Ogre::ResourceGroupManager::getSingleton()) - , mEnvironment(environment) , mOutput(new DEFAULT_OUTPUT(*this)) , mMasterVolume(1.0f) , mSFXVolume(1.0f) @@ -113,7 +113,7 @@ namespace MWSound std::string SoundManager::lookup(const std::string &soundId, float &volume, float &min, float &max) { - const ESM::Sound *snd = mEnvironment.mWorld->getStore().sounds.search(soundId); + const ESM::Sound *snd = MWBase::Environment::get().getWorld()->getStore().sounds.search(soundId); if(snd == NULL) throw std::runtime_error(std::string("Failed to lookup sound ")+soundId); @@ -380,7 +380,7 @@ namespace MWSound void SoundManager::updateRegionSound(float duration) { - MWWorld::Ptr::CellStore *current = mEnvironment.mWorld->getPlayer().getPlayer().getCell(); + MWWorld::Ptr::CellStore *current = MWBase::Environment::get().getWorld()->getPlayer().getPlayer().getCell(); static int total = 0; static std::string regionName = ""; static float timePassed = 0.0; @@ -397,7 +397,7 @@ namespace MWSound total = 0; } - const ESM::Region *regn = mEnvironment.mWorld->getStore().regions.find(regionName); + const ESM::Region *regn = MWBase::Environment::get().getWorld()->getStore().regions.find(regionName); std::vector::const_iterator soundIter; if(total == 0) { @@ -445,8 +445,8 @@ namespace MWSound if(!isMusicPlaying()) startRandomTitle(); - const ESM::Cell *cell = mEnvironment.mWorld->getPlayer().getPlayer().getCell()->cell; - Ogre::Camera *cam = mEnvironment.mWorld->getPlayer().getRenderer()->getCamera(); + const ESM::Cell *cell = MWBase::Environment::get().getWorld()->getPlayer().getPlayer().getCell()->cell; + Ogre::Camera *cam = MWBase::Environment::get().getWorld()->getPlayer().getRenderer()->getCamera(); Ogre::Vector3 nPos, nDir, nUp; nPos = cam->getRealPosition(); nDir = cam->getRealDirection(); diff --git a/apps/openmw/mwsound/soundmanager.hpp b/apps/openmw/mwsound/soundmanager.hpp index d64db299b4..8afd488e11 100644 --- a/apps/openmw/mwsound/soundmanager.hpp +++ b/apps/openmw/mwsound/soundmanager.hpp @@ -16,11 +16,6 @@ namespace Ogre class Camera; } -namespace MWWorld -{ - struct Environment; -} - namespace MWSound { class Sound_Output; @@ -52,8 +47,6 @@ namespace MWSound { Ogre::ResourceGroupManager& mResourceMgr; - MWWorld::Environment& mEnvironment; - std::auto_ptr mOutput; float mMasterVolume; @@ -82,7 +75,7 @@ namespace MWSound friend class OpenAL_Output; public: - SoundManager(bool useSound, MWWorld::Environment& environment); + SoundManager(bool useSound); ~SoundManager(); void stopMusic(); diff --git a/apps/openmw/mwworld/action.hpp b/apps/openmw/mwworld/action.hpp index 1558193355..d5cf12779e 100644 --- a/apps/openmw/mwworld/action.hpp +++ b/apps/openmw/mwworld/action.hpp @@ -3,8 +3,6 @@ namespace MWWorld { - class Environment; - /// \brief Abstract base for actions class Action { @@ -18,7 +16,7 @@ namespace MWWorld virtual ~Action() {} - virtual void execute (Environment& environment) = 0; + virtual void execute() = 0; }; } diff --git a/apps/openmw/mwworld/actiontake.cpp b/apps/openmw/mwworld/actiontake.cpp index bbe9540497..b1e2e1fc3d 100644 --- a/apps/openmw/mwworld/actiontake.cpp +++ b/apps/openmw/mwworld/actiontake.cpp @@ -1,8 +1,9 @@ #include "actiontake.hpp" +#include "../mwbase/environment.hpp" + #include "class.hpp" -#include "environment.hpp" #include "world.hpp" #include "containerstore.hpp" @@ -10,14 +11,14 @@ namespace MWWorld { ActionTake::ActionTake (const MWWorld::Ptr& object) : mObject (object) {} - void ActionTake::execute (Environment& environment) + void ActionTake::execute() { // insert into player's inventory - MWWorld::Ptr player = environment.mWorld->getPtr ("player", true); + MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPtr ("player", true); MWWorld::Class::get (player).getContainerStore (player).add (mObject); // remove from world - environment.mWorld->deleteObject (mObject); + MWBase::Environment::get().getWorld()->deleteObject (mObject); } } diff --git a/apps/openmw/mwworld/actiontake.hpp b/apps/openmw/mwworld/actiontake.hpp index 509ebc6bbf..f495fc3c4a 100644 --- a/apps/openmw/mwworld/actiontake.hpp +++ b/apps/openmw/mwworld/actiontake.hpp @@ -14,7 +14,7 @@ namespace MWWorld ActionTake (const MWWorld::Ptr& object); - virtual void execute (Environment& environment); + virtual void execute(); }; } diff --git a/apps/openmw/mwworld/actiontalk.cpp b/apps/openmw/mwworld/actiontalk.cpp index 7d38c22fd7..b33b788323 100644 --- a/apps/openmw/mwworld/actiontalk.cpp +++ b/apps/openmw/mwworld/actiontalk.cpp @@ -1,7 +1,7 @@ #include "actiontalk.hpp" -#include "environment.hpp" +#include "../mwbase/environment.hpp" #include "../mwdialogue/dialoguemanager.hpp" @@ -9,8 +9,8 @@ namespace MWWorld { ActionTalk::ActionTalk (const Ptr& actor) : mActor (actor) {} - void ActionTalk::execute (Environment& environment) + void ActionTalk::execute() { - environment.mDialogueManager->startDialogue (mActor); + MWBase::Environment::get().getDialogueManager()->startDialogue (mActor); } } diff --git a/apps/openmw/mwworld/actiontalk.hpp b/apps/openmw/mwworld/actiontalk.hpp index a60a61660b..1b7b9b6d6f 100644 --- a/apps/openmw/mwworld/actiontalk.hpp +++ b/apps/openmw/mwworld/actiontalk.hpp @@ -15,7 +15,7 @@ namespace MWWorld ActionTalk (const Ptr& actor); ///< \param actor The actor the player is talking to - virtual void execute (Environment& environment); + virtual void execute(); }; } diff --git a/apps/openmw/mwworld/actionteleport.cpp b/apps/openmw/mwworld/actionteleport.cpp index 207e2c50e9..6ebbd7b7f3 100644 --- a/apps/openmw/mwworld/actionteleport.cpp +++ b/apps/openmw/mwworld/actionteleport.cpp @@ -1,7 +1,8 @@ #include "actionteleport.hpp" -#include "environment.hpp" +#include "../mwbase/environment.hpp" + #include "world.hpp" namespace MWWorld @@ -11,11 +12,11 @@ namespace MWWorld : mCellName (cellName), mPosition (position) {} - void ActionTeleportPlayer::execute (Environment& environment) + void ActionTeleportPlayer::execute() { if (mCellName.empty()) - environment.mWorld->changeToExteriorCell (mPosition); + MWBase::Environment::get().getWorld()->changeToExteriorCell (mPosition); else - environment.mWorld->changeToInteriorCell (mCellName, mPosition); + MWBase::Environment::get().getWorld()->changeToInteriorCell (mCellName, mPosition); } } diff --git a/apps/openmw/mwworld/actionteleport.hpp b/apps/openmw/mwworld/actionteleport.hpp index e4c972a9e3..00efdc8765 100644 --- a/apps/openmw/mwworld/actionteleport.hpp +++ b/apps/openmw/mwworld/actionteleport.hpp @@ -19,7 +19,7 @@ namespace MWWorld ActionTeleportPlayer (const std::string& cellName, const ESM::Position& position); ///< If cellName is empty, an exterior cell is asumed. - virtual void execute (Environment& environment); + virtual void execute(); }; } diff --git a/apps/openmw/mwworld/class.cpp b/apps/openmw/mwworld/class.cpp index d49b98d0fb..c53ebcfd04 100644 --- a/apps/openmw/mwworld/class.cpp +++ b/apps/openmw/mwworld/class.cpp @@ -27,17 +27,17 @@ namespace MWWorld } - void Class::insertObject(const Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const + void Class::insertObject(const Ptr& ptr, MWWorld::PhysicsSystem& physics) const { } - void Class::enable (const Ptr& ptr, MWWorld::Environment& environment) const + void Class::enable (const Ptr& ptr) const { } - void Class::disable (const Ptr& ptr, MWWorld::Environment& environment) const + void Class::disable (const Ptr& ptr) const { } @@ -62,14 +62,12 @@ namespace MWWorld throw std::runtime_error ("class does not have item health"); } - boost::shared_ptr Class::activate (const Ptr& ptr, const Ptr& actor, - const Environment& environment) const + boost::shared_ptr Class::activate (const Ptr& ptr, const Ptr& actor) const { return boost::shared_ptr (new NullAction); } - boost::shared_ptr Class::use (const Ptr& ptr, - const Environment& environment) const + boost::shared_ptr Class::use (const Ptr& ptr) const { return boost::shared_ptr (new NullAction); } @@ -134,7 +132,7 @@ namespace MWWorld return std::make_pair (std::vector(), false); } - int Class::getEquipmentSkill (const Ptr& ptr, const Environment& environment) const + int Class::getEquipmentSkill (const Ptr& ptr) const { return -1; } @@ -164,12 +162,12 @@ namespace MWWorld sClasses.insert (std::make_pair (key, instance)); } - std::string Class::getUpSoundId (const Ptr& ptr, const MWWorld::Environment& environment) const + std::string Class::getUpSoundId (const Ptr& ptr) const { throw std::runtime_error ("class does not have an up sound"); } - std::string Class::getDownSoundId (const Ptr& ptr, const MWWorld::Environment& environment) const + std::string Class::getDownSoundId (const Ptr& ptr) const { throw std::runtime_error ("class does not have an down sound"); } diff --git a/apps/openmw/mwworld/class.hpp b/apps/openmw/mwworld/class.hpp index e474e9b926..622d9eeaee 100644 --- a/apps/openmw/mwworld/class.hpp +++ b/apps/openmw/mwworld/class.hpp @@ -33,7 +33,6 @@ namespace MWMechanics namespace MWWorld { class Ptr; - class Environment; class ContainerStore; class InventoryStore; @@ -65,15 +64,15 @@ namespace MWWorld /// (default implementation: throw an exception) virtual void insertObjectRendering (const Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const; - virtual void insertObject(const Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const; + virtual void insertObject(const Ptr& ptr, MWWorld::PhysicsSystem& physics) const; ///< Add reference into a cell for rendering (default implementation: don't render anything). - virtual void enable (const Ptr& ptr, MWWorld::Environment& environment) const; + virtual void enable (const Ptr& ptr) const; ///< Enable reference; only does the non-rendering part (default implementation: ignore) /// \attention This is not the same as the script instruction with the same name. References /// should only be enabled while in an active cell. - virtual void disable (const Ptr& ptr, MWWorld::Environment& environment) const; + virtual void disable (const Ptr& ptr) const; ///< Enable reference; only does the non-rendering part (default implementation: ignore) /// \attention This is not the same as the script instruction with the same name. References /// should only be enabled while in an active cell. @@ -97,11 +96,10 @@ namespace MWWorld ///< Return item max health or throw an exception, if class does not have item health /// (default implementation: throw an exceoption) - virtual boost::shared_ptr activate (const Ptr& ptr, const Ptr& actor, - const Environment& environment) const; + virtual boost::shared_ptr activate (const Ptr& ptr, const Ptr& actor) const; ///< Generate action for activation (default implementation: return a null action). - virtual boost::shared_ptr use (const Ptr& ptr, const Environment& environment) + virtual boost::shared_ptr use (const Ptr& ptr) const; ///< Generate action for using via inventory menu (default implementation: return a /// null action). @@ -149,7 +147,7 @@ namespace MWWorld /// /// Default implementation: return (empty vector, false). - virtual int getEquipmentSkill (const Ptr& ptr, const Environment& environment) + virtual int getEquipmentSkill (const Ptr& ptr) const; /// Return the index of the skill this item corresponds to when equiopped or -1, if there is /// no such skill. @@ -167,11 +165,11 @@ namespace MWWorld static void registerClass (const std::string& key, boost::shared_ptr instance); - virtual std::string getUpSoundId (const Ptr& ptr, const MWWorld::Environment& environment) const; + virtual std::string getUpSoundId (const Ptr& ptr) const; ///< Return the up sound ID of \a ptr or throw an exception, if class does not support ID retrieval /// (default implementation: throw an exception) - virtual std::string getDownSoundId (const Ptr& ptr, const MWWorld::Environment& environment) const; + virtual std::string getDownSoundId (const Ptr& ptr) const; ///< Return the down sound ID of \a ptr or throw an exception, if class does not support ID retrieval /// (default implementation: throw an exception) }; diff --git a/apps/openmw/mwworld/environment.hpp b/apps/openmw/mwworld/environment.hpp deleted file mode 100644 index 8c4a001e0c..0000000000 --- a/apps/openmw/mwworld/environment.hpp +++ /dev/null @@ -1,63 +0,0 @@ -#ifndef GAME_WORLD_INVIRONMENT_H -#define GAME_WORLD_INVIRONMENT_H - -namespace MWSound -{ - class SoundManager; -} - -namespace MWScript -{ - class ScriptManager; -} - -namespace MWGui -{ - class WindowManager; -} - -namespace MWMechanics -{ - class MechanicsManager; -} - -namespace MWDialogue -{ - class DialogueManager; - class Journal; -} - -namespace MWInput -{ - struct MWInputManager; -} - -namespace MWWorld -{ - class World; - - ///< Collection of script-accessable sub-systems - class Environment - { - public: - Environment() - : mWorld (0), mSoundManager (0), mScriptManager (0), mWindowManager (0), - mMechanicsManager (0), mDialogueManager (0), mJournal (0), mFrameDuration (0), - mInputManager (0) - {} - - World *mWorld; - MWSound::SoundManager *mSoundManager; - MWScript::ScriptManager *mScriptManager; - MWGui::WindowManager *mWindowManager; - MWMechanics::MechanicsManager *mMechanicsManager; - MWDialogue::DialogueManager *mDialogueManager; - MWDialogue::Journal *mJournal; - float mFrameDuration; - - // For setting GUI mode - MWInput::MWInputManager *mInputManager; - }; -} - -#endif diff --git a/apps/openmw/mwworld/inventorystore.cpp b/apps/openmw/mwworld/inventorystore.cpp index 230f7d69a0..b93a62e4ea 100644 --- a/apps/openmw/mwworld/inventorystore.cpp +++ b/apps/openmw/mwworld/inventorystore.cpp @@ -72,7 +72,7 @@ void MWWorld::InventoryStore::equip (int slot, const ContainerStoreIterator& ite /// \todo restack item previously in this slot (if required) /// \todo unstack item pointed to by iterator if required) - + mSlots[slot] = iterator; flagAsModified(); @@ -96,8 +96,7 @@ MWWorld::ContainerStoreIterator MWWorld::InventoryStore::getSlot (int slot) return mSlots[slot]; } -void MWWorld::InventoryStore::autoEquip (const MWMechanics::NpcStats& stats, - const Environment& environment) +void MWWorld::InventoryStore::autoEquip (const MWMechanics::NpcStats& stats) { TSlots slots; initSlots (slots); @@ -105,7 +104,7 @@ void MWWorld::InventoryStore::autoEquip (const MWMechanics::NpcStats& stats, for (ContainerStoreIterator iter (begin()); iter!=end(); ++iter) { Ptr test = *iter; - int testSkill = MWWorld::Class::get (test).getEquipmentSkill (test, environment); + int testSkill = MWWorld::Class::get (test).getEquipmentSkill (test); std::pair, bool> itemsSlots = MWWorld::Class::get (*iter).getEquipmentSlots (*iter); @@ -125,7 +124,7 @@ void MWWorld::InventoryStore::autoEquip (const MWMechanics::NpcStats& stats, { // check skill int oldSkill = - MWWorld::Class::get (old).getEquipmentSkill (old, environment); + MWWorld::Class::get (old).getEquipmentSkill (old); if (testSkill!=-1 || oldSkill!=-1 || testSkill!=oldSkill) { diff --git a/apps/openmw/mwworld/inventorystore.hpp b/apps/openmw/mwworld/inventorystore.hpp index 60b89b0b47..5eeaf570d0 100644 --- a/apps/openmw/mwworld/inventorystore.hpp +++ b/apps/openmw/mwworld/inventorystore.hpp @@ -10,8 +10,6 @@ namespace MWMechanics namespace MWWorld { - class Environment; - ///< \brief Variant of the ContainerStore for NPCs class InventoryStore : public ContainerStore { @@ -64,7 +62,7 @@ namespace MWWorld ContainerStoreIterator getSlot (int slot); - void autoEquip (const MWMechanics::NpcStats& stats, const Environment& environment); + void autoEquip (const MWMechanics::NpcStats& stats); ///< Auto equip items according to stats and item value. }; } diff --git a/apps/openmw/mwworld/nullaction.hpp b/apps/openmw/mwworld/nullaction.hpp index 820fc45388..c8e3368e44 100644 --- a/apps/openmw/mwworld/nullaction.hpp +++ b/apps/openmw/mwworld/nullaction.hpp @@ -10,7 +10,7 @@ namespace MWWorld { public: - virtual void execute (Environment& environment) {} + virtual void execute() {} }; } diff --git a/apps/openmw/mwworld/scene.cpp b/apps/openmw/mwworld/scene.cpp index 2123b47999..abb988c838 100644 --- a/apps/openmw/mwworld/scene.cpp +++ b/apps/openmw/mwworld/scene.cpp @@ -1,6 +1,7 @@ #include "scene.hpp" #include "world.hpp" +#include "../mwbase/environment.hpp" #include "../mwmechanics/mechanicsmanager.hpp" @@ -9,7 +10,6 @@ #include "../mwgui/window_manager.hpp" #include "ptr.hpp" -#include "environment.hpp" #include "player.hpp" #include "class.hpp" @@ -18,7 +18,7 @@ namespace { template -void insertCellRefList(MWRender::RenderingManager& rendering, MWWorld::Environment& environment, +void insertCellRefList(MWRender::RenderingManager& rendering, T& cellRefList, ESMS::CellStore &cell, MWWorld::PhysicsSystem& physics) { if (!cellRefList.list.empty()) @@ -36,8 +36,8 @@ void insertCellRefList(MWRender::RenderingManager& rendering, MWWorld::Environme try { rendering.addObject(ptr); - class_.insertObject(ptr, physics, environment); - class_.enable (ptr, environment); + class_.insertObject(ptr, physics); + class_.enable (ptr); } catch (const std::exception& e) { @@ -86,12 +86,12 @@ namespace MWWorld //mPhysics->removeObject("Unnamed_43"); mWorld->getLocalScripts().clearCell (*iter); - mEnvironment.mMechanicsManager->dropActors (*iter); - mEnvironment.mSoundManager->stopSound (*iter); + MWBase::Environment::get().getMechanicsManager()->dropActors (*iter); + MWBase::Environment::get().getSoundManager()->stopSound (*iter); mActiveCells.erase(*iter); - - + + } void Scene::loadCell (Ptr::CellStore *cell) @@ -104,7 +104,7 @@ namespace MWWorld std::pair result = mActiveCells.insert(cell); if(result.second){ - insertCell(*cell, mEnvironment); + insertCell(*cell); mRendering.cellAdded(cell); mRendering.configureAmbient(*cell); mRendering.requestMap(cell); @@ -122,10 +122,10 @@ namespace MWWorld mWorld->getPlayer().setCell (cell); // TODO orientation - mEnvironment.mMechanicsManager->addActor (mWorld->getPlayer().getPlayer()); - mEnvironment.mMechanicsManager->watchActor (mWorld->getPlayer().getPlayer()); + MWBase::Environment::get().getMechanicsManager()->addActor (mWorld->getPlayer().getPlayer()); + MWBase::Environment::get().getMechanicsManager()->watchActor (mWorld->getPlayer().getPlayer()); - mEnvironment.mWindowManager->changeCell( mCurrentCell ); + MWBase::Environment::get().getWindowManager()->changeCell( mCurrentCell ); } void Scene::changeCell (int X, int Y, const ESM::Position& position, bool adjustPlayerPos) @@ -133,7 +133,7 @@ namespace MWWorld mRendering.preCellChange(mCurrentCell); // remove active - mEnvironment.mMechanicsManager->removeActor (mWorld->getPlayer().getPlayer()); + MWBase::Environment::get().getMechanicsManager()->removeActor (mWorld->getPlayer().getPlayer()); CellStoreCollection::iterator active = mActiveCells.begin(); @@ -207,8 +207,8 @@ namespace MWWorld } //We need the ogre renderer and a scene node. - Scene::Scene (Environment& environment, World *world, MWRender::RenderingManager& rendering, PhysicsSystem *physics) - : mCurrentCell (0), mCellChanged (false), mEnvironment (environment), mWorld(world), + Scene::Scene (World *world, MWRender::RenderingManager& rendering, PhysicsSystem *physics) + : mCurrentCell (0), mCellChanged (false), mWorld(world), mPhysics(physics), mRendering(rendering) { } @@ -243,12 +243,12 @@ namespace MWWorld Ptr::CellStore *cell = mWorld->getInterior(cellName); loadCell (cell); - + // adjust player mCurrentCell = cell; playerCellChange (cell, position); - + // adjust fog mRendering.configureFog(*cell); @@ -278,30 +278,29 @@ namespace MWWorld mCellChanged = false; } -void Scene::insertCell(ESMS::CellStore &cell, - MWWorld::Environment& environment) +void Scene::insertCell(ESMS::CellStore &cell) { // Loop through all references in the cell - insertCellRefList(mRendering, environment, cell.activators, cell, *mPhysics); - insertCellRefList(mRendering, environment, cell.potions, cell, *mPhysics); - insertCellRefList(mRendering, environment, cell.appas, cell, *mPhysics); - insertCellRefList(mRendering, environment, cell.armors, cell, *mPhysics); - insertCellRefList(mRendering, environment, cell.books, cell, *mPhysics); - insertCellRefList(mRendering, environment, cell.clothes, cell, *mPhysics); - insertCellRefList(mRendering, environment, cell.containers, cell, *mPhysics); - insertCellRefList(mRendering, environment, cell.creatures, cell, *mPhysics); - insertCellRefList(mRendering, environment, cell.doors, cell, *mPhysics); - insertCellRefList(mRendering, environment, cell.ingreds, cell, *mPhysics); - insertCellRefList(mRendering, environment, cell.creatureLists, cell, *mPhysics); - insertCellRefList(mRendering, environment, cell.itemLists, cell, *mPhysics); - insertCellRefList(mRendering, environment, cell.lights, cell, *mPhysics); - insertCellRefList(mRendering, environment, cell.lockpicks, cell, *mPhysics); - insertCellRefList(mRendering, environment, cell.miscItems, cell, *mPhysics); - insertCellRefList(mRendering, environment, cell.npcs, cell, *mPhysics); - insertCellRefList(mRendering, environment, cell.probes, cell, *mPhysics); - insertCellRefList(mRendering, environment, cell.repairs, cell, *mPhysics); - insertCellRefList(mRendering, environment, cell.statics, cell, *mPhysics); - insertCellRefList(mRendering, environment, cell.weapons, cell, *mPhysics); + insertCellRefList(mRendering, cell.activators, cell, *mPhysics); + insertCellRefList(mRendering, cell.potions, cell, *mPhysics); + insertCellRefList(mRendering, cell.appas, cell, *mPhysics); + insertCellRefList(mRendering, cell.armors, cell, *mPhysics); + insertCellRefList(mRendering, cell.books, cell, *mPhysics); + insertCellRefList(mRendering, cell.clothes, cell, *mPhysics); + insertCellRefList(mRendering, cell.containers, cell, *mPhysics); + insertCellRefList(mRendering, cell.creatures, cell, *mPhysics); + insertCellRefList(mRendering, cell.doors, cell, *mPhysics); + insertCellRefList(mRendering, cell.ingreds, cell, *mPhysics); + insertCellRefList(mRendering, cell.creatureLists, cell, *mPhysics); + insertCellRefList(mRendering, cell.itemLists, cell, *mPhysics); + insertCellRefList(mRendering, cell.lights, cell, *mPhysics); + insertCellRefList(mRendering, cell.lockpicks, cell, *mPhysics); + insertCellRefList(mRendering, cell.miscItems, cell, *mPhysics); + insertCellRefList(mRendering, cell.npcs, cell, *mPhysics); + insertCellRefList(mRendering, cell.probes, cell, *mPhysics); + insertCellRefList(mRendering, cell.repairs, cell, *mPhysics); + insertCellRefList(mRendering, cell.statics, cell, *mPhysics); + insertCellRefList(mRendering, cell.weapons, cell, *mPhysics); } diff --git a/apps/openmw/mwworld/scene.hpp b/apps/openmw/mwworld/scene.hpp index 4d1bd6fb51..1a9f2f271a 100644 --- a/apps/openmw/mwworld/scene.hpp +++ b/apps/openmw/mwworld/scene.hpp @@ -46,7 +46,6 @@ namespace MWRender namespace MWWorld { - class Environment; class Player; class Scene @@ -62,7 +61,6 @@ namespace MWWorld Ptr::CellStore* mCurrentCell; // the cell, the player is in CellStoreCollection mActiveCells; bool mCellChanged; - Environment& mEnvironment; World *mWorld; PhysicsSystem *mPhysics; MWRender::RenderingManager& mRendering; @@ -73,7 +71,7 @@ namespace MWWorld public: - Scene (Environment& environment, World *world, MWRender::RenderingManager& rendering, PhysicsSystem *physics); + Scene (World *world, MWRender::RenderingManager& rendering, PhysicsSystem *physics); ~Scene(); @@ -100,7 +98,7 @@ namespace MWWorld void markCellAsUnchanged(); - void insertCell(ESMS::CellStore &cell, MWWorld::Environment& environment); + void insertCell(ESMS::CellStore &cell); void update (float duration); }; diff --git a/apps/openmw/mwworld/weather.cpp b/apps/openmw/mwworld/weather.cpp index fb0480171d..803fce1e11 100644 --- a/apps/openmw/mwworld/weather.cpp +++ b/apps/openmw/mwworld/weather.cpp @@ -9,7 +9,9 @@ #include #include -#include +#include + +#include "../mwbase/environment.hpp" using namespace Ogre; using namespace MWWorld; @@ -34,15 +36,14 @@ const float WeatherGlobals::mThunderFrequency = .4; const float WeatherGlobals::mThunderThreshold = 0.6; const float WeatherGlobals::mThunderSoundDelay = 0.25; -WeatherManager::WeatherManager(MWRender::RenderingManager* rendering, MWWorld::Environment* env) : +WeatherManager::WeatherManager(MWRender::RenderingManager* rendering) : mHour(14), mCurrentWeather("clear"), mFirstUpdate(true), mWeatherUpdateTime(0), mThunderFlash(0), mThunderChance(0), mThunderChanceNeeded(50), mThunderSoundDelay(0) { mRendering = rendering; - mEnvironment = env; - + #define clr(r,g,b) ColourValue(r/255.f, g/255.f, b/255.f) - + /// \todo read these from Morrowind.ini Weather clear; clear.mCloudTexture = "tx_sky_clear.dds"; @@ -71,7 +72,7 @@ WeatherManager::WeatherManager(MWRender::RenderingManager* rendering, MWWorld::E clear.mCloudSpeed = 1.25; clear.mGlareView = 1.0; mWeatherSettings["clear"] = clear; - + Weather cloudy; cloudy.mCloudTexture = "tx_sky_cloudy.dds"; cloudy.mCloudsMaximumPercent = 1.0; @@ -99,7 +100,7 @@ WeatherManager::WeatherManager(MWRender::RenderingManager* rendering, MWWorld::E cloudy.mCloudSpeed = 2; cloudy.mGlareView = 1.0; mWeatherSettings["cloudy"] = cloudy; - + Weather foggy; foggy.mCloudTexture = "tx_sky_foggy.dds"; foggy.mCloudsMaximumPercent = 1.0; @@ -127,7 +128,7 @@ WeatherManager::WeatherManager(MWRender::RenderingManager* rendering, MWWorld::E foggy.mCloudSpeed = 1.25; foggy.mGlareView = 0.25; mWeatherSettings["foggy"] = foggy; - + Weather thunderstorm; thunderstorm.mCloudTexture = "tx_sky_thunder.dds"; thunderstorm.mCloudsMaximumPercent = 0.66; @@ -156,7 +157,7 @@ WeatherManager::WeatherManager(MWRender::RenderingManager* rendering, MWWorld::E thunderstorm.mGlareView = 0; thunderstorm.mRainLoopSoundID = "rain heavy"; mWeatherSettings["thunderstorm"] = thunderstorm; - + Weather rain; rain.mCloudTexture = "tx_sky_rainy.dds"; rain.mCloudsMaximumPercent = 0.66; @@ -185,7 +186,7 @@ WeatherManager::WeatherManager(MWRender::RenderingManager* rendering, MWWorld::E rain.mGlareView = 0; rain.mRainLoopSoundID = "rain"; mWeatherSettings["rain"] = rain; - + Weather overcast; overcast.mCloudTexture = "tx_sky_overcast.dds"; overcast.mCloudsMaximumPercent = 1.0; @@ -213,7 +214,7 @@ WeatherManager::WeatherManager(MWRender::RenderingManager* rendering, MWWorld::E overcast.mCloudSpeed = 1.5; overcast.mGlareView = 0; mWeatherSettings["overcast"] = overcast; - + Weather ashstorm; ashstorm.mCloudTexture = "tx_sky_ashstorm.dds"; ashstorm.mCloudsMaximumPercent = 1.0; @@ -242,7 +243,7 @@ WeatherManager::WeatherManager(MWRender::RenderingManager* rendering, MWWorld::E ashstorm.mGlareView = 0; ashstorm.mAmbientLoopSoundID = "ashstorm"; mWeatherSettings["ashstorm"] = ashstorm; - + Weather blight; blight.mCloudTexture = "tx_sky_blight.dds"; blight.mCloudsMaximumPercent = 1.0; @@ -300,7 +301,7 @@ WeatherManager::WeatherManager(MWRender::RenderingManager* rendering, MWWorld::E snow.mCloudSpeed = 1.5; snow.mGlareView = 0; mWeatherSettings["snow"] = snow; - + Weather blizzard; blizzard.mCloudTexture = "tx_bm_sky_blizzard.dds"; blizzard.mCloudsMaximumPercent = 1.0; @@ -484,15 +485,15 @@ WeatherResult WeatherManager::transition(float factor) void WeatherManager::update(float duration) { - mWeatherUpdateTime -= duration * mEnvironment->mWorld->getTimeScaleFactor(); + mWeatherUpdateTime -= duration * MWBase::Environment::get().getWorld()->getTimeScaleFactor(); - bool exterior = (mEnvironment->mWorld->isCellExterior() || mEnvironment->mWorld->isCellQuasiExterior()); + bool exterior = (MWBase::Environment::get().getWorld()->isCellExterior() || MWBase::Environment::get().getWorld()->isCellQuasiExterior()); if (exterior) { - std::string regionstr = mEnvironment->mWorld->getPlayer().getPlayer().getCell()->cell->region; + std::string regionstr = MWBase::Environment::get().getWorld()->getPlayer().getPlayer().getCell()->cell->region; boost::algorithm::to_lower(regionstr); - + if (mWeatherUpdateTime <= 0 || regionstr != mCurrentRegion) { mCurrentRegion = regionstr; @@ -505,7 +506,7 @@ void WeatherManager::update(float duration) else { // get weather probabilities for the current region - const ESM::Region *region = mEnvironment->mWorld->getStore().regions.find (regionstr); + const ESM::Region *region = MWBase::Environment::get().getWorld()->getStore().regions.find (regionstr); float clear = region->data.clear/255.f; float cloudy = region->data.cloudy/255.f; @@ -553,7 +554,7 @@ void WeatherManager::update(float duration) if (mNextWeather != "") { - mRemainingTransitionTime -= duration * mEnvironment->mWorld->getTimeScaleFactor(); + mRemainingTransitionTime -= duration * MWBase::Environment::get().getWorld()->getTimeScaleFactor(); if (mRemainingTransitionTime < 0) { mCurrentWeather = mNextWeather; @@ -588,8 +589,8 @@ void WeatherManager::update(float duration) int facing = (mHour > 13.f) ? 1 : -1; Vector3 final( - -(1-height)*facing, - -(1-height)*facing, + -(1-height)*facing, + -(1-height)*facing, height); mRendering->setSunDirection(final); @@ -609,13 +610,13 @@ void WeatherManager::update(float duration) float moonHeight = 1-std::abs((night-0.5)*2); int facing = (mHour > 0.f && mHour<12.f) ? 1 : -1; Vector3 masser( - (1-moonHeight)*facing, - (1-moonHeight)*facing, + (1-moonHeight)*facing, + (1-moonHeight)*facing, moonHeight); Vector3 secunda( - (1-moonHeight)*facing*0.8, - (1-moonHeight)*facing*1.25, + (1-moonHeight)*facing*0.8, + (1-moonHeight)*facing*1.25, moonHeight); mRendering->getSkyManager()->setMasserDirection(masser); @@ -676,7 +677,7 @@ void WeatherManager::update(float duration) else if (sound == 1) soundname = WeatherGlobals::mThunderSoundID1; else if (sound == 2) soundname = WeatherGlobals::mThunderSoundID2; else if (sound == 3) soundname = WeatherGlobals::mThunderSoundID3; - mEnvironment->mSoundManager->playSound(soundname, 1.0, 1.0); + MWBase::Environment::get().getSoundManager()->playSound(soundname, 1.0, 1.0); mThunderSoundDelay = 1000; } @@ -729,7 +730,7 @@ void WeatherManager::update(float duration) if (std::find(mSoundsPlaying.begin(), mSoundsPlaying.end(), ambientSnd) == mSoundsPlaying.end()) { mSoundsPlaying.push_back(ambientSnd); - mEnvironment->mSoundManager->playSound(ambientSnd, 1.0, 1.0, true); + MWBase::Environment::get().getSoundManager()->playSound(ambientSnd, 1.0, 1.0, true); } } @@ -740,7 +741,7 @@ void WeatherManager::update(float duration) if (std::find(mSoundsPlaying.begin(), mSoundsPlaying.end(), rainSnd) == mSoundsPlaying.end()) { mSoundsPlaying.push_back(rainSnd); - mEnvironment->mSoundManager->playSound(rainSnd, 1.0, 1.0, true); + MWBase::Environment::get().getSoundManager()->playSound(rainSnd, 1.0, 1.0, true); } } @@ -750,7 +751,7 @@ void WeatherManager::update(float duration) { if ( *it != ambientSnd && *it != rainSnd) { - mEnvironment->mSoundManager->stopSound(*it); + MWBase::Environment::get().getSoundManager()->stopSound(*it); it = mSoundsPlaying.erase(it); } else @@ -772,7 +773,7 @@ void WeatherManager::setDate(const int day, const int month) unsigned int WeatherManager::getWeatherID() const { // Source: http://www.uesp.net/wiki/Tes3Mod:GetCurrentWeather - + if (mCurrentWeather == "clear") return 0; else if (mCurrentWeather == "cloudy") @@ -793,7 +794,7 @@ unsigned int WeatherManager::getWeatherID() const return 8; else if (mCurrentWeather == "blizzard") return 9; - + else return 0; } diff --git a/apps/openmw/mwworld/weather.hpp b/apps/openmw/mwworld/weather.hpp index b9b40e6fad..5e0388751f 100644 --- a/apps/openmw/mwworld/weather.hpp +++ b/apps/openmw/mwworld/weather.hpp @@ -11,8 +11,6 @@ namespace MWRender namespace MWWorld { - class Environment; - /// Global weather manager properties (according to INI) struct WeatherGlobals { @@ -67,8 +65,8 @@ namespace MWWorld Snow Gravity Scale=0.1 Snow High Kill=700 Snow Low Kill=150 - - + + [Moons] Masser Size=94 Masser Fade In Start=14 @@ -94,14 +92,14 @@ namespace MWWorld Secunda Moon Shadow Early Fade Angle=0.5 Script Color=255,20,20 */ - + static const float mSunriseTime; static const float mSunsetTime; static const float mSunriseDuration; static const float mSunsetDuration; - + static const float mWeatherUpdateTime; - + // morrowind sets these per-weather, but since they are only used by 'thunderstorm' // weather setting anyway, we can just as well set them globally static const float mThunderFrequency; @@ -119,154 +117,153 @@ namespace MWWorld Ogre::String mCloudTexture; Ogre::String mNextCloudTexture; float mCloudBlendFactor; - + Ogre::ColourValue mFogColor; - + Ogre::ColourValue mAmbientColor; - + Ogre::ColourValue mSkyColor; - + Ogre::ColourValue mSunColor; - + Ogre::ColourValue mSunDiscColor; - + float mFogDepth; - + float mWindSpeed; - + float mCloudSpeed; - + float mCloudOpacity; - + float mGlareView; - + bool mNight; // use night skybox float mNightFade; // fading factor for night skybox - + Ogre::String mAmbientLoopSoundID; }; - - + + /// Defines a single weather setting (according to INI) struct Weather { Ogre::String mCloudTexture; - - // Sky (atmosphere) colors + + // Sky (atmosphere) colors Ogre::ColourValue mSkySunriseColor, mSkyDayColor, mSkySunsetColor, mSkyNightColor; - + // Fog colors Ogre::ColourValue mFogSunriseColor, mFogDayColor, mFogSunsetColor, mFogNightColor; - + // Ambient lighting colors Ogre::ColourValue mAmbientSunriseColor, mAmbientDayColor, mAmbientSunsetColor, mAmbientNightColor; - + // Sun (directional) lighting colors Ogre::ColourValue mSunSunriseColor, mSunDayColor, mSunSunsetColor, mSunNightColor; - + // Fog depth/density float mLandFogDayDepth, mLandFogNightDepth; - + // Color modulation for the sun itself during sunset (not completely sure) Ogre::ColourValue mSunDiscSunsetColor; - + // Duration of weather transition (in days) float mTransitionDelta; - + // No idea what this one is used for? float mWindSpeed; - + // Cloud animation speed multiplier float mCloudSpeed; - + // Multiplier for clouds transparency float mCloudsMaximumPercent; - + // Value between 0 and 1, defines the strength of the sun glare effect float mGlareView; - + // Sound effect // This is used for Blight, Ashstorm and Blizzard (Bloodmoon) Ogre::String mAmbientLoopSoundID; - + // Rain sound effect Ogre::String mRainLoopSoundID; - + /// \todo disease chance }; - + /// /// Interface for weather settings /// class WeatherManager { public: - WeatherManager(MWRender::RenderingManager*, MWWorld::Environment*); - + WeatherManager(MWRender::RenderingManager*); + /** * Change the weather in the specified region * @param region that should be changed * @param ID of the weather setting to shift to */ void changeWeather(const std::string& region, const unsigned int id); - + /** * Per-frame update * @param duration */ void update(float duration); - + void setHour(const float hour); - + void setDate(const int day, const int month); - + unsigned int getWeatherID() const; - + private: float mHour; int mDay, mMonth; - + MWRender::RenderingManager* mRendering; - MWWorld::Environment* mEnvironment; - + std::map mWeatherSettings; std::map mRegionOverrides; std::vector mSoundsPlaying; - + Ogre::String mCurrentWeather; Ogre::String mNextWeather; - + std::string mCurrentRegion; - + bool mFirstUpdate; - + float mWeatherUpdateTime; - + float mRemainingTransitionTime; - + float mThunderFlash; float mThunderChance; float mThunderChanceNeeded; float mThunderSoundDelay; - + WeatherResult transition(const float factor); WeatherResult getResult(const Ogre::String& weather); - + void setWeather(const Ogre::String& weather, bool instant=false); }; } diff --git a/apps/openmw/mwworld/world.cpp b/apps/openmw/mwworld/world.cpp index 1c64039d4c..66eedcb845 100644 --- a/apps/openmw/mwworld/world.cpp +++ b/apps/openmw/mwworld/world.cpp @@ -6,6 +6,8 @@ #include #include +#include "../mwbase/environment.hpp" + #include "../mwrender/sky.hpp" #include "../mwrender/player.hpp" @@ -15,7 +17,6 @@ #include "ptr.hpp" -#include "environment.hpp" #include "class.hpp" #include "player.hpp" #include "weather.hpp" @@ -174,18 +175,18 @@ namespace MWWorld World::World (OEngine::Render::OgreRenderer& renderer, const Files::Collections& fileCollections, - const std::string& master, const boost::filesystem::path& resDir, - bool newGame, Environment& environment, const std::string& encoding, std::map fallbackMap) + const std::string& master, const boost::filesystem::path& resDir, bool newGame, + const std::string& encoding, std::map fallbackMap) : mPlayer (0), mLocalScripts (mStore), mGlobalVariables (0), - mSky (true), mEnvironment (environment), mNextDynamicRecord (0), mCells (mStore, mEsm, *this), + mSky (true), mNextDynamicRecord (0), mCells (mStore, mEsm, *this), mNumFacing(0) { mPhysics = new PhysicsSystem(renderer); mPhysEngine = mPhysics->getEngine(); - mRendering = new MWRender::RenderingManager(renderer, resDir, mPhysEngine, environment); + mRendering = new MWRender::RenderingManager(renderer, resDir, mPhysEngine); - mWeatherManager = new MWWorld::WeatherManager(mRendering, &environment); + mWeatherManager = new MWWorld::WeatherManager(mRendering); boost::filesystem::path masterPath (fileCollections.getCollection (".esm").getPath (master)); @@ -209,7 +210,7 @@ namespace MWWorld mGlobalVariables->setInt ("chargenstate", 1); } - mWorldScene = new Scene(environment, this, *mRendering, mPhysics); + mWorldScene = new Scene(this, *mRendering, mPhysics); setFallbackValues(fallbackMap); @@ -357,7 +358,7 @@ namespace MWWorld //render->enable (reference.getRefData().getHandle()); if(mWorldScene->getActiveCells().find (reference.getCell()) != mWorldScene->getActiveCells().end()) - Class::get (reference).enable (reference, mEnvironment); + Class::get (reference).enable (reference); } @@ -372,8 +373,8 @@ namespace MWWorld //render->disable (reference.getRefData().getHandle()); if(mWorldScene->getActiveCells().find (reference.getCell())!=mWorldScene->getActiveCells().end()){ - Class::get (reference).disable (reference, mEnvironment); - mEnvironment.mSoundManager->stopSound3D (reference); + Class::get (reference).disable (reference); + MWBase::Environment::get().getSoundManager()->stopSound3D (reference); } @@ -547,7 +548,7 @@ namespace MWWorld if (mWorldScene->getActiveCells().find (ptr.getCell())!=mWorldScene->getActiveCells().end()){ // Class::get (ptr).disable (ptr, mEnvironment); /// \todo this line needs to be removed - mEnvironment.mSoundManager->stopSound3D (ptr); + MWBase::Environment::get().getSoundManager()->stopSound3D (ptr); mPhysics->removeObject (ptr.getRefData().getHandle()); mRendering->removeObject(ptr); diff --git a/apps/openmw/mwworld/world.hpp b/apps/openmw/mwworld/world.hpp index 8dd370ad76..77e5bcef62 100644 --- a/apps/openmw/mwworld/world.hpp +++ b/apps/openmw/mwworld/world.hpp @@ -51,7 +51,6 @@ namespace MWRender namespace MWWorld { class WeatherManager; - class Environment; class Player; /// \brief The game world and its visual representation @@ -81,7 +80,6 @@ namespace MWWorld MWWorld::Globals *mGlobalVariables; MWWorld::PhysicsSystem *mPhysics; bool mSky; - Environment& mEnvironment; int mNextDynamicRecord; Cells mCells; @@ -111,7 +109,7 @@ namespace MWWorld World (OEngine::Render::OgreRenderer& renderer, const Files::Collections& fileCollections, const std::string& master, const boost::filesystem::path& resDir, bool newGame, - Environment& environment, const std::string& encoding, std::map fallbackMap); + const std::string& encoding, std::map fallbackMap); ~World();