forked from teamnwah/openmw-tes3coop
Use the MWWorld::Ptr() instead of string ID
This commit is contained in:
parent
0375bedab2
commit
9b72a6ac69
2 changed files with 16 additions and 9 deletions
|
@ -264,7 +264,7 @@ namespace MWMechanics
|
||||||
if (slot == MWWorld::InventoryStore::Slot_CarriedRight)
|
if (slot == MWWorld::InventoryStore::Slot_CarriedRight)
|
||||||
MWBase::Environment::get().getWorld()->getPlayer().setDrawState(MWMechanics::DrawState_Weapon);
|
MWBase::Environment::get().getWorld()->getPlayer().setDrawState(MWMechanics::DrawState_Weapon);
|
||||||
|
|
||||||
mPreviousItems[slot] = std::make_pair(itemId, prevItem.isEmpty() ? "" : prevItem.getCellRef().getRefId());
|
mPreviousItems[slot] = std::make_pair(itemId, prevItem);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -275,21 +275,28 @@ namespace MWMechanics
|
||||||
|
|
||||||
int slot = getBoundItemSlot(itemId);
|
int slot = getBoundItemSlot(itemId);
|
||||||
|
|
||||||
std::pair<std::string, std::string> prevItem = mPreviousItems[slot];
|
std::pair<std::string, MWWorld::Ptr> prevItem = mPreviousItems[slot];
|
||||||
|
|
||||||
if (prevItem.first != itemId)
|
if (prevItem.first != itemId)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
MWWorld::Ptr ptr = MWWorld::Ptr();
|
|
||||||
if (prevItem.second != "")
|
|
||||||
ptr = store.search (prevItem.second);
|
|
||||||
|
|
||||||
mPreviousItems.erase(slot);
|
mPreviousItems.erase(slot);
|
||||||
|
|
||||||
if (ptr.isEmpty())
|
if (prevItem.second.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
MWWorld::ActionEquip action(ptr);
|
// check if the item is still in the player's inventory
|
||||||
|
MWWorld::ContainerStoreIterator it = store.begin();
|
||||||
|
for (; it != store.end(); ++it)
|
||||||
|
{
|
||||||
|
if (*it == prevItem.second)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (it == store.end())
|
||||||
|
return;
|
||||||
|
|
||||||
|
MWWorld::ActionEquip action(prevItem.second);
|
||||||
action.execute(actor);
|
action.execute(actor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ namespace MWMechanics
|
||||||
class Actors
|
class Actors
|
||||||
{
|
{
|
||||||
std::map<std::string, int> mDeathCount;
|
std::map<std::string, int> mDeathCount;
|
||||||
typedef std::map<int, std::pair<std::string, std::string>> PreviousItems;
|
typedef std::map<int, std::pair<std::string, MWWorld::Ptr>> PreviousItems;
|
||||||
PreviousItems mPreviousItems;
|
PreviousItems mPreviousItems;
|
||||||
|
|
||||||
void adjustBoundItem (const std::string& itemId, bool bound, const MWWorld::Ptr& actor);
|
void adjustBoundItem (const std::string& itemId, bool bound, const MWWorld::Ptr& actor);
|
||||||
|
|
Loading…
Reference in a new issue