diff options
Diffstat (limited to 'src/gamestate.cpp')
-rw-r--r-- | src/gamestate.cpp | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/src/gamestate.cpp b/src/gamestate.cpp index b009e4c..ceed091 100644 --- a/src/gamestate.cpp +++ b/src/gamestate.cpp | |||
@@ -10,6 +10,8 @@ | |||
10 | #include <gats/types.h> | 10 | #include <gats/types.h> |
11 | 11 | ||
12 | #include <bu/sio.h> | 12 | #include <bu/sio.h> |
13 | |||
14 | #include <stdlib.h> | ||
13 | using namespace Bu; | 15 | using namespace Bu; |
14 | 16 | ||
15 | GameState::GameState( Game *pGame, Interface *pIface ) : | 17 | GameState::GameState( Game *pGame, Interface *pIface ) : |
@@ -281,7 +283,9 @@ void GameState::gotoSituation( const Bu::String &sName ) | |||
281 | hsSituation.insert( sName, new Scope() ); | 283 | hsSituation.insert( sName, new Scope() ); |
282 | pSit->exec( *this, Situation::modeSetup ); | 284 | pSit->exec( *this, Situation::modeSetup ); |
283 | if( !sGoto.isSet() ) | 285 | if( !sGoto.isSet() ) |
286 | { | ||
284 | pSit->exec( *this, Situation::modeEnter ); | 287 | pSit->exec( *this, Situation::modeEnter ); |
288 | } | ||
285 | } | 289 | } |
286 | else | 290 | else |
287 | { | 291 | { |
@@ -290,7 +294,7 @@ void GameState::gotoSituation( const Bu::String &sName ) | |||
290 | 294 | ||
291 | if( sGoto.isSet() ) | 295 | if( sGoto.isSet() ) |
292 | { | 296 | { |
293 | gotoSituation( sGoto ); | 297 | gotoSituation( sGoto.clone() ); |
294 | } | 298 | } |
295 | } | 299 | } |
296 | 300 | ||
@@ -315,7 +319,7 @@ void GameState::execCommand( const Bu::String &sCmd ) | |||
315 | } | 319 | } |
316 | 320 | ||
317 | if( sGoto.isSet() ) | 321 | if( sGoto.isSet() ) |
318 | gotoSituation( sGoto ); | 322 | gotoSituation( sGoto.clone() ); |
319 | } | 323 | } |
320 | 324 | ||
321 | void GameState::execOption( int idx ) | 325 | void GameState::execOption( int idx ) |
@@ -323,7 +327,7 @@ void GameState::execOption( int idx ) | |||
323 | pGame->getSituation( sCurSituation )->execOption( *this, idx ); | 327 | pGame->getSituation( sCurSituation )->execOption( *this, idx ); |
324 | 328 | ||
325 | if( sGoto.isSet() ) | 329 | if( sGoto.isSet() ) |
326 | gotoSituation( sGoto ); | 330 | gotoSituation( sGoto.clone() ); |
327 | } | 331 | } |
328 | 332 | ||
329 | bool GameState::hasVariable( const Bu::String &sName, ScopeId id ) | 333 | bool GameState::hasVariable( const Bu::String &sName, ScopeId id ) |
@@ -461,8 +465,21 @@ Variable &GameState::deref( Variable &src, bool bCreate ) | |||
461 | return sPlayer.get( r.sName ); | 465 | return sPlayer.get( r.sName ); |
462 | 466 | ||
463 | case sidSituation: | 467 | case sidSituation: |
464 | hsSituation.get( sCurSituation )->insert( r.sName, Variable() ); | 468 | if( hsSituation.has( sCurSituation ) ) |
465 | return hsSituation.get( sCurSituation )->get( r.sName ); | 469 | { |
470 | hsSituation.get( sCurSituation )->insert( r.sName, Variable() ); | ||
471 | return hsSituation.get( sCurSituation )->get( r.sName ); | ||
472 | } | ||
473 | else | ||
474 | { | ||
475 | Bu::println("No such situation: %1").arg( sCurSituation ); | ||
476 | Bu::println("Available:"); | ||
477 | for( ScopeHash::iterator i = hsSituation.begin(); i; i++ ) | ||
478 | { | ||
479 | Bu::println(" <<%1>>").arg( i.getKey() ); | ||
480 | } | ||
481 | ::exit( 0 ); | ||
482 | } | ||
466 | } | 483 | } |
467 | } | 484 | } |
468 | else | 485 | else |