From b93bfc4380264322680a0a79f7b05e3db05257b6 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Mon, 6 Feb 2012 01:45:17 -0700 Subject: Correct errors for improper input. --- src/gamebuilder.cpp | 4 ++++ src/situation.cpp | 2 ++ 2 files changed, 6 insertions(+) (limited to 'src') diff --git a/src/gamebuilder.cpp b/src/gamebuilder.cpp index 353e254..bfeffec 100644 --- a/src/gamebuilder.cpp +++ b/src/gamebuilder.cpp @@ -177,6 +177,8 @@ void GameBuilder::closeGlobal() void GameBuilder::beginCommand( const Bu::String &sValue ) { + if( !bGlobal && pCurSit->getInputType() != Situation::inputCommand ) + throw Bu::ExceptionBase("Command in non-command situation."); pCurNode = pCurRoot = new AstBranch( AstNode::tScope ); pCurCmd = new Command(); pCurCmd->addLiteral( sValue ); @@ -221,6 +223,8 @@ void GameBuilder::closeCommand() void GameBuilder::beginOption( const Bu::String &sValue ) { + if( pCurSit->getInputType() != Situation::inputOption ) + throw Bu::ExceptionBase("Option in non-option situation."); pCurNode = pCurRoot = new AstBranch( AstNode::tScope ); pCurCmd = new Command(); pCurCmd->addLiteral( sValue ); diff --git a/src/situation.cpp b/src/situation.cpp index 923eea7..1d3a853 100644 --- a/src/situation.cpp +++ b/src/situation.cpp @@ -75,5 +75,7 @@ Bu::Formatter &operator<<( Bu::Formatter &f, Situation::Mode m ) case Situation::modeEnter: return f << "Enter"; } + + return f << "**ERROR**"; } -- cgit v1.2.3