mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 22:53:50 +00:00
Fix bug when enchanting: only the mBase pointer was updated, not the CellRef mRefID, which is used for container stacking. The new (enchanted) item was stacking with the old item when it was added, so the enchantment completely disappears.
This commit is contained in:
parent
800a2845b0
commit
6641fd4635
4 changed files with 13 additions and 9 deletions
|
@ -281,6 +281,7 @@ namespace MWClass
|
||||||
newItem.mEnchant=enchId;
|
newItem.mEnchant=enchId;
|
||||||
const ESM::Armor *record = MWBase::Environment::get().getWorld()->createRecord (newItem);
|
const ESM::Armor *record = MWBase::Environment::get().getWorld()->createRecord (newItem);
|
||||||
ref->mBase = record;
|
ref->mBase = record;
|
||||||
|
ref->mRef.mRefID = record->mId;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<int, std::string> Armor::canBeEquipped(const MWWorld::Ptr &ptr, const MWWorld::Ptr &npc) const
|
std::pair<int, std::string> Armor::canBeEquipped(const MWWorld::Ptr &ptr, const MWWorld::Ptr &npc) const
|
||||||
|
|
|
@ -171,6 +171,7 @@ namespace MWClass
|
||||||
newItem.mEnchant=enchId;
|
newItem.mEnchant=enchId;
|
||||||
const ESM::Book *record = MWBase::Environment::get().getWorld()->createRecord (newItem);
|
const ESM::Book *record = MWBase::Environment::get().getWorld()->createRecord (newItem);
|
||||||
ref->mBase = record;
|
ref->mBase = record;
|
||||||
|
ref->mRef.mRefID = record->mId;
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::shared_ptr<MWWorld::Action> Book::use (const MWWorld::Ptr& ptr) const
|
boost::shared_ptr<MWWorld::Action> Book::use (const MWWorld::Ptr& ptr) const
|
||||||
|
|
|
@ -227,6 +227,7 @@ namespace MWClass
|
||||||
newItem.mEnchant=enchId;
|
newItem.mEnchant=enchId;
|
||||||
const ESM::Clothing *record = MWBase::Environment::get().getWorld()->createRecord (newItem);
|
const ESM::Clothing *record = MWBase::Environment::get().getWorld()->createRecord (newItem);
|
||||||
ref->mBase = record;
|
ref->mBase = record;
|
||||||
|
ref->mRef.mRefID = record->mId;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<int, std::string> Clothing::canBeEquipped(const MWWorld::Ptr &ptr, const MWWorld::Ptr &npc) const
|
std::pair<int, std::string> Clothing::canBeEquipped(const MWWorld::Ptr &ptr, const MWWorld::Ptr &npc) const
|
||||||
|
|
|
@ -370,16 +370,17 @@ namespace MWClass
|
||||||
|
|
||||||
void Weapon::applyEnchantment(const MWWorld::Ptr &ptr, const std::string& enchId, int enchCharge, const std::string& newName) const
|
void Weapon::applyEnchantment(const MWWorld::Ptr &ptr, const std::string& enchId, int enchCharge, const std::string& newName) const
|
||||||
{
|
{
|
||||||
MWWorld::LiveCellRef<ESM::Weapon> *ref =
|
MWWorld::LiveCellRef<ESM::Weapon> *ref =
|
||||||
ptr.get<ESM::Weapon>();
|
ptr.get<ESM::Weapon>();
|
||||||
|
|
||||||
ESM::Weapon newItem = *ref->mBase;
|
ESM::Weapon newItem = *ref->mBase;
|
||||||
newItem.mId="";
|
newItem.mId="";
|
||||||
newItem.mName=newName;
|
newItem.mName=newName;
|
||||||
newItem.mData.mEnchant=enchCharge;
|
newItem.mData.mEnchant=enchCharge;
|
||||||
newItem.mEnchant=enchId;
|
newItem.mEnchant=enchId;
|
||||||
const ESM::Weapon *record = MWBase::Environment::get().getWorld()->createRecord (newItem);
|
const ESM::Weapon *record = MWBase::Environment::get().getWorld()->createRecord (newItem);
|
||||||
ref->mBase = record;
|
ref->mBase = record;
|
||||||
|
ref->mRef.mRefID = record->mId;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<int, std::string> Weapon::canBeEquipped(const MWWorld::Ptr &ptr, const MWWorld::Ptr &npc) const
|
std::pair<int, std::string> Weapon::canBeEquipped(const MWWorld::Ptr &ptr, const MWWorld::Ptr &npc) const
|
||||||
|
|
Loading…
Reference in a new issue