Update a reference's base record pointer on resurrection

iwyu_full
Evil Eye 1 year ago
parent f4ac32efc9
commit 209a102061

@ -27,6 +27,7 @@
Bug #7034: Misc items defined in one content file are not treated as keys if another content file uses them as such
Bug #7042: Weapon follow animations that immediately follow the hit animations cause multiple hits
Bug #7044: Changing a class' services does not affect autocalculated NPCs
Bug #7084: Resurrecting an actor doesn't take into account base record changes
Feature #6447: Add LOD support to Object Paging
Feature #6933: Support high-resolution cursor textures
Feature #6945: Support S3TC-compressed and BGR/BGRA NiPixelData

@ -2,6 +2,7 @@
#include <cmath>
#include <components/esm3/loadcrea.hpp>
#include <components/esm3/loadnpc.hpp>
#include "../mwworld/esmstore.hpp"
@ -62,6 +63,14 @@ namespace
stat.setBase(std::clamp(base + amount, 0.f, 100.f), true);
stat.setModifier(newModified - stat.getBase());
}
template <class T>
void updateBaseRecord(MWWorld::Ptr& ptr)
{
const auto& store = MWBase::Environment::get().getWorld()->getStore();
const T* base = store.get<T>().find(ptr.getCellRef().getRefId());
ptr.get<T>()->mBase = base;
}
}
namespace MWScript
@ -1130,6 +1139,12 @@ namespace MWScript
windowManager->onDeleteCustomData(ptr);
// HACK: disable/enable object to re-add it to the scene properly (need a new Animation).
MWBase::Environment::get().getWorld()->disable(ptr);
// The actor's base record may have changed after this specific reference was created.
// So we need to update to the current version
if (ptr.getClass().isNpc())
updateBaseRecord<ESM::NPC>(ptr);
else
updateBaseRecord<ESM::Creature>(ptr);
if (wasOpen && !windowManager->containsMode(MWGui::GM_Container))
{
// Reopen the loot GUI if it was closed because we resurrected the actor we were looting

Loading…
Cancel
Save