|
|
|
@ -56,9 +56,74 @@ namespace MWWorld
|
|
|
|
|
listCellScripts (mStore, cell.weapons, mLocalScripts);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Ptr World::getPtr (const std::string& name, CellStore& cell)
|
|
|
|
|
{
|
|
|
|
|
if (ESMS::LiveCellRef<ESM::Activator, RefData> *ref = cell.activators.find (name))
|
|
|
|
|
return ref;
|
|
|
|
|
|
|
|
|
|
if (ESMS::LiveCellRef<ESM::Potion, RefData> *ref = cell.potions.find (name))
|
|
|
|
|
return ref;
|
|
|
|
|
|
|
|
|
|
if (ESMS::LiveCellRef<ESM::Apparatus, RefData> *ref = cell.appas.find (name))
|
|
|
|
|
return ref;
|
|
|
|
|
|
|
|
|
|
if (ESMS::LiveCellRef<ESM::Armor, RefData> *ref = cell.armors.find (name))
|
|
|
|
|
return ref;
|
|
|
|
|
|
|
|
|
|
if (ESMS::LiveCellRef<ESM::Book, RefData> *ref = cell.books.find (name))
|
|
|
|
|
return ref;
|
|
|
|
|
|
|
|
|
|
if (ESMS::LiveCellRef<ESM::Clothing, RefData> *ref = cell.clothes.find (name))
|
|
|
|
|
return ref;
|
|
|
|
|
|
|
|
|
|
if (ESMS::LiveCellRef<ESM::Container, RefData> *ref = cell.containers.find (name))
|
|
|
|
|
return ref;
|
|
|
|
|
|
|
|
|
|
if (ESMS::LiveCellRef<ESM::Creature, RefData> *ref = cell.creatures.find (name))
|
|
|
|
|
return ref;
|
|
|
|
|
|
|
|
|
|
if (ESMS::LiveCellRef<ESM::Door, RefData> *ref = cell.doors.find (name))
|
|
|
|
|
return ref;
|
|
|
|
|
|
|
|
|
|
if (ESMS::LiveCellRef<ESM::Ingredient, RefData> *ref = cell.ingreds.find (name))
|
|
|
|
|
return ref;
|
|
|
|
|
|
|
|
|
|
if (ESMS::LiveCellRef<ESM::CreatureLevList, RefData> *ref = cell.creatureLists.find (name))
|
|
|
|
|
return ref;
|
|
|
|
|
|
|
|
|
|
if (ESMS::LiveCellRef<ESM::ItemLevList, RefData> *ref = cell.itemLists.find (name))
|
|
|
|
|
return ref;
|
|
|
|
|
|
|
|
|
|
if (ESMS::LiveCellRef<ESM::Light, RefData> *ref = cell.lights.find (name))
|
|
|
|
|
return ref;
|
|
|
|
|
|
|
|
|
|
if (ESMS::LiveCellRef<ESM::Tool, RefData> *ref = cell.lockpicks.find (name))
|
|
|
|
|
return ref;
|
|
|
|
|
|
|
|
|
|
if (ESMS::LiveCellRef<ESM::Misc, RefData> *ref = cell.miscItems.find (name))
|
|
|
|
|
return ref;
|
|
|
|
|
|
|
|
|
|
if (ESMS::LiveCellRef<ESM::NPC, RefData> *ref = cell.npcs.find (name))
|
|
|
|
|
return ref;
|
|
|
|
|
|
|
|
|
|
if (ESMS::LiveCellRef<ESM::Tool, RefData> *ref = cell.probes.find (name))
|
|
|
|
|
return ref;
|
|
|
|
|
|
|
|
|
|
if (ESMS::LiveCellRef<ESM::Tool, RefData> *ref = cell.repairs.find (name))
|
|
|
|
|
return ref;
|
|
|
|
|
|
|
|
|
|
if (ESMS::LiveCellRef<ESM::Static, RefData> *ref = cell.statics.find (name))
|
|
|
|
|
return ref;
|
|
|
|
|
|
|
|
|
|
if (ESMS::LiveCellRef<ESM::Weapon, RefData> *ref = cell.weapons.find (name))
|
|
|
|
|
return ref;
|
|
|
|
|
|
|
|
|
|
return Ptr();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
World::World (Render::OgreRenderer& renderer, const boost::filesystem::path& dataDir,
|
|
|
|
|
const std::string& master, const std::string& startCell, bool newGame)
|
|
|
|
|
: mSkyManager (0), mScene (renderer), mPlayerPos (mScene.getCamera())
|
|
|
|
|
: mSkyManager (0), mScene (renderer), mPlayerPos (0)
|
|
|
|
|
{
|
|
|
|
|
boost::filesystem::path masterPath (dataDir);
|
|
|
|
|
masterPath /= master;
|
|
|
|
@ -73,6 +138,8 @@ namespace MWWorld
|
|
|
|
|
|
|
|
|
|
insertInteriorScripts (mInteriors[startCell]);
|
|
|
|
|
|
|
|
|
|
mPlayerPos = new MWRender::PlayerPos (mScene.getCamera(), mStore.npcs.find ("player"));
|
|
|
|
|
|
|
|
|
|
// global variables
|
|
|
|
|
for (ESMS::RecListT<ESM::Global>::MapType::const_iterator iter
|
|
|
|
|
(mStore.globals.list.begin());
|
|
|
|
@ -114,12 +181,13 @@ namespace MWWorld
|
|
|
|
|
iter!=mBufferedCells.end(); ++iter)
|
|
|
|
|
delete iter->second;
|
|
|
|
|
|
|
|
|
|
delete mPlayerPos;
|
|
|
|
|
delete mSkyManager;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MWRender::PlayerPos& World::getPlayerPos()
|
|
|
|
|
{
|
|
|
|
|
return mPlayerPos;
|
|
|
|
|
return *mPlayerPos;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ESMS::ESMStore& World::getStore()
|
|
|
|
@ -147,4 +215,33 @@ namespace MWWorld
|
|
|
|
|
|
|
|
|
|
return iter->second;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::pair<Ptr, World::CellStore *> World::getPtr (const std::string& name, bool activeOnly)
|
|
|
|
|
{
|
|
|
|
|
// the player is always in an active cell.
|
|
|
|
|
if (name=="player")
|
|
|
|
|
{
|
|
|
|
|
// TODO: find real cell (might need to be stored in playerPos). For now we
|
|
|
|
|
// use the first active cell. This will fail the moment we move into an
|
|
|
|
|
// exterior cell.
|
|
|
|
|
return std::make_pair (mPlayerPos->getPlayer(), mActiveCells.begin()->first);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// active cells
|
|
|
|
|
for (CellRenderCollection::iterator iter (mActiveCells.begin());
|
|
|
|
|
iter!=mActiveCells.end(); ++iter)
|
|
|
|
|
{
|
|
|
|
|
Ptr ptr = getPtr (name, *iter->first);
|
|
|
|
|
|
|
|
|
|
if (!ptr.isEmpty())
|
|
|
|
|
return std::make_pair (ptr, iter->first);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!activeOnly)
|
|
|
|
|
{
|
|
|
|
|
// TODO: inactive cells
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
throw std::runtime_error ("unknown ID: " + name);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|