#include "manualref.hpp" #include #include #include "esmstore.hpp" namespace { template void create(const MWWorld::Store& list, const ESM::RefId& name, std::any& refValue, MWWorld::Ptr& ptrValue) { const T* base = list.find(name); ESM::CellRef cellRef; cellRef.blank(); cellRef.mRefID = name; refValue = MWWorld::LiveCellRef(cellRef, base); ptrValue = MWWorld::Ptr(&std::any_cast&>(refValue), nullptr); } } MWWorld::ManualRef::ManualRef(const MWWorld::ESMStore& store, const ESM::RefId& name, const int count) { switch (store.find(name)) { case ESM::REC_ACTI: create(store.get(), name, mRef, mPtr); break; case ESM::REC_ALCH: create(store.get(), name, mRef, mPtr); break; case ESM::REC_APPA: create(store.get(), name, mRef, mPtr); break; case ESM::REC_ARMO: create(store.get(), name, mRef, mPtr); break; case ESM::REC_BOOK: create(store.get(), name, mRef, mPtr); break; case ESM::REC_CLOT: create(store.get(), name, mRef, mPtr); break; case ESM::REC_CONT: create(store.get(), name, mRef, mPtr); break; case ESM::REC_CREA: create(store.get(), name, mRef, mPtr); break; case ESM::REC_DOOR: create(store.get(), name, mRef, mPtr); break; case ESM::REC_INGR: create(store.get(), name, mRef, mPtr); break; case ESM::REC_LEVC: create(store.get(), name, mRef, mPtr); break; case ESM::REC_LEVI: create(store.get(), name, mRef, mPtr); break; case ESM::REC_LIGH: create(store.get(), name, mRef, mPtr); break; case ESM::REC_LOCK: create(store.get(), name, mRef, mPtr); break; case ESM::REC_MISC: create(store.get(), name, mRef, mPtr); break; case ESM::REC_NPC_: create(store.get(), name, mRef, mPtr); break; case ESM::REC_PROB: create(store.get(), name, mRef, mPtr); break; case ESM::REC_REPA: create(store.get(), name, mRef, mPtr); break; case ESM::REC_STAT: create(store.get(), name, mRef, mPtr); break; case ESM::REC_WEAP: create(store.get(), name, mRef, mPtr); break; case ESM::REC_BODY: create(store.get(), name, mRef, mPtr); break; case ESM::REC_STAT4: create(store.get(), name, mRef, mPtr); break; case ESM::REC_TERM4: create(store.get(), name, mRef, mPtr); break; case 0: throw std::logic_error("failed to create manual cell ref for " + name.toDebugString() + " (unknown ID)"); default: throw std::logic_error("failed to create manual cell ref for " + name.toDebugString() + " (unknown type)"); } mPtr.getRefData().setCount(count); }