Commit 6baa5da6 authored by Evil Eye's avatar Evil Eye

Fix scripts not executing on respawn

parent cad4ba04
......@@ -27,6 +27,7 @@
#include "../mwworld/containerstore.hpp"
#include "../mwphysics/physicssystem.hpp"
#include "../mwworld/cellstore.hpp"
#include "../mwworld/localscripts.hpp"
#include "../mwrender/renderinginterface.hpp"
#include "../mwrender/objects.hpp"
......@@ -844,7 +845,12 @@ namespace MWClass
if (ptr.getCellRef().hasContentFile())
{
if (ptr.getRefData().getCount() == 0)
{
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);
ptr.getRefData().setCustomData(nullptr);
......
#include "npc.hpp"
#include "npc.hpp"
#include <memory>
......@@ -37,6 +37,7 @@
#include "../mwworld/customdata.hpp"
#include "../mwphysics/physicssystem.hpp"
#include "../mwworld/cellstore.hpp"
#include "../mwworld/localscripts.hpp"
#include "../mwrender/objects.hpp"
#include "../mwrender/renderinginterface.hpp"
......@@ -1376,7 +1377,12 @@ namespace MWClass
if (ptr.getCellRef().hasContentFile())
{
if (ptr.getRefData().getCount() == 0)
{
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);
ptr.getRefData().setCustomData(nullptr);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment