Fix scripts not executing on respawn

pull/541/head
unknown 5 years ago
parent cad4ba0423
commit 6baa5da6c9

@ -27,6 +27,7 @@
#include "../mwworld/containerstore.hpp" #include "../mwworld/containerstore.hpp"
#include "../mwphysics/physicssystem.hpp" #include "../mwphysics/physicssystem.hpp"
#include "../mwworld/cellstore.hpp" #include "../mwworld/cellstore.hpp"
#include "../mwworld/localscripts.hpp"
#include "../mwrender/renderinginterface.hpp" #include "../mwrender/renderinginterface.hpp"
#include "../mwrender/objects.hpp" #include "../mwrender/objects.hpp"
@ -844,7 +845,12 @@ namespace MWClass
if (ptr.getCellRef().hasContentFile()) if (ptr.getCellRef().hasContentFile())
{ {
if (ptr.getRefData().getCount() == 0) if (ptr.getRefData().getCount() == 0)
{
ptr.getRefData().setCount(1); ptr.getRefData().setCount(1);
const std::string& script = getScript(ptr);
if(!script.empty())
MWBase::Environment::get().getWorld()->getLocalScripts().add(script, ptr);
}
MWBase::Environment::get().getWorld()->removeContainerScripts(ptr); MWBase::Environment::get().getWorld()->removeContainerScripts(ptr);
ptr.getRefData().setCustomData(nullptr); ptr.getRefData().setCustomData(nullptr);

@ -1,4 +1,4 @@
#include "npc.hpp" #include "npc.hpp"
#include <memory> #include <memory>
@ -37,6 +37,7 @@
#include "../mwworld/customdata.hpp" #include "../mwworld/customdata.hpp"
#include "../mwphysics/physicssystem.hpp" #include "../mwphysics/physicssystem.hpp"
#include "../mwworld/cellstore.hpp" #include "../mwworld/cellstore.hpp"
#include "../mwworld/localscripts.hpp"
#include "../mwrender/objects.hpp" #include "../mwrender/objects.hpp"
#include "../mwrender/renderinginterface.hpp" #include "../mwrender/renderinginterface.hpp"
@ -1376,7 +1377,12 @@ namespace MWClass
if (ptr.getCellRef().hasContentFile()) if (ptr.getCellRef().hasContentFile())
{ {
if (ptr.getRefData().getCount() == 0) if (ptr.getRefData().getCount() == 0)
{
ptr.getRefData().setCount(1); ptr.getRefData().setCount(1);
const std::string& script = getScript(ptr);
if (!script.empty())
MWBase::Environment::get().getWorld()->getLocalScripts().add(script, ptr);
}
MWBase::Environment::get().getWorld()->removeContainerScripts(ptr); MWBase::Environment::get().getWorld()->removeContainerScripts(ptr);
ptr.getRefData().setCustomData(nullptr); ptr.getRefData().setCustomData(nullptr);

Loading…
Cancel
Save