#include <game.h>
Inherited by GameClient, and GameServer.
Inheritance diagram for Game:


Public Member Functions | |
| Game (void) | |
| virtual | ~Game (void) |
| virtual bool | loadMap (const std::string mapName) |
| virtual void | init ()=0 |
| Init data structures for game. | |
| virtual void | run ()=0 |
| Start the game. | |
| virtual void | clean () |
| Clean data structures for game. | |
| virtual void | endFun () |
| Set flag that signalises engine to end. | |
| World & | getWorld () |
| Provide access to World. | |
| int | newPlayer (const Player &player, int ID=-1) |
| Register new player to game. | |
| Player & | getPlayer (int ID) |
| Return player associated with this ID. | |
| void | removePlayer (int ID) |
| Invalidate ID of player. | |
| std::vector< int > & | getValidPlayersID () |
| Create vector of all valid players ID. | |
| bool | isPlayerIDValid (int ID) |
| test of ID validity | |
| bool | isRunning () |
| Thread safe access to state of game. | |
| TaskManager & | getTaskManager () |
| Get task manager for game. | |
| EventQueue & | getEventQueue () |
| Returns reference to event queue. | |
Protected Member Functions | |
| void | recreateWorld () |
| Create new world. | |
| void | setRunning (bool state) |
| change running state. | |
| void | updateValidPlayersID () |
| Update mValidPlayersID to match mPlayers. | |
Protected Attributes | |
| EventQueue | mEventQueue |
| Queue to handle events from network or other input - for update tasks. | |
| bool | mRunning |
| True if game is not lodaing or.. simply the game is running. | |
| Mutex | mRunningMutex |
| For safe access to mRunning. | |
| World * | mWorld |
| World structure holded by Game. | |
| TaskManager | mTaskManager |
| All tasks. | |
| bool | mEndFun |
| if true, engine will stop | |
| std::vector< Player * > | mPlayers |
| Vector of all players in game. | |
| std::vector< int > | mValidPlayersID |
| List of valid players ID. | |
Itself implements access to players in game. You can't create instance of this class. This class implements common Game features for server and client.
Definition at line 21 of file game.h.
|
|
|
|
|
|
|
|
Clean data structures for game. It mean for examlpe unloading textures and models... This function shouls clean players vector. So don't forget to call it in derived classes. Reimplemented in GameClient, and GameServer. Definition at line 29 of file game.cpp. References mPlayers, and updateValidPlayersID(). Referenced by GameServer::clean(), and GameClient::clean(). Here is the call graph for this function: ![]() |
|
|
Set flag that signalises engine to end.
Definition at line 49 of file game.cpp. Referenced by InputManager::checkSDLEvents(), CommanderServer::command_quit(), and CommanderClient::command_quit(). |
|
|
Returns reference to event queue.
Definition at line 158 of file game.h. References mEventQueue. |
|
|
Return player associated with this ID. The program will be halted if you call this with invalid ID.
Definition at line 105 of file game.cpp. References DIE(), LOGE, and mPlayers. Referenced by CommanderClient::command_players(), Tank::initSpecific(), and Projectile::initSpecific(). Here is the call graph for this function: ![]() |
|
|
Get task manager for game. The task manager may contain App.TaskManager as a member
Definition at line 184 of file game.cpp. References mTaskManager. Referenced by GameServer::run(), and GameClient::run(). |
|
|
Create vector of all valid players ID. NOTE that this vector may change in next loop run since some players may leave/join the game. So be carefull. Please dn't modify returned vector.
Definition at line 132 of file game.cpp. References mValidPlayersID. Referenced by CommanderClient::command_players(). |
|
|
Provide access to World.
Definition at line 42 of file game.cpp. References assertL, and mWorld. Referenced by TaskSimulationServer::checkTerrainHeights(), TaskRender::init(), LayerGame::initRefs(), GameServer::run(), GameClient::run(), TaskSimulationServer::setCollModelTransformations(), TaskSimulationServer::tick(), and TaskSimulationServer::updateHistory(). |
|
|
Init data structures for game. This is for example loading some textures, models, registering to input manager,... Implemented in GameClient, and GameServer. |
|
|
test of ID validity This function may be needed because client may kick some other player using its ID but the player allready left so we may get in troubles when calling removePlayer directly.
Definition at line 150 of file game.cpp. References mPlayers. Referenced by World::createProjectile(), and World::createTank(). |
|
|
Thread safe access to state of game. This is good to test if it is a good idea to send/receive/process network messages like Up/down/tank movement/... Provides access to mRunning.
Definition at line 157 of file game.cpp. References Mutex::lock(), mRunning, mRunningMutex, and Mutex::unlock(). Here is the call graph for this function: ![]() |
|
|
Load data for some map.
Reimplemented in GameServer. Definition at line 56 of file game.cpp. Referenced by GameServer::loadMap(), and ApplicationClient::run(). |
|
||||||||||||
|
Register new player to game. Note that generated ID doesn't has to be unique. It may be some older ID that has been invalidated.
Definition at line 66 of file game.cpp. References DIE(), LOGE, mPlayers, and updateValidPlayersID(). Referenced by TaskSimulationServer::tick(). Here is the call graph for this function: ![]() |
|
|
Create new world. delete old if existed and create new. Be carefull when calling this :-) Definition at line 174 of file game.cpp. Referenced by GameServer::run(), and GameClient::run(). Here is the call graph for this function: ![]() |
|
|
Invalidate ID of player. The ID must not be used then. But the ID may be recycled and later returned by newPlayer. TODO: there should be some fetare that check te vector of players and resize it if number of players is <= 1/2 of allocated space for players. (But at least 8 ? Or something like that)
Definition at line 117 of file game.cpp. References DIE(), LOGE, and mPlayers. Here is the call graph for this function: ![]() |
|
|
Start the game. Creates tasks and start main loop. Implemented in GameClient, and GameServer. |
|
|
change running state. Thread safe. Provides access to mRunning.
Definition at line 167 of file game.cpp. References Mutex::lock(), mRunning, mRunningMutex, and Mutex::unlock(). Referenced by GameServer::loadNewMap(), and GameServer::run(). Here is the call graph for this function: ![]() |
|
|
Update mValidPlayersID to match mPlayers. This should be called after every change of mPlayers Definition at line 137 of file game.cpp. References mPlayers, and mValidPlayersID. Referenced by clean(), and newPlayer(). |
|
|
if true, engine will stop
Definition at line 195 of file game.h. Referenced by endFun(), GameServer::run(), and GameClient::run(). |
|
|
Queue to handle events from network or other input - for update tasks.
Definition at line 168 of file game.h. Referenced by getEventQueue(). |
|
|
Vector of all players in game. Note that not all positions has to be valid. Definition at line 202 of file game.h. Referenced by clean(), getPlayer(), isPlayerIDValid(), newPlayer(), removePlayer(), and updateValidPlayersID(). |
|
|
True if game is not lodaing or.. simply the game is running.
Definition at line 186 of file game.h. Referenced by Game(), isRunning(), and setRunning(). |
|
|
For safe access to mRunning.
Definition at line 187 of file game.h. Referenced by isRunning(), and setRunning(). |
|
|
All tasks.
Definition at line 193 of file game.h. Referenced by getTaskManager(), GameServer::run(), and GameClient::run(). |
|
|
List of valid players ID.
Definition at line 203 of file game.h. Referenced by getValidPlayersID(), and updateValidPlayersID(). |
|
|
World structure holded by Game.
Definition at line 191 of file game.h. Referenced by Game(), getWorld(), and recreateWorld(). |
1.4.5