CEL

Public API Reference

iCelGameFactory Struct Reference

A factory to manage game sessions. More...

#include <physicallayer/network.h>

Inheritance diagram for iCelGameFactory:

List of all members.

Public Member Functions

virtual bool CloseGame ()=0
 The player leaves the current game or playback.
virtual bool ConnectGame (celGameInfo *game_info, celPlayer *player)=0
 Connect the player to the game specified in game_info.
virtual bool CreateNewGame (celNetworkGameType game_type, celGameInfo *game_info, celPlayer *player=0)=0
 Create a new game, ie at least a server, but also a client if a player is provided.
virtual iCelGameGetCurrentGame () const =0
 Return the current game or 0 if no game is available.
virtual const char * GetGameName () const =0
 Return the name of the game.
virtual const char * GetProtocolVersion () const =0
 Return the network protocol version used by this application.
virtual void RegisterGameFactoryManager (celGameFactoryManager *manager)=0
 Register a manager for this game factory.
virtual void SetGameName (const char *game_name)=0
 Set the name of the game.
virtual void SetProtocolVersion (const char *protocol_version)=0
 Set the name of the network protocol version used by this application.
virtual void StartPlayBackGame (const char *filename, csTicks start_time, csTicks stop_time)=0
 Start a game where incoming events are read from a file from start_time to stop_time.
virtual void StartRecordingGame (const char *filename)=0
 Incoming events are recorded in a file.
virtual void StartSearchForGameList (celNetworkGameType game_type, celGameInfo *filter=0)=0
 Start to search for the list of available games with the same game name, protocol version and game type.
virtual void StopRecordingGame ()=0
 Incoming events are no more recorded in a file.
virtual void StopSearchForGameList ()=0
 Stop searching for the list of available games.

Detailed Description

A factory to manage game sessions.

You can use it to:

You must define and register a iCelGameFactoryManager which will catch the events from this factory.

There should be only one game factory in an application.

Definition at line 98 of file network.h.


Member Function Documentation

virtual bool iCelGameFactory::CloseGame (  )  [pure virtual]

The player leaves the current game or playback.

If a server was also set, it will be closed.

Returns:
true if the game can be closed, false otherwise.
virtual bool iCelGameFactory::ConnectGame ( celGameInfo game_info,
celPlayer player 
) [pure virtual]

Connect the player to the game specified in game_info.

If a game is already running, it will be closed before the new game is launched. The game_info field must contain the necessary data to find the server, ie a game_id field previously returned by celGameFactoryManager::GameInfoReceived, or the ip_address and port_nb fields. If the game factory was searching for games, it will stop its search.

Parameters:
game_info the informations on the game we want to connect to.
player the player which is connecting to the game.
Returns:
true if the game can be connected.
virtual bool iCelGameFactory::CreateNewGame ( celNetworkGameType  game_type,
celGameInfo game_info,
celPlayer player = 0 
) [pure virtual]

Create a new game, ie at least a server, but also a client if a player is provided.

Only one game can be created at a time, so if a game is already running, it will be closed before the new game is launched. If the game factory was searching for games, it will stop its search.

Parameters:
game_type the type of the game. It can be CEL_NET_SINGLEPLAYER, CEL_NET_LOCAL or CEL_NET_PUBLIC.
game_info the informations on the game.
player the player launching the game. He can be given special access rights to modify the game. If player is different from 0, then a client will also be created.
Returns:
true if the game can be created.
virtual iCelGame* iCelGameFactory::GetCurrentGame (  )  const [pure virtual]

Return the current game or 0 if no game is available.

virtual const char* iCelGameFactory::GetGameName (  )  const [pure virtual]

Return the name of the game.

Client and server instances can talk together only if they have the same game name and protocol version.

virtual const char* iCelGameFactory::GetProtocolVersion (  )  const [pure virtual]

Return the network protocol version used by this application.

Client and server instances can talk together only if they have the same game name and protocol version.

virtual void iCelGameFactory::RegisterGameFactoryManager ( celGameFactoryManager manager  )  [pure virtual]

Register a manager for this game factory.

The manager will be notified when events are thrown from the game factory. Only one manager can be registered at a time.

A manager must be registered before any operation on the factory.

virtual void iCelGameFactory::SetGameName ( const char *  game_name  )  [pure virtual]

Set the name of the game.

Client and server instances can talk together only if they have the same game name and protocol version.

A game name must be set before any operation on the factory.

Parameters:
game_name an arbitrary game name, like "Crystal Core".
virtual void iCelGameFactory::SetProtocolVersion ( const char *  protocol_version  )  [pure virtual]

Set the name of the network protocol version used by this application.

Client and server instances can talk together only if they have the same game name and protocol version.

A protocol version must be set before any operation on the factory.

The protocol version should be changed each time something has been changed in the network protocol of the game, ie in the meaning of the network events, like changes in the implementation of the network plugin, the selection of property classes of the entities, the client and server events, the network links and the baselines.

Parameters:
protocol_version an arbitrary protocol version name, like "v0.3".
virtual void iCelGameFactory::StartPlayBackGame ( const char *  filename,
csTicks  start_time,
csTicks  stop_time 
) [pure virtual]

Start a game where incoming events are read from a file from start_time to stop_time.

CloseGame can be used to stop the playback. If the game factory was searching for available games or if a game was running, they will be stopped.

virtual void iCelGameFactory::StartRecordingGame ( const char *  filename  )  [pure virtual]

Incoming events are recorded in a file.

A game must previously be running.

virtual void iCelGameFactory::StartSearchForGameList ( celNetworkGameType  game_type,
celGameInfo filter = 0 
) [pure virtual]

Start to search for the list of available games with the same game name, protocol version and game type.

The registered celGameFactoryManager will be notified through celGameFactoryManager::GameInfoReceived each time a game has been found. A celGameInfo object can be provided to filter the games.

Parameters:
filter a new game info will be received only if celGameInfo::MatchFilter returns true with this filter.
virtual void iCelGameFactory::StopRecordingGame (  )  [pure virtual]

Incoming events are no more recorded in a file.

virtual void iCelGameFactory::StopSearchForGameList (  )  [pure virtual]

Stop searching for the list of available games.

No more celGameFactoryManager::GameInfoReceived will be raised.


The documentation for this struct was generated from the following file:

Generated for CEL: Crystal Entity Layer 2.0 by doxygen 1.6.1