From 03a35c38df9a8fc788d98978f1ab73f98f8d1866 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Tue, 6 Sep 2016 16:33:26 +0200 Subject: [PATCH] add missing item when executing the Equip instruction --- apps/openmw/mwscript/containerextensions.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/apps/openmw/mwscript/containerextensions.cpp b/apps/openmw/mwscript/containerextensions.cpp index 366e88f1e..0b4c9a0fc 100644 --- a/apps/openmw/mwscript/containerextensions.cpp +++ b/apps/openmw/mwscript/containerextensions.cpp @@ -102,7 +102,7 @@ namespace MWScript || ::Misc::StringUtils::ciEqual(item, "gold_025") || ::Misc::StringUtils::ciEqual(item, "gold_100")) item = "gold_001"; - + MWWorld::ContainerStore& store = ptr.getClass().getContainerStore (ptr); runtime.push (store.count(item)); @@ -136,7 +136,7 @@ namespace MWScript || ::Misc::StringUtils::ciEqual(item, "gold_025") || ::Misc::StringUtils::ciEqual(item, "gold_100")) item = "gold_001"; - + MWWorld::ContainerStore& store = ptr.getClass().getContainerStore (ptr); std::string itemName; @@ -188,7 +188,11 @@ namespace MWScript break; } if (it == invStore.end()) - throw std::runtime_error("Item to equip not found"); + { + it = ptr.getClass().getContainerStore (ptr).add (item, 1, ptr); + std::cerr << "Implicitly adding one " << item << " to container " + "to fulfil requirements of Equip instruction" << std::endl; + } if (ptr == MWBase::Environment::get().getWorld()->getPlayerPtr()) MWBase::Environment::get().getWindowManager()->useItem(*it);