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"
Go to the source code of this file.
Functions | |
character_t * | GAME_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_t * | GAME_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_t * | GAME_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_t * | Com_GetMapDefinitionByID (const char *mapDefID) |
mapDef_t * | Com_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 } |
Shared game type code.
Definition in file cl_game.c.
static void CL_NetSendInventory | ( | struct dbuffer * | buf, | |
const inventory_t * | i | |||
) | [static] |
Definition at line 540 of file cl_game.c.
References inventory_s::c, CL_NetSendItem(), csi, INV_INVENTORY_BYTES, invList_s::item, NET_WriteShort(), invList_s::next, csi_s::numIDs, invList_s::x, and invList_s::y.
Referenced by GAME_SendCurrentTeamSpawningInfo().
static void CL_NetSendItem | ( | struct dbuffer * | buf, | |
item_t | item, | |||
containerIndex_t | container, | |||
int | x, | |||
int | y | |||
) | [static] |
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 | ) |
Definition at line 829 of file cl_game.c.
References cls, and client_static_s::mds.
Referenced by CL_ParseMapDefinition(), CL_ResetSinglePlayerData(), Com_GetMapDefinitionByID(), CP_ChooseMap(), CP_MapIsSelectable(), CP_SaveMapDefStatXML(), GAME_CP_MapInfo(), GAME_MP_ChangeGametype_f(), GAME_MP_MapInfo(), GAME_MP_StartServer_f(), GAME_SK_MapInfo(), GAME_SK_Start_f(), NAT_ScriptSanityCheck(), UI_MapInfoGetNext(), and UI_SelectMap_f().
mapDef_t* Com_GetMapDefinitionByID | ( | const char * | mapDefID | ) |
Definition at line 813 of file cl_game.c.
References cls, Com_DPrintf(), Com_GetMapDefByIDX(), DEBUG_CLIENT, i, mapDef_s::id, and client_static_s::numMDs.
Referenced by CP_BaseAttackGoToBase(), CP_ChooseMap(), CP_LoadMapDefStatXML(), CP_LoadMissionsXML(), and CP_SpawnAlienBaseMission().
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 | |||
) |
Definition at line 87 of file cl_game.c.
References chr_list_s::chr, chrDisplayList, CL_GenerateCharacter(), cls, Com_Error(), inventoryInterface_s::EquipActor, ERR_DROP, GAME_GetCharacter(), character_s::i, client_static_s::i, chr_list_s::num, and character_s::teamDef.
Referenced by GAME_GenerateTeam(), and GAME_SK_Start_f().
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
).
[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.
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.
playerNum | The server player number of the player that has ended the round | |
team | The team the player is in |
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] |
void GAME_GenerateTeam | ( | const char * | teamDefID, | |
const equipDef_t * | ed, | |||
int | teamMembers | |||
) |
Definition at line 104 of file cl_game.c.
References Com_Error(), ERR_DROP, GAME_AppendTeamMember(), GAME_GetCharacterArraySize(), GAME_ResetCharacters(), and i.
Referenced by GAME_MP_AutoTeam(), GAME_SK_Start_f(), and GAME_Spawn().
character_t* GAME_GetCharacter | ( | int | index | ) |
Returns a character that can be used to store the game type specific character values.
index | The index of the character array. This value must be greater than 0 and not bigger than the value GAME_GetCharacterArraySize returned |
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 | ) |
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] |
Definition at line 120 of file cl_game.c.
References cls, GAME_NONE, cgame_export_t::gametype, client_static_s::gametype, and cgame_export_t::name.
Referenced by GAME_CharacterCvars(), GAME_DisplayItemInfo(), GAME_Drop(), GAME_EndRoundAnnounce(), GAME_Frame(), GAME_GetCurrentTeam(), GAME_GetEquipmentDefinition(), GAME_GetModelForItem(), GAME_HandleResults(), GAME_InitializeBattlescape(), GAME_ItemIsUseable(), GAME_ReloadMode(), GAME_SetMode(), GAME_Spawn(), GAME_SpawnSoldiers(), GAME_StartBattlescape(), GAME_TeamIsKnown(), and UI_MapInfo().
equipDef_t* GAME_GetEquipmentDefinition | ( | void | ) |
Definition at line 720 of file cl_game.c.
References GAME_GetCurrentType(), and cgame_export_t::GetEquipmentDefinition().
Referenced by CL_InvReload(), MP_GetEquipment(), MP_LoadTeamMultiplayer(), and MP_SaveTeamMultiplayer().
Get a model for an item.
[in] | od | The object definition to get the model from. |
[out] | menuModel | The menu model pointer. |
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 | ) |
Definition at line 629 of file cl_game.c.
References Cvar_GetString().
Referenced by E_CreateEmployeeAtIndex(), GAME_ItemIsUseable(), GAME_MP_AutoTeam(), GAME_SK_Start_f(), and GAME_Spawn().
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.
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 | ) |
Definition at line 834 of file cl_game.c.
References Cmd_AddCommand(), GAME_Abort_f(), GAME_Exit_f(), GAME_SetMode_f(), UI_ChangeMap_f(), UI_GetMaps_f(), and UI_SelectMap_f().
Referenced by CL_InitLocal().
static qboolean GAME_IsArmourUseableForTeam | ( | const objDef_t * | od, | |
const teamDef_t * | teamDef | |||
) | [static] |
Definition at line 469 of file cl_game.c.
References teamDef_s::armour, CHRSH_IsTeamDefAlien(), INV_IsArmour, qfalse, qtrue, teamDef_s::race, RACE_CIVILIAN, RACE_PHALANX_HUMAN, TEAM_ALIEN, TEAM_CIVILIAN, TEAM_PHALANX, and objDef_s::useable.
Referenced by GAME_ItemIsUseable().
Definition at line 485 of file cl_game.c.
References Com_GetTeamDefinitionByID(), GAME_GetCurrentType(), GAME_GetTeamDef(), GAME_IsArmourUseableForTeam(), qfalse, and qtrue.
Referenced by CL_ActorGetContainerForReload(), CL_ActorReload(), HUD_ShotReserve_f(), HUD_UpdateActorFireMode(), HUD_UpdateReactionFiremodes(), INV_DecreaseItem_f(), INV_IncreaseItem_f(), INV_ItemDescription(), UI_BaseInventoryNodeDrawItems(), UI_BaseInventoryNodeGetItem(), UI_ContainerItemIteratorNext(), UI_ContainerNodeUpdateEquipment(), and UI_GetItemTooltip().
static void GAME_NetSendCharacter | ( | struct dbuffer * | buf, | |
const character_t * | chr | |||
) | [static] |
Send the character information to the server that is needed to spawn the soldiers of the player.
[out] | buf | The net channel buffer to write the character data into. |
[in] | chr | The character to get the data from. |
Definition at line 563 of file cl_game.c.
References ACTOR_SIZE_2x2, ACTOR_SIZE_NORMAL, chrScoreGlobal_s::assignedMissions, character_s::body, Com_Error(), ERR_DROP, chrScoreGlobal_s::experience, character_s::fieldSize, character_s::gender, character_s::head, character_s::HP, teamDef_s::idx, chrScoreGlobal_s::initialSkills, KILLED_NUM_TYPES, chrScoreGlobal_s::kills, character_s::maxHP, character_s::morale, character_s::name, NET_WriteByte(), NET_WriteLong(), NET_WriteShort(), NET_WriteString(), character_s::path, character_s::score, SKILL_NUM_TYPES, chrScoreGlobal_s::skills, character_s::skin, character_s::STUN, chrScoreGlobal_s::stuns, character_s::teamDef, and character_s::ucn.
Referenced by GAME_SendCurrentTeamSpawningInfo().
void GAME_ReloadMode | ( | void | ) |
Definition at line 136 of file cl_game.c.
References GAME_GetCurrentType(), GAME_NONE, GAME_SetMode(), and cgame_export_t::gametype.
Referenced by GAME_SK_Restart_f(), SAV_GameLoad(), and VID_Restart_f().
void GAME_ResetCharacters | ( | void | ) |
Will reset (memset) all characters in the static character array.
Definition at line 81 of file cl_game.c.
References chrDisplayList, and chr_list_s::num.
Referenced by GAME_GenerateTeam(), and MP_LoadTeamMultiplayerInfo().
Stores a team-list (chr-list) info to buffer (which might be a network buffer, too).
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 | ) |
Definition at line 293 of file cl_game.c.
References CL_Disconnect(), cls, Com_Printf(), csi, GAME_GetCurrentType(), GAME_MAX, client_static_s::gametype, client_static_s::i, INV_DestroyInventory(), INV_InitInventory(), cgame_export_t::name, qtrue, UI_InitStack(), and UI_IsWindowOnStack().
Referenced by CL_Shutdown(), GAME_Drop(), GAME_Exit_f(), GAME_ReloadMode(), and GAME_SetMode_f().
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] |
Definition at line 637 of file cl_game.c.
References chr_list_s::chr, chrDisplayList, cl, cls, csi, GAME_GenerateTeam(), GAME_GetCharacterArraySize(), GAME_GetCurrentType(), GAME_GetTeamDef(), client_static_s::i, i, INV_DestroyInventory(), INV_GetEquipmentDefinitionByID(), INV_InitInventory(), chr_list_s::num, and qtrue.
Referenced by GAME_SpawnSoldiers().
void GAME_SpawnSoldiers | ( | void | ) |
Called during startup of mission to send team info.
Definition at line 682 of file cl_game.c.
References cl, clc_stringcmd, cls, GAME_GetCurrentType(), GAME_InitializeBattlescape(), GAME_SendCurrentTeamSpawningInfo(), GAME_Spawn(), NET_WriteByte(), NET_WriteMsg(), NET_WriteString(), client_static_s::netStream, and new_dbuffer().
Referenced by CL_SpawnSoldiers_f().
void GAME_StartBattlescape | ( | qboolean | isTeamPlay | ) |
Called when the server sends the EV_START
event.
isTeamPlay | true if the game is a teamplay round. This can be interesting for multiplayer based game types |
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().
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.
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] |
Definition at line 329 of file cl_game.c.
References cls, Com_GetMapDefByIDX(), client_static_s::currentSelectedMap, mapDef_s::map, and client_static_s::numMDs.
Referenced by UI_MapInfo().
static void UI_SelectMap_f | ( | void | ) | [static] |
Definition at line 407 of file cl_game.c.
References cls, Cmd_Argc(), Cmd_Argv(), Com_GetMapDefByIDX(), Com_Printf(), client_static_s::currentSelectedMap, i, mapDef_s::id, mapDef_s::map, client_static_s::numMDs, and UI_MapInfo().
Referenced by GAME_InitStartup().
character_t characters[MAX_ACTIVETEAM] [static] |
const cgame_export_t gameTypeList[] [static] |
{ {"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} }
const inventoryImport_t inventoryImport = { GAME_FreeInventory, GAME_FreeAllInventory, GAME_AllocInventoryMemory } [static] |
const int TAG_INVENTORY = 17462 [static] |