From 8afdf0f46bc08b97622a900c6f10369ea1b2c989 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Wed, 15 Oct 2014 16:12:57 +0200 Subject: [PATCH] dagoth fix --- apps/openmw/mwscript/ref.hpp | 11 ++++++++--- apps/openmw/mwscript/statsextensions.cpp | 14 +++++++++++++- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/apps/openmw/mwscript/ref.hpp b/apps/openmw/mwscript/ref.hpp index 795839139..9fb713539 100644 --- a/apps/openmw/mwscript/ref.hpp +++ b/apps/openmw/mwscript/ref.hpp @@ -16,18 +16,23 @@ namespace MWScript { struct ExplicitRef { - MWWorld::Ptr operator() (Interpreter::Runtime& runtime, bool required=true) const + MWWorld::Ptr operator() (Interpreter::Runtime& runtime, bool required=true, + bool activeOnly = false) const { std::string id = runtime.getStringLiteral (runtime[0].mInteger); runtime.pop(); - return MWBase::Environment::get().getWorld()->getPtr (id, false); + if (required) + return MWBase::Environment::get().getWorld()->getPtr (id, activeOnly); + else + return MWBase::Environment::get().getWorld()->searchPtr (id, activeOnly); } }; struct ImplicitRef { - MWWorld::Ptr operator() (Interpreter::Runtime& runtime, bool required=true) const + MWWorld::Ptr operator() (Interpreter::Runtime& runtime, bool required=true, + bool activeOnly = false) const { MWScript::InterpreterContext& context = static_cast (runtime.getContext()); diff --git a/apps/openmw/mwscript/statsextensions.cpp b/apps/openmw/mwscript/statsextensions.cpp index 4d7dd910e..9980ab0fb 100644 --- a/apps/openmw/mwscript/statsextensions.cpp +++ b/apps/openmw/mwscript/statsextensions.cpp @@ -217,6 +217,8 @@ namespace MWScript virtual void execute (Interpreter::Runtime& runtime) { + int peek = runtime[0].mInteger; + MWWorld::Ptr ptr = R()(runtime); Interpreter::Type_Float diff = runtime[0].mFloat; @@ -224,7 +226,17 @@ namespace MWScript // workaround broken endgame scripts that kill dagoth ur if (Misc::StringUtils::ciEqual(ptr.getCellRef().getRefId(), "dagoth_ur_1")) - return; + { + runtime.push (peek); + + if (R()(runtime, false, true).isEmpty()) + { + std::cerr + << "Compensating for broken script in Morrowind.esm by " + << "ignoring remote access to dagoth_ur_1" << std::endl; + return; + } + } MWMechanics::CreatureStats& stats = ptr.getClass().getCreatureStats (ptr);