CellRefList<X>::find(CellRef &, Y &list) -> ::load(CellRef &, ESMStore &)

actorid
greye 12 years ago
parent 242a9b5a59
commit 0fd22ce4b0

@ -98,26 +98,26 @@ namespace MWWorld
*/
switch(rec)
{
case ESM::REC_ACTI: mActivators.find(ref, store.activators); break;
case ESM::REC_ALCH: mPotions.find(ref, store.potions); break;
case ESM::REC_APPA: mAppas.find(ref, store.appas); break;
case ESM::REC_ARMO: mArmors.find(ref, store.armors); break;
case ESM::REC_BOOK: mBooks.find(ref, store.books); break;
case ESM::REC_CLOT: mClothes.find(ref, store.clothes); break;
case ESM::REC_CONT: mContainers.find(ref, store.containers); break;
case ESM::REC_CREA: mCreatures.find(ref, store.creatures); break;
case ESM::REC_DOOR: mDoors.find(ref, store.doors); break;
case ESM::REC_INGR: mIngreds.find(ref, store.ingreds); break;
case ESM::REC_LEVC: mCreatureLists.find(ref, store.creatureLists); break;
case ESM::REC_LEVI: mItemLists.find(ref, store.itemLists); break;
case ESM::REC_LIGH: mLights.find(ref, store.lights); break;
case ESM::REC_LOCK: mLockpicks.find(ref, store.lockpicks); break;
case ESM::REC_MISC: mMiscItems.find(ref, store.miscItems); break;
case ESM::REC_NPC_: mNpcs.find(ref, store.npcs); break;
case ESM::REC_PROB: mProbes.find(ref, store.probes); break;
case ESM::REC_REPA: mRepairs.find(ref, store.repairs); break;
case ESM::REC_STAT: mStatics.find(ref, store.statics); break;
case ESM::REC_WEAP: mWeapons.find(ref, store.weapons); break;
case ESM::REC_ACTI: mActivators.load(ref, store); break;
case ESM::REC_ALCH: mPotions.load(ref, store); break;
case ESM::REC_APPA: mAppas.load(ref, store); break;
case ESM::REC_ARMO: mArmors.load(ref, store); break;
case ESM::REC_BOOK: mBooks.load(ref, store); break;
case ESM::REC_CLOT: mClothes.load(ref, store); break;
case ESM::REC_CONT: mContainers.load(ref, store); break;
case ESM::REC_CREA: mCreatures.load(ref, store); break;
case ESM::REC_DOOR: mDoors.load(ref, store); break;
case ESM::REC_INGR: mIngreds.load(ref, store); break;
case ESM::REC_LEVC: mCreatureLists.load(ref, store); break;
case ESM::REC_LEVI: mItemLists.load(ref, store); break;
case ESM::REC_LIGH: mLights.load(ref, store); break;
case ESM::REC_LOCK: mLockpicks.load(ref, store); break;
case ESM::REC_MISC: mMiscItems.load(ref, store); break;
case ESM::REC_NPC_: mNpcs.load(ref, store); break;
case ESM::REC_PROB: mProbes.load(ref, store); break;
case ESM::REC_REPA: mRepairs.load(ref, store); break;
case ESM::REC_STAT: mStatics.load(ref, store); break;
case ESM::REC_WEAP: mWeapons.load(ref, store); break;
case 0: std::cout << "Cell reference " + ref.mRefID + " not found!\n"; break;
default:

@ -7,6 +7,7 @@
#include <algorithm>
#include "refdata.hpp"
#include "esmstore.hpp"
namespace MWWorld
{
@ -50,17 +51,20 @@ namespace MWWorld
typedef std::list<LiveRef> List;
List mList;
// Search for the given reference in the given reclist from
// ESMStore. Insert the reference into the list if a match is
// found. If not, throw an exception.
template <typename Y>
void find(ESM::CellRef &ref, const Y& recList)
/// Searches for reference of appropriate type in given ESMStore.
/// If reference exists, loads it into container, throws an exception
/// on miss
void load(ESM::CellRef &ref, const MWWorld::ESMStore &esmStore)
{
const X* obj = recList.find(ref.mRefID);
if(obj == NULL)
throw std::runtime_error("Error resolving cell reference " + ref.mRefID);
// for throwing exception on unhandled record type
const MWWorld::Store<X> &store = esmStore.get<X>();
const X *ptr = store.find(ref.mRefID);
mList.push_back(LiveRef(ref, obj));
/// \note redundant because Store<X>::find() throws exception on miss
if (ptr == NULL) {
throw std::runtime_error("Error resolving cell reference " + ref.mRefID);
}
mList.push_back(LiveRef(ref, ptr));
}
LiveRef *find (const std::string& name)

Loading…
Cancel
Save