mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 20:53:50 +00:00
improved error reporting for dialogue scripts (enabled via --script-verbose)
This commit is contained in:
parent
c621a9f7e4
commit
2a1727d4c5
3 changed files with 24 additions and 11 deletions
|
@ -356,7 +356,7 @@ void OMW::Engine::go()
|
||||||
|
|
||||||
// Create dialog system
|
// Create dialog system
|
||||||
mEnvironment.setJournal (new MWDialogue::Journal);
|
mEnvironment.setJournal (new MWDialogue::Journal);
|
||||||
mEnvironment.setDialogueManager (new MWDialogue::DialogueManager (mExtensions));
|
mEnvironment.setDialogueManager (new MWDialogue::DialogueManager (mExtensions, mVerboseScripts));
|
||||||
|
|
||||||
// Sets up the input system
|
// Sets up the input system
|
||||||
mEnvironment.setInputManager (new MWInput::InputManager (*mOgre,
|
mEnvironment.setInputManager (new MWInput::InputManager (*mOgre,
|
||||||
|
|
|
@ -75,11 +75,11 @@ namespace
|
||||||
|
|
||||||
namespace MWDialogue
|
namespace MWDialogue
|
||||||
{
|
{
|
||||||
DialogueManager::DialogueManager (const Compiler::Extensions& extensions) :
|
DialogueManager::DialogueManager (const Compiler::Extensions& extensions, bool scriptVerbose) :
|
||||||
mCompilerContext (MWScript::CompilerContext::Type_Dialgoue),
|
mCompilerContext (MWScript::CompilerContext::Type_Dialgoue),
|
||||||
mErrorStream(std::cout.rdbuf()),mErrorHandler(mErrorStream)
|
mErrorStream(std::cout.rdbuf()),mErrorHandler(mErrorStream)
|
||||||
, mTemporaryDispositionChange(0.f)
|
, mTemporaryDispositionChange(0.f)
|
||||||
, mPermanentDispositionChange(0.f)
|
, mPermanentDispositionChange(0.f), mScriptVerbose (scriptVerbose)
|
||||||
{
|
{
|
||||||
mChoice = -1;
|
mChoice = -1;
|
||||||
mIsInChoice = false;
|
mIsInChoice = false;
|
||||||
|
@ -174,6 +174,8 @@ namespace MWDialogue
|
||||||
|
|
||||||
bool DialogueManager::compile (const std::string& cmd,std::vector<Interpreter::Type_Code>& code)
|
bool DialogueManager::compile (const std::string& cmd,std::vector<Interpreter::Type_Code>& code)
|
||||||
{
|
{
|
||||||
|
bool success = true;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
mErrorHandler.reset();
|
mErrorHandler.reset();
|
||||||
|
@ -195,23 +197,33 @@ namespace MWDialogue
|
||||||
Compiler::ScriptParser parser(mErrorHandler,mCompilerContext, locals, false);
|
Compiler::ScriptParser parser(mErrorHandler,mCompilerContext, locals, false);
|
||||||
|
|
||||||
scanner.scan (parser);
|
scanner.scan (parser);
|
||||||
if(mErrorHandler.isGood())
|
|
||||||
{
|
if (!mErrorHandler.isGood())
|
||||||
parser.getCode(code);
|
success = false;
|
||||||
return true;
|
|
||||||
}
|
if (success)
|
||||||
return false;
|
parser.getCode (code);
|
||||||
}
|
}
|
||||||
catch (const Compiler::SourceException& /* error */)
|
catch (const Compiler::SourceException& /* error */)
|
||||||
{
|
{
|
||||||
// error has already been reported via error handler
|
// error has already been reported via error handler
|
||||||
|
success = false;
|
||||||
}
|
}
|
||||||
catch (const std::exception& error)
|
catch (const std::exception& error)
|
||||||
{
|
{
|
||||||
printError (std::string ("An exception has been thrown: ") + error.what());
|
printError (std::string ("An exception has been thrown: ") + error.what());
|
||||||
|
success = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
if (!success && mScriptVerbose)
|
||||||
|
{
|
||||||
|
std::cerr
|
||||||
|
<< "compiling failed (dialogue script)" << std::endl
|
||||||
|
<< cmd
|
||||||
|
<< std::endl << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DialogueManager::executeScript (const std::string& script)
|
void DialogueManager::executeScript (const std::string& script)
|
||||||
|
|
|
@ -35,6 +35,7 @@ namespace MWDialogue
|
||||||
|
|
||||||
float mTemporaryDispositionChange;
|
float mTemporaryDispositionChange;
|
||||||
float mPermanentDispositionChange;
|
float mPermanentDispositionChange;
|
||||||
|
bool mScriptVerbose;
|
||||||
|
|
||||||
void parseText (const std::string& text);
|
void parseText (const std::string& text);
|
||||||
|
|
||||||
|
@ -47,7 +48,7 @@ namespace MWDialogue
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
DialogueManager (const Compiler::Extensions& extensions);
|
DialogueManager (const Compiler::Extensions& extensions, bool scriptVerbose);
|
||||||
|
|
||||||
virtual void startDialogue (const MWWorld::Ptr& actor);
|
virtual void startDialogue (const MWWorld::Ptr& actor);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue