mirror of
https://github.com/OpenMW/openmw.git
synced 2025-06-19 13:41:32 +00:00
Always print context for script warnings to remove the need for verbose option
(Fixes #2813)
This commit is contained in:
parent
9728a6967e
commit
3f27c8cc97
9 changed files with 24 additions and 32 deletions
|
@ -194,7 +194,6 @@ OMW::Engine::Engine(Files::ConfigurationManager& configurationManager)
|
||||||
: mWindow(NULL)
|
: mWindow(NULL)
|
||||||
, mEncoding(ToUTF8::WINDOWS_1252)
|
, mEncoding(ToUTF8::WINDOWS_1252)
|
||||||
, mEncoder(NULL)
|
, mEncoder(NULL)
|
||||||
, mVerboseScripts (false)
|
|
||||||
, mSkipMenu (false)
|
, mSkipMenu (false)
|
||||||
, mUseSound (true)
|
, mUseSound (true)
|
||||||
, mCompileAll (false)
|
, mCompileAll (false)
|
||||||
|
@ -284,11 +283,6 @@ void OMW::Engine::addContentFile(const std::string& file)
|
||||||
mContentFiles.push_back(file);
|
mContentFiles.push_back(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OMW::Engine::setScriptsVerbosity(bool scriptsVerbosity)
|
|
||||||
{
|
|
||||||
mVerboseScripts = scriptsVerbosity;
|
|
||||||
}
|
|
||||||
|
|
||||||
void OMW::Engine::setSkipMenu (bool skipMenu, bool newGame)
|
void OMW::Engine::setSkipMenu (bool skipMenu, bool newGame)
|
||||||
{
|
{
|
||||||
mSkipMenu = skipMenu;
|
mSkipMenu = skipMenu;
|
||||||
|
@ -534,8 +528,7 @@ void OMW::Engine::prepareEngine (Settings::Manager & settings)
|
||||||
mScriptContext = new MWScript::CompilerContext (MWScript::CompilerContext::Type_Full);
|
mScriptContext = new MWScript::CompilerContext (MWScript::CompilerContext::Type_Full);
|
||||||
mScriptContext->setExtensions (&mExtensions);
|
mScriptContext->setExtensions (&mExtensions);
|
||||||
|
|
||||||
mEnvironment.setScriptManager (new MWScript::ScriptManager (mEnvironment.getWorld()->getStore(),
|
mEnvironment.setScriptManager (new MWScript::ScriptManager (mEnvironment.getWorld()->getStore(), *mScriptContext, mWarningsMode,
|
||||||
mVerboseScripts, *mScriptContext, mWarningsMode,
|
|
||||||
mScriptBlacklistUse ? mScriptBlacklist : std::vector<std::string>()));
|
mScriptBlacklistUse ? mScriptBlacklist : std::vector<std::string>()));
|
||||||
|
|
||||||
// Create game mechanics system
|
// Create game mechanics system
|
||||||
|
@ -544,7 +537,7 @@ void OMW::Engine::prepareEngine (Settings::Manager & settings)
|
||||||
|
|
||||||
// Create dialog system
|
// Create dialog system
|
||||||
mEnvironment.setJournal (new MWDialogue::Journal);
|
mEnvironment.setJournal (new MWDialogue::Journal);
|
||||||
mEnvironment.setDialogueManager (new MWDialogue::DialogueManager (mExtensions, mVerboseScripts, mTranslationDataStorage));
|
mEnvironment.setDialogueManager (new MWDialogue::DialogueManager (mExtensions, mTranslationDataStorage));
|
||||||
|
|
||||||
// scripts
|
// scripts
|
||||||
if (mCompileAll)
|
if (mCompileAll)
|
||||||
|
|
|
@ -84,7 +84,6 @@ namespace OMW
|
||||||
osg::ref_ptr<osgViewer::ScreenCaptureHandler> mScreenCaptureHandler;
|
osg::ref_ptr<osgViewer::ScreenCaptureHandler> mScreenCaptureHandler;
|
||||||
std::string mCellName;
|
std::string mCellName;
|
||||||
std::vector<std::string> mContentFiles;
|
std::vector<std::string> mContentFiles;
|
||||||
bool mVerboseScripts;
|
|
||||||
bool mSkipMenu;
|
bool mSkipMenu;
|
||||||
bool mUseSound;
|
bool mUseSound;
|
||||||
bool mCompileAll;
|
bool mCompileAll;
|
||||||
|
@ -158,9 +157,6 @@ namespace OMW
|
||||||
*/
|
*/
|
||||||
void addContentFile(const std::string& file);
|
void addContentFile(const std::string& file);
|
||||||
|
|
||||||
/// Enable or disable verbose script output
|
|
||||||
void setScriptsVerbosity(bool scriptsVerbosity);
|
|
||||||
|
|
||||||
/// Disable or enable all sounds
|
/// Disable or enable all sounds
|
||||||
void setSoundUsage(bool soundUsage);
|
void setSoundUsage(bool soundUsage);
|
||||||
|
|
||||||
|
|
|
@ -98,9 +98,6 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat
|
||||||
("no-sound", bpo::value<bool>()->implicit_value(true)
|
("no-sound", bpo::value<bool>()->implicit_value(true)
|
||||||
->default_value(false), "disable all sounds")
|
->default_value(false), "disable all sounds")
|
||||||
|
|
||||||
("script-verbose", bpo::value<bool>()->implicit_value(true)
|
|
||||||
->default_value(false), "verbose script output")
|
|
||||||
|
|
||||||
("script-all", bpo::value<bool>()->implicit_value(true)
|
("script-all", bpo::value<bool>()->implicit_value(true)
|
||||||
->default_value(false), "compile all scripts (excluding dialogue scripts) at startup")
|
->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
|
// scripts
|
||||||
engine.setCompileAll(variables["script-all"].as<bool>());
|
engine.setCompileAll(variables["script-all"].as<bool>());
|
||||||
engine.setCompileAllDialogue(variables["script-all-dialogue"].as<bool>());
|
engine.setCompileAllDialogue(variables["script-all-dialogue"].as<bool>());
|
||||||
engine.setScriptsVerbosity(variables["script-verbose"].as<bool>());
|
|
||||||
engine.setScriptConsoleMode (variables["script-console"].as<bool>());
|
engine.setScriptConsoleMode (variables["script-console"].as<bool>());
|
||||||
engine.setStartupScript (variables["script-run"].as<Files::EscapeHashString>().toStdString());
|
engine.setStartupScript (variables["script-run"].as<Files::EscapeHashString>().toStdString());
|
||||||
engine.setWarningsMode (variables["script-warn"].as<int>());
|
engine.setWarningsMode (variables["script-warn"].as<int>());
|
||||||
|
|
|
@ -48,7 +48,7 @@
|
||||||
|
|
||||||
namespace MWDialogue
|
namespace MWDialogue
|
||||||
{
|
{
|
||||||
DialogueManager::DialogueManager (const Compiler::Extensions& extensions, bool scriptVerbose, Translation::Storage& translationDataStorage) :
|
DialogueManager::DialogueManager (const Compiler::Extensions& extensions, Translation::Storage& translationDataStorage) :
|
||||||
mTranslationDataStorage(translationDataStorage)
|
mTranslationDataStorage(translationDataStorage)
|
||||||
, mCompilerContext (MWScript::CompilerContext::Type_Dialogue)
|
, mCompilerContext (MWScript::CompilerContext::Type_Dialogue)
|
||||||
, mErrorStream(std::cout.rdbuf())
|
, mErrorStream(std::cout.rdbuf())
|
||||||
|
@ -198,6 +198,8 @@ namespace MWDialogue
|
||||||
{
|
{
|
||||||
mErrorHandler.reset();
|
mErrorHandler.reset();
|
||||||
|
|
||||||
|
mErrorHandler.setContext("[dialogue script]");
|
||||||
|
|
||||||
std::istringstream input (cmd + "\n");
|
std::istringstream input (cmd + "\n");
|
||||||
|
|
||||||
Compiler::Scanner scanner (mErrorHandler, input, mCompilerContext.getExtensions());
|
Compiler::Scanner scanner (mErrorHandler, input, mCompilerContext.getExtensions());
|
||||||
|
|
|
@ -58,7 +58,7 @@ namespace MWDialogue
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
DialogueManager (const Compiler::Extensions& extensions, bool scriptVerbose, Translation::Storage& translationDataStorage);
|
DialogueManager (const Compiler::Extensions& extensions, Translation::Storage& translationDataStorage);
|
||||||
|
|
||||||
virtual void clear();
|
virtual void clear();
|
||||||
|
|
||||||
|
|
|
@ -21,10 +21,10 @@
|
||||||
|
|
||||||
namespace MWScript
|
namespace MWScript
|
||||||
{
|
{
|
||||||
ScriptManager::ScriptManager (const MWWorld::ESMStore& store, bool verbose,
|
ScriptManager::ScriptManager (const MWWorld::ESMStore& store,
|
||||||
Compiler::Context& compilerContext, int warningsMode,
|
Compiler::Context& compilerContext, int warningsMode,
|
||||||
const std::vector<std::string>& scriptBlacklist)
|
const std::vector<std::string>& scriptBlacklist)
|
||||||
: mErrorHandler (std::cerr), mStore (store), mVerbose (verbose),
|
: mErrorHandler (std::cerr), mStore (store),
|
||||||
mCompilerContext (compilerContext), mParser (mErrorHandler, mCompilerContext),
|
mCompilerContext (compilerContext), mParser (mErrorHandler, mCompilerContext),
|
||||||
mOpcodesInstalled (false), mGlobalScripts (store)
|
mOpcodesInstalled (false), mGlobalScripts (store)
|
||||||
{
|
{
|
||||||
|
@ -44,8 +44,7 @@ namespace MWScript
|
||||||
|
|
||||||
if (const ESM::Script *script = mStore.get<ESM::Script>().find (name))
|
if (const ESM::Script *script = mStore.get<ESM::Script>().find (name))
|
||||||
{
|
{
|
||||||
if (mVerbose)
|
mErrorHandler.setContext(name);
|
||||||
std::cout << "compiling script: " << name << std::endl;
|
|
||||||
|
|
||||||
bool Success = true;
|
bool Success = true;
|
||||||
try
|
try
|
||||||
|
@ -74,8 +73,6 @@ namespace MWScript
|
||||||
{
|
{
|
||||||
std::cerr
|
std::cerr
|
||||||
<< "compiling failed: " << name << std::endl;
|
<< "compiling failed: " << name << std::endl;
|
||||||
if (mVerbose)
|
|
||||||
std::cerr << script->mScriptText << std::endl << std::endl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Success)
|
if (Success)
|
||||||
|
@ -172,13 +169,10 @@ namespace MWScript
|
||||||
|
|
||||||
if (const ESM::Script *script = mStore.get<ESM::Script>().search (name2))
|
if (const ESM::Script *script = mStore.get<ESM::Script>().search (name2))
|
||||||
{
|
{
|
||||||
if (mVerbose)
|
|
||||||
std::cout
|
|
||||||
<< "scanning script for local variable declarations: " << name2
|
|
||||||
<< std::endl;
|
|
||||||
|
|
||||||
Compiler::Locals locals;
|
Compiler::Locals locals;
|
||||||
|
|
||||||
|
mErrorHandler.setContext(name2 + "[local variables]");
|
||||||
|
|
||||||
std::istringstream stream (script->mScriptText);
|
std::istringstream stream (script->mScriptText);
|
||||||
Compiler::QuickFileParser parser (mErrorHandler, mCompilerContext, locals);
|
Compiler::QuickFileParser parser (mErrorHandler, mCompilerContext, locals);
|
||||||
Compiler::Scanner scanner (mErrorHandler, stream, mCompilerContext.getExtensions());
|
Compiler::Scanner scanner (mErrorHandler, stream, mCompilerContext.getExtensions());
|
||||||
|
|
|
@ -36,7 +36,6 @@ namespace MWScript
|
||||||
{
|
{
|
||||||
Compiler::StreamErrorHandler mErrorHandler;
|
Compiler::StreamErrorHandler mErrorHandler;
|
||||||
const MWWorld::ESMStore& mStore;
|
const MWWorld::ESMStore& mStore;
|
||||||
bool mVerbose;
|
|
||||||
Compiler::Context& mCompilerContext;
|
Compiler::Context& mCompilerContext;
|
||||||
Compiler::FileParser mParser;
|
Compiler::FileParser mParser;
|
||||||
Interpreter::Interpreter mInterpreter;
|
Interpreter::Interpreter mInterpreter;
|
||||||
|
@ -52,7 +51,7 @@ namespace MWScript
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
ScriptManager (const MWWorld::ESMStore& store, bool verbose,
|
ScriptManager (const MWWorld::ESMStore& store,
|
||||||
Compiler::Context& compilerContext, int warningsMode,
|
Compiler::Context& compilerContext, int warningsMode,
|
||||||
const std::vector<std::string>& scriptBlacklist);
|
const std::vector<std::string>& scriptBlacklist);
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,9 @@ namespace Compiler
|
||||||
else
|
else
|
||||||
mStream << "warning ";
|
mStream << "warning ";
|
||||||
|
|
||||||
|
if (!mContext.empty())
|
||||||
|
mStream << mContext << " ";
|
||||||
|
|
||||||
mStream
|
mStream
|
||||||
<< "line " << loc.mLine+1 << ", column " << loc.mColumn+1
|
<< "line " << loc.mLine+1 << ", column " << loc.mColumn+1
|
||||||
<< " (" << loc.mLiteral << ")" << std::endl
|
<< " (" << loc.mLiteral << ")" << std::endl
|
||||||
|
@ -34,5 +37,10 @@ namespace Compiler
|
||||||
<< " " << message << std::endl;
|
<< " " << message << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void StreamErrorHandler::setContext(const std::string &context)
|
||||||
|
{
|
||||||
|
mContext = context;
|
||||||
|
}
|
||||||
|
|
||||||
StreamErrorHandler::StreamErrorHandler (std::ostream& ErrorStream) : mStream (ErrorStream) {}
|
StreamErrorHandler::StreamErrorHandler (std::ostream& ErrorStream) : mStream (ErrorStream) {}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,8 @@ namespace Compiler
|
||||||
{
|
{
|
||||||
std::ostream& mStream;
|
std::ostream& mStream;
|
||||||
|
|
||||||
|
std::string mContext;
|
||||||
|
|
||||||
// not implemented
|
// not implemented
|
||||||
|
|
||||||
StreamErrorHandler (const StreamErrorHandler&);
|
StreamErrorHandler (const StreamErrorHandler&);
|
||||||
|
@ -26,6 +28,8 @@ namespace Compiler
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
void setContext(const std::string& context);
|
||||||
|
|
||||||
// constructors
|
// constructors
|
||||||
|
|
||||||
StreamErrorHandler (std::ostream& ErrorStream);
|
StreamErrorHandler (std::ostream& ErrorStream);
|
||||||
|
|
Loading…
Reference in a new issue