forked from mirror/openmw-tes3mp
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)
|
||||
, 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<std::string>()));
|
||||
|
||||
// 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)
|
||||
|
|
|
@ -84,7 +84,6 @@ namespace OMW
|
|||
osg::ref_ptr<osgViewer::ScreenCaptureHandler> mScreenCaptureHandler;
|
||||
std::string mCellName;
|
||||
std::vector<std::string> 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);
|
||||
|
||||
|
|
|
@ -98,9 +98,6 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat
|
|||
("no-sound", bpo::value<bool>()->implicit_value(true)
|
||||
->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)
|
||||
->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<bool>());
|
||||
engine.setCompileAllDialogue(variables["script-all-dialogue"].as<bool>());
|
||||
engine.setScriptsVerbosity(variables["script-verbose"].as<bool>());
|
||||
engine.setScriptConsoleMode (variables["script-console"].as<bool>());
|
||||
engine.setStartupScript (variables["script-run"].as<Files::EscapeHashString>().toStdString());
|
||||
engine.setWarningsMode (variables["script-warn"].as<int>());
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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<std::string>& 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<ESM::Script>().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<ESM::Script>().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());
|
||||
|
|
|
@ -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<std::string>& scriptBlacklist);
|
||||
|
||||
|
|
|
@ -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) {}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue