Data Structures | |
struct | Player_t |
The data describing a player in the game and player options. More... | |
Typedefs | |
typedef Player_t | Player |
Enumerations | |
enum | PLAYER_FLAGS { PLAYER_FORWARD = 1, PLAYER_BACKWARD = 2, PLAYER_ROTRIGHT = 4, PLAYER_STARTROTRIGHT = 8, PLAYER_ROTLEFT = 0x10, PLAYER_STARTROTLEFT = 0x20, PLAYER_SHOT = 0x40, PLAYER_PONG = 0x80, PLAYER_UPDATE_IDENT = 0x100, PLAYER_UPDATE_TANK = 0x200, PLAYER_UPDATE_SHELL = 0x400, PLAYER_UPDATE_DFS = 0x800, PLAYER_DEAD = 0x1000, PLAYER_ACTIVE = 0x2000, PLAYER_UPDATEREQ = 0x4000, PLAYER_MOVEMENT_MASK = 0xFF, PLAYER_MOVEMENT_SOUND = 3, PLAYER_CLIENT_MASK = 0x700, PLAYER_LOCAL_MASK = ~0x207F, PLAYER_UPDATE_ITEMS = 0xF00 } |
Player status flags for use with Player::flags. More... | |
Functions | |
void | AddPlayer (Player *p) |
Initializes the graphics items required to render a player. | |
MsgDescr * | AppendPlayerData (MsgDescr *msg, Player *p, Uint32 time) |
Adds update information for another player to a player update message. | |
static int | CalculateOffset (NetBuffer *buffer, int offset) |
Calculates the offset of the next player update item after the one which starts at the given offset. | |
Bool | HandlePlayerSpawn (SocketAddr *origin, NetBuffer *buffer, Uint8 *clientId, Uint16 noid) |
Processes an incomming client request to spawn their tank. | |
Bool | HandlePlayerUpdate (SocketAddr *origin, NetBuffer *buffer, Uint8 *clientId, Uint16 noid) |
Processes incomming player data. | |
static Uint8 * | ReadPlayer (Uint8 *ptr, Uint32 time) |
Reads in a player's update information from a buffer and updates the corresponding player. | |
void | RemovePlayer (Player *p) |
Removes a player from the game by marking the player as inactive and destroying related player data. | |
Bool | SendSpawnRequest () |
Sends a request to the server to spawn the local player. | |
Variables | |
Uint32 | localPlayer |
The player ID for the player that is also the user of this process. | |
Uint8 | localUpdateFlags |
The set of update flags used to track locally made changes to the local player so that the updated parts can be transmitted to the server. | |
Player | players [32] |
The global array of player data. |
enum PLAYER_FLAGS |
Player status flags for use with Player::flags.
The lower 8 flags are sent by both the server and client. The upper 8 flags are only sent by the server.
PLAYER_FORWARD | Forward motion flag. |
PLAYER_BACKWARD | Backward motion flag. |
PLAYER_ROTRIGHT | Right rotation flag. |
PLAYER_STARTROTRIGHT | Just started right rotation flag. |
PLAYER_ROTLEFT | Left rotation flag. |
PLAYER_STARTROTLEFT | Just started left rotation flag. |
PLAYER_SHOT | True when this player's shell is in flight. |
PLAYER_PONG |
True if the tank uses pong shells.
|
PLAYER_UPDATE_IDENT | Indicates that the local player's identity has been updated and needs to be sent to the server. |
PLAYER_UPDATE_TANK |
Indicates that the tank position and/or orientation data has been changed and needs to be sent to the server.
This flag should be set whenever the player's tank movement input changes and when tanks collide with tanks. |
PLAYER_UPDATE_SHELL |
Indicates the local player's shell has been fired and the sever has not yet been told of the event.
The server will update the shell's position, direction, and collisions without further updates from the client. |
PLAYER_UPDATE_DFS | Indicates a change in dead time, flags, and/or score. |
PLAYER_DEAD | Dead flag. |
PLAYER_ACTIVE |
True if this player is in use; false if this data does not yet represent a player.
This flag has no meaning in messages sent over the network. |
PLAYER_UPDATEREQ |
True when a network update must be sent.
|
PLAYER_MOVEMENT_MASK | All tank & movement related flags. |
PLAYER_MOVEMENT_SOUND | A mask for the flags that trigger a movement sound. |
PLAYER_CLIENT_MASK | The mask of all the flags that the client can update, save for movement related flags. |
PLAYER_LOCAL_MASK |
A mask of most of the flags that the server can update for the local client.
The server can update all flags for any other client. The following flags should not be updated for the local client, but are in the mask so that the read function can move past the data:
|
PLAYER_UPDATE_ITEMS | A mask for the flags used to indicate the items being updated. |
void AddPlayer | ( | Player * | p | ) |
Initializes the graphics items required to render a player.
p | The player who's graphics items need to be initialized. |
Definition at line 36 of file player.c.
References AddRenderItem(), COLOR_BLACK, colorFmtInd, colorVals, RenderItem_t::data, DEAD_TIME, Player_t::deadTime, dInfo, DrawTank(), Player_t::flags, FONT_PLAYER, Player_t::labelName, LAYER_NAMES, LAYER_TANKS, RenderItem_t::loc, DisplayInfo_t::luh, DisplayInfo_t::luw, Player_t::name, Player_t::pid, PlacePlayerLabel(), PLAYER_ACTIVE, PLAYER_DEAD, QueuePlaceTank, RenderItem_t::renderer, rtsa_strcpy, Player_t::shell, DisplayInfo_t::showLabels, SolidFillRenderer(), STRING_DEFAULTNAME, strings, Player_t::tank, Player_t::team, TextRenderString(), Player_t::x, and Player_t::y.
Referenced by GameInit(), and ReadPlayer().
Here is the call graph for this function:
Adds update information for another player to a player update message.
msg | A pointer to an existing player update message to which the player data will be appended, or NULL if a new message should be created. If the given message is too small to fit the indicated player data, a new message will be created. | |
p | A pointer to the player data to add to the message. | |
time | The common game time of the update. |
Definition at line 38 of file playernet.c.
References MsgDescr_t::ackFunc, AddMessage(), MsgDescr_t::approveFunc, MsgDescr_t::buffer, BufferNew(), Player_t::captures, NetBuffer_t::data, Player_t::deadTime, MsgDescr_t::destMap, MsgDescr_t::failFunc, Player_t::flags, Player_t::kills, NetBuffer_t::length, MAX_NAME_LEN, MessageFree(), MessageNew(), MSG_MAX_SIZE, MSG_TYPE_PLAYER_UPDATE, MSG_WRITE_16, MSG_WRITE_32, MSG_WRITE_32C, MSG_WRITE_8, MsgFailDisconnect(), Player_t::name, NETSTATE_CLIENT, NETSTATE_SERVER, networkState, Player_t::pid, PLAYER_CLIENT_MASK, PLAYER_MOVEMENT_MASK, PLAYER_UPDATE_DFS, PLAYER_UPDATE_IDENT, PLAYER_UPDATE_ITEMS, PLAYER_UPDATE_SHELL, PLAYER_UPDATE_TANK, Player_t::rot, rtsa_strlen, SetDestToAll, Player_t::shellDist, Player_t::shellRot, Player_t::shellX, Player_t::shellY, Player_t::team, TextNativeToUTF16(), Player_t::x, and Player_t::y.
Referenced by AddToConfigList(), GameInit(), and GameRun().
Here is the call graph for this function:
static int CalculateOffset | ( | NetBuffer * | buffer, | |
int | offset | |||
) | [static] |
Calculates the offset of the next player update item after the one which starts at the given offset.
For internal use only.
buffer | The network data to inspect. | |
offset | The index of the first byte of the player update data in the buffer. This must be within the bounds of the buffer. |
Definition at line 171 of file playernet.c.
References NetBuffer_t::data, Player_t::flags, NetBuffer_t::length, NETSTATE_SERVER, networkState, PLAYER_CLIENT_MASK, PLAYER_UPDATE_DFS, PLAYER_UPDATE_IDENT, PLAYER_UPDATE_SHELL, and PLAYER_UPDATE_TANK.
Referenced by HandlePlayerUpdate().
Bool HandlePlayerSpawn | ( | SocketAddr * | origin, | |
NetBuffer * | buffer, | |||
Uint8 * | clientId, | |||
Uint16 | noid | |||
) |
Processes an incomming client request to spawn their tank.
origin | The originating address of the message. | |
buffer | The buffer that contains the message to process. | |
clientId | A pointer to the client ID that needs an acknowledgment. | |
noid | A required but unused part of the function prototype. |
Definition at line 562 of file playernet.c.
References NetBuffer_t::data, DEAD_TIME, Player_t::deadTime, FALSE, Player_t::flags, NetBuffer_t::length, NETSTATE_SERVER, networkState, PLAYER_DEAD, players, SpawnTank(), TRUE, and ValidateClient().
Here is the call graph for this function:
Bool HandlePlayerUpdate | ( | SocketAddr * | origin, | |
NetBuffer * | buffer, | |||
Uint8 * | clientId, | |||
Uint16 | noid | |||
) |
Processes incomming player data.
For servers, a single player update is read from a single client. For clients, one or more player updates are read.
origin | The originating address of the message. | |
buffer | The buffer that contains the message to process. | |
clientId | A pointer to the client ID that needs an acknowledgment. | |
noid | A required but unused part of the function prototype. |
Definition at line 464 of file playernet.c.
References CalculateOffset(), NetBuffer_t::data, FALSE, NetBuffer_t::length, MSG_READ_32, NETSTATE_CLIENT, NETSTATE_RCVCFG, NETSTATE_SERVER, networkState, ReadPlayer(), TRUE, ValidateClient(), and ValidateServer().
Here is the call graph for this function:
static Uint8* ReadPlayer | ( | Uint8 * | ptr, | |
Uint32 | time | |||
) | [static] |
Reads in a player's update information from a buffer and updates the corresponding player.
For internal use only.
ptr | A pointer to the start of where to read from the buffer. | |
time | The update time indicated in the message. |
Definition at line 210 of file playernet.c.
References AddPlayer(), Player_t::captures, ClearRenderItem(), DEAD_TIME, Player_t::deadTime, UpdateTimes_t::dfsTime, dInfo, DistSq, FALSE, Player_t::flags, UpdateTimes_t::identTime, Player_t::kills, Player_t::lastUpdate, RenderItem_t::loc, localPlayer, DisplayInfo_t::luh, MAX_NAME_LEN, MAX_PLAYERS, MAX_SQ_DIST, MoveTank(), MSG_READ_16, MSG_READ_32, MSG_READ_8, Player_t::name, NETSTATE_SERVER, networkState, Player_t::pid, PLAYER_ACTIVE, PLAYER_BACKWARD, PLAYER_CLIENT_MASK, PLAYER_DEAD, PLAYER_FORWARD, PLAYER_LOCAL_MASK, PLAYER_MOVEMENT_MASK, PLAYER_ROTLEFT, PLAYER_ROTRIGHT, PLAYER_SHOT, PLAYER_UPDATE_DFS, PLAYER_UPDATE_IDENT, PLAYER_UPDATE_ITEMS, PLAYER_UPDATE_SHELL, PLAYER_UPDATE_TANK, players, PlayLocalDeath(), PlayTankKilled, PlayTankShoot, QueuePlaceShell, QueuePlaceTank, RemoveShell(), Player_t::rot, Player_t::shell, Player_t::shellDist, UpdateTimes_t::shellPosTime, Player_t::shellRot, Player_t::shellX, Player_t::shellY, UpdateTimes_t::tankPosTime, Player_t::team, TextUTF16toNative(), TRUE, Player_t::x, and Player_t::y.
Referenced by HandlePlayerUpdate().
Here is the call graph for this function:
void RemovePlayer | ( | Player * | p | ) |
Removes a player from the game by marking the player as inactive and destroying related player data.
Definition at line 78 of file player.c.
References ClearRenderItem(), RenderItem_t::data, Player_t::flags, Player_t::labelName, PLAYER_ACTIVE, RemoveRenderItem(), RenderItem_t::renderer, Player_t::shell, and Player_t::tank.
Referenced by GameUninit(), HandleConnDisconn(), and MsgFailDisconnect().
Here is the call graph for this function:
Bool SendSpawnRequest | ( | ) |
Sends a request to the server to spawn the local player.
Definition at line 533 of file playernet.c.
References MsgDescr_t::ackFunc, AddMessage(), MsgDescr_t::approveFunc, MsgDescr_t::bcast, MsgDescr_t::buffer, BufferNew(), NetBuffer_t::data, MsgDescr_t::destMap, MsgDescr_t::failFunc, FALSE, NetBuffer_t::length, localPlayer, MessageFree(), MessageNew(), MSG_TYPE_PLAYER_SPWAN, MsgFailDropConnection(), and TRUE.
Referenced by HandleInput().
Here is the call graph for this function:
Uint32 localPlayer |
Uint8 localUpdateFlags |
The set of update flags used to track locally made changes to the local player so that the updated parts can be transmitted to the server.
Local changes to other player data is not tracked by the client because the server is authoritative source for thier information.
The global array of player data.
The data is initialized to zeros at program start.
Definition at line 34 of file player.c.
Referenced by AddScoreNotice(), AddToConfigList(), BatchRender(), DisablePlayerLabels(), EnablePlayerLabels(), GameInit(), GameRun(), GameUninit(), HandleConnDisconn(), HandleInput(), HandlePlayerSpawn(), MsgFailDisconnect(), MsgFailDropConnection(), ReadPlayer(), SendScoreUpdate(), SpawnTank(), TeamSelUninit(), TeamSelUpdate(), and UpdatePlayers().