mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-31 21:45:33 +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
|
||||
mEnvironment.setJournal (new MWDialogue::Journal);
|
||||
mEnvironment.setDialogueManager (new MWDialogue::DialogueManager (mExtensions));
|
||||
mEnvironment.setDialogueManager (new MWDialogue::DialogueManager (mExtensions, mVerboseScripts));
|
||||
|
||||
// Sets up the input system
|
||||
mEnvironment.setInputManager (new MWInput::InputManager (*mOgre,
|
||||
|
|
|
@ -75,11 +75,11 @@ namespace
|
|||
|
||||
namespace MWDialogue
|
||||
{
|
||||
DialogueManager::DialogueManager (const Compiler::Extensions& extensions) :
|
||||
DialogueManager::DialogueManager (const Compiler::Extensions& extensions, bool scriptVerbose) :
|
||||
mCompilerContext (MWScript::CompilerContext::Type_Dialgoue),
|
||||
mErrorStream(std::cout.rdbuf()),mErrorHandler(mErrorStream)
|
||||
, mTemporaryDispositionChange(0.f)
|
||||
, mPermanentDispositionChange(0.f)
|
||||
, mPermanentDispositionChange(0.f), mScriptVerbose (scriptVerbose)
|
||||
{
|
||||
mChoice = -1;
|
||||
mIsInChoice = false;
|
||||
|
@ -174,6 +174,8 @@ namespace MWDialogue
|
|||
|
||||
bool DialogueManager::compile (const std::string& cmd,std::vector<Interpreter::Type_Code>& code)
|
||||
{
|
||||
bool success = true;
|
||||
|
||||
try
|
||||
{
|
||||
mErrorHandler.reset();
|
||||
|
@ -195,23 +197,33 @@ namespace MWDialogue
|
|||
Compiler::ScriptParser parser(mErrorHandler,mCompilerContext, locals, false);
|
||||
|
||||
scanner.scan (parser);
|
||||
if(mErrorHandler.isGood())
|
||||
{
|
||||
parser.getCode(code);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
if (!mErrorHandler.isGood())
|
||||
success = false;
|
||||
|
||||
if (success)
|
||||
parser.getCode (code);
|
||||
}
|
||||
catch (const Compiler::SourceException& /* error */)
|
||||
{
|
||||
// error has already been reported via error handler
|
||||
success = false;
|
||||
}
|
||||
catch (const std::exception& error)
|
||||
{
|
||||
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)
|
||||
|
|
|
@ -35,6 +35,7 @@ namespace MWDialogue
|
|||
|
||||
float mTemporaryDispositionChange;
|
||||
float mPermanentDispositionChange;
|
||||
bool mScriptVerbose;
|
||||
|
||||
void parseText (const std::string& text);
|
||||
|
||||
|
@ -47,7 +48,7 @@ namespace MWDialogue
|
|||
|
||||
public:
|
||||
|
||||
DialogueManager (const Compiler::Extensions& extensions);
|
||||
DialogueManager (const Compiler::Extensions& extensions, bool scriptVerbose);
|
||||
|
||||
virtual void startDialogue (const MWWorld::Ptr& actor);
|
||||
|
||||
|
|
Loading…
Reference in a new issue