Network Game Configuration
[Networking]

Collaboration diagram for Network Game Configuration:

Implements the process of sending the game configuration from the server to all the clients, and receiving it on the client. More...

Data Structures

struct  ScoreUpdate_t
 A store of score updates used to retain updates over a frame and send them all out together. More...

Defines

#define MAX_OBSTACLES_PER_MSG   62
 The maximum number of obstacles that can be transmitted in a single MSG_TYPE_OBSTACLE message.

Typedefs

typedef ScoreUpdate_t ScoreUpdate

Functions

void AddToConfigList (ClientData *client)
 Adds a client to the list of clients waiting for game configuration data.
Bool HandleArea (SocketAddr *origin, NetBuffer *buffer, Uint8 *unused, Uint16 noid)
 Handles an incomming message from the network describing the goal and spawn areas.
Bool HandleGameOption (SocketAddr *origin, NetBuffer *buffer, Uint8 *unused, Uint16 noid)
 Handles an incomming message from the network describing the game options.
Bool HandleObstacle (SocketAddr *origin, NetBuffer *buffer, Uint8 *unused, Uint16 noid)
 Handles an incomming message from the network describing the obstacles on the battlefield.
Bool HandleScoreUpdate (SocketAddr *origin, NetBuffer *buffer, Uint8 *unused, Uint16 noid)
 Handles an incomming message from the network with a updated scores.
Bool InitGameConfig (const char *fname)
 Loads in a game configuration and prepares to send the configuration to all clients.
void RemoveFromConfigList (ClientData *client)
 Removes a given client from the list of clients waiting to receive the game configuration if the client is in the list.
Bool SendScoreUpdate (ScoreUpdate *scores, int len)
 Sends a score update to all connected clients.
Bool ServiceGameConfig ()
 Handles an iteration of sending game configuration data.
void UninitGameConfig ()
 Destroyes a loaded game configuration and deallocates all memory used to store that configuration.

Variables

ClientDataconfigListEnd
 The end of the list of clients that need to be given the game configuration.
ClientDataconfigListStart
 The start of the list of clients that need to be given the game configuration.

Detailed Description

Implements the process of sending the game configuration from the server to all the clients, and receiving it on the client.

Todo:
Complete this doc!
Initialize by creating all messages with config data. Then number of messages and contents will be known prior to transmission.

On the server, ServiceGameConfig() is called every frame to handle sending out more of the game's configuration. Clients are added to a list of clients needing more information when they acknowledge the connection acceptence message (see AckConnAccept()). When all the data is sent, the process will begin again if there is at least one client still lacking some of the configuration data. Sending the configuration happens as a global action rather than on a per client basis to minimize the required bandwith on a LAN.

Todo:
Fix the above and below to match realtiy.
The process of sending the configuration data once is:

The waits above are ment to limit the bandwith required by the server to prevent joining players from disrupting a game in progress. Its implementation performs the following actions in order:

Author:
Jeff Jackowski

Define Documentation

#define MAX_OBSTACLES_PER_MSG   62

The maximum number of obstacles that can be transmitted in a single MSG_TYPE_OBSTACLE message.

Note:
There is no corresponding constant for the number of spawn points that a message may contain because the different message format makes the maximum a variable.

Definition at line 249 of file gameconfig.h.

Referenced by HandleObstacle(), and MakeBuffers().


Typedef Documentation

typedef struct ScoreUpdate_t ScoreUpdate

Definition at line 378 of file gameconfig.h.


Function Documentation

void AddToConfigList ( ClientData client  ) 

Adds a client to the list of clients waiting for game configuration data.

Clients may be added to the list prior to calling InitGameConfig().

Parameters:
client A pointer to the client to add.
Author:
Jeff Jackowski

Todo:
Limit the score to send just to the new client

Definition at line 1152 of file gameconfig.c.

References AppendPlayerData(), MsgDescr_t::bcast, ClientData_t::cid, ClientData_t::configFirst, configListEnd, configListStart, ClientData_t::configNext, ClientData_t::configPrev, MsgDescr_t::destMap, FALSE, Player_t::flags, ConfigFileStackFrame_t::flags, GetDestMapFlag, GetDestMapIndex, MAX_PLAYERS, MsgDescr_t::mcast, PLAYER_ACTIVE, PLAYER_DEAD, PLAYER_UPDATE_DFS, PLAYER_UPDATE_IDENT, PLAYER_UPDATE_SHELL, PLAYER_UPDATE_TANK, and players.

Referenced by AckConnAccept().

Here is the call graph for this function:

Bool HandleArea ( SocketAddr origin,
NetBuffer buffer,
Uint8 *  unused,
Uint16  noid 
)

Handles an incomming message from the network describing the goal and spawn areas.

For internal use only.

Parameters:
origin The originating address of the message.
buffer The buffer that contains the message to process.
unused A required but unused part of the function prototype.
noid A required but unused part of the function prototype.
Returns:
True when a valid disconnect is received.
Author:
Jeff Jackowski

Definition at line 1459 of file gameconfig.c.

References NetBuffer_t::data, FALSE, FlagCfgMsg(), GameOptions_t::flags, gameOpts, goalAreas, GameOptions_t::goalAreas, NetBuffer_t::length, MSG_READ_16, MSG_READ_8, MSG_TYPE_GOAL, MSG_TYPE_SPAWN, NETSTATE_CLIENT, NETSTATE_RCVCFG, networkState, OPT_ERROR, spawnAreas, GameOptions_t::spawnAreas, TRUE, and ValidateServer().

Here is the call graph for this function:

Bool HandleGameOption ( SocketAddr origin,
NetBuffer buffer,
Uint8 *  unused,
Uint16  noid 
)

Handles an incomming message from the network describing the game options.

For internal use only.

Parameters:
origin The originating address of the message.
buffer The buffer that contains the message to process.
unused A required but unused part of the function prototype.
noid A required but unused part of the function prototype.
Returns:
True when a valid disconnect is received.
Author:
Jeff Jackowski

Definition at line 1357 of file gameconfig.c.

References NetBuffer_t::data, GameOptions_t::duration, FALSE, FlagCfgMsg(), GameOptions_t::flags, gameOpts, GameOptions_t::height, NetBuffer_t::length, MSG_READ_16C, MSG_READ_32C, NETSTATE_CLIENT, NETSTATE_RCVCFG, networkState, GameOptions_t::teamScore, TRUE, ValidateServer(), GameOptions_t::width, and GameOptions_t::winScore.

Here is the call graph for this function:

Bool HandleObstacle ( SocketAddr origin,
NetBuffer buffer,
Uint8 *  unused,
Uint16  noid 
)

Handles an incomming message from the network describing the obstacles on the battlefield.

For internal use only.

Parameters:
origin The originating address of the message.
buffer The buffer that contains the message to process.
unused A required but unused part of the function prototype.
noid A required but unused part of the function prototype.
Returns:
True when a valid disconnect is received.
Author:
Jeff Jackowski

Definition at line 1386 of file gameconfig.c.

References NetBuffer_t::data, FALSE, FlagCfgMsg(), GameOptions_t::flags, gameOpts, Obstacle_t::loc, MAX_OBSTACLES_PER_MSG, MSG_READ_16, NETSTATE_CLIENT, NETSTATE_RCVCFG, networkState, obstacles, GameOptions_t::obstacles, OPT_ERROR, TRUE, and ValidateServer().

Here is the call graph for this function:

Bool HandleScoreUpdate ( SocketAddr origin,
NetBuffer buffer,
Uint8 *  unused,
Uint16  noid 
)

Handles an incomming message from the network with a updated scores.

For internal use only.

Parameters:
origin The originating address of the message.
buffer The buffer that contains the message to process.
unused A required but unused part of the function prototype.
noid A required but unused part of the function prototype.
Returns:
True when a valid disconnect is received.
Author:
Jeff Jackowski

Definition at line 1554 of file gameconfig.c.

References AddScoreNotice(), NetBuffer_t::data, FALSE, GameOptions_t::flags, gameOpts, NetBuffer_t::length, MAX_PLAYERS, MSG_READ_16, MSG_READ_8, NETSTATE_CLIENT, NETSTATE_RCVCFG, networkState, OPT_UPDATESCORE, GameOptions_t::teamScore, TRUE, and ValidateServer().

Here is the call graph for this function:

Bool InitGameConfig ( const char *  fname  ) 

Loads in a game configuration and prepares to send the configuration to all clients.

Prior to calling this function, set all the fields of gameOpts that do not relate to the battle field. Clients may be added to the list of those waiting to receive the game configuration prior to calling this function.

Author:
Jeff Jackowski
Parameters:
fname The name of the file that contains the battle field description. If the full path is not given, the working directory will be searched for the file.

Definition at line 1088 of file gameconfig.c.

References Vector_t::array, cfgMsgBuffVec, FALSE, GameOptions_t::flags, gameOpts, MakeBuffers(), Vector_t::minSize, OPT_ERROR, OPT_ISSET, StartLoadConfig(), TRUE, and Vector_t::VectorInit().

Referenced by GameInit().

Here is the call graph for this function:

void RemoveFromConfigList ( ClientData client  ) 

Removes a given client from the list of clients waiting to receive the game configuration if the client is in the list.

Parameters:
client The client to remove from the list. It may be a client that is not in the list.
Author:
Jeff Jackowski

Definition at line 1205 of file gameconfig.c.

References ClientData_t::cid, configListEnd, configListStart, ClientData_t::configNext, ClientData_t::configPrev, GetDestMapFlag, and GetDestMapIndex.

Referenced by HandleConnDisconn(), MsgFailDisconnect(), and MsgFailDropConnection().

Bool SendScoreUpdate ( ScoreUpdate scores,
int  len 
)

Sends a score update to all connected clients.

Parameters:
scores The new scores/kills to send.
len The number of player updates to send.
Returns:
True on sucess.
Author:
Jeff Jackowski

Definition at line 1594 of file gameconfig.c.

References MsgDescr_t::ackFunc, AddMessage(), MsgDescr_t::approveFunc, MsgDescr_t::bcast, MsgDescr_t::buffer, BufferNew(), NetBuffer_t::data, MsgDescr_t::failFunc, FALSE, gameOpts, MsgDescr_t::interval, Player_t::kills, NetBuffer_t::length, MessageFree(), MessageNew(), MSG_TYPE_SCORE, MSG_WRITE_16, MSG_WRITE_8, MsgFailDisconnect(), NETSTATE_SERVER, networkState, players, scores, SetDestToAll, GameOptions_t::teamScore, and TRUE.

Here is the call graph for this function:

Bool ServiceGameConfig (  ) 

Handles an iteration of sending game configuration data.

Intended to be called every frame by the server between the calls to ReceiveMessages() and ServiceMessages().

Returns:
True on success, false if a message could not be transmitted.
Author:
Jeff Jackowski

Todo:
Add in check to see if any clients have received data before continuing.

Definition at line 1228 of file gameconfig.c.

References MsgDescr_t::ackFunc, AddMessage(), MsgDescr_t::approveFunc, MsgDescr_t::bcast, MsgDescr_t::buffer, MsgDescr_t::buffLifeUnmanaged, cfgMsgBuffVec, configListStart, MsgDescr_t::destMap, DESTMAPLEN, MsgDescr_t::failFunc, FALSE, GameOptions_t::flags, gameOpts, Vector_t::items, NetBuffer_t::length, MessageNew(), OPT_ISSET, TRUE, and Vector_t::VectorItem.

Referenced by ProcessNetworkMessages().

Here is the call graph for this function:

void UninitGameConfig (  ) 

Destroyes a loaded game configuration and deallocates all memory used to store that configuration.

Author:
Jeff Jackowski

Definition at line 1117 of file gameconfig.c.

References configListEnd, configListStart, gameOpts, goalAreas, GameOptions_t::goalAreas, ObstacleUninit(), spawnAreas, and GameOptions_t::spawnAreas.

Referenced by GameUninit().

Here is the call graph for this function:


Variable Documentation

ClientData* configListEnd

The end of the list of clients that need to be given the game configuration.

Clients will normally be added to this end.

Definition at line 298 of file gameconfig.h.

ClientData* configListStart

The start of the list of clients that need to be given the game configuration.

Clients will normally be removed from this end.

Definition at line 292 of file gameconfig.h.


Generated on Mon May 28 04:41:41 2007 for Retro Tank Super Attack by  doxygen 1.5.2