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

Primary functions for the client. NB: The main() is system-specific and can currently be found in ports/. More...

#include "client.h"
#include "battlescape/cl_localentity.h"
#include "battlescape/events/e_server.h"
#include "battlescape/cl_particle.h"
#include "battlescape/cl_radar.h"
#include "battlescape/cl_actor.h"
#include "battlescape/cl_hud.h"
#include "battlescape/cl_parse.h"
#include "battlescape/events/e_parse.h"
#include "battlescape/cl_view.h"
#include "cl_console.h"
#include "cl_screen.h"
#include "cgame/cl_game.h"
#include "cl_tutorials.h"
#include "cl_tip.h"
#include "cl_team.h"
#include "cl_language.h"
#include "cl_irc.h"
#include "cinematic/cl_sequence.h"
#include "cl_inventory.h"
#include "cl_menu.h"
#include "cl_http.h"
#include "cl_lua.h"
#include "input/cl_joystick.h"
#include "cinematic/cl_cinematic.h"
#include "sound/s_music.h"
#include "sound/s_mumble.h"
#include "web/web_main.h"
#include "renderer/r_main.h"
#include "renderer/r_particle.h"
#include "ui/ui_main.h"
#include "ui/ui_popup.h"
#include "ui/ui_draw.h"
#include "ui/ui_font.h"
#include "ui/ui_nodes.h"
#include "ui/ui_parse.h"
#include "ui/ui_lua.h"
#include "cgame/cl_game_team.h"
#include "../shared/infostring.h"
#include "../shared/parse.h"
#include "../ports/system.h"

Go to the source code of this file.

Functions

void Cmd_ForwardToServer (void)
 adds the current command line as a clc_stringcmd to the client message. things like action, turn, etc, are commands directed to the server, so when they are typed in at the console, they will need to be forwarded. More...
 
static void CL_Env_f (void)
 Set or print some environment variables via console command. More...
 
static void CL_ForwardToServer_f (void)
 
static void CL_Quit_f (void)
 
void CL_Drop (void)
 Ensures the right menu cvars are set after error drop or map change. More...
 
static void CL_Reconnect (void)
 
static void CL_FreeClientStream (void)
 
static void CL_Connect (void)
 
static void CL_ClearState (void)
 Called after tactical missions to wipe away the tactical-mission-only data. More...
 
void CL_Disconnect (void)
 Sets the cls.state to ca_disconnected and informs the server. More...
 
static void CL_ConnectionlessPacket (dbuffer *msg)
 Responses to broadcasts, etc. More...
 
static void CL_ReadPackets (void)
 
static void CL_UserInfo_f (void)
 Prints the current userinfo string to the game console. More...
 
static void CL_SpawnSoldiers_f (void)
 Send the clc_teaminfo command to server. More...
 
static void CL_StartMatch_f (void)
 
static bool CL_DownloadUMPMap (const char *tiles)
 
static bool CL_DownloadMap (const char *map)
 
static bool CL_CanMultiplayerStart (void)
 
void CL_RequestNextDownload (void)
 
static void CL_Precache_f (void)
 The server will send this command right before allowing the client into the server. More...
 
static void CL_SetRatioFilter_f (void)
 
static void CL_ParseActorSkin (const char *name, const char **text)
 
static int Com_MapDefSort (const void *mapDef1, const void *mapDef2)
 
void CL_InitAfter (void)
 Init function for clients - called after menu was initialized and ufo-scripts were parsed. More...
 
bool CL_ParseClientData (const char *type, const char *name, const char **text)
 Called at client startup. More...
 
static void CL_ShowConfigstrings_f (void)
 Print the configstrings to game console. More...
 
static void CL_OpenURL_f (void)
 Opens the specified URL and minimizes the game window. You have to specify the whole url including the protocol. More...
 
static void CL_InitLocal (void)
 Calls all reset functions for all subsystems like production and research also initializes the cvars and commands. More...
 
static void CL_SendChangedUserinfos (void)
 Send the userinfo to the server (and to all other clients) when they changed (CVAR_USERINFO) More...
 
static void CL_SendCommand (void)
 
int CL_GetClientState (void)
 
void CL_SetClientState (connstate_t state)
 Sets the client state. More...
 
void CL_Frame (int now, void *data)
 
void CL_SlowFrame (int now, void *data)
 
static void CL_InitMemPools (void)
 
static void CL_RContextCvarChange (const char *cvarName, const char *oldValue, const char *newValue, void *data)
 
static void CL_RImagesCvarChange (const char *cvarName, const char *oldValue, const char *newValue, void *data)
 
void CL_Init (void)
 
int CL_Milliseconds (void)
 
void CL_Shutdown (void)
 Saves configuration file and shuts the client systems down. More...
 

Variables

cvar_tcl_fps
 
cvar_tcl_leshowinvis
 
cvar_tcl_selected
 
static cvar_tcl_connecttimeout
 
static cvar_tcl_name
 
static cvar_tcl_msg
 
static cvar_tcl_ready
 
cvar_tcl_teamnum
 
client_static_t cls
 
static bool isdown
 
memPool_tcl_genericPool
 
memPool_tvid_genericPool
 
memPool_tvid_imagePool
 
memPool_tvid_lightPool
 
memPool_tvid_modelPool
 
static const value_t actorskin_vals []
 valid actorskin descriptors More...
 

Detailed Description

Primary functions for the client. NB: The main() is system-specific and can currently be found in ports/.

Definition in file cl_main.cpp.

Function Documentation

static bool CL_CanMultiplayerStart ( void  )
static
Returns
true if are a compatible client and nothing else must be downloaded or no downloads are still running, false if the start of the match must get a little bit postponed (running downloads).
Note
throws ERR_DISCONNECT if we are not compatible to the server

Definition at line 551 of file cl_main.cpp.

References _, cl, CL_DownloadMap(), CL_GetConfigString(), CL_GetConfigStringInteger(), CL_PendingHTTPDownloads(), CM_LoadMap(), Com_Error(), Com_GetScriptChecksum(), Com_Printf(), Com_sprintf(), CS_ENTITYSTRING, CS_LIGHTMAP, CS_MAPCHECKSUM, CS_NAME, CS_OBJECTAMOUNT, CS_POSITIONS, CS_TILES, CS_UFOCHECKSUM, CS_VERSION, csi, client_static_s::downloadMaps, ERR_DISCONNECT, mapData_s::mapChecksum, clientBattleScape_s::mapData, clientBattleScape_s::mapTiles, csi_s::numODs, popupText, Q_streq, SCR_BeginLoadingPlaque(), UFO_VERSION, and UI_Popup().

Referenced by CL_RequestNextDownload().

static void CL_ClearState ( void  )
static

Called after tactical missions to wipe away the tactical-mission-only data.

See also
CL_ParseServerData
CL_Disconnect
R_ClearScene

Definition at line 235 of file cl_main.cpp.

References clientBattleScape_s::cam, cl, CL_ViewCalcFieldOfViewX(), LE_Cleanup(), OBJZERO, r_numParticles, RDF_IRGOGGLES, refdef, rendererData_t::rendererFlags, and camera_s::zoom.

Referenced by CL_Disconnect(), CL_Init(), and CL_SetClientState().

void CL_Disconnect ( void  )

Sets the cls.state to ca_disconnected and informs the server.

See also
CL_Drop
Note
Goes from a connected state to disconnected state Sends a disconnect message to the server This is also called on Com_Error, so it shouldn't cause any errors

Definition at line 257 of file cl_main.cpp.

References ca_connecting, ca_disconnected, CL_ClearBattlescapeEvents(), CL_ClearState(), CL_SetClientState(), clc_stringcmd, Com_Printf(), Com_ServerState(), GAME_EndBattlescape(), NET_STATE_DISCONNECT, NET_StreamFinished(), NET_Wait(), NET_WriteByte(), NET_WriteMsg(), NET_WriteString(), client_static_s::netStream, R_FreeWorldImages(), R_ShutdownModels(), S_Stop(), and client_static_s::state.

Referenced by CL_Drop(), CL_Quit_f(), CL_Reconnect(), GAME_GetImportData(), and GAME_SetMode().

static bool CL_DownloadMap ( const char *  map)
static
static bool CL_DownloadUMPMap ( const char *  tiles)
static

Definition at line 499 of file cl_main.cpp.

References CL_CheckOrDownloadFile(), Com_Parse(), Com_sprintf(), MAX_QPATH, MAX_VAR, name, Q_strncpyz(), and va().

Referenced by CL_DownloadMap().

void CL_Drop ( void  )

Ensures the right menu cvars are set after error drop or map change.

Note
E.g. called after an ERR_DROP was thrown
See also
CL_Disconnect
SV_Map

Definition at line 167 of file cl_main.cpp.

References CL_Disconnect(), GAME_Drop(), and SCR_EndLoadingPlaque().

Referenced by CL_ConnectionlessPacket(), CL_ParseServerMessage(), Com_Error(), GAME_GetImportData(), and GAME_HandleResults().

static void CL_Env_f ( void  )
static

Set or print some environment variables via console command.

See also
Sys_Setenv

Definition at line 122 of file cl_main.cpp.

References Cmd_Argc(), Cmd_Argv(), Com_Printf(), and Sys_Setenv().

Referenced by CL_InitLocal().

static void CL_FreeClientStream ( void  )
static

Definition at line 189 of file cl_main.cpp.

References Com_Printf(), and client_static_s::netStream.

Referenced by CL_Connect().

int CL_GetClientState ( void  )

Definition at line 1008 of file cl_main.cpp.

References client_static_s::state.

Referenced by GAME_GetImportData().

void CL_InitAfter ( void  )

Init function for clients - called after menu was initialized and ufo-scripts were parsed.

See also
Qcommon_Init

Definition at line 738 of file cl_main.cpp.

References CL_LanguageInit(), CL_ViewPrecacheModels(), CLMN_Init(), Com_MapDefSort(), csi, cvar_s::integer, csi_s::mds, csi_s::numMDs, S_Frame(), S_LoadSamples(), and sv_dedicated.

Referenced by Qcommon_Init().

static void CL_InitMemPools ( void  )
static

Definition at line 1123 of file cl_main.cpp.

References Mem_CreatePool.

Referenced by CL_Init().

static void CL_OpenURL_f ( void  )
static

Opens the specified URL and minimizes the game window. You have to specify the whole url including the protocol.

Definition at line 839 of file cl_main.cpp.

References Cmd_Argc(), Cmd_Argv(), Com_Printf(), Sys_OpenURL(), and VID_Minimize().

Referenced by CL_InitLocal().

static void CL_ParseActorSkin ( const char *  name,
const char **  text 
)
static
bool CL_ParseClientData ( const char *  type,
const char *  name,
const char **  text 
)

Called at client startup.

Note
not called for dedicated servers parses all *.ufos that are needed for single- and multiplayer
See also
Com_ParseScripts
CL_ParseScriptSecond
CL_ParseScriptFirst
Note
Nothing here should depends on items, equipments, actors and all other entities that are parsed in Com_ParseScripts (because maybe items are not parsed but e.g. techs would need those parsed items - thus we have to parse e.g. techs at a later stage)
This data is persistent until you shutdown the game
Returns
True if the parsing function succeeded.

Definition at line 771 of file cl_main.cpp.

References CL_ParseActorSkin(), CL_ParseLanguages(), CL_ParseParticle(), CL_ParseSequence(), CL_ParseTipOfTheDay(), GAME_ParseModes(), M_ParseMusic(), Q_streq, SCR_DrawLoadingScreen(), TUT_ParseTutorials(), UI_ParseAndLoadLuaScript(), UI_ParseComponent(), UI_ParseFont(), UI_ParseSprite(), UI_ParseUIModel(), and UI_ParseWindow().

Referenced by Com_ParseScripts(), and TEST_ParseScript().

static void CL_Precache_f ( void  )
static

The server will send this command right before allowing the client into the server.

See also
CL_StartGame
SV_Configstrings_f

Definition at line 640 of file cl_main.cpp.

References CL_RequestNextDownload(), and client_static_s::downloadMaps.

Referenced by CL_InitLocal().

static void CL_Quit_f ( void  )
static

Definition at line 155 of file cl_main.cpp.

References CL_Disconnect(), and Com_Quit().

Referenced by CL_InitLocal().

static void CL_RContextCvarChange ( const char *  cvarName,
const char *  oldValue,
const char *  newValue,
void data 
)
static

Definition at line 1128 of file cl_main.cpp.

References _, and UI_DisplayNotice().

Referenced by CL_Init(), and CL_Shutdown().

static void CL_RImagesCvarChange ( const char *  cvarName,
const char *  oldValue,
const char *  newValue,
void data 
)
static

Definition at line 1133 of file cl_main.cpp.

References _, and UI_DisplayNotice().

Referenced by CL_Init(), and CL_Shutdown().

static void CL_SendChangedUserinfos ( void  )
static

Send the userinfo to the server (and to all other clients) when they changed (CVAR_USERINFO)

See also
CL_Connect

Definition at line 944 of file cl_main.cpp.

References ca_connected, clc_userinfo, Com_IsUserinfoModified(), Com_SetUserinfoModified(), Cvar_Userinfo(), MAX_INFO_STRING, NET_WriteByte(), NET_WriteMsg(), NET_WriteString(), client_static_s::netStream, and client_static_s::state.

Referenced by CL_SendCommand().

static void CL_SetRatioFilter_f ( void  )
static
Todo:
We should check the ratio list and remove matched resolutions, here it is a hack

Definition at line 647 of file cl_main.cpp.

References Cmd_Argc(), Cmd_Argv(), Com_Error(), Com_Printf(), ERR_FATAL, uiNode_t::invis, uiNode_t::next, OPTION_VIDEO_RESOLUTIONS, OPTIONEXTRADATA, Q_streq, UI_GetOption(), and UI_RegisterOption().

Referenced by CL_InitLocal().

static void CL_ShowConfigstrings_f ( void  )
static

Print the configstrings to game console.

See also
SV_PrintConfigStrings_f

Definition at line 817 of file cl_main.cpp.

References CL_GetConfigString(), Com_Printf(), CS_MODELS, CS_POSITIONS, CS_TILES, i, and MAX_CONFIGSTRINGS.

Referenced by CL_InitLocal().

void CL_Shutdown ( void  )

Saves configuration file and shuts the client systems down.

Todo:
this is a callback from Sys_Quit and Com_Error. It would be better to run quit through here before the final handoff to the sys code.
See also
Sys_Quit
CL_Init

Definition at line 1220 of file cl_main.cpp.

References CIN_Shutdown(), CL_HTTP_Cleanup(), CL_LanguageShutdown(), CL_RContextCvarChange(), CL_RImagesCvarChange(), CL_ShutdownLua(), CLMN_Shutdown(), Con_SaveConsoleHistory(), Cvar_GetFirst(), CVAR_R_CONTEXT, CVAR_R_IMAGES, Cvar_UnRegisterChangeListener(), GAME_SetMode(), GAME_Shutdown(), GAME_UnloadGame(), Irc_Shutdown(), isdown, Key_WriteBindings(), cvar_s::next, R_Shutdown(), S_Shutdown(), SCR_Shutdown(), SEQ_Shutdown(), TOTD_Shutdown(), and UI_Shutdown().

Referenced by Com_Error(), Com_Quit(), Qcommon_Frame(), and Sys_Quit().

void CL_SlowFrame ( int  now,
void data 
)
static void CL_SpawnSoldiers_f ( void  )
static

Send the clc_teaminfo command to server.

See also
GAME_SendCurrentTeamSpawningInfo

Definition at line 475 of file cl_main.cpp.

References cl, CL_OnBattlescape(), GAME_SpawnSoldiers(), and clientBattleScape_s::spawned.

Referenced by CL_InitLocal().

static void CL_StartMatch_f ( void  )
static

Definition at line 487 of file cl_main.cpp.

References cl, GAME_StartMatch(), clientBattleScape_s::spawned, and clientBattleScape_s::started.

Referenced by CL_InitLocal().

static void CL_UserInfo_f ( void  )
static

Prints the current userinfo string to the game console.

See also
SV_UserInfo_f

Definition at line 464 of file cl_main.cpp.

References Com_Printf(), Cvar_Userinfo(), Info_Print(), and MAX_INFO_STRING.

Referenced by CL_InitLocal().

void Cmd_ForwardToServer ( void  )

adds the current command line as a clc_stringcmd to the client message. things like action, turn, etc, are commands directed to the server, so when they are typed in at the console, they will need to be forwarded.

adds the current command line as a clc_stringcmd to the client message. things like godmode, noclip, etc, are commands directed to the server, so when they are typed in at the console, they will need to be forwarded.

Definition at line 98 of file cl_main.cpp.

References dbuffer::add(), ca_connected, clc_stringcmd, Cmd_Argc(), Cmd_Args(), Cmd_Argv(), Com_Printf(), NET_WriteByte(), NET_WriteMsg(), client_static_s::netStream, and client_static_s::state.

Referenced by Cmd_vExecuteString().

static int Com_MapDefSort ( const void mapDef1,
const void mapDef2 
)
static
See also
FS_MapDefSort

Definition at line 720 of file cl_main.cpp.

References Q_StringSort().

Referenced by CL_InitAfter().

Variable Documentation

const value_t actorskin_vals[]
static
Initial value:
= {
{"name", V_STRING, offsetof(actorSkin_t, name), 0},
{"singleplayer", V_BOOL, offsetof(actorSkin_t, singleplayer), MEMBER_SIZEOF(actorSkin_t, singleplayer)},
{"multiplayer", V_BOOL, offsetof(actorSkin_t, multiplayer), MEMBER_SIZEOF(actorSkin_t, multiplayer)},
{nullptr, V_NULL, 0, 0}
}
Definition: scripts.h:49
Definition: scripts.h:50
QGL_EXTERN GLuint GLsizei GLsizei GLint GLenum GLchar * name
Definition: r_gl.h:110
#define MEMBER_SIZEOF(TYPE, MEMBER)
Definition: scripts.h:34

valid actorskin descriptors

Definition at line 694 of file cl_main.cpp.

cvar_t* cl_connecttimeout
static

Definition at line 75 of file cl_main.cpp.

cvar_t* cl_fps

Definition at line 71 of file cl_main.cpp.

Referenced by SCR_UpdateScreen().

cvar_t* cl_leshowinvis

Definition at line 72 of file cl_main.cpp.

cvar_t* cl_msg
static

Definition at line 79 of file cl_main.cpp.

cvar_t* cl_name
static

Definition at line 78 of file cl_main.cpp.

cvar_t* cl_ready
static

Definition at line 80 of file cl_main.cpp.

cvar_t* cl_selected

Definition at line 73 of file cl_main.cpp.

Referenced by CL_ActorUpdate_f(), CL_ChangeSkin_f(), and UI_ContainerNodeAutoPlace().

cvar_t* cl_teamnum

Definition at line 81 of file cl_main.cpp.

Referenced by SP_worldspawn().

Definition at line 83 of file cl_main.cpp.

Referenced by CL_ActorAddToTeamList(), CL_ActorAppear(), CL_ActorAppearTime(), CL_ActorCheckAction(), CL_ActorCleanup(), CL_ActorConfirmAction_f(), CL_ActorDie(), CL_ActorDoShootTime(), CL_ActorGetMuzzle(), CL_ActorMoveMouse(), CL_ActorRevitalised(), CL_ActorStartShoot(), CL_ActorStateChange(), CL_AddActor(), CL_AddTargetingBox(), CL_AddUGV(), CL_AllocateActorSkin(), CL_CameraMove(), CL_CancelHTTPDownloads(), CL_CheckAndQueueDownload(), CL_CountVisibleEnemies(), CL_DoEndRound(), CL_EntPerish(), CL_ExecuteBattlescapeEvent(), CL_FinishHTTPDownload(), CL_GenerateCharacter(), CL_GetActorSkinByIDS(), CL_GetActorSkinCount(), CL_GetFreeDLHandle(), CL_GetPlayerNum(), CL_HTTP_Cleanup(), CL_HTTP_Progress(), CL_InvAdd(), CL_InvAmmo(), CL_InvDel(), CL_InvReload(), CL_NextAlien_f(), CL_NextAlienVisibleFromActor_f(), CL_NextRound_f(), CL_OnBattlescape(), CL_ParseResults(), CL_ParseServerMessage(), CL_ParticleRun2(), CL_PendingHTTPDownloads(), CL_PrevAlien_f(), CL_QueueHTTPDownload(), CL_Reset(), CL_ReVerifyHTTPQueue(), CL_RunHTTPDownloads(), CL_SetHTTPServer(), CL_SoundEvent(), CL_StartHTTPDownload(), CL_StartNextHTTPDownload(), CL_TargetingStraight(), CL_ViewPrecacheModels(), CL_ViewRender(), Con_Close(), Con_DrawInput(), Con_ToggleChat_f(), Con_ToggleConsole_f(), uiRadarNode::draw(), GAME_AppendTeamMember(), GAME_AutoTeam(), GAME_CollectItems(), GAME_DestroyInventory(), GAME_EndBattlescape(), GAME_EquipActor(), GAME_Frame(), GAME_GetCGameAPI(), GAME_GetCurrentSelectedMap(), GAME_GetCurrentTeam(), GAME_GetCurrentType(), GAME_GetNextUniqueCharacterNumber(), GAME_InitializeBattlescape(), GAME_LoadCharacter(), GAME_LoadDefaultTeam(), GAME_LoadGame(), GAME_LoadInventory(), GAME_LoadTeam_f(), GAME_NET_OOB_Printf2(), GAME_RemoveFromInventory(), GAME_SetMode(), GAME_SetNextUniqueCharacterNumber(), GAME_SetServerInfo(), GAME_Spawn(), GAME_SpawnSoldiers(), GAME_StartMatch(), GAME_SwitchCurrentSelectedMap(), GAME_UnloadGame(), HUD_DisplayActions(), HUD_Update(), IN_Frame(), IN_Parse(), IN_ToggleFullscreen(), INV_MoveItem(), INV_UnloadWeapon(), Key_Event(), Key_SetDest(), LE_CenterView(), LE_Cleanup(), LE_PlaceItem(), LE_Think(), LET_StartPathMove(), LM_AddToSceneOrder(), MSG_Write_PA(), R_EndFrame(), R_InitGraphics(), R_SetSDLIcon(), ResetInventoryList(), Rimp_Shutdown(), S_MumbleUpdate(), SCR_BeginLoadingPlaque(), SCR_DrawCursor(), SCR_DrawDownloading(), SCR_DrawLoading(), SCR_EndLoadingPlaque(), SCR_RunConsole(), SCR_TimeRefresh_f(), SCR_UpdateScreen(), SEQ_Render2D(), SEQ_Render3D(), SEQ_SetCamera(), ParticleTest::SetUpTestCase(), ScriptTest::SetUpTestCase(), FootStepTest::SetUpTestCase(), MapDefStatsTest::SetUpTestCase(), MapDefTest::SetUpTestCase(), MapDefMassRMATest::SetUpTestCase(), CampaignTest::SetUpTestCase(), UI_ContainerNodeUpdateEquipment(), UI_DrawModelNode(), UI_DrawModelNodeWithUIModel(), UI_EnableFlashing(), UI_MapInfoGetNext(), UI_MaterialEditorStart_f(), UI_RadarNodeGetActorColor(), UI_SelectMap_f(), and VID_Minimize().

bool isdown
static

Definition at line 84 of file cl_main.cpp.

Referenced by CL_Init(), and CL_Shutdown().

memPool_t* vid_genericPool

also holds all the static models

Definition at line 87 of file cl_main.cpp.

Referenced by CIN_OGM_OpenCinematic(), CIN_ROQ_OpenCinematic(), R_SphereGenerate(), and VID_Init().

memPool_t* vid_lightPool

lightmap - wiped with every new map

Definition at line 89 of file cl_main.cpp.

Referenced by R_BeginBuildingLightmaps(), R_BuildDefaultLightmap(), R_BuildLightmap(), R_ModLoadLighting(), R_ShutdownModels(), and VID_Init().