cl_main.c 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_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 "cl_game.h"
#include "cl_tutorials.h"
#include "cl_tip.h"
#include "cl_team.h"
#include "cl_language.h"
#include "cl_irc.h"
#include "cl_sequence.h"
#include "cl_inventory.h"
#include "cl_menu.h"
#include "cl_http.h"
#include "input/cl_joystick.h"
#include "cinematic/cl_cinematic.h"
#include "sound/s_music.h"
#include "sound/s_sample.h"
#include "renderer/r_main.h"
#include "renderer/r_particle.h"
#include "ui/ui_main.h"
#include "ui/ui_popup.h"
#include "ui/ui_font.h"
#include "ui/ui_nodes.h"
#include "ui/ui_parse.h"
#include "multiplayer/mp_callbacks.h"
#include "multiplayer/mp_serverlist.h"
#include "multiplayer/mp_team.h"
#include "../shared/infostring.h"
#include "../shared/parse.h"
#include "../ports/system.h"
Include dependency graph for cl_main.c:

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.
static void CL_Env_f (void)
 Set or print some environment variables via console command.
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.
static void CL_Connect (void)
static void CL_ClearState (void)
 Called after tactical missions to wipe away the tactical-mission-only data.
void CL_Disconnect (void)
 Sets the cls.state to ca_disconnected and informs the server.
static void CL_ConnectionlessPacket (struct dbuffer *msg)
 Responses to broadcasts, etc.
static void CL_ReadPackets (void)
static void CL_UserInfo_f (void)
 Prints the current userinfo string to the game console.
static void CL_SpawnSoldiers_f (void)
 Send the clc_teaminfo command to server.
static qboolean CL_DownloadUMPMap (const char *tiles)
static qboolean CL_DownloadMap (const char *map)
static qboolean 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.
static void CL_SetRatioFilter_f (void)
static void CL_VideoInitMenu (void)
static void CL_TeamDefInitMenu (void)
static void CL_ParseCustomSkin (const char *name, const char **text)
static void CL_ParseMapDefinition (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.
void CL_ParseClientData (const char *type, const char *name, const char **text)
 Called at client startup.
static void CL_CheckCvars_f (void)
 Check cvars for some initial values that should/must be set.
static void CL_ShowConfigstrings_f (void)
 Print the configstrings to game console.
static void CL_InitLocal (void)
 Calls all reset functions for all subsystems like production and research also initializes the cvars and commands.
static void CL_SendChangedUserinfos (void)
 Send the userinfo to the server (and to all other clients) when they changed (CVAR_USERINFO).
static void CL_SendCommand (void)
void CL_SetClientState (int state)
 Sets the client state.
void CL_Frame (int now, void *data)
void CL_SlowFrame (int now, void *data)
static void CL_InitMemPools (void)
void CL_Init (void)
int CL_Milliseconds (void)
void CL_Shutdown (void)
 Saves configuration file and shuts the client systems down.

Variables

cvar_tcl_fps
cvar_tcl_leshowinvis
cvar_tcl_selected
cvar_tcl_lastsave
static cvar_tcl_connecttimeout
static cvar_tcl_introshown
static cvar_tcl_name
static cvar_tcl_msg
static cvar_tcl_ready
cvar_tcl_teamnum
cvar_tcl_team
client_static_t cls
struct memPool_scl_genericPool
struct memPool_scl_ircSysPool
struct memPool_scl_soundSysPool
struct memPool_svid_genericPool
struct memPool_svid_imagePool
struct memPool_svid_lightPool
struct memPool_svid_modelPool
static const value_t customskin_vals []
 valid customskin descriptors
static const value_t mapdef_vals []
 valid mapdef descriptors
static cvarList_t checkcvar []
 Cvars for initial check (popup at first start).

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.c.


Function Documentation

static qboolean 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 511 of file cl_main.c.

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

Referenced by CL_RequestNextDownload().

static void CL_CheckCvars_f ( void   )  [static]

Check cvars for some initial values that should/must be set.

Definition at line 976 of file cl_main.c.

References Com_Printf(), Cvar_Get(), cvarList_s::name, name, UI_PushWindow(), and cvarList_s::var.

Referenced by CL_InitLocal().

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 224 of file cl_main.c.

References cl, CL_ViewCalcFieldOfViewX(), LE_Cleanup(), r_numParticles, RDF_IRGOGGLES, refdef, and rendererData_t::rendererFlags.

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

static void CL_Connect ( void   )  [static]
static void CL_ConnectionlessPacket ( struct dbuffer msg  )  [static]
void CL_Disconnect ( void   ) 

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

See also:
CL_Disconnect_f
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 247 of file cl_main.c.

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

Referenced by CL_Connect_f(), CL_Drop(), CL_ParseServerMessage(), CL_Quit_f(), CL_Reconnect_f(), CL_SequenceStart_f(), CP_StartSelectedMission(), GAME_CP_Drop(), GAME_CP_Results(), and GAME_SetMode().

static qboolean CL_DownloadMap ( const char *  map  )  [static]
static qboolean CL_DownloadUMPMap ( const char *  tiles  )  [static]

Definition at line 459 of file cl_main.c.

References CL_CheckOrDownloadFile(), Com_Parse(), Com_sprintf(), MAX_QPATH, MAX_VAR, name, Q_strncpyz(), qfalse, 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 172 of file cl_main.c.

Referenced by CL_Disconnect_f(), CL_ParseServerMessage(), Com_Error(), GAME_HandleResults(), GAME_MP_Results(), and GAME_SK_Results().

static void CL_Env_f ( void   )  [static]

Set or print some environment variables via console command.

See also:
Sys_Setenv

Definition at line 127 of file cl_main.c.

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

Referenced by CL_InitLocal().

static void CL_ForwardToServer_f ( void   )  [static]
void CL_Frame ( int  now,
void *  data 
)
See also:
Qcommon_Frame

Definition at line 1201 of file cl_main.c.

Referenced by Qcommon_Init().

void CL_Init ( void   ) 
See also:
CL_Shutdown
CL_InitAfter

Definition at line 1285 of file cl_main.c.

Referenced by Qcommon_Init().

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 901 of file cl_main.c.

Referenced by Qcommon_Init().

static void CL_InitLocal ( void   )  [static]
static void CL_InitMemPools ( void   )  [static]

Definition at line 1274 of file cl_main.c.

References Mem_CreatePool.

Referenced by CL_Init().

int CL_Milliseconds ( void   ) 
void 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

Definition at line 936 of file cl_main.c.

Referenced by Com_ParseScripts().

static void CL_ParseCustomSkin ( const char *  name,
const char **  text 
) [static]
static void CL_ParseMapDefinition ( const char *  name,
const char **  text 
) [static]
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 598 of file cl_main.c.

References CL_RequestNextDownload(), client_static_s::downloadMaps, and qtrue.

Referenced by CL_InitLocal().

static void CL_Quit_f ( void   )  [static]

Definition at line 160 of file cl_main.c.

References CL_Disconnect(), and Com_Quit().

Referenced by CL_InitLocal().

static void CL_ReadPackets ( void   )  [static]
void CL_RequestNextDownload ( void   ) 
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 1101 of file cl_main.c.

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

Referenced by CL_SendCommand().

static void CL_SendCommand ( void   )  [static]
void CL_SetClientState ( int  state  ) 
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 605 of file cl_main.c.

References Cmd_Argc(), Cmd_Argv(), Com_Error(), Com_Printf(), ERR_FATAL, uiNode_s::invis, uiNode_s::next, OPTION_VIDEO_RESOLUTIONS, OPTIONEXTRADATA, qfalse, qtrue, 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 996 of file cl_main.c.

References CL_GetConfigString(), Com_Printf(), 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 1347 of file cl_main.c.

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

void CL_SlowFrame ( int  now,
void *  data 
)
See also:
CL_Frame

Definition at line 1263 of file cl_main.c.

Referenced by Qcommon_Init().

static void CL_SpawnSoldiers_f ( void   )  [static]

Send the clc_teaminfo command to server.

See also:
GAME_SendCurrentTeamSpawningInfo

Definition at line 447 of file cl_main.c.

References cl, CL_OnBattlescape(), GAME_SpawnSoldiers(), and qtrue.

Referenced by CL_InitLocal().

static void CL_TeamDefInitMenu ( void   )  [static]
static void CL_UserInfo_f ( void   )  [static]

Prints the current userinfo string to the game console.

See also:
SV_UserInfo_f

Definition at line 437 of file cl_main.c.

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

Referenced by CL_InitLocal().

static void CL_VideoInitMenu ( void   )  [static]
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 102 of file cl_main.c.

Referenced by Cmd_ExecuteString().

static int Com_MapDefSort ( const void *  mapDef1,
const void *  mapDef2 
) [static]
See also:
FS_MapDefSort

Definition at line 883 of file cl_main.c.

References Q_StringSort().

Referenced by CL_InitAfter().


Variable Documentation

cvarList_t checkcvar[] [static]
Initial value:
 {
    {"cl_name", NULL, NULL},
    {"s_language", NULL, NULL},

    {NULL, NULL, NULL}
}

Cvars for initial check (popup at first start).

Definition at line 967 of file cl_main.c.

Definition at line 75 of file cl_main.c.

Definition at line 69 of file cl_main.c.

Referenced by SCR_UpdateScreen().

cvar_t* cl_introshown [static]

Definition at line 77 of file cl_main.c.

irc pool

Definition at line 89 of file cl_main.c.

Referenced by Irc_Client_CmdRplNamreply(), and Irc_Logic_AddChannelName().

Definition at line 73 of file cl_main.c.

Referenced by SAV_GameContinue_f().

cvar_t* cl_msg [static]

Definition at line 81 of file cl_main.c.

cvar_t* cl_name [static]

Definition at line 80 of file cl_main.c.

cvar_t* cl_ready [static]

Definition at line 82 of file cl_main.c.

Definition at line 90 of file cl_main.c.

Referenced by S_LoadSample(), and S_Shutdown().

Definition at line 84 of file cl_main.c.

Referenced by GAME_MP_GetTeam(), GAME_SK_GetTeam(), and MP_GetEquipment().

Definition at line 83 of file cl_main.c.

Referenced by CL_TeamNum_f(), and SP_worldspawn().

Definition at line 86 of file cl_main.c.

Referenced by AII_CollectingItems(), AIR_RemoveEmployee(), B_PackInitialEquipment(), CL_ActorAddToTeamList(), CL_ActorAppear(), CL_ActorCheckAction(), CL_ActorCleanup(), CL_ActorConfirmAction_f(), CL_ActorDie(), CL_ActorDoShootTime(), CL_ActorGetMuzzle(), CL_ActorMoveMouse(), CL_ActorRemoveFromTeamList(), CL_ActorRevitalised(), CL_ActorSelect(), CL_ActorStartShoot(), CL_AddActor(), CL_AddTargetingBox(), CL_AddUGV(), CL_CameraMove(), CL_CampaignRun(), CL_CancelHTTPDownloads(), CL_CheckAndQueueDownload(), CL_CleanTempInventory(), CL_CleanupAircraftCrew(), CL_Connect_f(), CL_DoEndRound(), CL_EntPerish(), CL_ExecuteBattlescapeEvent(), CL_FinishHTTPDownload(), CL_GenerateCharacter(), CL_GetEventTime(), CL_GetFreeDLHandle(), CL_HTTP_Cleanup(), CL_HTTP_Progress(), CL_InvAdd(), CL_InvAmmo(), CL_InvDel(), CL_InvReload(), CL_LoadCharacterXML(), CL_LoadInventoryXML(), CL_NextAlien_f(), CL_NextAlienVisibleFromActor_f(), CL_NextRound_f(), CL_OnBattlescape(), CL_ParseResults(), CL_ParseServerMessage(), CL_ParticleRun(), CL_ParticleRun2(), CL_PendingHTTPDownloads(), CL_PingServers_f(), CL_PrecacheCharacterModels(), CL_QueueHTTPDownload(), CL_Rcon_f(), CL_Reconnect_f(), CL_Reset(), CL_ResetSinglePlayerData(), CL_ReVerifyHTTPQueue(), CL_RunHTTPDownloads(), CL_RunMapParticles(), CL_SelectTeam_Init_f(), CL_SequenceEnd_f(), CL_SetHTTPServer(), CL_StartHTTPDownload(), CL_StartNextHTTPDownload(), CL_TargetingStraight(), CL_ViewLoadMedia(), CL_ViewPrecacheModels(), CL_ViewRender(), Com_AllocateCustomSkin(), Com_GetCustomSkinByIDS(), Com_GetMapDefByIDX(), Com_GetMapDefinitionByID(), Con_Close(), Con_DrawInput(), Con_DrawNotify(), Con_ToggleChat_f(), Con_ToggleConsole_f(), CP_ChooseMap(), CP_LoadXML(), CP_SaveMapDefStatXML(), CP_SaveXML(), CP_StartMissionMap(), E_ResetEmployee(), GAME_AppendTeamMember(), GAME_CP_Frame(), GAME_CP_InitializeBattlescape(), GAME_CP_MapInfo(), GAME_CP_Results(), GAME_EndBattlescape(), GAME_GetCurrentType(), GAME_MP_ChangeGametype_f(), GAME_MP_MapInfo(), GAME_MP_Results(), GAME_MP_StartServer_f(), GAME_SetMode(), GAME_SK_MapInfo(), GAME_SK_Results(), GAME_SK_Start_f(), GAME_Spawn(), GAME_SpawnSoldiers(), GAME_StartBattlescape(), HUD_DisplayFiremodes(), HUD_Update(), IN_Parse(), INV_MoveItem(), INV_UnloadWeapon(), Key_Console(), Key_Event(), Key_Message(), Key_SetDest(), LE_Cleanup(), LE_PlaceItem(), LE_PlaySoundFileForContents(), LE_Think(), LM_AddToSceneOrder(), M_Change_f(), MAP_DrawMapMarkers(), MSG_Write_PA(), NAT_ScriptSanityCheck(), S_LoadSamples(), SCR_BeginLoadingPlaque(), SCR_DrawConsole(), SCR_DrawCursor(), SCR_DrawDownloading(), SCR_DrawLoading(), SCR_DrawPrecacheScreen(), SCR_EndLoadingPlaque(), SCR_RunConsole(), SCR_TimeRefresh_f(), SCR_UpdateScreen(), SEQ_Render2D(), SEQ_Render3D(), SEQ_SetCamera(), UI_ContainerNodeUpdateEquipment(), UI_DrawModelNode(), UI_DrawModelNodeWithUIModel(), UI_GetReferenceString(), UI_MapInfo(), UI_MapInfoGetNext(), UI_MaterialEditorStart_f(), UI_RadarNodeDraw(), UI_RadarNodeGetActorColor(), and UI_SelectMap_f().

const value_t customskin_vals[] [static]
Initial value:
 {
    {"name", V_STRING, offsetof(customSkin_t, name), 0},
    {"singleplayer", V_BOOL, offsetof(customSkin_t, singleplayer), MEMBER_SIZEOF(customSkin_t, singleplayer)},
    {"multiplayer", V_BOOL, offsetof(customSkin_t, multiplayer), MEMBER_SIZEOF(customSkin_t, multiplayer)},

    {NULL, 0, 0, 0}
}

valid customskin descriptors

Definition at line 681 of file cl_main.c.

const value_t mapdef_vals[] [static]
Initial value:
 {
    {"description", V_TRANSLATION_STRING, offsetof(mapDef_t, description), 0},
    {"map", V_CLIENT_HUNK_STRING, offsetof(mapDef_t, map), 0},
    {"param", V_CLIENT_HUNK_STRING, offsetof(mapDef_t, param), 0},
    {"size", V_CLIENT_HUNK_STRING, offsetof(mapDef_t, size), 0},

    {"maxaliens", V_INT, offsetof(mapDef_t, maxAliens), MEMBER_SIZEOF(mapDef_t, maxAliens)},
    {"storyrelated", V_BOOL, offsetof(mapDef_t, storyRelated), MEMBER_SIZEOF(mapDef_t, storyRelated)},
    {"hurtaliens", V_BOOL, offsetof(mapDef_t, hurtAliens), MEMBER_SIZEOF(mapDef_t, hurtAliens)},

    {"teams", V_INT, offsetof(mapDef_t, teams), MEMBER_SIZEOF(mapDef_t, teams)},
    {"multiplayer", V_BOOL, offsetof(mapDef_t, multiplayer), MEMBER_SIZEOF(mapDef_t, multiplayer)},

    {"onwin", V_CLIENT_HUNK_STRING, offsetof(mapDef_t, onwin), 0},
    {"onlose", V_CLIENT_HUNK_STRING, offsetof(mapDef_t, onlose), 0},

    {NULL, 0, 0, 0}
}

valid mapdef descriptors

Definition at line 766 of file cl_main.c.

also holds all the static models

Definition at line 91 of file cl_main.c.

Referenced by CIN_OGM_PlayCinematic(), CIN_ROQ_PlayCinematic(), R_SphereGenerate(), and VID_Init().

lightmap - wiped with every new map

Definition at line 93 of file cl_main.c.

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


Generated by  doxygen 1.6.2