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

Shared game type headers. More...

#include "../cl_shared.h"
#include "../ui/ui_main.h"
#include "cgame.h"

Go to the source code of this file.

Macros

#define GAME_IsSingleplayer()   (!GAME_IsMultiplayer())
 
#define CGAME_HARD_LINKED_FUNCTIONS
 

Functions

bool GAME_IsMultiplayer (void)
 
void GAME_ParseModes (const char *name, const char **text)
 
void GAME_InitStartup (void)
 
void GAME_Shutdown (void)
 
void GAME_InitUIData (void)
 Fills the game mode list entries with the parsed values from the script. More...
 
void GAME_UnloadGame (void)
 
void GAME_SetMode (const struct cgame_export_s *gametype)
 
void GAME_ReloadMode (void)
 
void GAME_Init (bool load)
 
void GAME_DisplayItemInfo (uiNode_t *node, const char *string)
 Shows game type specific item information (if it's not resolvable via objDef_t). More...
 
bool GAME_ItemIsUseable (const objDef_t *od)
 
void GAME_HandleResults (dbuffer *msg, int winner, int *numSpawned, int *numAlive, int numKilled[][MAX_TEAMS], int numStunned[][MAX_TEAMS], bool nextmap)
 After a mission was finished this function is called. More...
 
void GAME_SpawnSoldiers (void)
 Called during startup of mission to send team info. More...
 
void GAME_StartMatch (void)
 
const char * GAME_GetRelativeSavePath (char *buf, size_t bufSize)
 
const char * GAME_GetAbsoluteSavePath (char *buf, size_t bufSize)
 
equipDef_tGAME_GetEquipmentDefinition (void)
 
bool GAME_HandleServerCommand (const char *command, dbuffer *msg)
 
void GAME_AddChatMessage (const char *format,...)
 
void GAME_CharacterCvars (const character_t *chr)
 
character_tGAME_GetCharacter (int index)
 Returns a character that can be used to store the game type specific character values. More...
 
character_tGAME_GetCharacterByUCN (int ucn)
 Returns a character that can be used to store the game type specific character values. More...
 
size_t GAME_GetCharacterArraySize (void)
 
const char * GAME_GetCurrentName (void)
 
void GAME_ResetCharacters (void)
 Reset all characters in the static character array. More...
 
void GAME_GenerateTeam (const char *teamDefID, const equipDef_t *ed, int teamMembers)
 
void GAME_AppendTeamMember (int memberIndex, const char *teamDefID, const equipDef_t *ed)
 
void GAME_StartBattlescape (bool isTeamPlay)
 Called when the server sends the EV_START event. More...
 
void GAME_InitMissionBriefing (const char *title)
 
void GAME_EndBattlescape (void)
 This is called when a client quits the battlescape. More...
 
void GAME_EndRoundAnnounce (int playerNum, int team)
 Send end round announcements. More...
 
bool GAME_TeamIsKnown (const teamDef_t *teamDef)
 
void GAME_NotifyEvent (event_t eventType)
 
const char * GAME_GetTeamDef (void)
 
void GAME_Drop (void)
 
void GAME_Frame (void)
 Called every frame and allows us to hook into the current running game mode. More...
 
void GAME_DrawBaseLayout (int baseIdx, int x, int y, int totalMarge, int w, int h, int padding, const vec4_t bgcolor, const vec4_t color)
 
void GAME_DrawBaseLayoutTooltip (int baseIdx, int x, int y)
 Cgame callback to draw tooltip for baselayout UI node. More...
 
const char * GAME_GetModelForItem (const objDef_t *od, struct uiModel_s **menuModel)
 Get a model for an item. More...
 
const mapDef_tGAME_GetCurrentSelectedMap (void)
 
void GAME_SwitchCurrentSelectedMap (int step)
 
bool GAME_IsTeamEmpty (void)
 
int GAME_GetCurrentTeam (void)
 
void GAME_DrawMap (geoscapeData_t *data)
 
void GAME_DrawMapMarkers (uiNode_t *node)
 
void GAME_MapClick (uiNode_t *node, int x, int y, const vec2_t pos)
 
void GAME_SetServerInfo (const char *server, const char *serverport)
 
character_tGAME_GetSelectedChr (void)
 Returns the currently selected character. More...
 
int GAME_GetChrMaxLoad (const character_t *chr)
 Returns the max weight the given character can carry. More...
 
const equipDef_tGAME_ChangeEquip (const linkedList_t *equipmentList, changeEquipType_t changeType, const char *equipID)
 Changed the given cvar to the next/prev equipment definition. More...
 

Variables

geoscapeData_t geoscapeData
 

Detailed Description

Shared game type headers.

Definition in file cl_game.h.

Macro Definition Documentation

#define CGAME_HARD_LINKED_FUNCTIONS
Value:
void Sys_Error (const char* error, ...) \
{ \
va_list argptr; \
char text[1024]; \
va_start(argptr, error); \
Q_vsnprintf(text, sizeof(text), error, argptr); \
va_end(argptr); \
cgi->Sys_Error("%s", text); \
} \
void Com_Printf (const char* msg, ...) \
{ \
va_list argptr; \
char text[1024]; \
va_start(argptr, msg); \
Q_vsnprintf(text, sizeof(text), msg, argptr); \
va_end(argptr); \
cgi->Com_Printf("%s", text); \
} \
void Com_DPrintf (int level, const char* msg, ...) \
{ \
va_list argptr; \
char text[1024]; \
va_start(argptr, msg); \
Q_vsnprintf(text, sizeof(text), msg, argptr); \
va_end(argptr); \
cgi->Com_DPrintf(level, "%s", text); \
}
int Q_vsnprintf(char *str, size_t size, const char *format, va_list ap)
Safe (null terminating) vsnprintf implementation.
Definition: shared.cpp:535
void Sys_Error(const char *error,...)
Definition: g_main.cpp:421
void Com_Printf(const char *const fmt,...)
Definition: common.cpp:386
const cgame_import_t * cgi
void Com_DPrintf(int level, const char *fmt,...)
A Com_Printf that only shows up if the "developer" cvar is set.
Definition: common.cpp:398
const GLuint *typedef void(APIENTRY *GenRenderbuffersEXT_t)(GLsizei
Definition: r_gl.h:189
level_locals_t level
Definition: g_main.cpp:38

Definition at line 91 of file cl_game.h.

#define GAME_IsSingleplayer ( )    (!GAME_IsMultiplayer())

Definition at line 36 of file cl_game.h.

Referenced by CL_FixActorSkinIDX().

Function Documentation

void GAME_AddChatMessage ( const char *  format,
  ... 
)
const equipDef_t* GAME_ChangeEquip ( const linkedList_t equipmentList,
changeEquipType_t  changeType,
const char *  equipID 
)

Changed the given cvar to the next/prev equipment definition.

Definition at line 1783 of file cl_game.cpp.

References BACKWARD, Com_Error(), csi, linkedList_t::data, csi_s::eds, ERR_DROP, FORWARD, index, INV_GetEquipmentDefinitionByID(), LIST_ContainsString(), LIST_Foreach, LIST_IsEmpty(), linkedList_t::next, csi_s::numEDs, and Q_streq.

Referenced by GAME_GetImportData().

void GAME_CharacterCvars ( const character_t chr)

Definition at line 1642 of file cl_game.cpp.

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]nodeThe menu node to show the information in.
[in]stringThe id of the 'thing' to show information for.

Definition at line 338 of file cl_game.cpp.

References GAME_GetCurrentType(), cgame_export_s::GetModelForItem(), and UI_DrawModelNode().

Referenced by uiItemNode::draw().

void GAME_DrawBaseLayout ( int  baseIdx,
int  x,
int  y,
int  totalMarge,
int  w,
int  h,
int  padding,
const vec4_t  bgcolor,
const vec4_t  color 
)

Definition at line 1699 of file cl_game.cpp.

References GAME_GetCurrentType().

Referenced by uiBaseLayoutNode::draw().

void GAME_DrawBaseLayoutTooltip ( int  baseIdx,
int  x,
int  y 
)

Cgame callback to draw tooltip for baselayout UI node.

Parameters
[in]baseIdxNumeric index of the base
[in]xHorizontal screen position
[in]yVertical screen position

Definition at line 1712 of file cl_game.cpp.

References GAME_GetCurrentType().

Referenced by uiBaseLayoutNode::drawTooltip().

void GAME_DrawMap ( geoscapeData_t data)

Definition at line 931 of file cl_game.cpp.

References GAME_GetCurrentType().

Referenced by uiGeoscapeNode::draw().

void GAME_DrawMapMarkers ( uiNode_t node)

Definition at line 938 of file cl_game.cpp.

References GAME_GetCurrentType().

Referenced by uiGeoscapeNode::draw().

void GAME_Drop ( void  )

Definition at line 1658 of file cl_game.cpp.

References GAME_GetCurrentType(), GAME_SetMode(), GAME_UnloadGame(), 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 314 of file cl_game.cpp.

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

Referenced by CL_Disconnect().

void GAME_EndRoundAnnounce ( int  playerNum,
int  team 
)

Send end round announcements.

Parameters
playerNumThe server player number of the player that has ended the round
teamThe 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 325 of file cl_game.cpp.

References GAME_GetCurrentType().

Referenced by CL_EndRoundAnnounce().

void GAME_Frame ( void  )

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

Definition at line 1687 of file cl_game.cpp.

References cls, client_static_s::frametime, GAME_GetCurrentType(), key_console, and client_static_s::keyDest.

Referenced by CL_Frame().

void GAME_GenerateTeam ( const char *  teamDefID,
const equipDef_t ed,
int  teamMembers 
)
const char* GAME_GetAbsoluteSavePath ( char *  buf,
size_t  bufSize 
)
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
indexThe 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 196 of file cl_game.cpp.

References Com_Error(), ERR_DROP, index, and lengthof.

Referenced by GAME_AppendTeamMember(), and GAME_LoadTeamInfo().

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

Definition at line 226 of file cl_game.cpp.

References lengthof.

Referenced by GAME_AutoTeam_f(), GAME_GenerateTeam(), GAME_GetImportData(), GAME_LoadTeamInfo(), and GAME_Spawn().

character_t* GAME_GetCharacterByUCN ( int  ucn)

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
ucnThe unique character number
Returns
null if no character with the specified ucn was found.

Definition at line 210 of file cl_game.cpp.

References i, lengthof, and character_s::ucn.

int GAME_GetChrMaxLoad ( const character_t chr)

Returns the max weight the given character can carry.

Parameters
[in]chrThe character to find the max load for.
Returns
The max load the character can carry or NONE.

Definition at line 1768 of file cl_game.cpp.

References ABILITY_POWER, GAME_GetCurrentType(), NONE, character_s::score, and chrScoreGlobal_s::skills.

Referenced by CL_ActorInvMove(), GAME_AppendTeamMember(), GAME_GetImportData(), GAME_LoadCharacter(), HUD_UpdateActorLoad_f(), INV_MoveItem(), and INV_UpdateActorLoad_f().

const mapDef_t* GAME_GetCurrentSelectedMap ( void  )

Definition at line 921 of file cl_game.cpp.

References cls, Com_GetMapDefByIDX(), and client_static_s::currentSelectedMap.

Referenced by GAME_GetImportData().

int GAME_GetCurrentTeam ( void  )

Definition at line 926 of file cl_game.cpp.

References cls, and client_static_s::team.

Referenced by GAME_GetImportData().

equipDef_t* GAME_GetEquipmentDefinition ( void  )
const char* GAME_GetModelForItem ( const objDef_t od,
uiModel_t **  uiModel 
)

Get a model for an item.

Parameters
[in]odThe object definition to get the model from.
[out]uiModelThe menu model pointer.
Returns
The model path for the item. Never nullptr.

Definition at line 1725 of file cl_game.cpp.

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

Referenced by uiItemNode::draw(), and UI_DrawItem().

const char* GAME_GetRelativeSavePath ( char *  buf,
size_t  bufSize 
)
character_t* GAME_GetSelectedChr ( void  )

Returns the currently selected character.

Returns
The selected character or nullptr.

Definition at line 1746 of file cl_game.cpp.

References chrDisplayList, Cvar_GetInteger(), GAME_GetCurrentType(), cgame_export_s::GetSelectedChr(), and LIST_Foreach.

Referenced by INV_MoveItem(), and INV_UpdateActorLoad_f().

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

After a mission was finished this function is called.

Parameters
msgThe network message buffer
winnerThe winning team or -1 if it was a draw
numSpawnedThe amounts of all spawned actors per team
numAliveThe amount of survivors per team
numKilledThe amount of killed actors for all teams. The first dimension contains the attacker team, the second the victim team
numStunnedThe amount of stunned actors for all teams. The first dimension contains the attacker team, the second the victim team
nextmapIndicates if there is another map to follow within the same msission

Definition at line 1326 of file cl_game.cpp.

References CL_Drop(), and GAME_GetCurrentType().

Referenced by CL_ParseResults().

bool GAME_HandleServerCommand ( const char *  command,
dbuffer msg 
)

Definition at line 361 of file cl_game.cpp.

References GAME_GetCurrentType().

Referenced by CL_ConnectionlessPacket().

void GAME_Init ( bool  load)
void GAME_InitUIData ( void  )

Fills the game mode list entries with the parsed values from the script.

Definition at line 1840 of file cl_game.cpp.

References Com_Printf(), GAME_GetCGameAPI_(), GAME_UnloadGame(), i, cgame_export_s::isMultiplayer, cgameType_s::name, numCGameTypes, UI_ExecuteConfunc(), and cgameType_s::window.

Referenced by CLMN_Init().

bool GAME_IsMultiplayer ( void  )
bool GAME_IsTeamEmpty ( void  )

Definition at line 388 of file cl_game.cpp.

References chrDisplayList, and LIST_IsEmpty().

Referenced by GAME_GetImportData(), GAME_LoadDefaultTeam(), and GAME_LoadTeam_f().

void GAME_MapClick ( uiNode_t node,
int  x,
int  y,
const vec2_t  pos 
)

Definition at line 945 of file cl_game.cpp.

References GAME_GetCurrentType().

Referenced by uiGeoscapeNode::onLeftClick().

void GAME_NotifyEvent ( event_t  eventType)

Definition at line 1623 of file cl_game.cpp.

References GAME_GetCurrentType().

Referenced by CL_ExecuteBattlescapeEvent(), and CL_ParseEvent().

void GAME_ParseModes ( const char *  name,
const char **  text 
)
void GAME_ReloadMode ( void  )

Definition at line 290 of file cl_game.cpp.

References GAME_GetCurrentType(), and GAME_SetMode().

Referenced by GAME_GetImportData(), and VID_Restart_f().

void GAME_ResetCharacters ( void  )

Reset all characters in the static character array.

See also
GAME_GetCharacterArraySize
GAME_GetCharacter

Definition at line 243 of file cl_game.cpp.

References chrDisplayList, i, LIST_Delete(), MAX_ACTIVETEAM, and UI_ExecuteConfunc().

Referenced by GAME_GenerateTeam(), GAME_LoadTeamInfo(), and GAME_SetMode().

void GAME_SetMode ( const struct cgame_export_s gametype)
void GAME_SetServerInfo ( const char *  server,
const char *  serverport 
)

Definition at line 347 of file cl_game.cpp.

References cls, Q_strncpyz(), client_static_s::servername, and client_static_s::serverport.

Referenced by GAME_GetImportData().

void GAME_Shutdown ( void  )
void GAME_StartBattlescape ( bool  isTeamPlay)

Called when the server sends the EV_START event.

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

Definition at line 1487 of file cl_game.cpp.

References _, cl, CL_GetConfigString(), CS_MAPTITLE, Cvar_Set(), GAME_GetCurrentType(), GAME_InitMissionBriefing(), HUD_InitUI(), and clientBattleScape_s::mapMaxLevel.

Referenced by CL_StartGame().

void GAME_SwitchCurrentSelectedMap ( int  step)

Definition at line 912 of file cl_game.cpp.

References cls, csi, client_static_s::currentSelectedMap, and csi_s::numMDs.

Referenced by GAME_GetImportData().

bool GAME_TeamIsKnown ( const teamDef_t teamDef)

Definition at line 1630 of file cl_game.cpp.

References GAME_GetCurrentType().

Referenced by CL_ActorAppear(), and CL_AddTargetingBox().

Variable Documentation

geoscapeData_t geoscapeData

Definition at line 146 of file cl_game.cpp.

Referenced by uiGeoscapeNode::onLoading().