Commit 4c39fefd authored by Marc Zinnschlag's avatar Marc Zinnschlag

Issue #107: World is accessed only through the interface class from now on; some include cleanup

parent 035c1c4b
......@@ -47,7 +47,7 @@ add_openmw_dir (mwsound
)
add_openmw_dir (mwworld
refdata world physicssystem scene globals class action nullaction actionteleport
refdata worldimp physicssystem scene globals class action nullaction actionteleport
containerstore actiontalk actiontake manualref player cellfunctors
cells localscripts customdata weather inventorystore ptr actionopen actionread
actionequip timestamp actionalchemy cellstore
......
......@@ -38,10 +38,10 @@
#include "mwsound/soundmanager.hpp"
#include "mwworld/world.hpp"
#include "mwworld/class.hpp"
#include "mwworld/player.hpp"
#include "mwworld/cellstore.hpp"
#include "mwworld/worldimp.hpp"
#include "mwclass/classes.hpp"
......@@ -51,6 +51,7 @@
#include "mwmechanics/mechanicsmanager.hpp"
#include "mwbase/environment.hpp"
#include "mwbase/world.hpp"
void OMW::Engine::executeLocalScripts()
......
......@@ -9,13 +9,13 @@
#include "../mwsound/soundmanager.hpp"
#include "../mwworld/world.hpp"
#include "../mwdialogue/dialoguemanager.hpp"
#include "../mwdialogue/journal.hpp"
#include "../mwmechanics/mechanicsmanager.hpp"
#include "world.hpp"
MWBase::Environment *MWBase::Environment::sThis = 0;
MWBase::Environment::Environment()
......@@ -32,7 +32,7 @@ MWBase::Environment::~Environment()
sThis = 0;
}
void MWBase::Environment::setWorld (MWWorld::World *world)
void MWBase::Environment::setWorld (World *world)
{
mWorld = world;
}
......@@ -77,7 +77,7 @@ void MWBase::Environment::setFrameDuration (float duration)
mFrameDuration = duration;
}
MWWorld::World *MWBase::Environment::getWorld() const
MWBase::World *MWBase::Environment::getWorld() const
{
assert (mWorld);
return mWorld;
......
......@@ -32,13 +32,10 @@ namespace MWInput
struct MWInputManager;
}
namespace MWWorld
namespace MWBase
{
class World;
}
namespace MWBase
{
/// \brief Central hub for mw-subsystems
///
/// This class allows each mw-subsystem to access any others subsystem's top-level manager class.
......@@ -49,7 +46,7 @@ namespace MWBase
{
static Environment *sThis;
MWWorld::World *mWorld;
World *mWorld;
MWSound::SoundManager *mSoundManager;
MWScript::ScriptManager *mScriptManager;
MWGui::WindowManager *mWindowManager;
......@@ -71,7 +68,7 @@ namespace MWBase
~Environment();
void setWorld (MWWorld::World *world);
void setWorld (World *world);
void setSoundManager (MWSound::SoundManager *soundManager);
......@@ -90,7 +87,7 @@ namespace MWBase
void setFrameDuration (float duration);
///< Set length of current frame in seconds.
MWWorld::World *getWorld() const;
World *getWorld() const;
MWSound::SoundManager *getSoundManager() const;
......
......@@ -4,11 +4,11 @@
#include <components/esm/loadappa.hpp>
#include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp"
#include "../mwworld/ptr.hpp"
#include "../mwworld/actiontake.hpp"
#include "../mwworld/actionalchemy.hpp"
#include "../mwworld/world.hpp"
#include "../mwworld/cellstore.hpp"
#include "../mwrender/objects.hpp"
......
......@@ -5,15 +5,15 @@
#include <components/esm/loadskil.hpp>
#include <components/esm/loadgmst.hpp>
#include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp"
#include "../mwworld/ptr.hpp"
#include "../mwworld/actiontake.hpp"
#include "../mwworld/actionequip.hpp"
#include "../mwworld/inventorystore.hpp"
#include "../mwworld/world.hpp"
#include "../mwworld/cellstore.hpp"
#include "../mwbase/environment.hpp"
#include "../mwrender/objects.hpp"
#include "../mwgui/window_manager.hpp"
......
......@@ -4,10 +4,10 @@
#include <components/esm/loadbook.hpp>
#include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp"
#include "../mwworld/ptr.hpp"
#include "../mwworld/actionread.hpp"
#include "../mwworld/world.hpp"
#include "../mwworld/cellstore.hpp"
#include "../mwrender/objects.hpp"
......
......@@ -4,12 +4,12 @@
#include <components/esm/loadclot.hpp>
#include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp"
#include "../mwworld/ptr.hpp"
#include "../mwworld/actiontake.hpp"
#include "../mwworld/actionequip.hpp"
#include "../mwworld/inventorystore.hpp"
#include "../mwworld/world.hpp"
#include "../mwworld/cellstore.hpp"
#include "../mwgui/tooltips.hpp"
......
......@@ -4,12 +4,12 @@
#include <components/esm/loadcont.hpp>
#include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp"
#include "../mwworld/ptr.hpp"
#include "../mwworld/nullaction.hpp"
#include "../mwworld/containerstore.hpp"
#include "../mwworld/customdata.hpp"
#include "../mwworld/world.hpp"
#include "../mwworld/cellstore.hpp"
#include "../mwgui/window_manager.hpp"
......
......@@ -4,12 +4,12 @@
#include <components/esm/loaddoor.hpp>
#include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp"
#include "../mwworld/player.hpp"
#include "../mwworld/ptr.hpp"
#include "../mwworld/nullaction.hpp"
#include "../mwworld/actionteleport.hpp"
#include "../mwworld/world.hpp"
#include "../mwworld/cellstore.hpp"
#include "../mwgui/window_manager.hpp"
......
......@@ -4,10 +4,10 @@
#include <components/esm/loadingr.hpp>
#include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp"
#include "../mwworld/ptr.hpp"
#include "../mwworld/actiontake.hpp"
#include "../mwworld/world.hpp"
#include "../mwworld/cellstore.hpp"
#include "../mwgui/window_manager.hpp"
......
......@@ -4,13 +4,13 @@
#include <components/esm/loadligh.hpp>
#include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp"
#include "../mwworld/ptr.hpp"
#include "../mwworld/actiontake.hpp"
#include "../mwworld/actionequip.hpp"
#include "../mwworld/nullaction.hpp"
#include "../mwworld/inventorystore.hpp"
#include "../mwworld/world.hpp"
#include "../mwworld/cellstore.hpp"
#include "../mwgui/window_manager.hpp"
......
......@@ -4,12 +4,12 @@
#include <components/esm/loadlocks.hpp>
#include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp"
#include "../mwworld/ptr.hpp"
#include "../mwworld/actiontake.hpp"
#include "../mwworld/actionequip.hpp"
#include "../mwworld/inventorystore.hpp"
#include "../mwworld/world.hpp"
#include "../mwworld/cellstore.hpp"
#include "../mwgui/window_manager.hpp"
......
......@@ -6,10 +6,10 @@
#include <components/esm/loadmisc.hpp>
#include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp"
#include "../mwworld/ptr.hpp"
#include "../mwworld/actiontake.hpp"
#include "../mwworld/world.hpp"
#include "../mwworld/cellstore.hpp"
#include "../mwgui/window_manager.hpp"
......
......@@ -9,6 +9,9 @@
#include <components/esm/loadnpc.hpp>
#include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp"
#include "../mwmechanics/creaturestats.hpp"
#include "../mwmechanics/npcstats.hpp"
#include "../mwmechanics/movement.hpp"
......@@ -16,13 +19,12 @@
#include "../mwworld/ptr.hpp"
#include "../mwworld/actiontalk.hpp"
#include "../mwworld/world.hpp"
#include "../mwworld/inventorystore.hpp"
#include "../mwworld/customdata.hpp"
#include "../mwgui/window_manager.hpp"
#include "../mwrender/actors.hpp"
#include "../mwbase/environment.hpp"
#include "../mwgui/window_manager.hpp"
namespace
{
......
......@@ -4,10 +4,10 @@
#include <components/esm/loadalch.hpp>
#include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp"
#include "../mwworld/ptr.hpp"
#include "../mwworld/actiontake.hpp"
#include "../mwworld/world.hpp"
#include "../mwworld/cellstore.hpp"
#include "../mwgui/window_manager.hpp"
......
......@@ -4,12 +4,12 @@
#include <components/esm/loadlocks.hpp>
#include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp"
#include "../mwworld/ptr.hpp"
#include "../mwworld/actiontake.hpp"
#include "../mwworld/actionequip.hpp"
#include "../mwworld/inventorystore.hpp"
#include "../mwworld/world.hpp"
#include "../mwworld/cellstore.hpp"
#include "../mwgui/window_manager.hpp"
......
......@@ -4,10 +4,10 @@
#include <components/esm/loadlocks.hpp>
#include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp"
#include "../mwworld/ptr.hpp"
#include "../mwworld/actiontake.hpp"
#include "../mwworld/world.hpp"
#include "../mwworld/cellstore.hpp"
#include "../mwgui/window_manager.hpp"
......
......@@ -4,12 +4,12 @@
#include <components/esm/loadweap.hpp>
#include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp"
#include "../mwworld/ptr.hpp"
#include "../mwworld/actiontake.hpp"
#include "../mwworld/actionequip.hpp"
#include "../mwworld/inventorystore.hpp"
#include "../mwworld/world.hpp"
#include "../mwworld/cellstore.hpp"
#include "../mwgui/window_manager.hpp"
......
......@@ -10,9 +10,9 @@
#include <components/esm_store/store.hpp>
#include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp"
#include "../mwworld/class.hpp"
#include "../mwworld/world.hpp"
#include "../mwworld/refdata.hpp"
#include "../mwworld/player.hpp"
#include "../mwworld/containerstore.hpp"
......@@ -121,24 +121,24 @@ namespace
}
template<typename T>
bool checkGlobal (char comp, const std::string& name, T value, MWWorld::World& world)
bool checkGlobal (char comp, const std::string& name, T value)
{
switch (world.getGlobalVariableType (name))
switch (MWBase::Environment::get().getWorld()->getGlobalVariableType (name))
{
case 's':
return selectCompare (comp, world.getGlobalVariable (name).mShort, value);
return selectCompare (comp, MWBase::Environment::get().getWorld()->getGlobalVariable (name).mShort, value);
case 'l':
return selectCompare (comp, world.getGlobalVariable (name).mLong, value);
return selectCompare (comp, MWBase::Environment::get().getWorld()->getGlobalVariable (name).mLong, value);
case 'f':
return selectCompare (comp, world.getGlobalVariable (name).mFloat, value);
return selectCompare (comp, MWBase::Environment::get().getWorld()->getGlobalVariable (name).mFloat, value);
case ' ':
world.getGlobalVariable (name); // trigger exception
MWBase::Environment::get().getWorld()->getGlobalVariable (name); // trigger exception
break;
default:
......@@ -309,12 +309,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, *MWBase::Environment::get().getWorld()))
if (!checkGlobal (comp, toLower (name), select.i))
return false;
}
else if (select.type==ESM::VT_Float)
{
if (!checkGlobal (comp, toLower (name), select.f, *MWBase::Environment::get().getWorld()))
if (!checkGlobal (comp, toLower (name), select.f))
return false;
}
else
......
......@@ -2,12 +2,11 @@
#include "journal.hpp"
#include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp"
#include "../mwgui/window_manager.hpp"
#include "../mwgui/messagebox.hpp"
#include "../mwworld/world.hpp"
namespace MWDialogue
{
Quest& Journal::getQuest (const std::string& id)
......@@ -30,14 +29,13 @@ namespace MWDialogue
void Journal::addEntry (const std::string& id, int index)
{
StampedJournalEntry entry =
StampedJournalEntry::makeFromQuest (id, index, *MWBase::Environment::get().getWorld());
StampedJournalEntry entry = StampedJournalEntry::makeFromQuest (id, index);
mJournal.push_back (entry);
Quest& quest = getQuest (id);
quest.addEntry (entry, *MWBase::Environment::get().getWorld()); // we are doing slicing on purpose here
quest.addEntry (entry); // we are doing slicing on purpose here
std::vector<std::string> empty;
std::string notification = MWBase::Environment::get().getWorld()->getStore().gameSettings.search("sJournalEntry")->str;
......@@ -48,7 +46,7 @@ namespace MWDialogue
{
Quest& quest = getQuest (id);
quest.setIndex (index, *MWBase::Environment::get().getWorld());
quest.setIndex (index);
}
void Journal::addTopic (const std::string& topicId, const std::string& infoId)
......@@ -63,7 +61,7 @@ namespace MWDialogue
iter = result.first;
}
iter->second.addEntry (JournalEntry (topicId, infoId), *MWBase::Environment::get().getWorld());
iter->second.addEntry (JournalEntry (topicId, infoId));
}
int Journal::getJournalIndex (const std::string& id) const
......
......@@ -5,7 +5,8 @@
#include <components/esm_store/store.hpp>
#include "../mwworld/world.hpp"
#include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp"
namespace MWDialogue
{
......@@ -27,16 +28,14 @@ namespace MWDialogue
throw std::runtime_error ("unknown info ID " + mInfoId + " for topic " + mTopic);
}
JournalEntry JournalEntry::makeFromQuest (const std::string& topic, int index,
const MWWorld::World& world)
JournalEntry JournalEntry::makeFromQuest (const std::string& topic, int index)
{
return JournalEntry (topic, idFromIndex (topic, index, world));
return JournalEntry (topic, idFromIndex (topic, index));
}
std::string JournalEntry::idFromIndex (const std::string& topic, int index,
const MWWorld::World& world)
std::string JournalEntry::idFromIndex (const std::string& topic, int index)
{
const ESM::Dialogue *dialogue = world.getStore().dialogs.find (topic);
const ESM::Dialogue *dialogue = MWBase::Environment::get().getWorld()->getStore().dialogs.find (topic);
for (std::vector<ESM::DialInfo>::const_iterator iter (dialogue->mInfo.begin());
iter!=dialogue->mInfo.end(); ++iter)
......@@ -57,13 +56,12 @@ namespace MWDialogue
: JournalEntry (topic, infoId), mDay (day), mMonth (month), mDayOfMonth (dayOfMonth)
{}
StampedJournalEntry StampedJournalEntry::makeFromQuest (const std::string& topic, int index,
const MWWorld::World& world)
StampedJournalEntry StampedJournalEntry::makeFromQuest (const std::string& topic, int index)
{
int day = world.getGlobalVariable ("dayspassed").mLong;
int month = world.getGlobalVariable ("day").mLong;
int dayOfMonth = world.getGlobalVariable ("month").mLong;
int day = MWBase::Environment::get().getWorld()->getGlobalVariable ("dayspassed").mLong;
int month = MWBase::Environment::get().getWorld()->getGlobalVariable ("day").mLong;
int dayOfMonth = MWBase::Environment::get().getWorld()->getGlobalVariable ("month").mLong;
return StampedJournalEntry (topic, idFromIndex (topic, index, world), day, month, dayOfMonth);
return StampedJournalEntry (topic, idFromIndex (topic, index), day, month, dayOfMonth);
}
}
......@@ -8,11 +8,6 @@ namespace ESMS
struct ESMStore;
}
namespace MWWorld
{
class World;
}
namespace MWDialogue
{
/// \brief A quest or dialogue entry
......@@ -27,11 +22,9 @@ namespace MWDialogue
std::string getText (const ESMS::ESMStore& store) const;
static JournalEntry makeFromQuest (const std::string& topic, int index,
const MWWorld::World& world);
static JournalEntry makeFromQuest (const std::string& topic, int index);
static std::string idFromIndex (const std::string& topic, int index,
const MWWorld::World& world);
static std::string idFromIndex (const std::string& topic, int index);
};
/// \biref A quest entry with a timestamp.
......@@ -46,8 +39,7 @@ namespace MWDialogue
StampedJournalEntry (const std::string& topic, const std::string& infoId,
int day, int month, int dayOfMonth);
static StampedJournalEntry makeFromQuest (const std::string& topic, int index,
const MWWorld::World& world);
static StampedJournalEntry makeFromQuest (const std::string& topic, int index);
};
}
......
......@@ -3,7 +3,8 @@
#include <components/esm_store/store.hpp>
#include "../mwworld/world.hpp"
#include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp"
namespace MWDialogue
{
......@@ -15,9 +16,9 @@ namespace MWDialogue
: Topic (topic), mIndex (0), mFinished (false)
{}
const std::string Quest::getName (const MWWorld::World& world) const
const std::string Quest::getName() const
{
const ESM::Dialogue *dialogue = world.getStore().dialogs.find (mTopic);
const ESM::Dialogue *dialogue = MWBase::Environment::get().getWorld()->getStore().dialogs.find (mTopic);
for (std::vector<ESM::DialInfo>::const_iterator iter (dialogue->mInfo.begin());
iter!=dialogue->mInfo.end(); ++iter)
......@@ -32,9 +33,9 @@ namespace MWDialogue
return mIndex;
}
void Quest::setIndex (int index, const MWWorld::World& world)
void Quest::setIndex (int index)
{
const ESM::Dialogue *dialogue = world.getStore().dialogs.find (mTopic);
const ESM::Dialogue *dialogue = MWBase::Environment::get().getWorld()->getStore().dialogs.find (mTopic);
for (std::vector<ESM::DialInfo>::const_iterator iter (dialogue->mInfo.begin());
iter!=dialogue->mInfo.end(); ++iter)
......@@ -58,11 +59,11 @@ namespace MWDialogue
return mFinished;
}
void Quest::addEntry (const JournalEntry& entry, const MWWorld::World& world)
void Quest::addEntry (const JournalEntry& entry)
{
int index = -1;
const ESM::Dialogue *dialogue = world.getStore().dialogs.find (entry.mTopic);
const ESM::Dialogue *dialogue = MWBase::Environment::get().getWorld()->getStore().dialogs.find (entry.mTopic);
for (std::vector<ESM::DialInfo>::const_iterator iter (dialogue->mInfo.begin());
iter!=dialogue->mInfo.end(); ++iter)
......@@ -75,7 +76,7 @@ namespace MWDialogue
if (index==-1)
throw std::runtime_error ("unknown journal entry for topic " + mTopic);
setIndex (index, world);
setIndex (index);
for (TEntryIter iter (mEntries.begin()); iter!=mEntries.end(); ++iter)
if (*iter==entry.mInfoId)
......
......@@ -17,17 +17,17 @@ namespace MWDialogue
Quest (const std::string& topic);
const std::string getName (const MWWorld::World& world) const;
const std::string getName() const;
///< May be an empty string