cl_game.c File Reference

Shared game type code. More...

#include "cl_game.h"
#include "cgame.h"
#include "battlescape/cl_localentity.h"
#include "ui/ui_main.h"
#include "ui/ui_nodes.h"
#include "cl_team.h"
#include "battlescape/events/e_main.h"
#include "cl_inventory.h"
#include "ui/node/ui_node_model.h"
Include dependency graph for cl_game.c:

Go to the source code of this file.

Functions

character_tGAME_GetCharacter (int index)
 Returns a character that can be used to store the game type specific character values.
size_t GAME_GetCharacterArraySize (void)
void GAME_ResetCharacters (void)
 Will reset (memset) all characters in the static character array.
void GAME_AppendTeamMember (int memberIndex, const char *teamDefID, const equipDef_t *ed)
void GAME_GenerateTeam (const char *teamDefID, const equipDef_t *ed, int teamMembers)
static const cgame_export_tGAME_GetCurrentType (void)
void GAME_ReloadMode (void)
void GAME_StartBattlescape (qboolean isTeamPlay)
 Called when the server sends the EV_START event.
void GAME_EndBattlescape (void)
 This is called when a client quits the battlescape.
void GAME_EndRoundAnnounce (int playerNum, int team)
 Send end round announcements.
void GAME_DisplayItemInfo (uiNode_t *node, const char *string)
 Shows game type specific item information (if it's not resolvable via objDef_t).
static void GAME_FreeInventory (void *data)
static void * GAME_AllocInventoryMemory (size_t size)
static void GAME_FreeAllInventory (void)
void GAME_SetMode (int gametype)
static void UI_MapInfoGetNext (int step)
static void UI_MapInfo (int step)
 Prints the map info for the server creation dialogue.
static void UI_GetMaps_f (void)
static void UI_ChangeMap_f (void)
static void UI_SelectMap_f (void)
static void GAME_SetMode_f (void)
 Decides with game mode should be set - takes the menu as reference.
static qboolean GAME_IsArmourUseableForTeam (const objDef_t *od, const teamDef_t *teamDef)
qboolean GAME_ItemIsUseable (const objDef_t *od)
void GAME_HandleResults (struct dbuffer *msg, int winner, int *numSpawned, int *numAlive, int numKilled[][MAX_TEAMS], int numStunned[][MAX_TEAMS])
 After a mission was finished this function is called.
static void CL_NetSendItem (struct dbuffer *buf, item_t item, containerIndex_t container, int x, int y)
static void CL_NetSendInventory (struct dbuffer *buf, const inventory_t *i)
static void GAME_NetSendCharacter (struct dbuffer *buf, const character_t *chr)
 Send the character information to the server that is needed to spawn the soldiers of the player.
static void GAME_SendCurrentTeamSpawningInfo (struct dbuffer *buf, chrList_t *team)
 Stores a team-list (chr-list) info to buffer (which might be a network buffer, too).
const char * GAME_GetTeamDef (void)
static qboolean GAME_Spawn (void)
static void GAME_InitializeBattlescape (chrList_t *team)
 This is called if actors are spawned (or at least the spawning commands were send to the server). This callback can e.g. be used to set initial actor states. E.g. request crouch and so on. These events are executed without consuming time.
void GAME_SpawnSoldiers (void)
 Called during startup of mission to send team info.
int GAME_GetCurrentTeam (void)
equipDef_tGAME_GetEquipmentDefinition (void)
qboolean GAME_TeamIsKnown (const teamDef_t *teamDef)
void GAME_CharacterCvars (const character_t *chr)
static void GAME_Abort_f (void)
 Let the aliens win the match.
void GAME_Drop (void)
static void GAME_Exit_f (void)
 Quits the current running game by calling the shutdown callback.
void GAME_Frame (void)
 Called every frame and allows us to hook into the current running game mode.
const char * GAME_GetModelForItem (const objDef_t *od, uiModel_t **uiModel)
 Get a model for an item.
mapDef_tCom_GetMapDefinitionByID (const char *mapDefID)
mapDef_tCom_GetMapDefByIDX (int index)
void GAME_InitStartup (void)

Variables

static const cgame_export_t gameTypeList []
static character_t characters [MAX_ACTIVETEAM]
 static character array that can be used by a game mode to store the needed character values.
static const int TAG_INVENTORY = 17462
static const inventoryImport_t inventoryImport = { GAME_FreeInventory, GAME_FreeAllInventory, GAME_AllocInventoryMemory }

Detailed Description

Shared game type code.

Definition in file cl_game.c.


Function Documentation

static void CL_NetSendInventory ( struct dbuffer buf,
const inventory_t i 
) [static]
static void CL_NetSendItem ( struct dbuffer buf,
item_t  item,
containerIndex_t  container,
int  x,
int  y 
) [static]
See also:
G_WriteItem
G_ReadItem
Note:
The amount of the item_t struct should not be needed here - because the amount is only valid for idFloor and idEquip

Definition at line 527 of file cl_game.c.

References item_s::a, item_s::amount, CL_GetEvent(), Com_DPrintf(), DEBUG_CLIENT, EV_INV_TRANSFER, eventRegister_s::formatString, objDef_s::id, objDef_s::idx, item_s::m, NET_WriteFormat(), NONE, item_s::rotated, and item_s::t.

Referenced by CL_NetSendInventory().

mapDef_t* Com_GetMapDefByIDX ( int  index  ) 
mapDef_t* Com_GetMapDefinitionByID ( const char *  mapDefID  ) 
static void GAME_Abort_f ( void   )  [static]

Let the aliens win the match.

Definition at line 751 of file cl_game.c.

References Cbuf_AddText(), TEAM_ALIEN, and va().

Referenced by GAME_InitStartup().

static void* GAME_AllocInventoryMemory ( size_t  size  )  [static]

Definition at line 280 of file cl_game.c.

References cl_genericPool, and Mem_PoolAlloc.

void GAME_AppendTeamMember ( int  memberIndex,
const char *  teamDefID,
const equipDef_t ed 
)
void GAME_CharacterCvars ( const character_t chr  ) 

Definition at line 741 of file cl_game.c.

References GAME_GetCurrentType().

Referenced by CL_UpdateCharacterValues().

void GAME_DisplayItemInfo ( uiNode_t node,
const char *  string 
)

Shows game type specific item information (if it's not resolvable via objDef_t).

Parameters:
[in] node The menu node to show the information in.
[in] string The id of the 'thing' to show information for.

Definition at line 191 of file cl_game.c.

References GAME_GetCurrentType().

Referenced by UI_ItemNodeDraw().

void GAME_Drop ( void   ) 

Definition at line 757 of file cl_game.c.

References GAME_GetCurrentType(), GAME_NONE, GAME_SetMode(), qfalse, qtrue, SV_Shutdown(), and UI_InitStack().

Referenced by CL_Drop().

void GAME_EndBattlescape ( void   ) 

This is called when a client quits the battlescape.

See also:
GAME_StartBattlescape

Definition at line 168 of file cl_game.c.

References cls, Com_Printf(), inventoryInterface_s::GetUsedSlots, and client_static_s::i.

Referenced by CL_Disconnect().

void GAME_EndRoundAnnounce ( int  playerNum,
int  team 
)

Send end round announcements.

Parameters:
playerNum The server player number of the player that has ended the round
team The team the player is in

Todo:
do we need the team number here? isn't the playernum enough to get the team?

Definition at line 178 of file cl_game.c.

References GAME_GetCurrentType().

Referenced by CL_EndRoundAnnounce().

static void GAME_Exit_f ( void   )  [static]

Quits the current running game by calling the shutdown callback.

Definition at line 773 of file cl_game.c.

References GAME_NONE, and GAME_SetMode().

Referenced by GAME_InitStartup().

void GAME_Frame ( void   ) 

Called every frame and allows us to hook into the current running game mode.

Definition at line 781 of file cl_game.c.

References GAME_GetCurrentType().

Referenced by CL_Frame().

static void GAME_FreeAllInventory ( void   )  [static]

Definition at line 286 of file cl_game.c.

References cl_genericPool, and Mem_FreeTag.

static void GAME_FreeInventory ( void *  data  )  [static]

Definition at line 275 of file cl_game.c.

References Mem_Free.

void GAME_GenerateTeam ( const char *  teamDefID,
const equipDef_t ed,
int  teamMembers 
)
character_t* GAME_GetCharacter ( int  index  ) 

Returns a character that can be used to store the game type specific character values.

Note:
The returned pointer is a reference to static memory
Parameters:
index The index of the character array. This value must be greater than 0 and not bigger than the value GAME_GetCharacterArraySize returned
See also:
GAME_GetCharacterArraySize
GAME_ResetCharacters
Returns:
A character slot

Definition at line 58 of file cl_game.c.

References Com_Error(), ERR_DROP, and lengthof.

Referenced by GAME_AppendTeamMember(), and MP_LoadTeamMultiplayerInfo().

size_t GAME_GetCharacterArraySize ( void   ) 
Returns:
The size of the static character array
See also:
GAME_GetCharacter
GAME_ResetCharacters

Definition at line 71 of file cl_game.c.

References lengthof.

Referenced by GAME_GenerateTeam(), GAME_MP_AutoTeam(), GAME_SK_Start_f(), GAME_Spawn(), and MP_LoadTeamMultiplayerInfo().

int GAME_GetCurrentTeam ( void   ) 

Definition at line 710 of file cl_game.c.

References GAME_GetCurrentType(), and TEAM_DEFAULT.

static const cgame_export_t* GAME_GetCurrentType ( void   )  [static]
equipDef_t* GAME_GetEquipmentDefinition ( void   ) 
const char* GAME_GetModelForItem ( const objDef_t od,
uiModel_t **  uiModel 
)

Get a model for an item.

Parameters:
[in] od The object definition to get the model from.
[out] menuModel The menu model pointer.
Returns:
The model path for the item. Never NULL.

Definition at line 796 of file cl_game.c.

References GAME_GetCurrentType(), cgame_export_t::GetModelForItem(), objDef_s::model, and UI_GetUIModel().

Referenced by UI_DrawItem(), and UI_ItemNodeDraw().

const char* GAME_GetTeamDef ( void   ) 
void GAME_HandleResults ( struct dbuffer msg,
int  winner,
int *  numSpawned,
int *  numAlive,
int  numKilled[][MAX_TEAMS],
int  numStunned[][MAX_TEAMS] 
)

After a mission was finished this function is called.

Parameters:
msg The network message buffer
winner The winning team
numSpawned The amounts of all spawned actors per team
numAlive The amount of survivors per team
numKilled The amount of killed actors for all teams. The first dimension contains the attacker team, the second the victim team
numStunned The amount of stunned actors for all teams. The first dimension contains the attacker team, the second the victim team

Definition at line 512 of file cl_game.c.

References CL_Drop(), and GAME_GetCurrentType().

Referenced by CL_ParseResults().

static void GAME_InitializeBattlescape ( chrList_t team  )  [static]

This is called if actors are spawned (or at least the spawning commands were send to the server). This callback can e.g. be used to set initial actor states. E.g. request crouch and so on. These events are executed without consuming time.

Definition at line 666 of file cl_game.c.

References cl, GAME_GetCurrentType(), i, lengthof, and UI_ExecuteConfunc().

Referenced by GAME_SpawnSoldiers().

void GAME_InitStartup ( void   ) 
static qboolean GAME_IsArmourUseableForTeam ( const objDef_t od,
const teamDef_t teamDef 
) [static]
qboolean GAME_ItemIsUseable ( const objDef_t od  ) 
static void GAME_NetSendCharacter ( struct dbuffer buf,
const character_t chr 
) [static]
void GAME_ReloadMode ( void   ) 
void GAME_ResetCharacters ( void   ) 

Will reset (memset) all characters in the static character array.

See also:
GAME_GetCharacterArraySize
GAME_GetCharacter

Definition at line 81 of file cl_game.c.

References chrDisplayList, and chr_list_s::num.

Referenced by GAME_GenerateTeam(), and MP_LoadTeamMultiplayerInfo().

static void GAME_SendCurrentTeamSpawningInfo ( struct dbuffer buf,
chrList_t team 
) [static]

Stores a team-list (chr-list) info to buffer (which might be a network buffer, too).

See also:
G_ClientTeamInfo
MP_SaveTeamMultiplayerInfo
Note:
Called in CL_Precache_f to send the team info to server

Definition at line 611 of file cl_game.c.

References chr_list_s::chr, CL_NetSendInventory(), clc_teaminfo, Com_DPrintf(), DEBUG_CLIENT, GAME_NetSendCharacter(), character_s::i, i, NET_WriteByte(), and chr_list_s::num.

Referenced by GAME_SpawnSoldiers().

void GAME_SetMode ( int  gametype  ) 
static void GAME_SetMode_f ( void   )  [static]

Decides with game mode should be set - takes the menu as reference.

Definition at line 446 of file cl_game.c.

References Cmd_Argc(), Cmd_Argv(), Com_Printf(), GAME_SetMode(), cgame_export_t::gametype, cgame_export_t::menu, cgame_export_t::name, and UI_GetActiveWindowName().

Referenced by GAME_InitStartup().

static qboolean GAME_Spawn ( void   )  [static]
void GAME_SpawnSoldiers ( void   ) 
void GAME_StartBattlescape ( qboolean  isTeamPlay  ) 

Called when the server sends the EV_START event.

Parameters:
isTeamPlay true if the game is a teamplay round. This can be interesting for multiplayer based game types
See also:
GAME_EndBattlescape

Definition at line 152 of file cl_game.c.

References cls, Com_Printf(), GAME_GetCurrentType(), inventoryInterface_s::GetUsedSlots, client_static_s::i, mn_hud, qtrue, cvar_s::string, and UI_InitStack().

Referenced by CL_StartGame().

qboolean GAME_TeamIsKnown ( const teamDef_t teamDef  ) 

Definition at line 729 of file cl_game.c.

References GAME_GetCurrentType(), qfalse, and qtrue.

Referenced by CL_ActorAppear(), and CL_AddTargetingBox().

static void UI_ChangeMap_f ( void   )  [static]

Definition at line 399 of file cl_game.c.

References Cmd_Argv(), and UI_MapInfo().

Referenced by GAME_InitStartup().

static void UI_GetMaps_f ( void   )  [static]

Definition at line 394 of file cl_game.c.

References UI_MapInfo().

Referenced by GAME_InitStartup().

static void UI_MapInfo ( int  step  )  [static]

Prints the map info for the server creation dialogue.

Todo:
Skip special map that start with a '.' (e.g. .baseattack)

Definition at line 351 of file cl_game.c.

References cls, Cvar_Set(), FS_CheckFile(), GAME_GetCurrentType(), mapDef_s::map, cgame_export_t::MapInfo(), client_static_s::numMDs, mapDef_s::param, UI_MapInfoGetNext(), and va().

Referenced by UI_ChangeMap_f(), UI_GetMaps_f(), and UI_SelectMap_f().

static void UI_MapInfoGetNext ( int  step  )  [static]
static void UI_SelectMap_f ( void   )  [static]

Variable Documentation

character_t characters[MAX_ACTIVETEAM] [static]

static character array that can be used by a game mode to store the needed character values.

Definition at line 47 of file cl_game.c.

const cgame_export_t gameTypeList[] [static]
Initial value:
 {
    {"Multiplayer mode", "multiplayer", GAME_MULTIPLAYER, GAME_MP_InitStartup, GAME_MP_Shutdown, NULL, GAME_MP_GetTeam, GAME_MP_MapInfo, GAME_MP_Results, NULL, NULL, GAME_MP_GetEquipmentDefinition, NULL, NULL, NULL, NULL, NULL, NULL, GAME_MP_EndRoundAnnounce, GAME_MP_StartBattlescape},
    {"Campaign mode", "campaigns", GAME_CAMPAIGN, GAME_CP_InitStartup, GAME_CP_Shutdown, GAME_CP_Spawn, GAME_CP_GetTeam, GAME_CP_MapInfo, GAME_CP_Results, GAME_CP_ItemIsUseable, GAME_CP_DisplayItemInfo, GAME_CP_GetEquipmentDefinition, GAME_CP_CharacterCvars, GAME_CP_TeamIsKnown, GAME_CP_Drop, GAME_CP_InitializeBattlescape, GAME_CP_Frame, GAME_CP_GetModelForItem, NULL, NULL},
    {"Skirmish mode", "skirmish", GAME_SKIRMISH, GAME_SK_InitStartup, GAME_SK_Shutdown, NULL, GAME_SK_GetTeam, GAME_SK_MapInfo, GAME_SK_Results, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},

    {NULL, NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}
}

Definition at line 36 of file cl_game.c.

const inventoryImport_t inventoryImport = { GAME_FreeInventory, GAME_FreeAllInventory, GAME_AllocInventoryMemory } [static]

Definition at line 291 of file cl_game.c.

const int TAG_INVENTORY = 17462 [static]

Definition at line 273 of file cl_game.c.


Generated by  doxygen 1.6.2