GameServer Class Reference

#include <game_server.h>

Inherits Game.

Inheritance diagram for GameServer:

Inheritance graph
[legend]
Collaboration diagram for GameServer:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 GameServer ()
virtual ~GameServer ()
virtual void run ()
 Start the game.
double getSpeedMultiplicator ()
 Get curret game speed.
void setSpeedMultiplicator (double speedMultiplicator)
 Set new game speed.
virtual void init ()
 Init data structures for game.
virtual void clean ()
 Clean data structures for game.
virtual bool loadMap (const std::string mapName)
 Load new map.
virtual void unloadMap ()
 Clear all objects from map.
void loadNewMap (const std::string mapName)
 Clean old map and load new.
std::string getMapName ()
 Return name of current map.

Private Member Functions

void setMapName (const std::string mapName)
 Set new map name.
 GameServer (GameServer &copy)
 Program killer - trap.

Private Attributes

double mSpeedMultiplicator
 Modification of game speed.
std::string mMapName
 Name of currentply played map. Use mMapNameMutex when access.
Mutex mMapNameMutex
 Mutex for access to mMapName.

Detailed Description

Definition at line 9 of file game_server.h.


Constructor & Destructor Documentation

GameServer::GameServer  ) 
 

Definition at line 19 of file game_server.cpp.

References g_settings, Settings::getDouble(), mSpeedMultiplicator, and TIN.

Here is the call graph for this function:

GameServer::~GameServer  )  [virtual]
 

Definition at line 26 of file game_server.cpp.

References TIN.

GameServer::GameServer GameServer copy  )  [private]
 

Program killer - trap.

From security reasons we don't allow anyone to create copy of GameServer since it is probably a mistake. Anyway calling this constructor will kill program.

Parameters:
copy not used

Definition at line 32 of file game_server.cpp.

References DIE(), LOGE, and TIN.

Here is the call graph for this function:


Member Function Documentation

void GameServer::clean  )  [virtual]
 

Clean data structures for game.

Reimplemented from Game.

Definition at line 249 of file game_server.cpp.

References Game::clean().

Here is the call graph for this function:

std::string GameServer::getMapName  ) 
 

Return name of current map.

This is usefull if some client ask for map the network code may answer without need to wait for main loop. This call is thread safe.

Returns:
name of current map

Definition at line 256 of file game_server.cpp.

References Mutex::lock(), mMapName, mMapNameMutex, and Mutex::unlock().

Referenced by unloadMap().

Here is the call graph for this function:

double GameServer::getSpeedMultiplicator  ) 
 

Get curret game speed.

Returns:
mSpeedMultiplicator

Definition at line 229 of file game_server.cpp.

References mSpeedMultiplicator.

Referenced by TaskSimulationServer::update().

void GameServer::init  )  [virtual]
 

Init data structures for game.

Implements Game.

Definition at line 243 of file game_server.cpp.

Referenced by ApplicationServer::run().

bool GameServer::loadMap const std::string  mapName  )  [virtual]
 

Load new map.

Reimplemented from Game.

Definition at line 41 of file game_server.cpp.

References Game::loadMap(), LOGI, setMapName(), and TIN.

Referenced by loadNewMap().

Here is the call graph for this function:

void GameServer::loadNewMap const std::string  mapName  ) 
 

Clean old map and load new.

Definition at line 76 of file game_server.cpp.

References loadMap(), setMapName(), Game::setRunning(), and unloadMap().

Here is the call graph for this function:

void GameServer::run  )  [virtual]
 

Start the game.

Implements Game.

Definition at line 95 of file game_server.cpp.

References TaskManager::add(), getAppServer(), World::getLandscape(), Game::getTaskManager(), Landscape::getTerrain(), Game::getWorld(), Terrain::initServer(), TaskManager::initTasks(), Game::mEndFun, Game::mTaskManager, Game::recreateWorld(), Thread::reshedule(), Game::setRunning(), Thread::start(), TIN, and TaskManager::update().

Referenced by ApplicationServer::run().

Here is the call graph for this function:

void GameServer::setMapName const std::string  mapName  )  [private]
 

Set new map name.

The name is set in loadNewMap or loadMap

Parameters:
mapName 

Definition at line 267 of file game_server.cpp.

References Mutex::lock(), mMapName, mMapNameMutex, and Mutex::unlock().

Referenced by loadMap(), and loadNewMap().

Here is the call graph for this function:

void GameServer::setSpeedMultiplicator double  speedMultiplicator  ) 
 

Set new game speed.

The value is also saved to settings.

Parameters:
speedMultiplicator 

Definition at line 235 of file game_server.cpp.

References g_settings, Settings::getDouble(), and mSpeedMultiplicator.

Here is the call graph for this function:

void GameServer::unloadMap  )  [virtual]
 

Clear all objects from map.

Definition at line 59 of file game_server.cpp.

References getMapName(), LOGI, and TIN.

Referenced by loadNewMap().

Here is the call graph for this function:


Member Data Documentation

std::string GameServer::mMapName [private]
 

Name of currentply played map. Use mMapNameMutex when access.

Definition at line 111 of file game_server.h.

Referenced by getMapName(), and setMapName().

Mutex GameServer::mMapNameMutex [private]
 

Mutex for access to mMapName.

Definition at line 112 of file game_server.h.

Referenced by getMapName(), and setMapName().

double GameServer::mSpeedMultiplicator [private]
 

Modification of game speed.

The speed is double number where 1.0 means normal speed, 0.5 means half speed and 2.0 means double. This number is used vhen counting how often tick() for server is called.

Definition at line 109 of file game_server.h.

Referenced by GameServer(), getSpeedMultiplicator(), and setSpeedMultiplicator().


The documentation for this class was generated from the following files:
Generated on Wed Apr 12 14:16:29 2006 for bjs by  doxygen 1.4.5