Collaboration diagram for Network Game Configuration:
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 | |
ClientData * | configListEnd |
The end of the list of clients that need to be given the game configuration. | |
ClientData * | configListStart |
The start of the list of clients that need to be given the game configuration. |
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.
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:
#define MAX_OBSTACLES_PER_MSG 62 |
The maximum number of obstacles that can be transmitted in a single MSG_TYPE_OBSTACLE message.
Definition at line 249 of file gameconfig.h.
Referenced by HandleObstacle(), and MakeBuffers().
typedef struct ScoreUpdate_t ScoreUpdate |
Definition at line 378 of file gameconfig.h.
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().
client | A pointer to the client to add. |
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.
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. |
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.
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. |
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.
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. |
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.
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. |
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.
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.
client | The client to remove from the list. It may be a client that is not in the list. |
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.
scores | The new scores/kills to send. | |
len | The number of player updates to send. |
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().
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.
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:
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.
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.