From bbb6f75964f1d89909aaf6a78b36b358f57e429d Mon Sep 17 00:00:00 2001 From: "Martin Felis (berta)" Date: Sat, 11 Sep 2010 16:09:15 +0200 Subject: [PATCH] fixed annoying bug which would crash the game when pressing spacebar when the game was not in GameRunning state --- asteroids/ControllerCommands.cc | 8 +++++--- asteroids/Model.cc | 1 + engine/doc/Mainpage.h | 6 +++--- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/asteroids/ControllerCommands.cc b/asteroids/ControllerCommands.cc index 520e58a..7398a3b 100644 --- a/asteroids/ControllerCommands.cc +++ b/asteroids/ControllerCommands.cc @@ -107,10 +107,12 @@ bool Cmd_ControllerAttack (std::vector args) { assert (ControllerInstance); ShipEntity* player_entity = (ShipEntity*) Engine::GetEntity (Engine::GetPlayerEntityId ()); - assert (player_entity); - player_entity->Attack (); + if (player_entity) { + player_entity->Attack (); + return true; + } - return true; + return false; } void Controller::OnRegisterCommands () { diff --git a/asteroids/Model.cc b/asteroids/Model.cc index ba7f841..6268e52 100644 --- a/asteroids/Model.cc +++ b/asteroids/Model.cc @@ -359,6 +359,7 @@ int Model::DoSaveLevel (const char* filename) { level_file.close(); return 0; } + void Model::SetGameState (const unsigned int &state) { mLastGameState = mGameState; diff --git a/engine/doc/Mainpage.h b/engine/doc/Mainpage.h index c6b5551..412420c 100644 --- a/engine/doc/Mainpage.h +++ b/engine/doc/Mainpage.h @@ -72,8 +72,7 @@ * todos within the code have a look at the \ref todo. * * \todo [high] Create a simple racing or asteroids game - * \todo [high] Since introduction of the IMGUI pressing 'space' in the menu crashes the game -* \todo [med] Clear all references of EntityVisualState and EntityGameState + * \todo [med] Clear all references of EntityVisualState and EntityGameState * \todo [med] Clarify functionalities of CreateEntity, KillEntity, RegisterEntity, UnregisterEntity (which frees memory, which does only change the state of the Model?) * \todo [med] Add basic networking * \todo [med] Add serialization @@ -87,7 +86,8 @@ * Engine::Module::Init() * * Done: - * - [high] In Physics remove dependancy on the Model to pass on collision + * \todo [high] (11-09-2010) Since introduction of the IMGUI pressing 'space' in the menu crashes the game +* - [high] In Physics remove dependancy on the Model to pass on collision * events * - [high] Fix Physics bug when two actors collide actively (i.e. velocity * towards each other)