|
|
|
@ -79,6 +79,14 @@ MWWorld::ContainerStoreIterator MWWorld::ContainerStore::getState (CellRefList<T
|
|
|
|
|
return ContainerStoreIterator (this, --collection.mList.end());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MWWorld::ContainerStore::storeEquipmentState(const MWWorld::LiveCellRefBase &ref, int index, ESM::InventoryState &inventory) const
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MWWorld::ContainerStore::readEquipmentState(const MWWorld::ContainerStoreIterator& iter, int index, const ESM::InventoryState &inventory)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template<typename T>
|
|
|
|
|
void MWWorld::ContainerStore::storeState (const LiveCellRef<T>& ref, ESM::ObjectState& state) const
|
|
|
|
|
{
|
|
|
|
@ -87,7 +95,7 @@ void MWWorld::ContainerStore::storeState (const LiveCellRef<T>& ref, ESM::Object
|
|
|
|
|
|
|
|
|
|
template<typename T>
|
|
|
|
|
void MWWorld::ContainerStore::storeStates (CellRefList<T>& collection,
|
|
|
|
|
std::vector<std::pair<ESM::ObjectState, int> >& states, bool equipable) const
|
|
|
|
|
ESM::InventoryState& inventory, int& index, bool equipable) const
|
|
|
|
|
{
|
|
|
|
|
for (typename CellRefList<T>::List::const_iterator iter (collection.mList.begin());
|
|
|
|
|
iter!=collection.mList.end(); ++iter)
|
|
|
|
@ -96,18 +104,13 @@ void MWWorld::ContainerStore::storeStates (CellRefList<T>& collection,
|
|
|
|
|
continue;
|
|
|
|
|
ESM::ObjectState state;
|
|
|
|
|
storeState (*iter, state);
|
|
|
|
|
int slot = equipable ? getSlot (*iter) : -1;
|
|
|
|
|
states.push_back (std::make_pair (state, slot));
|
|
|
|
|
if (equipable)
|
|
|
|
|
storeEquipmentState(*iter, index, inventory);
|
|
|
|
|
inventory.mItems.push_back (state);
|
|
|
|
|
++index;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int MWWorld::ContainerStore::getSlot (const MWWorld::LiveCellRefBase& ref) const
|
|
|
|
|
{
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MWWorld::ContainerStore::setSlot (const MWWorld::ContainerStoreIterator& iter, int slot) {}
|
|
|
|
|
|
|
|
|
|
const std::string MWWorld::ContainerStore::sGoldId = "gold_001";
|
|
|
|
|
|
|
|
|
|
MWWorld::ContainerStore::ContainerStore() : mCachedWeight (0), mWeightUpToDate (false) {}
|
|
|
|
@ -645,49 +648,51 @@ void MWWorld::ContainerStore::writeState (ESM::InventoryState& state)
|
|
|
|
|
{
|
|
|
|
|
state.mItems.clear();
|
|
|
|
|
|
|
|
|
|
storeStates (potions, state.mItems);
|
|
|
|
|
storeStates (appas, state.mItems);
|
|
|
|
|
storeStates (armors, state.mItems, true);
|
|
|
|
|
storeStates (books, state.mItems);
|
|
|
|
|
storeStates (clothes, state.mItems, true);
|
|
|
|
|
storeStates (ingreds, state.mItems);
|
|
|
|
|
storeStates (lockpicks, state.mItems, true);
|
|
|
|
|
storeStates (miscItems, state.mItems);
|
|
|
|
|
storeStates (probes, state.mItems, true);
|
|
|
|
|
storeStates (repairs, state.mItems);
|
|
|
|
|
storeStates (weapons, state.mItems, true);
|
|
|
|
|
storeStates (lights, state.mItems, true);
|
|
|
|
|
int index = 0;
|
|
|
|
|
storeStates (potions, state, index);
|
|
|
|
|
storeStates (appas, state, index);
|
|
|
|
|
storeStates (armors, state, index, true);
|
|
|
|
|
storeStates (books, state, index, true); // not equipable as such, but for selectedEnchantItem
|
|
|
|
|
storeStates (clothes, state, index, true);
|
|
|
|
|
storeStates (ingreds, state, index);
|
|
|
|
|
storeStates (lockpicks, state, index, true);
|
|
|
|
|
storeStates (miscItems, state, index);
|
|
|
|
|
storeStates (probes, state, index, true);
|
|
|
|
|
storeStates (repairs, state, index);
|
|
|
|
|
storeStates (weapons, state, index, true);
|
|
|
|
|
storeStates (lights, state, index, true);
|
|
|
|
|
|
|
|
|
|
state.mLevelledItemMap = mLevelledItemMap;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MWWorld::ContainerStore::readState (const ESM::InventoryState& state)
|
|
|
|
|
void MWWorld::ContainerStore::readState (const ESM::InventoryState& inventory)
|
|
|
|
|
{
|
|
|
|
|
clear();
|
|
|
|
|
|
|
|
|
|
for (std::vector<std::pair<ESM::ObjectState, int> >::const_iterator
|
|
|
|
|
iter (state.mItems.begin()); iter!=state.mItems.end(); ++iter)
|
|
|
|
|
int index = 0;
|
|
|
|
|
for (std::vector<ESM::ObjectState>::const_iterator
|
|
|
|
|
iter (inventory.mItems.begin()); iter!=inventory.mItems.end(); ++iter)
|
|
|
|
|
{
|
|
|
|
|
int slot = iter->second;
|
|
|
|
|
|
|
|
|
|
const ESM::ObjectState& state = iter->first;
|
|
|
|
|
const ESM::ObjectState& state = *iter;
|
|
|
|
|
|
|
|
|
|
int type = MWBase::Environment::get().getWorld()->getStore().find(state.mRef.mRefID);
|
|
|
|
|
|
|
|
|
|
int thisIndex = index++;
|
|
|
|
|
|
|
|
|
|
switch (type)
|
|
|
|
|
{
|
|
|
|
|
case ESM::REC_ALCH: getState (potions, iter->first); break;
|
|
|
|
|
case ESM::REC_APPA: getState (appas, iter->first); break;
|
|
|
|
|
case ESM::REC_ARMO: setSlot (getState (armors, iter->first), slot); break;
|
|
|
|
|
case ESM::REC_BOOK: getState (books, iter->first); break;
|
|
|
|
|
case ESM::REC_CLOT: setSlot (getState (clothes, iter->first), slot); break;
|
|
|
|
|
case ESM::REC_INGR: getState (ingreds, iter->first); break;
|
|
|
|
|
case ESM::REC_LOCK: setSlot (getState (lockpicks, iter->first), slot); break;
|
|
|
|
|
case ESM::REC_MISC: getState (miscItems, iter->first); break;
|
|
|
|
|
case ESM::REC_PROB: setSlot (getState (probes, iter->first), slot); break;
|
|
|
|
|
case ESM::REC_REPA: getState (repairs, iter->first); break;
|
|
|
|
|
case ESM::REC_WEAP: setSlot (getState (weapons, iter->first), slot); break;
|
|
|
|
|
case ESM::REC_LIGH: setSlot (getState (lights, iter->first), slot); break;
|
|
|
|
|
case ESM::REC_ALCH: getState (potions, state); break;
|
|
|
|
|
case ESM::REC_APPA: getState (appas, state); break;
|
|
|
|
|
case ESM::REC_ARMO: readEquipmentState (getState (armors, state), thisIndex, inventory); break;
|
|
|
|
|
case ESM::REC_BOOK: readEquipmentState (getState (books, state), thisIndex, inventory); break; // not equipable as such, but for selectedEnchantItem
|
|
|
|
|
case ESM::REC_CLOT: readEquipmentState (getState (clothes, state), thisIndex, inventory); break;
|
|
|
|
|
case ESM::REC_INGR: getState (ingreds, state); break;
|
|
|
|
|
case ESM::REC_LOCK: readEquipmentState (getState (lockpicks, state), thisIndex, inventory); break;
|
|
|
|
|
case ESM::REC_MISC: getState (miscItems, state); break;
|
|
|
|
|
case ESM::REC_PROB: readEquipmentState (getState (probes, state), thisIndex, inventory); break;
|
|
|
|
|
case ESM::REC_REPA: getState (repairs, state); break;
|
|
|
|
|
case ESM::REC_WEAP: readEquipmentState (getState (weapons, state), thisIndex, inventory); break;
|
|
|
|
|
case ESM::REC_LIGH: readEquipmentState (getState (lights, state), thisIndex, inventory); break;
|
|
|
|
|
case 0:
|
|
|
|
|
std::cerr << "Dropping reference to '" << state.mRef.mRefID << "' (object no longer exists)" << std::endl;
|
|
|
|
|
break;
|
|
|
|
@ -698,7 +703,7 @@ void MWWorld::ContainerStore::readState (const ESM::InventoryState& state)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mLevelledItemMap = state.mLevelledItemMap;
|
|
|
|
|
mLevelledItemMap = inventory.mLevelledItemMap;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|