diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index 8723483f7..d54eed3a6 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -194,7 +194,6 @@ OMW::Engine::Engine(Files::ConfigurationManager& configurationManager) : mWindow(NULL) , mEncoding(ToUTF8::WINDOWS_1252) , mEncoder(NULL) - , mVerboseScripts (false) , mSkipMenu (false) , mUseSound (true) , mCompileAll (false) @@ -284,11 +283,6 @@ void OMW::Engine::addContentFile(const std::string& file) mContentFiles.push_back(file); } -void OMW::Engine::setScriptsVerbosity(bool scriptsVerbosity) -{ - mVerboseScripts = scriptsVerbosity; -} - void OMW::Engine::setSkipMenu (bool skipMenu, bool newGame) { mSkipMenu = skipMenu; @@ -534,8 +528,7 @@ void OMW::Engine::prepareEngine (Settings::Manager & settings) mScriptContext = new MWScript::CompilerContext (MWScript::CompilerContext::Type_Full); mScriptContext->setExtensions (&mExtensions); - mEnvironment.setScriptManager (new MWScript::ScriptManager (mEnvironment.getWorld()->getStore(), - mVerboseScripts, *mScriptContext, mWarningsMode, + mEnvironment.setScriptManager (new MWScript::ScriptManager (mEnvironment.getWorld()->getStore(), *mScriptContext, mWarningsMode, mScriptBlacklistUse ? mScriptBlacklist : std::vector())); // Create game mechanics system @@ -544,7 +537,7 @@ void OMW::Engine::prepareEngine (Settings::Manager & settings) // Create dialog system mEnvironment.setJournal (new MWDialogue::Journal); - mEnvironment.setDialogueManager (new MWDialogue::DialogueManager (mExtensions, mVerboseScripts, mTranslationDataStorage)); + mEnvironment.setDialogueManager (new MWDialogue::DialogueManager (mExtensions, mTranslationDataStorage)); // scripts if (mCompileAll) diff --git a/apps/openmw/engine.hpp b/apps/openmw/engine.hpp index 11b6ec0a6..d06ca594d 100644 --- a/apps/openmw/engine.hpp +++ b/apps/openmw/engine.hpp @@ -84,7 +84,6 @@ namespace OMW osg::ref_ptr mScreenCaptureHandler; std::string mCellName; std::vector mContentFiles; - bool mVerboseScripts; bool mSkipMenu; bool mUseSound; bool mCompileAll; @@ -158,9 +157,6 @@ namespace OMW */ void addContentFile(const std::string& file); - /// Enable or disable verbose script output - void setScriptsVerbosity(bool scriptsVerbosity); - /// Disable or enable all sounds void setSoundUsage(bool soundUsage); diff --git a/apps/openmw/main.cpp b/apps/openmw/main.cpp index 43901d579..adc12bdfc 100644 --- a/apps/openmw/main.cpp +++ b/apps/openmw/main.cpp @@ -98,9 +98,6 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat ("no-sound", bpo::value()->implicit_value(true) ->default_value(false), "disable all sounds") - ("script-verbose", bpo::value()->implicit_value(true) - ->default_value(false), "verbose script output") - ("script-all", bpo::value()->implicit_value(true) ->default_value(false), "compile all scripts (excluding dialogue scripts) at startup") @@ -238,7 +235,6 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat // scripts engine.setCompileAll(variables["script-all"].as()); engine.setCompileAllDialogue(variables["script-all-dialogue"].as()); - engine.setScriptsVerbosity(variables["script-verbose"].as()); engine.setScriptConsoleMode (variables["script-console"].as()); engine.setStartupScript (variables["script-run"].as().toStdString()); engine.setWarningsMode (variables["script-warn"].as()); diff --git a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp index 830c2bcac..29bbc80f8 100644 --- a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp +++ b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp @@ -48,7 +48,7 @@ namespace MWDialogue { - DialogueManager::DialogueManager (const Compiler::Extensions& extensions, bool scriptVerbose, Translation::Storage& translationDataStorage) : + DialogueManager::DialogueManager (const Compiler::Extensions& extensions, Translation::Storage& translationDataStorage) : mTranslationDataStorage(translationDataStorage) , mCompilerContext (MWScript::CompilerContext::Type_Dialogue) , mErrorStream(std::cout.rdbuf()) @@ -198,6 +198,8 @@ namespace MWDialogue { mErrorHandler.reset(); + mErrorHandler.setContext("[dialogue script]"); + std::istringstream input (cmd + "\n"); Compiler::Scanner scanner (mErrorHandler, input, mCompilerContext.getExtensions()); diff --git a/apps/openmw/mwdialogue/dialoguemanagerimp.hpp b/apps/openmw/mwdialogue/dialoguemanagerimp.hpp index 086b5ef2f..bbe42975c 100644 --- a/apps/openmw/mwdialogue/dialoguemanagerimp.hpp +++ b/apps/openmw/mwdialogue/dialoguemanagerimp.hpp @@ -58,7 +58,7 @@ namespace MWDialogue public: - DialogueManager (const Compiler::Extensions& extensions, bool scriptVerbose, Translation::Storage& translationDataStorage); + DialogueManager (const Compiler::Extensions& extensions, Translation::Storage& translationDataStorage); virtual void clear(); diff --git a/apps/openmw/mwscript/scriptmanagerimp.cpp b/apps/openmw/mwscript/scriptmanagerimp.cpp index b73c9a642..97ea19a63 100644 --- a/apps/openmw/mwscript/scriptmanagerimp.cpp +++ b/apps/openmw/mwscript/scriptmanagerimp.cpp @@ -21,10 +21,10 @@ namespace MWScript { - ScriptManager::ScriptManager (const MWWorld::ESMStore& store, bool verbose, + ScriptManager::ScriptManager (const MWWorld::ESMStore& store, Compiler::Context& compilerContext, int warningsMode, const std::vector& scriptBlacklist) - : mErrorHandler (std::cerr), mStore (store), mVerbose (verbose), + : mErrorHandler (std::cerr), mStore (store), mCompilerContext (compilerContext), mParser (mErrorHandler, mCompilerContext), mOpcodesInstalled (false), mGlobalScripts (store) { @@ -44,8 +44,7 @@ namespace MWScript if (const ESM::Script *script = mStore.get().find (name)) { - if (mVerbose) - std::cout << "compiling script: " << name << std::endl; + mErrorHandler.setContext(name); bool Success = true; try @@ -74,8 +73,6 @@ namespace MWScript { std::cerr << "compiling failed: " << name << std::endl; - if (mVerbose) - std::cerr << script->mScriptText << std::endl << std::endl; } if (Success) @@ -172,13 +169,10 @@ namespace MWScript if (const ESM::Script *script = mStore.get().search (name2)) { - if (mVerbose) - std::cout - << "scanning script for local variable declarations: " << name2 - << std::endl; - Compiler::Locals locals; + mErrorHandler.setContext(name2 + "[local variables]"); + std::istringstream stream (script->mScriptText); Compiler::QuickFileParser parser (mErrorHandler, mCompilerContext, locals); Compiler::Scanner scanner (mErrorHandler, stream, mCompilerContext.getExtensions()); diff --git a/apps/openmw/mwscript/scriptmanagerimp.hpp b/apps/openmw/mwscript/scriptmanagerimp.hpp index e4a123b86..c22a5da81 100644 --- a/apps/openmw/mwscript/scriptmanagerimp.hpp +++ b/apps/openmw/mwscript/scriptmanagerimp.hpp @@ -36,7 +36,6 @@ namespace MWScript { Compiler::StreamErrorHandler mErrorHandler; const MWWorld::ESMStore& mStore; - bool mVerbose; Compiler::Context& mCompilerContext; Compiler::FileParser mParser; Interpreter::Interpreter mInterpreter; @@ -52,7 +51,7 @@ namespace MWScript public: - ScriptManager (const MWWorld::ESMStore& store, bool verbose, + ScriptManager (const MWWorld::ESMStore& store, Compiler::Context& compilerContext, int warningsMode, const std::vector& scriptBlacklist); diff --git a/components/compiler/streamerrorhandler.cpp b/components/compiler/streamerrorhandler.cpp index 9ca8aa74b..04bee8adb 100644 --- a/components/compiler/streamerrorhandler.cpp +++ b/components/compiler/streamerrorhandler.cpp @@ -14,6 +14,9 @@ namespace Compiler else mStream << "warning "; + if (!mContext.empty()) + mStream << mContext << " "; + mStream << "line " << loc.mLine+1 << ", column " << loc.mColumn+1 << " (" << loc.mLiteral << ")" << std::endl @@ -34,5 +37,10 @@ namespace Compiler << " " << message << std::endl; } + void StreamErrorHandler::setContext(const std::string &context) + { + mContext = context; + } + StreamErrorHandler::StreamErrorHandler (std::ostream& ErrorStream) : mStream (ErrorStream) {} } diff --git a/components/compiler/streamerrorhandler.hpp b/components/compiler/streamerrorhandler.hpp index 85de1833a..d287833ee 100644 --- a/components/compiler/streamerrorhandler.hpp +++ b/components/compiler/streamerrorhandler.hpp @@ -13,6 +13,8 @@ namespace Compiler { std::ostream& mStream; + std::string mContext; + // not implemented StreamErrorHandler (const StreamErrorHandler&); @@ -26,6 +28,8 @@ namespace Compiler public: + void setContext(const std::string& context); + // constructors StreamErrorHandler (std::ostream& ErrorStream);