From 187d2bccda53da425f49bc7e652bee29c63822cf Mon Sep 17 00:00:00 2001 From: scrawl Date: Wed, 3 Feb 2016 16:06:25 +0100 Subject: [PATCH] Warn about adding a local script twice (Bug #2806) --- apps/openmw/mwworld/localscripts.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/apps/openmw/mwworld/localscripts.cpp b/apps/openmw/mwworld/localscripts.cpp index 2004a2ff3..374f5c632 100644 --- a/apps/openmw/mwworld/localscripts.cpp +++ b/apps/openmw/mwworld/localscripts.cpp @@ -110,6 +110,14 @@ void MWWorld::LocalScripts::add (const std::string& scriptName, const Ptr& ptr) { ptr.getRefData().setLocals (*script); + for (std::list >::iterator iter = mScripts.begin(); iter!=mScripts.end(); ++iter) + if (iter->second==ptr) + { + std::cout << "warning, tried to add local script twice for " << ptr.getCellRef().getRefId() << std::endl; + remove(ptr); + break; + } + mScripts.push_back (std::make_pair (scriptName, ptr)); } catch (const std::exception& exception)