From 54e14b41af171850f58147e184f81264fbd57be0 Mon Sep 17 00:00:00 2001 From: "Martin Felis (lola)" Date: Wed, 2 Jun 2010 13:39:39 +0200 Subject: [PATCH] imported patch gamestate_to_model --- asteroids/Model.h | 9 --------- engine/EnumToString.h | 9 ++++++--- engine/ModelBase.h | 9 +++++++++ 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/asteroids/Model.h b/asteroids/Model.h index ac790f3..827f9a6 100644 --- a/asteroids/Model.h +++ b/asteroids/Model.h @@ -14,12 +14,6 @@ class Model : public Engine::ModelBase { int DoSaveLevel (const char* filename); bool OnLevelComplete(); - void SetGameState (const GameState &state) { - mLastGameState = mGameState; - mGameState = state; - }; - GameState GetGameState () { return mGameState; }; - int GetPlayerLives () { return mPlayerLives; }; unsigned int GetPoints () { return mPoints; }; @@ -46,9 +40,6 @@ class Model : public Engine::ModelBase { /** \brief Keeps a list of all asteroids */ std::vector mAsteroids; - GameState mGameState; - GameState mLastGameState; - int mPlayerLives; unsigned int mPoints; std::vector mLevelList; diff --git a/engine/EnumToString.h b/engine/EnumToString.h index 9b9c09a..1a4f74c 100644 --- a/engine/EnumToString.h +++ b/engine/EnumToString.h @@ -23,10 +23,13 @@ #define DECL_ENUM_ELEMENT( element ) element #define BEGIN_ENUM( ENUM_NAME ) typedef enum tag##ENUM_NAME #define END_ENUM( ENUM_NAME ) ENUM_NAME; \ - const char* GetString##ENUM_NAME(enum tag##ENUM_NAME index); + const char* GetString##ENUM_NAME(enum tag##ENUM_NAME index); \ + const char* GetString##ENUM_NAME(unsigned int index); #else #define DECL_ENUM_ELEMENT( element ) #element #define BEGIN_ENUM( ENUM_NAME ) const char* gs_##ENUM_NAME [] = - #define END_ENUM( ENUM_NAME ) ; const char* GetString##ENUM_NAME(enum \ - tag##ENUM_NAME index){ return gs_##ENUM_NAME [index]; } + #define END_ENUM( ENUM_NAME ) ; \ + const char* GetString##ENUM_NAME(enum \ + tag##ENUM_NAME index){ return gs_##ENUM_NAME [index]; } \ + const char* GetString##ENUM_NAME(unsigned int index){ return gs_##ENUM_NAME [index]; } #endif diff --git a/engine/ModelBase.h b/engine/ModelBase.h index 6b86498..b35187e 100644 --- a/engine/ModelBase.h +++ b/engine/ModelBase.h @@ -72,6 +72,12 @@ class ModelBase : public Module { void SendEntityCollisionEvent (const unsigned int reference_entity_id, const unsigned int incidence_entity_id, float collision_time, vector3d normal); + void SetGameState (const unsigned int &state) { + mLastGameState = mGameState; + mGameState = state; + }; + unsigned int GetGameState () { return mGameState; }; + protected: /** \brief Initializes the system */ virtual int OnInit (int argc, char* argv[]); @@ -98,6 +104,9 @@ class ModelBase : public Module { unsigned int mEntityIdCounter; unsigned int mPlayerEntityId; + unsigned int mGameState; + unsigned int mLastGameState; + float mDeltaSec; friend class ViewBase;