From 92d7f21926cee660dfaa05ceb4b93c93c0994ed6 Mon Sep 17 00:00:00 2001 From: Capostrophic Date: Sun, 6 Jan 2019 21:04:24 +0300 Subject: [PATCH] Don't interrupt compilation when spell/effect functions are used for non-actors --- CHANGELOG.md | 1 + apps/openmw/mwscript/miscextensions.cpp | 12 ++++++++++++ apps/openmw/mwscript/statsextensions.cpp | 2 +- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0da3ba67d..41b57bf28 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ Bug #4746: Non-solid player can't run or sneak Bug #4750: Sneaking doesn't work in first person view if the player is in attack ready state Bug #4768: Fallback numerical value recovery chokes on invalid arguments + Bug #4778: Interiors of Illusion puzzle in Sotha Sil Expanded mod is broken Feature #2229: Improve pathfinding AI Feature #3442: Default values for fallbacks from ini file Feature #3610: Option to invert X axis diff --git a/apps/openmw/mwscript/miscextensions.cpp b/apps/openmw/mwscript/miscextensions.cpp index 0cf2fc464..d3b49239c 100644 --- a/apps/openmw/mwscript/miscextensions.cpp +++ b/apps/openmw/mwscript/miscextensions.cpp @@ -431,6 +431,12 @@ namespace MWScript std::string effect = runtime.getStringLiteral(runtime[0].mInteger); runtime.pop(); + if (!ptr.getClass().isActor()) + { + runtime.push(0); + return; + } + char *end; long key = strtol(effect.c_str(), &end, 10); if(key < 0 || key > 32767 || *end != '\0') @@ -659,6 +665,12 @@ namespace MWScript std::string id = runtime.getStringLiteral(runtime[0].mInteger); runtime.pop(); + if (!ptr.getClass().isActor()) + { + runtime.push(0); + return; + } + const MWMechanics::CreatureStats& stats = ptr.getClass().getCreatureStats(ptr); runtime.push(stats.getActiveSpells().isSpellActive(id) || stats.getSpells().isSpellActive(id)); } diff --git a/apps/openmw/mwscript/statsextensions.cpp b/apps/openmw/mwscript/statsextensions.cpp index 53316c44c..10d1252b9 100644 --- a/apps/openmw/mwscript/statsextensions.cpp +++ b/apps/openmw/mwscript/statsextensions.cpp @@ -536,7 +536,7 @@ namespace MWScript Interpreter::Type_Integer value = 0; - if (ptr.getClass().getCreatureStats(ptr).getSpells().hasSpell(id)) + if (ptr.getClass().isActor() && ptr.getClass().getCreatureStats(ptr).getSpells().hasSpell(id)) value = 1; runtime.push (value);