mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-16 19:19:56 +00:00
Move previous items to player
This commit is contained in:
parent
f977c6876f
commit
9fd2d57b86
4 changed files with 33 additions and 9 deletions
|
@ -262,7 +262,10 @@ namespace MWMechanics
|
|||
MWBase::Environment::get().getWorld()->getPlayer().setDrawState(MWMechanics::DrawState_Weapon);
|
||||
|
||||
if (prevItem != store.end())
|
||||
mPreviousItems[itemId] = (*prevItem).getCellRef().getRefId();
|
||||
{
|
||||
MWWorld::Player* player = &MWBase::Environment::get().getWorld()->getPlayer();
|
||||
player->setPreviousItem(itemId, prevItem->getCellRef().getRefId());
|
||||
}
|
||||
}
|
||||
|
||||
void Actors::removeBoundItem (const std::string& itemId, const MWWorld::Ptr& actor)
|
||||
|
@ -272,16 +275,16 @@ namespace MWMechanics
|
|||
|
||||
MWWorld::ContainerStoreIterator currentItem = store.getSlot(slot);
|
||||
|
||||
bool wasEquipped = currentItem != store.end() && Misc::StringUtils::ciEqual((*currentItem).getCellRef().getRefId(), itemId);
|
||||
bool wasEquipped = currentItem != store.end() && Misc::StringUtils::ciEqual(currentItem->getCellRef().getRefId(), itemId);
|
||||
|
||||
store.remove(itemId, 1, actor, true);
|
||||
|
||||
if (actor != MWMechanics::getPlayer())
|
||||
return;
|
||||
|
||||
std::string prevItemId = mPreviousItems[itemId];
|
||||
|
||||
mPreviousItems.erase(itemId);
|
||||
MWWorld::Player* player = &MWBase::Environment::get().getWorld()->getPlayer();
|
||||
std::string prevItemId = player->getPreviousItem(itemId);
|
||||
player->erasePreviousItem(itemId);
|
||||
|
||||
if (prevItemId.empty())
|
||||
return;
|
||||
|
@ -1956,7 +1959,6 @@ namespace MWMechanics
|
|||
}
|
||||
mActors.clear();
|
||||
mDeathCount.clear();
|
||||
mPreviousItems.clear();
|
||||
}
|
||||
|
||||
void Actors::updateMagicEffects(const MWWorld::Ptr &ptr)
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
#include <set>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <list>
|
||||
|
||||
#include "../mwbase/world.hpp"
|
||||
|
@ -25,8 +24,6 @@ namespace MWMechanics
|
|||
class Actors
|
||||
{
|
||||
std::map<std::string, int> mDeathCount;
|
||||
typedef std::map<std::string, std::string> PreviousItems;
|
||||
PreviousItems mPreviousItems;
|
||||
|
||||
void addBoundItem (const std::string& itemId, const MWWorld::Ptr& actor);
|
||||
void removeBoundItem (const std::string& itemId, const MWWorld::Ptr& actor);
|
||||
|
|
|
@ -287,6 +287,7 @@ namespace MWWorld
|
|||
mAttackingOrSpell = false;
|
||||
mCurrentCrimeId = -1;
|
||||
mPaidCrimeId = -1;
|
||||
mPreviousItems.clear();
|
||||
mLastKnownExteriorPosition = osg::Vec3f(0,0,0);
|
||||
|
||||
for (int i=0; i<ESM::Skill::Length; ++i)
|
||||
|
@ -461,4 +462,19 @@ namespace MWWorld
|
|||
{
|
||||
return mPaidCrimeId;
|
||||
}
|
||||
|
||||
void Player::setPreviousItem(const std::string& boundItemId, const std::string& previousItemId)
|
||||
{
|
||||
mPreviousItems[boundItemId] = previousItemId;
|
||||
}
|
||||
|
||||
std::string Player::getPreviousItem(const std::string& boundItemId)
|
||||
{
|
||||
return mPreviousItems[boundItemId];
|
||||
}
|
||||
|
||||
void Player::erasePreviousItem(const std::string& boundItemId)
|
||||
{
|
||||
mPreviousItems.erase(boundItemId);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
#ifndef GAME_MWWORLD_PLAYER_H
|
||||
#define GAME_MWWORLD_PLAYER_H
|
||||
|
||||
#include <map>
|
||||
|
||||
#include "../mwworld/refdata.hpp"
|
||||
#include "../mwworld/livecellref.hpp"
|
||||
|
||||
|
@ -46,6 +48,9 @@ namespace MWWorld
|
|||
int mCurrentCrimeId; // the id assigned witnesses
|
||||
int mPaidCrimeId; // the last id paid off (0 bounty)
|
||||
|
||||
typedef std::map<std::string, std::string> PreviousItems; // previous equipped items, needed for bound spells
|
||||
PreviousItems mPreviousItems;
|
||||
|
||||
// Saved stats prior to becoming a werewolf
|
||||
MWMechanics::SkillValue mSaveSkills[ESM::Skill::Length];
|
||||
MWMechanics::AttributeValue mSaveAttributes[ESM::Attribute::Length];
|
||||
|
@ -120,6 +125,10 @@ namespace MWWorld
|
|||
int getNewCrimeId(); // get new id for witnesses
|
||||
void recordCrimeId(); // record the paid crime id when bounty is 0
|
||||
int getCrimeId() const; // get the last paid crime id
|
||||
|
||||
void setPreviousItem(const std::string& boundItemId, const std::string& previousItemId);
|
||||
std::string getPreviousItem(const std::string& boundItemId);
|
||||
void erasePreviousItem(const std::string& boundItemId);
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue