1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-04-01 02:06:42 +00:00

workaround for NPC activation crash

This commit is contained in:
Marc Zinnschlag 2010-12-31 15:50:54 +01:00
parent 2628b5143c
commit 67a745cdf6

View file

@ -421,36 +421,45 @@ void OMW::Engine::go()
void OMW::Engine::activate() void OMW::Engine::activate()
{ {
std::string handle = mEnvironment.mWorld->getFacedHandle(); // TODO: This is only a workaround. The input dispatcher should catch any exceptions thrown inside
// the input handling functions. Looks like this will require an OpenEngine modification.
if (handle.empty()) try
return;
MWWorld::Ptr ptr = mEnvironment.mWorld->getPtrViaHandle (handle);
if (ptr.isEmpty())
return;
MWScript::InterpreterContext interpreterContext (mEnvironment,
&ptr.getRefData().getLocals(), ptr);
boost::shared_ptr<MWWorld::Action> action =
MWWorld::Class::get (ptr).activate (ptr, mEnvironment.mWorld->getPlayerPos().getPlayer(),
mEnvironment);
interpreterContext.activate (ptr, action);
std::string script = MWWorld::Class::get (ptr).getScript (ptr);
if (!script.empty())
{ {
mIgnoreLocalPtr = ptr; std::string handle = mEnvironment.mWorld->getFacedHandle();
mScriptManager->run (script, interpreterContext);
if (handle.empty())
return;
MWWorld::Ptr ptr = mEnvironment.mWorld->getPtrViaHandle (handle);
if (ptr.isEmpty())
return;
MWScript::InterpreterContext interpreterContext (mEnvironment,
&ptr.getRefData().getLocals(), ptr);
boost::shared_ptr<MWWorld::Action> action =
MWWorld::Class::get (ptr).activate (ptr, mEnvironment.mWorld->getPlayerPos().getPlayer(),
mEnvironment);
interpreterContext.activate (ptr, action);
std::string script = MWWorld::Class::get (ptr).getScript (ptr);
if (!script.empty())
{
mIgnoreLocalPtr = ptr;
mScriptManager->run (script, interpreterContext);
}
if (!interpreterContext.hasActivationBeenHandled())
{
interpreterContext.executeActivation();
}
} }
catch (const std::exception& e)
if (!interpreterContext.hasActivationBeenHandled())
{ {
interpreterContext.executeActivation(); std::cerr << "Activation failed: " << e.what() << std::endl;
} }
} }