#include "manualref.hpp" #include "esmstore.hpp" namespace { template void create(const MWWorld::Store& 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.mChargeIntRemainder = 0.0f; cellRef.mGoldValue = 1; cellRef.mEnchantmentCharge = -1; cellRef.mTeleport = false; cellRef.mLockLevel = 0; cellRef.mReferenceBlocked = 0; /* Start of tes3mp addition Set the mMpNum (unique multiplayer reference number) to 0 by default */ cellRef.mMpNum = 0; /* End of tes3mp addition */ MWWorld::LiveCellRef ref(cellRef, base); refValue = ref; ptrValue = MWWorld::Ptr(&boost::any_cast&>(refValue), nullptr); } } 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(), lowerName, mRef, mPtr); break; case ESM::REC_ALCH: create(store.get(), lowerName, mRef, mPtr); break; case ESM::REC_APPA: create(store.get(), lowerName, mRef, mPtr); break; case ESM::REC_ARMO: create(store.get(), lowerName, mRef, mPtr); break; case ESM::REC_BOOK: create(store.get(), lowerName, mRef, mPtr); break; case ESM::REC_CLOT: create(store.get(), lowerName, mRef, mPtr); break; case ESM::REC_CONT: create(store.get(), lowerName, mRef, mPtr); break; case ESM::REC_CREA: create(store.get(), lowerName, mRef, mPtr); break; case ESM::REC_DOOR: create(store.get(), lowerName, mRef, mPtr); break; case ESM::REC_INGR: create(store.get(), lowerName, mRef, mPtr); break; case ESM::REC_LEVC: create(store.get(), lowerName, mRef, mPtr); break; case ESM::REC_LEVI: create(store.get(), lowerName, mRef, mPtr); break; case ESM::REC_LIGH: create(store.get(), lowerName, mRef, mPtr); break; case ESM::REC_LOCK: create(store.get(), lowerName, mRef, mPtr); break; case ESM::REC_MISC: create(store.get(), lowerName, mRef, mPtr); break; case ESM::REC_NPC_: create(store.get(), lowerName, mRef, mPtr); break; case ESM::REC_PROB: create(store.get(), lowerName, mRef, mPtr); break; case ESM::REC_REPA: create(store.get(), lowerName, mRef, mPtr); break; case ESM::REC_STAT: create(store.get(), lowerName, mRef, mPtr); break; case ESM::REC_WEAP: create(store.get(), lowerName, mRef, mPtr); break; case ESM::REC_BODY: create(store.get(), 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); }