UFO: Alien Invasion
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
g_client.cpp File Reference

Main part of the game logic. More...

#include "g_client.h"
#include "g_actor.h"
#include "g_ai.h"
#include "g_combat.h"
#include "g_edicts.h"
#include "g_inventory.h"
#include "g_match.h"
#include "g_move.h"
#include "g_reaction.h"
#include "g_utils.h"
#include "g_vis.h"

Go to the source code of this file.

Functions

Player * G_PlayerGetNextHuman (Player *lastPlayer)
 Iterate through the list of players. More...
 
Player * G_PlayerGetNextAI (Player *lastPlayer)
 Iterate through the list of players. More...
 
Player * G_PlayerGetNextActiveHuman (Player *lastPlayer)
 Iterate through the list of players. More...
 
Player * G_PlayerGetNextActiveAI (Player *lastPlayer)
 Iterate through the list of players. More...
 
playermask_t G_TeamToPM (int team)
 Generates the player bit mask for a given team. More...
 
teammask_t G_PMToVis (playermask_t playerMask)
 Converts player mask to vis mask. More...
 
playermask_t G_VisToPM (teammask_t teamMask)
 Converts vis mask to player mask. More...
 
void G_ClientPrintf (const Player &player, int printLevel, const char *fmt,...)
 
void G_GiveTimeUnits (int team)
 Network function to update the time units (TUs) for each team-member. More...
 
void G_AppearPerishEvent (playermask_t playerMask, bool appear, Edict &check, const Edict *ent)
 Send the appear or perish event to the affected clients. More...
 
void G_SendInvisible (const Player &player)
 This function sends all the actors to the client that are not visible initially - this is needed because an actor can e.g. produce sounds that are send over the net. And the client can only handle them if he knows the le_t (local entity) already. More...
 
int G_GetActiveTeam (void)
 Returns the current active team to the server. More...
 
static bool G_ActionCheck (const Player &player, Edict *ent)
 Checks whether the requested action is possible. More...
 
bool G_ActionCheckForCurrentTeam (const Player &player, Actor *ent, int TU)
 Checks whether the requested action is possible for the current active team. More...
 
bool G_ActionCheckForReaction (const Player &player, Actor *actor, int TU)
 Checks whether the requested action is possible. More...
 
static void G_ClientTurn (Player &player, Actor *actor, dvec_t dvec)
 Sends the actual actor turn event over the netchannel. More...
 
static void G_ClientStateChangeUpdate (Edict &ent)
 After an actor changed his state, he might get visible for other players. Check the vis here and send the state change to the clients that are seeing him already. More...
 
void G_ClientStateChange (const Player &player, Actor *actor, int reqState, bool checkaction)
 Changes the state of a player/soldier. More...
 
bool G_ClientCanReload (Actor *actor, containerIndex_t containerID)
 Returns true if actor can reload weapon. More...
 
bool G_ClientGetWeaponFromInventory (Actor *actor)
 Retrieve or collect a loaded weapon from any linked container for the actor's right hand. More...
 
bool G_ClientUseEdict (const Player &player, Actor *actor, Edict *edict)
 This function 'uses' the edict. E.g. it opens the door when the player wants it to open. More...
 
int G_ClientAction (Player &player)
 The client sent us a message that he did something. We now execute the related function(s) and notify him if necessary. More...
 
static void G_GetTeam (Player &player)
 Sets the teamnum var for this match. More...
 
bool G_SetTeamForPlayer (Player &player, const int team)
 Set the used team for the given player. More...
 
int G_ClientGetTeamNum (const Player &player)
 Returns the assigned team number of the player. More...
 
int G_ClientGetTeamNumPref (const Player &player)
 Returns the preferred team number for the player. More...
 
bool G_ClientIsReady (const Player *player)
 
static void G_GetStartingTeam (const Player &player)
 Chose a team that should start the match. More...
 
static EdictG_ClientGetFreeSpawnPoint (const Player &player, int spawnType)
 Find valid actor spawn fields for this player. More...
 
static bool G_ActorSpawnIsAllowed (const int num, const int team)
 Checks whether the spawn of an actor is allowed for the current running match. More...
 
static void G_ThinkActorDieAfterSpawn (Edict *ent)
 Think function for actors that spawn dead. More...
 
static void G_ThinkActorGoCrouch (Edict *ent)
 Think function for actors that spawn crouched. More...
 
ActorG_ClientGetFreeSpawnPointForActorSize (const Player &player, const actorSizeEnum_t actorSize)
 Searches a free spawning point for a given actor size and turns it into an actor. More...
 
static void G_ClientReadInventory (Edict *ent)
 Read the inventory from the clients team data. More...
 
static void G_ClientReadCharacter (Edict *ent)
 Reads the character data from the netchannel that is needed to spawn an actor. More...
 
static void G_ClientSkipActorInfo (void)
 Call this if you want to skip some actor netchannel data. More...
 
static void G_ClientAssignDefaultActorValues (Actor *actor)
 Used after spawning an actor to set some default values that are not read from the network event. More...
 
void G_ClientInitActorStates (const Player &player)
 This is called after the actors are spawned and will set actor states without consuming TUs. More...
 
void G_ClientTeamInfo (const Player &player)
 The client lets the server spawn the actors for a given player by sending their information (models, inventory, etc..) over the network. More...
 
static void G_ClientSendEdictsAndBrushModels (const Player &player)
 Send brush models for entities like func_breakable and func_door and triggers with their bounding boxes to the client and let him know about them. There are also entities that are announced here, but fully handled clientside - like func_rotating. More...
 
bool G_ClientBegin (Player &player)
 This functions starts the client. More...
 
void G_ClientStartMatch (Player &player)
 Sets the team, init the TU and sends the player stats. More...
 
void G_ClientUserinfoChanged (Player &player, const char *userinfo)
 called whenever the player updates a userinfo variable. More...
 
bool G_ClientConnect (Player *player, char *userinfo, size_t userinfoSize)
 Checks whether the connection is valid or invalid and set some user info keys. More...
 
void G_ClientDisconnect (Player &player)
 
void G_ResetClientData (void)
 Called after every player has joined. More...
 

Variables

static chrScoreMission_t scoreMission [MAX_EDICTS]
 
static int scoreMissionNum = 0
 

Detailed Description

Main part of the game logic.

Connection

In case the connection is established (G_ClientConnect), the client state is cs_connected. The client will send SV_STATE_NEW, SV_New_f sets the state to cs_spawning, and asks the client to precache the data after sending the configstrings. After the client is done with it, it will send "begin" to the server. SV_Begin_f will now set the client state to cs_began and calls G_ClientBegin. The server will ask the client to execute "spawnsoldiers" now. The client is answering with clc_teaminfo and the server will call G_ClientTeamInfo. The client state is now cs_spawned. Last but not least the server informs the client that the match can now get started by asking to execute "startmatch". The client answers with NET_STATE_STARTMATCH and G_ClientStartMatch is executed.

Definition in file g_client.cpp.

Function Documentation

static bool G_ActionCheck ( const Player &  player,
Edict ent 
)
static

Checks whether the requested action is possible.

Parameters
[in]playerWhich player (human player) is trying to do the action
[in]entWhich of his units is trying to do the action.

Definition at line 337 of file g_client.cpp.

References _, G_ClientPrintf(), G_IsActor, G_IsDead, G_IsStunned, Edict::getPlayerNum(), Edict::getTeam(), Edict::inuse, and PRINT_HUD.

Referenced by G_ActionCheckForCurrentTeam(), and G_ActionCheckForReaction().

bool G_ActionCheckForCurrentTeam ( const Player &  player,
Actor ent,
int  TU 
)

Checks whether the requested action is possible for the current active team.

Parameters
[in]playerWhich player (human player) is trying to do the action
[in]entWhich of his units is trying to do the action.
[in]TUThe time units to check against the ones ent has. the action with

Definition at line 380 of file g_client.cpp.

References _, level_locals_s::activeTeam, G_ActionCheck(), G_ActorUsableTUs(), G_ClientPrintf(), level, and PRINT_HUD.

Referenced by G_ActorInvMove(), G_ClientMove(), G_ClientShoot(), G_ClientStateChange(), G_ClientTurn(), and G_ClientUseEdict().

bool G_ActionCheckForReaction ( const Player &  player,
Actor actor,
int  TU 
)

Checks whether the requested action is possible.

Parameters
[in]playerWhich player (human player) is trying to do the action
[in]actorWhich of his units is trying to do the action.
[in]TUThe time units to check against the ones actor has. the action with
See also
G_ActionCheck

Definition at line 403 of file g_client.cpp.

References G_ActionCheck(), and Edict::getTus().

Referenced by G_ClientShoot().

static bool G_ActorSpawnIsAllowed ( const int  num,
const int  team 
)
inlinestatic

Checks whether the spawn of an actor is allowed for the current running match.

Note
Don't allow spawning of soldiers for multiplayer if:
  • the sv_maxsoldiersperplayer limit is hit (e.g. the assembled team is bigger than the allowed number of soldiers)
  • the team already hit the max allowed amount of soldiers
Parameters
numThe nth actor the player want to spawn in the game.
teamThe team the player is part of.
Returns
true if spawn is allowed, false otherwise.

Definition at line 1002 of file g_client.cpp.

References G_IsSinglePlayer, cvar_s::integer, level, level_locals_s::num_spawned, sv_maxsoldiersperplayer, and sv_maxsoldiersperteam.

Referenced by G_ClientTeamInfo().

void G_AppearPerishEvent ( playermask_t  playerMask,
bool  appear,
Edict check,
const Edict ent 
)

Send the appear or perish event to the affected clients.

Parameters
[in]playerMaskThese are the affected players or clients In case of e.g. teamplay there can be more than one client affected - thus this is a player mask
[in]appearIs this event about an appearing actor (or a perishing one)
[in]checkThe edict we are talking about (that appears or perishes)
[in]entThe edict that was responsible for letting the check edict appear or perish. Might be nullptr.
See also
CL_ActorAppear

Definition at line 245 of file g_client.cpp.

References ET_ACTOR, ET_ACTOR2x2, ET_CAMERA, ET_ITEM, ET_PARTICLE, ET_TRIGGER_RESCUE, G_EventActorAppear(), G_EventAddBrushModel(), G_EventCameraAppear(), G_EventEdictAppear(), G_EventEdictPerish(), G_EventSendParticle(), G_IsVisibleOnBattlefield, G_PMToVis(), G_SendInventory(), G_VisFlagsSwap(), gi, makeActor(), and Edict::type.

Referenced by AI_CheckRespawn(), G_DoTestVis(), G_MissionThink(), G_SplashDamage(), and G_VisMakeEverythingVisible().

int G_ClientAction ( Player &  player)

The client sent us a message that he did something. We now execute the related function(s) and notify him if necessary.

Parameters
[in]playerThe player to execute the action for (the actor belongs to this player)
Note
a client action will also send the server side edict number to determine the actor

Definition at line 638 of file g_client.cpp.

References Edict::chr, Edict::clientAction, format(), G_ActorInvMove(), G_ActorReserveTUs(), G_ActorUseDoor(), G_ClientMove(), G_ClientShoot(), G_ClientStateChange(), G_ClientTurn(), G_EdictsGetByNum(), G_IsDoor, G_ReactionFireSettingsUpdate(), Inventory::getItemAtPos(), gi, i, character_s::inv, INVDEF, INVSH_GetItemByIDX(), isValidContId(), makeActor(), pa_format, PA_INVMOVE, PA_MOVE, PA_NULL, PA_REACT_SELECT, PA_RESERVE_STATE, PA_SHOOT, PA_STATE, PA_TURN, PA_USE, chrReservations_s::reaction, and character_s::reservedTus.

Referenced by GetGameAPI().

static void G_ClientAssignDefaultActorValues ( Actor actor)
static

Used after spawning an actor to set some default values that are not read from the network event.

Parameters
actorThe actor edict to set the values for.
Todo:
for now, heal fully upon entering mission

Definition at line 1190 of file g_client.cpp.

References ABILITY_MIND, chrScoreMission_s::carriedWeight, Edict::chr, CHRSH_CharGetBody(), CHRSH_CharGetHead(), GET_MORALE, Inventory::getWeight(), gi, Edict::HP, character_s::HP, chrScoreMission_s::init(), character_s::inv, character_s::morale, character_s::score, character_s::scoreMission, scoreMissionNum, Actor::setBody(), Actor::setHead(), Edict::setMorale(), and chrScoreGlobal_s::skills.

Referenced by G_ClientTeamInfo().

bool G_ClientBegin ( Player &  player)
bool G_ClientCanReload ( Actor actor,
containerIndex_t  containerID 
)
bool G_ClientConnect ( Player *  player,
char *  userinfo,
size_t  userinfoSize 
)

Checks whether the connection is valid or invalid and set some user info keys.

Parameters
[in,out]playerThe player that is trying to connect to the game
[in,out]userinfoThe userinfo data that is checked and changed
[in]userinfoSizeThe size of the userinfo buffer
See also
G_ClientDisconnect
CL_ConnectionlessPacket
Todo:
Check if the teamnum preference has already reached maxsoldiers and reject connection if so
Returns
false if the connection is refused, true otherwise

Definition at line 1436 of file g_client.cpp.

References Com_Printf(), G_ClientDisconnect(), G_ClientUserinfoChanged(), G_PlayerToPM, gi, Info_SetValueForKey(), Info_ValueForKey(), OBJZERO, password, PRINT_CONSOLE, Q_streq, REJ_BANNED, REJ_PASSWORD_REQUIRED_OR_INCORRECT, REJ_SERVER_FULL, cvar_s::string, and SV_FilterPacket().

Referenced by GetGameAPI().

static Edict* G_ClientGetFreeSpawnPoint ( const Player &  player,
int  spawnType 
)
static

Find valid actor spawn fields for this player.

Note
Already used spawn-point are not found because ent->type is changed in G_ClientTeamInfo.
Parameters
[in]playerThe player to spawn the actors for.
[in]spawnTypeThe type of spawn-point so search for (ET_ACTORSPAWN or ET_ACTOR2x2SPAWN)
Returns
A pointer to a found spawn point or nullptr if nothing was found or on error.

Definition at line 963 of file g_client.cpp.

References count, ET_ACTOR2x2SPAWN, ET_ACTORSPAWN, G_EdictsGetLivingActorFromPos(), G_EdictsGetNextInUse(), Edict::getTeam(), level, MAX_EDICTS, level_locals_s::noRandomSpawn, Edict::pos, and Edict::type.

Referenced by G_ClientGetFreeSpawnPointForActorSize().

Actor* G_ClientGetFreeSpawnPointForActorSize ( const Player &  player,
const actorSizeEnum_t  actorSize 
)

Searches a free spawning point for a given actor size and turns it into an actor.

Parameters
[in]playerThe player to get the free spawn points for
[in]actorSizeThe actor size to get a spawning point for
Returns
An actor edict or nullptr if no free spawning point was found

Definition at line 1039 of file g_client.cpp.

References ACTOR_SIZE_2x2, ACTOR_SIZE_NORMAL, Edict::chr, ET_ACTOR, ET_ACTOR2x2, ET_ACTOR2x2SPAWN, ET_ACTORSPAWN, Edict::fieldSize, character_s::fieldSize, FL_DESTROYABLE, Edict::flags, G_ActorModifyCounters(), G_ClientGetFreeSpawnPoint(), G_EdictDuplicate(), G_ReactionFireTargetsCreate(), G_ThinkActorDieAfterSpawn(), G_ThinkActorGoCrouch(), G_VisFlagsReset(), Edict::getTeam(), gi, Edict::HP, level, makeActor(), Edict::nextthink, level_locals_s::num_spawned, Edict::setMorale(), Edict::setPlayerNum(), Edict::spawnflags, STATE_CROUCHED, STATE_DEAD, STATE_STUN, Edict::think, and Edict::type.

Referenced by G_ClientTeamInfo(), and G_SpawnAIPlayer().

int G_ClientGetTeamNum ( const Player &  player)

Returns the assigned team number of the player.

Definition at line 889 of file g_client.cpp.

Referenced by G_GetTeam(), and GetGameAPI().

int G_ClientGetTeamNumPref ( const Player &  player)

Returns the preferred team number for the player.

Definition at line 897 of file g_client.cpp.

References Info_IntegerForKey().

Referenced by G_GetTeam().

bool G_ClientGetWeaponFromInventory ( Actor actor)

Retrieve or collect a loaded weapon from any linked container for the actor's right hand.

Note
This function will also collect items from floor containers when the actor is standing on a given point.
See also
AI_ActorThink

Definition at line 568 of file g_client.cpp.

References Edict::chr, CID_RIGHT, Item::def(), Container::def(), G_ActorInvMove(), Inventory::getNextCont(), Container::getNextItem(), character_s::inv, INVDEF, Item::isWeapon(), Item::mustReload(), invDef_s::out, character_s::teamDef, and teamDef_s::weapons.

Referenced by AI_ActorThink(), and AIL_grabweapon().

void G_ClientInitActorStates ( const Player &  player)

This is called after the actors are spawned and will set actor states without consuming TUs.

Parameters
playerThe player to perform the action for

Definition at line 1215 of file g_client.cpp.

References G_ActorSetTU(), G_ClientStateChange(), G_ClientStateChangeUpdate(), G_EdictsGetActorByUCN(), G_ReactionFireSettingsReserveTUs(), G_ReactionFireSettingsUpdate(), Edict::getTus(), gi, i, INVSH_GetItemByIDX(), length, and NONE.

Referenced by GetGameAPI().

bool G_ClientIsReady ( const Player *  player)
Returns
true if the player is for starting the multiplayer match

Definition at line 905 of file g_client.cpp.

Referenced by GetGameAPI().

void G_ClientPrintf ( const Player &  player,
int  printLevel,
const char *  fmt,
  ... 
)

Send messages to human players

Parameters
playerA player (AI players are ignored here)
printLevelA numeric value to restrict and channel the printing (CONSOLE, HUD, CHAT...)
fmtA format string as in printf

Definition at line 206 of file g_client.cpp.

References G_IsAIPlayer, and gi.

Referenced by G_ActionCheck(), G_ActionCheckForCurrentTeam(), G_ActorInvMove(), G_CheckFlood(), G_ClientShoot(), G_ClientStateChange(), G_Players_f(), G_ReactionFireCanBeEnabled(), G_Say_f(), G_ShootGrenade(), Message_Use(), and Touch_NextMapTrigger().

static void G_ClientReadInventory ( Edict ent)
static
static void G_ClientSendEdictsAndBrushModels ( const Player &  player)
static

Send brush models for entities like func_breakable and func_door and triggers with their bounding boxes to the client and let him know about them. There are also entities that are announced here, but fully handled clientside - like func_rotating.

See also
CL_AddBrushModel
EV_ADD_BRUSH_MODEL
Parameters
[in]playerThe player the edicts are send to

Definition at line 1296 of file g_client.cpp.

References ET_NULL, G_EdictsGetFirst(), G_EdictsGetNextInUse(), G_EventAddBrushModel(), G_PlayerToPM, G_VisFlagsAdd(), Edict::solid, SOLID_BSP, Edict::type, and Edict::visflags.

Referenced by G_ClientBegin().

static void G_ClientSkipActorInfo ( void  )
static

Call this if you want to skip some actor netchannel data.

Note
The fieldsize is not skipped
See also
G_ClientTeamInfo

Definition at line 1168 of file g_client.cpp.

References G_ClientReadCharacter(), G_ReadItem(), gi, and i.

Referenced by G_ClientTeamInfo().

void G_ClientStateChange ( const Player &  player,
Actor actor,
int  reqState,
bool  checkaction 
)

Changes the state of a player/soldier.

Parameters
[in,out]playerThe player who controls the actor
[in]actorthe edict to perform the state change for
[in]reqStateThe bit-map of the requested state change
[in]checkactionif false only activate the events - network stuff is handled in the calling function don't even use the G_ActionCheckForCurrentTeam function
Note
Use checkaction false only for e.g. spawning values

Definition at line 473 of file g_client.cpp.

References _, Edict::chr, chrReservations_s::crouch, Edict::fieldSize, G_ActionCheckForCurrentTeam(), G_ActorReserveTUs(), G_ActorSetMaxs(), G_ActorUseTU(), G_ClientPrintf(), G_ClientStateChangeUpdate(), G_EventReactionFireChange(), G_IsAI, G_ReactionFireSettingsReserveTUs(), G_SetState, G_ToggleCrouched, gi, Actor::isCrouched(), Actor::isReaction(), Actor::isShaken(), Edict::pos, PRINT_HUD, Actor::removeReaction(), character_s::reservedTus, chrReservations_s::shot, STATE_CROUCHED, STATE_REACTION, and TU_CROUCH.

Referenced by AI_ActorThink(), AI_InitPlayer(), AIL_crouch(), AIL_reactionfire(), G_ActorDieOrStun(), G_ClientAction(), G_ClientInitActorStates(), G_ClientMove(), G_MoraleBehaviour(), G_MoralePanic(), G_MoraleRage(), G_ReactionFireSettingsUpdate(), and G_ThinkActorGoCrouch().

static void G_ClientStateChangeUpdate ( Edict ent)
static

After an actor changed his state, he might get visible for other players. Check the vis here and send the state change to the clients that are seeing him already.

Parameters
entThe actor edict

Definition at line 446 of file g_client.cpp.

References G_CheckVis(), G_CheckVisTeamAll(), G_EventEnd(), G_EventSendState(), G_SendStats(), G_VisToPM(), Edict::getTeam(), and Edict::visflags.

Referenced by G_ClientInitActorStates(), and G_ClientStateChange().

void G_ClientTeamInfo ( const Player &  player)
static void G_ClientTurn ( Player &  player,
Actor actor,
dvec_t  dvec 
)
static

Sends the actual actor turn event over the netchannel.

Definition at line 415 of file g_client.cpp.

References Edict::dir, G_ActionCheckForCurrentTeam(), G_ActorDoTurn(), G_ActorUseTU(), G_EventActorTurn(), G_EventEnd(), G_SendStats(), getDVdir, and TU_TURN.

Referenced by G_ClientAction().

bool G_ClientUseEdict ( const Player &  player,
Actor actor,
Edict edict 
)

This function 'uses' the edict. E.g. it opens the door when the player wants it to open.

See also
PA_USE_DOOR
Parameters
[in]playerThe player is trying to activate the door
[in,out]actorThe actor the player is using to activate the entity
[in,out]edictThe entity that is to be used
Todo:
Do we have to change the trigger position here, too? I don't think this is really needed.
See also
CL_ActorUse
G_UseEdict

Definition at line 614 of file g_client.cpp.

References G_ActionCheckForCurrentTeam(), G_ActorUseTU(), G_EventEnd(), G_SendStats(), G_UseEdict(), and Edict::TU.

Referenced by G_ActorUseDoor().

void G_ClientUserinfoChanged ( Player &  player,
const char *  userinfo 
)

called whenever the player updates a userinfo variable.

Note
The game can override any of the settings in place (forcing skins or names, etc) before copying it off.

Definition at line 1393 of file g_client.cpp.

References Com_DPrintf(), CS_PLAYERNAMES, DEBUG_GAME, G_GetTeam(), G_MatchIsRunning(), gi, Info_IntegerForKey(), Info_Validate(), Info_ValueForKey(), Q_strncpyz(), and TEAM_NO_ACTIVE.

Referenced by G_ClientConnect(), and GetGameAPI().

int G_GetActiveTeam ( void  )

Returns the current active team to the server.

If this has the value TEAM_NO_ACTIVE there is either no
living actor for any player left, or the turn wasn't started yet.

Definition at line 327 of file g_client.cpp.

References level_locals_s::activeTeam, and level.

Referenced by G_ClientEndRound(), G_GetNextActiveTeam(), and GetGameAPI().

static void G_GetStartingTeam ( const Player &  player)
static

Chose a team that should start the match.

Parameters
[in]playerIn singleplayer mode the team of this player will get the first turn
See also
SVCmd_StartGame_f

Definition at line 916 of file g_client.cpp.

References level_locals_s::activeTeam, frand(), G_IsSinglePlayer, G_MatchIsRunning(), G_PlayerGetNextActiveHuman(), G_PrintStats(), int(), level, level_locals_s::mapname, MAX_TEAMS, and level_locals_s::teamOfs.

Referenced by G_ClientStartMatch().

static void G_GetTeam ( Player &  player)
static
void G_GiveTimeUnits ( int  team)

Network function to update the time units (TUs) for each team-member.

Parameters
[in]teamThe index of the team to update the values for.
See also
G_SendStats

Definition at line 224 of file g_client.cpp.

References G_ActorGiveTimeUnits(), G_EdictsGetNextLivingActorOfTeam(), and G_SendStats().

Referenced by G_ClientEndRound().

Player* G_PlayerGetNextActiveAI ( Player *  lastPlayer)

Iterate through the list of players.

Parameters
lastPlayerThe player found in the previous iteration; if nullptr, we start at the beginning

Definition at line 126 of file g_client.cpp.

References G_PlayerGetNextAI().

Referenced by AI_Run(), G_ClientEndRound(), G_GetPlayerForTeam(), and G_GetTeam().

Player* G_PlayerGetNextActiveHuman ( Player *  lastPlayer)

Iterate through the list of players.

Parameters
lastPlayerThe player found in the previous iteration; if nullptr, we start at the beginning

Definition at line 110 of file g_client.cpp.

References G_PlayerGetNextHuman().

Referenced by AI_Run(), G_CheckForceEndRound(), G_ClientEndRound(), G_GetPlayerForTeam(), G_GetStartingTeam(), G_GetTeam(), G_Players_f(), G_PMToVis(), G_Say_f(), and G_VisToPM().

Player* G_PlayerGetNextAI ( Player *  lastPlayer)

Iterate through the list of players.

Parameters
lastPlayerThe player found in the previous iteration; if nullptr, we start at the beginning

Definition at line 84 of file g_client.cpp.

References game, game_locals_s::players, and game_locals_s::sv_maxplayersperteam.

Referenced by AI_CreatePlayer(), and G_PlayerGetNextActiveAI().

Player* G_PlayerGetNextHuman ( Player *  lastPlayer)

Iterate through the list of players.

Parameters
lastPlayerThe player found in the previous iteration; if nullptr, we start at the beginning

Definition at line 58 of file g_client.cpp.

References game, game_locals_s::players, and game_locals_s::sv_maxplayersperteam.

Referenced by G_PlayerGetNextActiveHuman(), G_SetTeamForPlayer(), G_TeamToPM(), and TEST_F().

teammask_t G_PMToVis ( playermask_t  playerMask)

Converts player mask to vis mask.

Parameters
[in]playerMaskThe player bit mask (contains the player numbers) that is converted to a vis mask
Returns
Returns a vis mask for all the teams of the connected players that are marked in the given playerMask.

Definition at line 165 of file g_client.cpp.

References G_PlayerGetNextActiveHuman(), G_PlayerToPM, and G_TeamToVisMask.

Referenced by G_AppearPerishEvent(), and G_SplashDamage().

void G_ResetClientData ( void  )

Called after every player has joined.

Definition at line 1510 of file g_client.cpp.

References OBJZERO, and scoreMissionNum.

Referenced by G_SpawnEntities().

void G_SendInvisible ( const Player &  player)

This function sends all the actors to the client that are not visible initially - this is needed because an actor can e.g. produce sounds that are send over the net. And the client can only handle them if he knows the le_t (local entity) already.

Note
Call this for the first G_CheckVis call for every new actor or player
See also
G_CheckVis
CL_ActorAdd

Definition at line 302 of file g_client.cpp.

References G_EdictsGetNextActor(), G_EventActorAdd(), G_IsVisibleForTeam, G_PlayerToPM, Edict::getTeam(), level, level_locals_s::num_alive, and TEAM_NO_ACTIVE.

Referenced by G_ClientStartMatch().

bool G_SetTeamForPlayer ( Player &  player,
const int  team 
)

Set the used team for the given player.

Parameters
[out]playerThe player the team should be set for
[in]teamThe team to set for the given player
Returns
true if the team was set successfully, false otherwise.

Definition at line 852 of file g_client.cpp.

References G_IsAIPlayer, g_nospawn, G_PlayerGetNextHuman(), gi, Info_SetValueForKeyAsInteger(), cvar_s::integer, level, MAX_TEAMS, level_locals_s::num_spawnpoints, sv_teamplay, TEAM_ALIEN, TEAM_CIVILIAN, and TEAM_NO_ACTIVE.

Referenced by AI_CreatePlayer(), and G_GetTeam().

playermask_t G_TeamToPM ( int  team)

Generates the player bit mask for a given team.

Parameters
[in]teamThe team to create the player bit mask for
Note
E.g. multiplayer team play can have more than one human player on the same team.

Definition at line 144 of file g_client.cpp.

References G_PlayerGetNextHuman(), and G_PlayerToPM.

Referenced by G_ActorInvMove(), G_CheckVisTeam(), G_EventActorAppear(), G_EventSendState(), G_EventSetClientAction(), G_GetClosePlayerMask(), G_SendStats(), G_SplashDamage(), and G_VisMakeEverythingVisible().

static void G_ThinkActorDieAfterSpawn ( Edict ent)
static

Think function for actors that spawn dead.

Parameters
entThe actor

Definition at line 1014 of file g_client.cpp.

References G_ActorDieOrStun(), makeActor(), and Edict::think.

Referenced by G_ClientGetFreeSpawnPointForActorSize().

static void G_ThinkActorGoCrouch ( Edict ent)
static

Think function for actors that spawn crouched.

Parameters
entThe actor

Definition at line 1026 of file g_client.cpp.

References G_ClientStateChange(), Edict::getPlayer(), makeActor(), STATE_CROUCHED, and Edict::think.

Referenced by G_ClientGetFreeSpawnPointForActorSize().

Variable Documentation

chrScoreMission_t scoreMission[MAX_EDICTS]
static

Definition at line 51 of file g_client.cpp.

Referenced by G_UpdateCharacterBodycount().

int scoreMissionNum = 0
static

Definition at line 52 of file g_client.cpp.

Referenced by G_ClientAssignDefaultActorValues(), and G_ResetClientData().