Move manualref code out of header

celladd
Alexander "Ace" Olofsson 10 years ago
parent e81d2a9dde
commit df5a08b6de

@ -12,6 +12,7 @@
#include "../mwworld/ptr.hpp"
#include "../mwworld/actiontake.hpp"
#include "../mwworld/cellstore.hpp"
#include "../mwworld/esmstore.hpp"
#include "../mwworld/physicssystem.hpp"
#include "../mwworld/manualref.hpp"
#include "../mwworld/nullaction.hpp"

@ -3,6 +3,7 @@
#include <iostream>
#include "../mwworld/manualref.hpp"
#include "../mwworld/esmstore.hpp"
#include "../mwworld/class.hpp"
#include "../mwbase/environment.hpp"

@ -16,6 +16,7 @@
#include "../mwworld/manualref.hpp"
#include "../mwworld/class.hpp"
#include "../mwworld/containerstore.hpp"
#include "../mwworld/esmstore.hpp"
#include "../mwmechanics/creaturestats.hpp"

@ -2,6 +2,7 @@
#include "../mwworld/manualref.hpp"
#include "../mwworld/class.hpp"
#include "../mwworld/containerstore.hpp"
#include "../mwworld/esmstore.hpp"
#include "../mwbase/mechanicsmanager.hpp"
#include "creaturestats.hpp"

@ -2,6 +2,7 @@
#define OPENMW_MECHANICS_LEVELLEDLIST_H
#include "../mwworld/ptr.hpp"
#include "../mwworld/esmstore.hpp"
#include "../mwworld/manualref.hpp"
#include "../mwworld/class.hpp"
#include "../mwbase/world.hpp"

@ -1,8 +1,6 @@
#ifndef OPENMW_MECHANICS_OBSTACLE_H
#define OPENMW_MECHANICS_OBSTACLE_H
//#include "../mwbase/world.hpp"
//#include "../mwworld/class.hpp"
#include "../mwworld/cellstore.hpp"
namespace MWWorld

@ -11,6 +11,7 @@
#include "../mwbase/environment.hpp"
#include "../mwworld/cellstore.hpp"
#include "../mwworld/class.hpp"
#include "../mwworld/manualref.hpp"
#include "../mwworld/player.hpp"

@ -0,0 +1,67 @@
#include "manualref.hpp"
#include "esmstore.hpp"
#include "cellstore.hpp"
namespace
{
template<typename T>
void create(const MWWorld::Store<T>& list, const std::string& name, boost::any& refValue, MWWorld::Ptr& ptrValue)
{
const T* base = list.find(name);
ESM::CellRef cellRef;
cellRef.mRefNum.unset();
cellRef.mRefID = name;
cellRef.mScale = 1;
cellRef.mFactionRank = 0;
cellRef.mChargeInt = -1;
cellRef.mGoldValue = 1;
cellRef.mEnchantmentCharge = -1;
cellRef.mTeleport = false;
cellRef.mLockLevel = 0;
cellRef.mReferenceBlocked = 0;
MWWorld::LiveCellRef<T> ref(cellRef, base);
refValue = ref;
ptrValue = MWWorld::Ptr(&boost::any_cast<MWWorld::LiveCellRef<T>&>(refValue), 0);
}
}
MWWorld::ManualRef::ManualRef(const MWWorld::ESMStore& store, const std::string& name, const int count)
{
std::string lowerName = Misc::StringUtils::lowerCase(name);
switch (store.find(lowerName))
{
case ESM::REC_ACTI: create(store.get<ESM::Activator>(), lowerName, mRef, mPtr); break;
case ESM::REC_ALCH: create(store.get<ESM::Potion>(), lowerName, mRef, mPtr); break;
case ESM::REC_APPA: create(store.get<ESM::Apparatus>(), lowerName, mRef, mPtr); break;
case ESM::REC_ARMO: create(store.get<ESM::Armor>(), lowerName, mRef, mPtr); break;
case ESM::REC_BOOK: create(store.get<ESM::Book>(), lowerName, mRef, mPtr); break;
case ESM::REC_CLOT: create(store.get<ESM::Clothing>(), lowerName, mRef, mPtr); break;
case ESM::REC_CONT: create(store.get<ESM::Container>(), lowerName, mRef, mPtr); break;
case ESM::REC_CREA: create(store.get<ESM::Creature>(), lowerName, mRef, mPtr); break;
case ESM::REC_DOOR: create(store.get<ESM::Door>(), lowerName, mRef, mPtr); break;
case ESM::REC_INGR: create(store.get<ESM::Ingredient>(), lowerName, mRef, mPtr); break;
case ESM::REC_LEVC: create(store.get<ESM::CreatureLevList>(), lowerName, mRef, mPtr); break;
case ESM::REC_LEVI: create(store.get<ESM::ItemLevList>(), lowerName, mRef, mPtr); break;
case ESM::REC_LIGH: create(store.get<ESM::Light>(), lowerName, mRef, mPtr); break;
case ESM::REC_LOCK: create(store.get<ESM::Lockpick>(), lowerName, mRef, mPtr); break;
case ESM::REC_MISC: create(store.get<ESM::Miscellaneous>(), lowerName, mRef, mPtr); break;
case ESM::REC_NPC_: create(store.get<ESM::NPC>(), lowerName, mRef, mPtr); break;
case ESM::REC_PROB: create(store.get<ESM::Probe>(), lowerName, mRef, mPtr); break;
case ESM::REC_REPA: create(store.get<ESM::Repair>(), lowerName, mRef, mPtr); break;
case ESM::REC_STAT: create(store.get<ESM::Static>(), lowerName, mRef, mPtr); break;
case ESM::REC_WEAP: create(store.get<ESM::Weapon>(), lowerName, mRef, mPtr); break;
case 0:
throw std::logic_error("failed to create manual cell ref for " + lowerName + " (unknown ID)");
default:
throw std::logic_error("failed to create manual cell ref for " + lowerName + " (unknown type)");
}
mPtr.getRefData().setCount(count);
}

@ -3,9 +3,7 @@
#include <boost/any.hpp>
#include "esmstore.hpp"
#include "ptr.hpp"
#include "cellstore.hpp"
namespace MWWorld
{
@ -18,66 +16,8 @@ namespace MWWorld
ManualRef (const ManualRef&);
ManualRef& operator= (const ManualRef&);
template<typename T>
void create (const MWWorld::Store<T>& list, const std::string& name)
{
const T* base = list.find(name);
ESM::CellRef cellRef;
cellRef.mRefNum.unset();
cellRef.mRefID = name;
cellRef.mScale = 1;
cellRef.mFactionRank = 0;
cellRef.mChargeInt = -1;
cellRef.mGoldValue = 1;
cellRef.mEnchantmentCharge = -1;
cellRef.mTeleport = false;
cellRef.mLockLevel = 0;
cellRef.mReferenceBlocked = 0;
LiveCellRef<T> ref(cellRef, base);
mRef = ref;
mPtr = Ptr (&boost::any_cast<LiveCellRef<T>&> (mRef), 0);
}
public:
ManualRef (const MWWorld::ESMStore& store, const std::string& name, const int count=1)
{
std::string lowerName = Misc::StringUtils::lowerCase (name);
switch (store.find (lowerName))
{
case ESM::REC_ACTI: create (store.get<ESM::Activator>(), lowerName); break;
case ESM::REC_ALCH: create (store.get<ESM::Potion>(), lowerName); break;
case ESM::REC_APPA: create (store.get<ESM::Apparatus>(), lowerName); break;
case ESM::REC_ARMO: create (store.get<ESM::Armor>(), lowerName); break;
case ESM::REC_BOOK: create (store.get<ESM::Book>(), lowerName); break;
case ESM::REC_CLOT: create (store.get<ESM::Clothing>(), lowerName); break;
case ESM::REC_CONT: create (store.get<ESM::Container>(), lowerName); break;
case ESM::REC_CREA: create (store.get<ESM::Creature>(), lowerName); break;
case ESM::REC_DOOR: create (store.get<ESM::Door>(), lowerName); break;
case ESM::REC_INGR: create (store.get<ESM::Ingredient>(), lowerName); break;
case ESM::REC_LEVC: create (store.get<ESM::CreatureLevList>(), lowerName); break;
case ESM::REC_LEVI: create (store.get<ESM::ItemLevList>(), lowerName); break;
case ESM::REC_LIGH: create (store.get<ESM::Light>(), lowerName); break;
case ESM::REC_LOCK: create (store.get<ESM::Lockpick>(), lowerName); break;
case ESM::REC_MISC: create (store.get<ESM::Miscellaneous>(), lowerName); break;
case ESM::REC_NPC_: create (store.get<ESM::NPC>(), lowerName); break;
case ESM::REC_PROB: create (store.get<ESM::Probe>(), lowerName); break;
case ESM::REC_REPA: create (store.get<ESM::Repair>(), lowerName); break;
case ESM::REC_STAT: create (store.get<ESM::Static>(), lowerName); break;
case ESM::REC_WEAP: create (store.get<ESM::Weapon>(), lowerName); break;
case 0:
throw std::logic_error ("failed to create manual cell ref for " + lowerName + " (unknown ID)");
default:
throw std::logic_error ("failed to create manual cell ref for " + lowerName + " (unknown type)");
}
mPtr.getRefData().setCount(count);
}
ManualRef(const MWWorld::ESMStore& store, const std::string& name, const int count = 1);
const Ptr& getPtr() const
{

@ -9,6 +9,7 @@
#include "../mwworld/manualref.hpp"
#include "../mwworld/class.hpp"
#include "../mwworld/esmstore.hpp"
#include "../mwworld/inventorystore.hpp"
#include "../mwbase/soundmanager.hpp"

Loading…
Cancel
Save