UFO: Alien Invasion
Doxygen documentation generating
cl_main.cpp
Go to the documentation of this file.
1 
6 /*
7 All original material Copyright (C) 2002-2023 UFO: Alien Invasion.
8 
9 Original file from Quake 2 v3.21: quake2-2.31/client/cl_main.c
10 Copyright (C) 1997-2001 Id Software, Inc.
11 
12 This program is free software; you can redistribute it and/or
13 modify it under the terms of the GNU General Public License
14 as published by the Free Software Foundation; either version 2
15 of the License, or (at your option) any later version.
16 
17 This program is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
20 
21 See the GNU General Public License for more details.
22 
23 You should have received a copy of the GNU General Public License
24 along with this program; if not, write to the Free Software
25 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26 
27 */
28 
29 #include "client.h"
33 #include "battlescape/cl_radar.h"
34 #include "battlescape/cl_actor.h"
35 #include "battlescape/cl_hud.h"
36 #include "battlescape/cl_parse.h"
38 #include "battlescape/cl_view.h"
39 #include "cl_console.h"
40 #include "cl_screen.h"
41 #include "cgame/cl_game.h"
42 #include "cl_tutorials.h"
43 #include "cl_tip.h"
44 #include "cl_team.h"
45 #include "cl_language.h"
46 #include "cl_irc.h"
47 #include "cinematic/cl_sequence.h"
48 #include "cl_inventory.h"
49 #include "cl_menu.h"
50 #include "cl_http.h"
51 #include "cl_lua.h"
52 #include "input/cl_joystick.h"
53 #include "cinematic/cl_cinematic.h"
54 #include "sound/s_music.h"
55 #include "sound/s_mumble.h"
56 #include "web/web_main.h"
57 #include "renderer/r_main.h"
58 #include "renderer/r_particle.h"
59 #include "ui/ui_main.h"
60 #include "ui/ui_popup.h"
61 #include "ui/ui_draw.h"
62 #include "ui/ui_font.h"
63 #include "ui/ui_nodes.h"
64 #include "ui/ui_parse.h"
65 #include "ui/ui_lua.h"
66 #include "cgame/cl_game_team.h"
67 #include "../shared/infostring.h"
68 #include "../shared/parse.h"
69 #include "../ports/system.h"
70 
74 
75 static cvar_t* cl_connecttimeout; /* multiplayer connection timeout value (ms) */
76 
77 /* userinfo */
78 static cvar_t* cl_name;
79 static cvar_t* cl_msg;
80 static cvar_t* cl_ready;
82 
84 static bool isdown;
85 
91 /*====================================================================== */
92 
99 {
100  const char* cmd = Cmd_Argv(0);
101 
102  if (cls.state <= ca_connected || cmd[0] == '-' || cmd[0] == '+') {
103  Com_Printf("Unknown command \"%s\" - wasn't sent to server\n", cmd);
104  return;
105  }
106 
107  dbuffer msg;
109  msg.add(cmd, strlen(cmd));
110  if (Cmd_Argc() > 1) {
111  msg.add(" ", 1);
112  msg.add(Cmd_Args(), strlen(Cmd_Args()));
113  }
114  msg.add("", 1);
115  NET_WriteMsg(cls.netStream, msg);
116 }
117 
122 static void CL_Env_f (void)
123 {
124  const int argc = Cmd_Argc();
125 
126  if (argc == 3) {
127  Sys_Setenv(Cmd_Argv(1), Cmd_Argv(2));
128  } else if (argc == 2) {
129  const char* env = SDL_getenv(Cmd_Argv(1));
130  if (env)
131  Com_Printf("%s=%s\n", Cmd_Argv(1), env);
132  else
133  Com_Printf("%s undefined\n", Cmd_Argv(1));
134  }
135 }
136 
137 
138 static void CL_ForwardToServer_f (void)
139 {
140  if (cls.state != ca_connected && cls.state != ca_active) {
141  Com_Printf("Can't \"%s\", not connected\n", Cmd_Argv(0));
142  return;
143  }
144 
145  /* don't forward the first argument */
146  if (Cmd_Argc() > 1) {
147  const int len = strlen(Cmd_Args()) + 1;
148  dbuffer msg(len + 1);
150  msg.add(Cmd_Args(), len);
151  NET_WriteMsg(cls.netStream, msg);
152  }
153 }
154 
155 static void CL_Quit_f (void)
156 {
157  CL_Disconnect();
158  Com_Quit();
159 }
160 
167 void CL_Drop (void)
168 {
169  CL_Disconnect();
170 
171  /* drop loading plaque */
173 
174  GAME_Drop();
175 }
176 
177 static void CL_Reconnect (void)
178 {
180  return;
181 
182  Com_Printf("Reconnecting...\n");
183  CL_Disconnect();
185  /* otherwise we would time out */
186  cls.connectTime = CL_Milliseconds() - 1500;
187 }
188 
189 static void CL_FreeClientStream (void)
190 {
191  cls.netStream = nullptr;
192  Com_Printf("Client stream was closed\n");
193 }
194 
200 static void CL_Connect (void)
201 {
203 
204  assert(!cls.netStream);
205 
206  if (cls.servername[0] != '\0') {
207  assert(cls.serverport[0] != '\0');
208  Com_Printf("Connecting to %s %s...\n", cls.servername, cls.serverport);
210  } else {
211  Com_Printf("Connecting to localhost...\n");
213  }
214 
215  if (cls.netStream) {
216  char info[MAX_INFO_STRING];
217  NET_OOB_Printf(cls.netStream, SV_CMD_CONNECT " %i \"%s\"\n", PROTOCOL_VERSION, Cvar_Userinfo(info, sizeof(info)));
219  } else {
220  if (cls.servername[0] != '\0') {
221  assert(cls.serverport[0]);
222  Com_Printf("Could not connect to %s %s\n", cls.servername, cls.serverport);
223  } else {
224  Com_Printf("Could not connect to localhost\n");
225  }
226  }
227 }
228 
235 static void CL_ClearState (void)
236 {
237  LE_Cleanup();
238 
240  cl.cam.zoom = 1.0;
242 
243  /* wipe the particles with every new map */
244  r_numParticles = 0;
245  /* reset ir goggle state with every new map */
247 }
248 
256 void CL_Disconnect (void)
257 {
258  if (cls.state < ca_connecting)
259  return;
260 
261  Com_Printf("Disconnecting...\n");
262 
263  /* send a disconnect message to the server */
264  if (!Com_ServerState()) {
265  dbuffer msg;
268  NET_WriteMsg(cls.netStream, msg);
269  /* make sure, that this is send */
270  NET_Wait(0);
271  }
272 
274  cls.netStream = nullptr;
275 
276  CL_ClearState();
277 
278  S_Stop();
279 
280  R_ShutdownModels(false);
282 
286 }
287 
288 /* it's dangerous to activate this */
289 /*#define ACTIVATE_PACKET_COMMAND*/
290 #ifdef ACTIVATE_PACKET_COMMAND
291 
298 static void CL_Packet_f (void)
299 {
300  if (Cmd_Argc() != 4) {
301  Com_Printf("Usage: %s <destination> <port> <contents>\n", Cmd_Argv(0));
302  return;
303  }
304 
305  struct net_stream* s = NET_Connect(Cmd_Argv(1), Cmd_Argv(2));
306  if (!s) {
307  Com_Printf("Could not connect to %s at port %s\n", Cmd_Argv(1), Cmd_Argv(2));
308  return;
309  }
310 
311  const char* in = Cmd_Argv(3);
312 
313  const int l = strlen(in);
314  char buf[MAX_STRING_TOKENS];
315  char* out = buf;
316 
317  for (int i = 0; i < l; i++) {
318  if (in[i] == '\\' && in[i + 1] == 'n') {
319  *out++ = '\n';
320  i++;
321  } else {
322  *out++ = in[i];
323  }
324  }
325  *out = 0;
326 
327  NET_OOB_Printf(s, "%s %i", out, PROTOCOL_VERSION);
329 }
330 #endif
331 
340 {
341  char s[512];
342  NET_ReadStringLine(msg, s, sizeof(s));
343 
344  Cmd_TokenizeString(s, false);
345 
346  const char* c = Cmd_Argv(0);
347  Com_DPrintf(DEBUG_CLIENT, "server OOB: %s (%s)\n", c, Cmd_Args());
348 
349  /* server connection */
350  if (Q_streq(c, CL_CMD_CLIENT_CONNECT)) {
351  int i;
352  for (i = 1; i < Cmd_Argc(); i++) {
353  if (char const* const p = Q_strstart(Cmd_Argv(i), "dlserver=")) {
355  CL_SetHTTPServer(p);
356  if (cls.downloadServer[0])
357  Com_Printf("HTTP downloading enabled, URL: %s\n", cls.downloadServer);
358  }
359  }
360  if (cls.state == ca_connected) {
361  Com_Printf("Dup connect received. Ignored.\n");
362  return;
363  }
364  dbuffer buf(5);
368  GAME_InitMissionBriefing(_("Loading"));
369  return;
370  }
371 
372  /* remote command from gui front end */
373  if (Q_streq(c, CL_CMD_COMMAND)) {
375  Com_Printf("Command packet from remote host. Ignored.\n");
376  return;
377  } else {
378  char str[512];
379  NET_ReadString(msg, str, sizeof(str));
380  Cbuf_AddText("%s\n", str);
381  }
382  return;
383  }
384 
385  /* ping from server */
386  if (Q_streq(c, CL_CMD_PING)) {
388  return;
389  }
390 
391  /* echo request from server */
392  if (Q_streq(c, CL_CMD_ECHO)) {
394  return;
395  }
396 
397  /* print */
398  if (Q_streq(c, SV_CMD_PRINT)) {
399  NET_ReadString(msg, popupText, sizeof(popupText));
400  /* special reject messages needs proper handling */
402  UI_PushWindow("serverpassword");
403  if (Q_strvalid(Cvar_GetString("password"))) {
404  Cvar_Set("password", "%s", "");
405  CL_Drop();
406  UI_Popup(_("Connection failure"), _("The password you specified was wrong."));
407  } else {
408  CL_Drop();
409  UI_Popup(_("Connection failure"), _("This server requires a password."));
410  }
411  } else if (strstr(popupText, REJ_SERVER_FULL)) {
412  CL_Drop();
413  UI_Popup(_("Connection failure"), _("This server is full."));
414  } else if (strstr(popupText, REJ_BANNED)) {
415  CL_Drop();
416  UI_Popup(_("Connection failure"), _("You are banned on this server."));
417  } else if (strstr(popupText, REJ_GAME_ALREADY_STARTED)) {
418  CL_Drop();
419  UI_Popup(_("Connection failure"), _("The game has already started."));
420  } else if (strstr(popupText, REJ_SERVER_VERSION_MISMATCH)) {
421  CL_Drop();
422  UI_Popup(_("Connection failure"), _("The server is running a different version of the game."));
423  } else if (strstr(popupText, BAD_RCON_PASSWORD)) {
424  Cvar_Set("rcon_password", "%s", "");
425  UI_Popup(_("Bad rcon password"), _("The rcon password you specified was wrong."));
426  } else if (strstr(popupText, REJ_CONNECTION_REFUSED)) {
427  CL_Drop();
428  UI_Popup(_("Connection failure"), _("The server refused the connection."));
429  } else if (Q_strvalid(popupText)) {
430  UI_Popup(_("Notice"), _(popupText));
431  }
432  return;
433  }
434 
435  if (!GAME_HandleServerCommand(c, msg))
436  Com_Printf("Unknown command received \"%s\"\n", c);
437 }
438 
446 static void CL_ReadPackets (void)
447 {
448  dbuffer* msg;
449  while ((msg = NET_ReadMsg(cls.netStream))) {
450  const svc_ops_t cmd = NET_ReadByte(msg);
451  if (cmd == svc_oob)
453  else
454  CL_ParseServerMessage(cmd, msg);
455  delete msg;
456  }
457 }
458 
463 static void CL_UserInfo_f (void)
464 {
465  Com_Printf("User info settings:\n");
466  char info[MAX_INFO_STRING];
467  Info_Print(Cvar_Userinfo(info, sizeof(info)));
468 }
469 
474 static void CL_SpawnSoldiers_f (void)
475 {
476  if (!CL_OnBattlescape())
477  return;
478 
479  if (cl.spawned)
480  return;
481 
482  cl.spawned = true;
484 }
485 
486 static void CL_StartMatch_f (void)
487 {
488  if (!cl.spawned)
489  return;
490 
491  if (cl.started)
492  return;
493 
494  cl.started = true;
495  GAME_StartMatch();
496 }
497 
498 static bool CL_DownloadUMPMap (const char* tiles)
499 {
500  char name[MAX_VAR];
501  char base[MAX_QPATH];
502  bool startedDownload = false;
503 
504  /* load tiles */
505  while (tiles) {
506  /* get tile name */
507  const char* token = Com_Parse(&tiles);
508  if (!tiles)
509  return startedDownload;
510 
511  /* get base path */
512  if (token[0] == '-') {
513  Q_strncpyz(base, token + 1, sizeof(base));
514  continue;
515  }
516 
517  /* get tile name */
518  if (token[0] == '+')
519  Com_sprintf(name, sizeof(name), "%s%s", base, token + 1);
520  else
521  Q_strncpyz(name, token, sizeof(name));
522 
523  startedDownload |= !CL_CheckOrDownloadFile(va("maps/%s.bsp", name));
524  }
525 
526  return startedDownload;
527 }
528 
529 static bool CL_DownloadMap (const char* map)
530 {
531  bool startedDownload;
532  if (map[0] != '+') {
533  startedDownload = !CL_CheckOrDownloadFile(va("maps/%s.bsp", map));
534  } else {
535  startedDownload = !CL_CheckOrDownloadFile(va("maps/%s.ump", map + 1));
536  if (!startedDownload) {
537  const char* tiles = CL_GetConfigString(CS_TILES);
538  startedDownload = CL_DownloadUMPMap(tiles);
539  }
540  }
541 
542  return startedDownload;
543 }
544 
550 static bool CL_CanMultiplayerStart (void)
551 {
552  const int day = CL_GetConfigStringInteger(CS_LIGHTMAP);
553  const char* serverVersion = CL_GetConfigString(CS_VERSION);
554 
555  /* checksum doesn't match with the one the server gave us via configstring */
556  if (!Q_streq(UFO_VERSION, serverVersion)) {
557  Com_sprintf(popupText, sizeof(popupText), _("Local game version (%s) differs from the server version (%s)"), UFO_VERSION, serverVersion);
558  UI_Popup(_("Error"), popupText);
559  Com_Error(ERR_DISCONNECT, "Local game version (%s) differs from the server version (%s)", UFO_VERSION, serverVersion);
560  /* amount of objects from script files doesn't match */
562  UI_Popup(_("Error"), _("Script files are not the same"));
563  Com_Error(ERR_DISCONNECT, "Script files are not the same");
564  }
565 
566  /* activate the map loading screen for multiplayer, too */
568 
569  /* check download */
570  if (cls.downloadMaps) { /* confirm map */
572  return false;
573  cls.downloadMaps = false;
574  }
575 
576  /* map might still be downloading? */
578  return false;
579 
581  Com_Printf("You are using modified ufo script files - might produce problems\n");
582 
584 
585 #if 0
587  UI_Popup(_("Error"), _("Local map version differs from server"));
588  Com_Error(ERR_DISCONNECT, "Local map version differs from server: %u != '%i'",
590  }
591 #endif
592 
593  return true;
594 }
595 
603 {
604  if (cls.state != ca_connected) {
605  Com_Printf("CL_RequestNextDownload: Not connected (%i)\n", cls.state);
606  return;
607  }
608 
609  /* Use the map data from the server */
612 
613  /* as a multiplayer client we have to load the map here and
614  * check the compatibility with the server */
616  return;
617 
619 
620  dbuffer msg(7);
621  /* send begin */
622  /* this will activate the render process (see client state ca_active) */
624  /* see CL_StartGame */
625  NET_WriteString(&msg, NET_STATE_BEGIN "\n");
626  NET_WriteMsg(cls.netStream, msg);
627 
629 
630  S_MumbleLink();
631 }
632 
633 
639 static void CL_Precache_f (void)
640 {
641  cls.downloadMaps = true;
642 
644 }
645 
646 static void CL_SetRatioFilter_f (void)
647 {
649  uiNode_t* option = firstOption;
650  float requestedRation = atof(Cmd_Argv(1));
651  bool all = false;
652  bool custom = false;
653  const float delta = 0.01;
654 
655  if (Cmd_Argc() != 2) {
656  Com_Printf("Usage: %s <all|floatration>\n", Cmd_Argv(0));
657  return;
658  }
659 
660  if (Q_streq(Cmd_Argv(1), "all"))
661  all = true;
662  else if (Q_streq(Cmd_Argv(1), "custom"))
663  custom = true;
664  else
665  requestedRation = atof(Cmd_Argv(1));
666 
667  while (option) {
668  int width;
669  int height;
670  bool visible = false;
671  const int result = sscanf(OPTIONEXTRADATA(option).label, "%i x %i", &width, &height);
672  if (result != 2)
673  Com_Error(ERR_FATAL, "CL_SetRatioFilter_f: Impossible to decode resolution label.\n");
674  const float ratio = (float)width / (float)height;
675 
676  if (all)
677  visible = true;
678  else if (custom)
680  visible = ratio > 2 || (ratio > 1.7 && ratio < 1.76);
681  else
682  visible = ratio - delta < requestedRation && ratio + delta > requestedRation;
683 
684  option->invis = !visible;
685  option = option->next;
686  }
687 
688  /* the content change */
690 }
691 
693 static const value_t actorskin_vals[] = {
694  {"name", V_STRING, offsetof(actorSkin_t, name), 0},
695  {"singleplayer", V_BOOL, offsetof(actorSkin_t, singleplayer), MEMBER_SIZEOF(actorSkin_t, singleplayer)},
696  {"multiplayer", V_BOOL, offsetof(actorSkin_t, multiplayer), MEMBER_SIZEOF(actorSkin_t, multiplayer)},
697 
698  {nullptr, V_NULL, 0, 0}
699 };
700 
701 
702 static void CL_ParseActorSkin (const char* name, const char** text)
703 {
704  /* NOTE: first skin is special cause we don't get the skin with suffix */
705  if (CL_GetActorSkinCount() == 0) {
706  if (!Q_streq(name, "default") != 0) {
707  Com_Error(ERR_DROP, "CL_ParseActorSkin: First actorskin read from script must be \"default\" skin.");
708  }
709  }
710 
712 
713  Com_ParseBlock(name, text, skin, actorskin_vals, nullptr);
714 }
715 
719 static int Com_MapDefSort (const void* mapDef1, const void* mapDef2)
720 {
721  const char* map1 = ((const mapDef_t*)mapDef1)->mapTheme;
722  const char* map2 = ((const mapDef_t*)mapDef2)->mapTheme;
723 
724  /* skip special map chars for rma and base attack */
725  if (map1[0] == '+' || map1[0] == '.')
726  map1++;
727  if (map2[0] == '+' || map2[0] == '.')
728  map2++;
729 
730  return Q_StringSort(map1, map2);
731 }
732 
737 void CL_InitAfter (void)
738 {
739  if (sv_dedicated->integer)
740  return;
741 
742  /* start the music track already while precaching data */
743  S_Frame();
744  S_LoadSamples();
745 
746  /* preload all models for faster access */
748  CL_LanguageInit();
749 
750  CLMN_Init();
751 
752  /* sort the mapdef array */
753  qsort(csi.mds, csi.numMDs, sizeof(mapDef_t), Com_MapDefSort);
754 }
755 
770 bool CL_ParseClientData (const char* type, const char* name, const char** text)
771 {
772 #ifndef COMPILE_UNITTESTS
773  static int progressCurrent = 0;
774 
775  progressCurrent++;
776  if (progressCurrent % 10 == 0)
777  SCR_DrawLoadingScreen(false, std::min(progressCurrent * 30 / 1500, 30));
778 #endif
779 
780  if (Q_streq(type, "window"))
781  return UI_ParseWindow(type, name, text);
782  else if (Q_streq(type, "component"))
783  return UI_ParseComponent(type, name, text);
784  else if (Q_streq(type, "particle"))
785  CL_ParseParticle(name, text);
786  else if (Q_streq(type, "language"))
787  CL_ParseLanguages(name, text);
788  else if (Q_streq(type, "font"))
789  return UI_ParseFont(name, text);
790  else if (Q_streq(type, "tutorial"))
791  TUT_ParseTutorials(name, text);
792  else if (Q_streq(type, "menu_model"))
793  return UI_ParseUIModel(name, text);
794  else if (Q_streq(type, "sprite"))
795  return UI_ParseSprite(name, text);
796  else if (Q_streq(type, "sequence"))
797  CL_ParseSequence(name, text);
798  else if (Q_streq(type, "music"))
799  M_ParseMusic(name, text);
800  else if (Q_streq(type, "actorskin"))
801  CL_ParseActorSkin(name, text);
802  else if (Q_streq(type, "cgame"))
803  GAME_ParseModes(name, text);
804  else if (Q_streq(type, "tip"))
805  CL_ParseTipOfTheDay(name, text);
806  else if (Q_streq(type, "lua"))
807  return UI_ParseAndLoadLuaScript(name, text);
808 
809  return true;
810 }
811 
816 static void CL_ShowConfigstrings_f (void)
817 {
818  for (int i = 0; i < MAX_CONFIGSTRINGS; i++) {
819  const char* configString;
820  /* CS_TILES and CS_POSITIONS can stretch over multiple configstrings,
821  * so don't print the middle parts */
822  if (i > CS_TILES && i < CS_POSITIONS)
823  continue;
824  if (i > CS_POSITIONS && i < CS_MODELS)
825  continue;
826 
827  configString = CL_GetConfigString(i);
828  if (configString[0] == '\0')
829  continue;
830  Com_Printf("configstring[%3i]: %s\n", i, configString);
831  }
832 }
833 
838 static void CL_OpenURL_f (void)
839 {
840  if (Cmd_Argc() != 2) {
841  Com_Printf("usage: %s <url>\n", Cmd_Argv(0));
842  return;
843  }
844 
845  VID_Minimize();
846  Sys_OpenURL(Cmd_Argv(1));
847 }
848 
854 static void CL_InitLocal (void)
855 {
858 
859  /* register our variables */
860  cl_fps = Cvar_Get("cl_fps", "0", CVAR_ARCHIVE, "Show frames per second");
861  cl_log_battlescape_events = Cvar_Get("cl_log_battlescape_events", "1", 0, "Log all battlescape events to events.log");
862  cl_selected = Cvar_Get("cl_selected", "0", CVAR_NOSET, "Current selected soldier");
863  cl_connecttimeout = Cvar_Get("cl_connecttimeout", "25000", CVAR_ARCHIVE, "Connection timeout for multiplayer connects");
864  /* userinfo */
865  cl_name = Cvar_Get("cl_name", Sys_GetCurrentUser(), CVAR_USERINFO | CVAR_ARCHIVE, "Playername");
866  cl_teamnum = Cvar_Get("cl_teamnum", "1", CVAR_USERINFO | CVAR_ARCHIVE, "Preferred teamnum for multiplayer teamplay games");
867  cl_ready = Cvar_Get("cl_ready", "0", CVAR_USERINFO, "Ready indicator in the userinfo for tactical missions");
868  cl_msg = Cvar_Get("cl_msg", "2", CVAR_USERINFO | CVAR_ARCHIVE, "Sets the message level for server messages the client receives");
869  sv_maxclients = Cvar_Get("sv_maxclients", "1", CVAR_SERVERINFO, "If sv_maxclients is 1 we are in singleplayer - otherwise we are multiplayer mode (see sv_teamplay)");
870 
871  masterserver_url = Cvar_Get("masterserver_url", MASTER_SERVER, CVAR_ARCHIVE, "URL of UFO:AI masterserver");
872 
873  cl_map_debug = Cvar_Get("debug_map", "0", 0, "Activate realtime map debugging options - bitmask. Valid values are 0, 1, 3 and 7");
874  cl_le_debug = Cvar_Get("debug_le", "0", 0, "Activates some local entity debug rendering");
875  cl_trace_debug = Cvar_Get("debug_trace", "0", 0, "Activates some client side trace debug rendering");
876  cl_leshowinvis = Cvar_Get("cl_leshowinvis", "0", CVAR_ARCHIVE, "Show invisible local entities as null models");
877 
878  /* register our commands */
879  Cmd_AddCommand("targetalign", CL_ActorTargetAlign_f, N_("Target your shot to the ground"));
880 
881  Cmd_AddCommand("cl_setratiofilter", CL_SetRatioFilter_f, "Filter the resolution screen list with a ratio");
882 
883  Cmd_AddCommand("cmd", CL_ForwardToServer_f, "Forward to server");
884  Cmd_AddCommand("cl_userinfo", CL_UserInfo_f, "Prints your userinfo string");
885 #ifdef ACTIVATE_PACKET_COMMAND
886  /* this is dangerous to leave in */
887  Cmd_AddCommand("packet", CL_Packet_f, "Dangerous debug function for network testing");
888 #endif
889  Cmd_AddCommand("quit", CL_Quit_f, "Quits the game");
890  Cmd_AddCommand("env", CL_Env_f);
891 
892  Cmd_AddCommand(CL_PRECACHE, CL_Precache_f, "Function that is called at mapload to precache map data");
893  Cmd_AddCommand(CL_SPAWNSOLDIERS, CL_SpawnSoldiers_f, "Spawns the soldiers for the selected teamnum");
894  Cmd_AddCommand(CL_STARTMATCH, CL_StartMatch_f, "Start the match once every player is ready");
895  Cmd_AddCommand("cl_configstrings", CL_ShowConfigstrings_f, "Print client configstrings to game console");
896  Cmd_AddCommand("cl_openurl", CL_OpenURL_f, "Opens the given url in a browser");
897 
898  /* forward to server commands
899  * the only thing this does is allow command completion
900  * to work -- all unknown commands are automatically
901  * forwarded to the server */
902  Cmd_AddCommand("say", nullptr, "Chat command");
903  Cmd_AddCommand("say_team", nullptr, "Team chat command");
904  Cmd_AddCommand("players", nullptr, "List of team and player name");
905 #ifdef DEBUG
906  Cmd_AddCommand("debug_cgrid", Grid_DumpWholeClientMap_f, "Shows the whole client side pathfinding grid of the current loaded map");
907  Cmd_AddCommand("debug_croute", Grid_DumpClientRoutes_f, "Shows the whole client side pathfinding grid of the current loaded map");
908  Cmd_AddCommand("debug_listle", LE_List_f, "Shows a list of current know local entities with type and status");
909  Cmd_AddCommand("debug_listlm", LM_List_f, "Shows a list of current know local models");
910  /* forward commands again */
911  Cmd_AddCommand("debug_edictdestroy", nullptr, "Call the 'destroy' function of a given edict");
912  Cmd_AddCommand("debug_edictuse", nullptr, "Call the 'use' function of a given edict");
913  Cmd_AddCommand("debug_edicttouch", nullptr, "Call the 'touch' function of a given edict");
914  Cmd_AddCommand("debug_killteam", nullptr, "Kills a given team");
915  Cmd_AddCommand("debug_stunteam", nullptr, "Stuns a given team");
916  Cmd_AddCommand("debug_listscore", nullptr, "Shows mission-score entries of all team members");
917  Cmd_AddCommand("debug_statechange", nullptr, "Change the state of an edict");
918 #endif
919 
920  IN_Init();
922  CL_CameraInit();
924 
925  UI_Init();
926  TUT_InitStartup();
927  PTL_InitStartup();
929  WEB_InitStartup();
933  HUD_InitStartup();
934  INV_InitStartup();
936 }
937 
943 static void CL_SendChangedUserinfos (void)
944 {
945  /* send a userinfo update if needed */
946  if (cls.state < ca_connected)
947  return;
948  if (!Com_IsUserinfoModified())
949  return;
950  char info[MAX_INFO_STRING];
951  const char* userInfo = Cvar_Userinfo(info, sizeof(info));
952  dbuffer msg(strlen(userInfo) + 2);
954  NET_WriteString(&msg, userInfo);
955  NET_WriteMsg(cls.netStream, msg);
957 }
958 
962 static void CL_SendCommand (void)
963 {
964  /* get new key events */
966 
967  /* process console commands */
968  Cbuf_Execute();
969 
970  /* send intentions now */
972 
973  /* fix any cheating cvars */
975 
976  switch (cls.state) {
977  case ca_disconnected:
978  /* if the local server is running and we aren't connected then connect */
979  if (Com_ServerState()) {
980  cls.servername[0] = '\0';
981  cls.serverport[0] = '\0';
983  return;
984  }
985  break;
986  case ca_connecting:
988  if (GAME_IsMultiplayer())
989  Com_Error(ERR_DROP, "Server is not reachable");
990  }
991  break;
992  case ca_connected:
993  if (cls.waitingForStart) {
995  Com_Error(ERR_DROP, "Server aborted connection - the server didn't response in %is. You can try to increase the cvar cl_connecttimeout",
996  cl_connecttimeout->integer / 1000);
997  } else {
998  SCR_DrawLoading(100);
999  }
1000  }
1001  break;
1002  default:
1003  break;
1004  }
1005 }
1006 
1008 {
1009  return cls.state;
1010 }
1011 
1016 {
1017  Com_DPrintf(DEBUG_CLIENT, "CL_SetClientState: Set new state to %i (old was: %i)\n", state, cls.state);
1018  cls.state = state;
1019 
1020  switch (cls.state) {
1021  case ca_uninitialized:
1022  Com_Error(ERR_FATAL, "CL_SetClientState: Don't set state ca_uninitialized\n");
1023  break;
1024  case ca_active:
1025  cls.waitingForStart = 0;
1026  break;
1027  case ca_connecting:
1028  cls.reconnectTime = 0;
1029  CL_Connect();
1030  break;
1031  case ca_disconnected:
1032  cls.waitingForStart = 0;
1033  break;
1034  case ca_connected:
1035  /* wipe the client_state_t struct */
1036  CL_ClearState();
1037  Cvar_Set("cl_ready", "0");
1038  break;
1039  default:
1040  break;
1041  }
1042 }
1043 
1047 void CL_Frame (int now, void* data)
1048 {
1049  static int lastFrame = 0;
1050  int delta;
1051 
1054 
1055  /* decide the simulation time */
1056  delta = now - lastFrame;
1057  if (lastFrame)
1058  cls.frametime = delta / 1000.0;
1059  else
1060  cls.frametime = 0;
1062  cl.time = now;
1063  lastFrame = now;
1064 
1065  /* frame rate calculation */
1066  if (delta)
1067  cls.framerate = 1000.0 / delta;
1068 
1069  if (cls.state == ca_connected) {
1070  /* we run full speed when connecting */
1072  }
1073 
1074  /* fetch results from server */
1075  CL_ReadPackets();
1076 
1077  CL_SendCommand();
1078 
1079  IN_Frame();
1080 
1081  GAME_Frame();
1082 
1083  /* update camera position */
1084  CL_CameraMove();
1085 
1086  if (cls.state == ca_active)
1087  CL_ParticleRun();
1088 
1089  /* update the screen */
1090  SCR_UpdateScreen();
1091 
1092  /* advance local effects for next frame */
1093  SCR_RunConsole();
1094 
1095  /* LE updates */
1096  LE_Think();
1097 
1098  /* sound frame */
1099  S_Frame();
1100 
1101  /* send a new command message to the server */
1102  CL_SendCommand();
1103 }
1104 
1108 void CL_SlowFrame (int now, void* data)
1109 {
1110  /* language */
1111  if (s_language->modified) {
1113  }
1114 
1115  Irc_Logic_Frame();
1116 
1117  CL_Reconnect();
1118 
1119  HUD_Update();
1120 }
1121 
1122 static void CL_InitMemPools (void)
1123 {
1124  cl_genericPool = Mem_CreatePool("Client: Generic");
1125 }
1126 
1127 static void CL_RContextCvarChange (const char* cvarName, const char* oldValue, const char* newValue, void* data)
1128 {
1129  UI_DisplayNotice(_("This change requires a restart!"), 2000, nullptr);
1130 }
1131 
1132 static void CL_RImagesCvarChange (const char* cvarName, const char* oldValue, const char* newValue, void* data)
1133 {
1134  UI_DisplayNotice(_("This change might require a restart."), 2000, nullptr);
1135 }
1136 
1141 void CL_Init (void)
1142 {
1143  /* i18n through gettext */
1144  char languagePath[MAX_OSPATH];
1145  cvar_t* fs_i18ndir;
1146 
1147  isdown = false;
1148 
1149  if (sv_dedicated->integer)
1150  return; /* nothing running on the client */
1151 
1152  OBJZERO(cls);
1153 
1154  fs_i18ndir = Cvar_Get("fs_i18ndir", "", 0, "System path to language files");
1155  /* i18n through gettext */
1156  setlocale(LC_ALL, "C");
1157 
1158 // MSVC 2013 do not accept LC_MESSAGES
1159 #ifndef _MSC_VER
1160  setlocale(LC_MESSAGES, "");
1161 #endif
1162 
1163  /* use system locale dir if we can't find in gamedir */
1164  if (fs_i18ndir->string[0] != '\0')
1165  Q_strncpyz(languagePath, fs_i18ndir->string, sizeof(languagePath));
1166  else
1167 #ifdef LOCALEDIR
1168  Com_sprintf(languagePath, sizeof(languagePath), LOCALEDIR);
1169 #else
1170  Com_sprintf(languagePath, sizeof(languagePath), "%s/" BASEDIRNAME "/i18n/", FS_GetCwd());
1171 #endif
1172  Com_DPrintf(DEBUG_CLIENT, "...using mo files from %s\n", languagePath);
1173  bindtextdomain(TEXT_DOMAIN, languagePath);
1174  bind_textdomain_codeset(TEXT_DOMAIN, "UTF-8");
1175  /* load language file */
1176  textdomain(TEXT_DOMAIN);
1177 
1178  CL_InitMemPools();
1179 
1180  /* all archived variables will now be loaded */
1181  Con_Init();
1182 
1183  CIN_Init();
1184 
1185  VID_Init();
1186  SCR_DrawLoadingScreen(false, 0);
1187  S_Init();
1188  SCR_Init();
1189 
1190  CL_InitLua();
1191  CL_InitLocal();
1192 
1193  Irc_Init();
1194  CL_ViewInit();
1195 
1196  CL_ClearState();
1197 
1198  /* cvar feedback */
1199  for (const cvar_t* var = Cvar_GetFirst(); var; var = var->next) {
1200  if (var->flags & CVAR_R_CONTEXT)
1202  if (var->flags & CVAR_R_IMAGES)
1204  }
1205 }
1206 
1208 {
1209  return cls.realtime;
1210 }
1211 
1219 void CL_Shutdown (void)
1220 {
1221  if (isdown) {
1222  printf("recursive shutdown\n");
1223  return;
1224  }
1225  isdown = true;
1226 
1227  /* remove cvar feedback */
1228  for (const cvar_t* var = Cvar_GetFirst(); var; var = var->next) {
1229  if (var->flags & CVAR_R_CONTEXT)
1231  if (var->flags & CVAR_R_IMAGES)
1233  }
1234 
1235  CLMN_Shutdown();
1236  GAME_SetMode(nullptr);
1237  GAME_UnloadGame();
1238  CL_HTTP_Cleanup();
1239  Irc_Shutdown();
1241  Key_WriteBindings("keys.cfg");
1242  S_Shutdown();
1243  R_Shutdown();
1244  UI_Shutdown();
1245  CL_ShutdownLua();
1246  CIN_Shutdown();
1247  SEQ_Shutdown();
1248  GAME_Shutdown();
1250  TOTD_Shutdown();
1251  SCR_Shutdown();
1252 }
static cvar_t * cl_ready
Definition: cl_main.cpp:80
bool CL_ParseClientData(const char *type, const char *name, const char **text)
Called at client startup.
Definition: cl_main.cpp:770
bool Com_ParseBlock(const char *name, const char **text, void *base, const value_t *values, memPool_t *mempool)
Definition: scripts.cpp:1393
#define BASEDIRNAME
Definition: filesys.h:34
void CL_CameraMove(void)
Update the camera position. This can be done in two different reasons. The first is the user input...
Definition: cl_camera.cpp:93
const char * Cmd_Argv(int arg)
Returns a given argument.
Definition: cmd.cpp:516
static cvar_t * fs_i18ndir
Definition: cl_language.cpp:35
void NET_StreamFinished(struct net_stream *s)
Call NET_StreamFinished to mark the stream as uninteresting, but to finish sending any data in the bu...
Definition: net.cpp:832
void Cmd_AddCommand(const char *cmdName, xcommand_t function, const char *desc)
Add a new command to the script interface.
Definition: cmd.cpp:744
static cvar_t * cl_name
Definition: cl_main.cpp:78
void CL_ViewInit(void)
Definition: cl_view.cpp:298
float zoom
Definition: cl_camera.h:39
mapTiles_t * SV_GetMapTiles(void)
Definition: sv_main.cpp:952
static void CL_InitMemPools(void)
Definition: cl_main.cpp:1122
cvar_t * cl_teamnum
Definition: cl_main.cpp:81
static void CL_SetRatioFilter_f(void)
Definition: cl_main.cpp:646
#define CVAR_USERINFO
Definition: cvar.h:41
unsigned mapChecksum
Definition: typedefs.h:336
cvarChangeListener_t * Cvar_RegisterChangeListener(const char *varName, cvarChangeListenerFunc_t listenerFunc)
Registers a listener that is executed each time a cvar changed its value.
Definition: cvar.cpp:446
cvar_t * cl_leshowinvis
Definition: cl_main.cpp:72
cvar_t * cl_map_debug
Definition: cl_view.cpp:41
void SCR_DrawLoading(int percent)
Draws the current loading pic of the map from base/pics/maps/loading.
Definition: cl_screen.cpp:140
void CIN_Shutdown(void)
void Sys_SetAffinityAndPriority(void)
char popupText[UI_MAX_SMALLTEXTLEN]
strings to be used for popup when text is not static
Definition: ui_popup.cpp:37
memPool_t * vid_modelPool
Definition: cl_main.cpp:90
static void CL_UserInfo_f(void)
Prints the current userinfo string to the game console.
Definition: cl_main.cpp:463
float framerate
Definition: client.h:60
QGL_EXTERN GLint GLenum type
Definition: r_gl.h:94
#define CL_PRECACHE
Definition: q_shared.h:601
cvar_t * sys_affinity
Definition: common.cpp:60
struct net_stream * NET_Connect(const char *node, const char *service, stream_onclose_func *onclose)
Try to connect to a given host on a given port.
Definition: net.cpp:644
void Cvar_UnRegisterChangeListener(const char *varName, cvarChangeListenerFunc_t listenerFunc)
Unregisters a cvar change listener.
Definition: cvar.cpp:487
static void CL_ShowConfigstrings_f(void)
Print the configstrings to game console.
Definition: cl_main.cpp:816
bool UI_ParseAndLoadLuaScript(const char *name, const char **text)
Parses and loads a .ufo file holding a lua script.
Definition: ui_lua.cpp:386
void S_Stop(void)
Stop all channels.
Definition: s_main.cpp:58
void TOTD_InitStartup(void)
Init function for cvars and console command bindings.
Definition: cl_tip.cpp:96
void UI_Init(void)
Definition: ui_main.cpp:278
#define NET_STATE_DISCONNECT
Definition: q_shared.h:611
void CL_ViewPrecacheModels(void)
Precaches all models at game startup - for faster access.
Definition: cl_view.cpp:152
void TUT_ParseTutorials(const char *name, const char **text)
Basic lua initialization for the ui.
bool CL_OnBattlescape(void)
Check whether we are in a tactical mission as server or as client. But this only means that we are ab...
bool UI_ParseComponent(const char *type, const char *name, const char **text)
Parse a component.
Definition: ui_parse.cpp:1261
int Sys_Setenv(const char *name, const char *value)
set/unset environment variables (empty value removes it)
Definition: unix_shared.cpp:60
void GAME_SpawnSoldiers(void)
Called during startup of mission to send team info.
Definition: cl_game.cpp:1401
static const value_t actorskin_vals[]
valid actorskin descriptors
Definition: cl_main.cpp:693
#define TEXT_DOMAIN
Definition: cl_shared.h:43
const char * va(const char *format,...)
does a varargs printf into a temp buffer, so I don&#39;t need to have varargs versions of all text functi...
Definition: shared.cpp:410
bool invis
Definition: ui_nodes.h:101
#define CL_CMD_CLIENT_CONNECT
Definition: q_shared.h:606
#define SV_CMD_CONNECT
Definition: q_shared.h:588
void M_ParseMusic(const char *name, const char **text)
Parses music definitions for different situations.
Definition: s_music.cpp:73
static void CL_Precache_f(void)
The server will send this command right before allowing the client into the server.
Definition: cl_main.cpp:639
void UI_Shutdown(void)
Reset and free the UI data hunk.
Definition: ui_main.cpp:205
char downloadServer[512]
Definition: client.h:92
#define CL_STARTMATCH
Definition: q_shared.h:603
#define BAD_RCON_PASSWORD
Definition: q_shared.h:581
static void CL_SendChangedUserinfos(void)
Send the userinfo to the server (and to all other clients) when they changed (CVAR_USERINFO) ...
Definition: cl_main.cpp:943
cvar_t * sv_maxclients
Definition: g_main.cpp:43
#define _(String)
Definition: cl_shared.h:44
char * CL_GetConfigString(int index)
void NET_Wait(int timeout)
Definition: net.cpp:423
void SCR_DrawLoadingScreen(bool string, int percent)
Precache and loading screen at startup.
Definition: cl_screen.cpp:100
static void CL_ReadPackets(void)
Definition: cl_main.cpp:446
void ACTOR_InitStartup(void)
Definition: cl_actor.cpp:2522
void GAME_Shutdown(void)
Definition: cl_game.cpp:1713
csi_t csi
Definition: common.cpp:39
bool Com_sprintf(char *dest, size_t size, const char *fmt,...)
copies formatted string with buffer-size checking
Definition: shared.cpp:494
void SCR_Shutdown(void)
Definition: cl_screen.cpp:397
void CL_SlowFrame(int now, void *data)
Definition: cl_main.cpp:1108
#define REJ_CONNECTION_REFUSED
Definition: q_shared.h:586
bool GAME_HandleServerCommand(const char *command, dbuffer *msg)
Definition: cl_game.cpp:361
void Com_Quit(void)
Definition: common.cpp:511
struct net_stream * NET_ConnectToLoopBack(stream_onclose_func *onclose)
Definition: net.cpp:681
#define CL_SPAWNSOLDIERS
Definition: q_shared.h:602
void CL_ServerEventsInit(void)
Definition: e_server.cpp:50
void R_ShutdownModels(bool complete)
Frees the model pool.
Definition: r_model.cpp:391
void CL_LanguageInit(void)
Fills the options language menu node with the parsed language mappings.
#define CS_MAPCHECKSUM
Definition: q_shared.h:312
void CL_LanguageShutdown(void)
void Con_Init(void)
Definition: cl_console.cpp:276
void Cbuf_AddText(const char *format,...)
Adds command text at the end of the buffer.
Definition: cmd.cpp:126
void NET_WriteString(dbuffer *buf, const char *str)
Definition: netpack.cpp:59
void GAME_ParseModes(const char *name, const char **text)
Definition: cl_game.cpp:999
Shared game type headers.
void IN_SendKeyEvents(void)
Definition: cl_input.cpp:1284
int integer
Definition: cvar.h:81
static void CL_ParseActorSkin(const char *name, const char **text)
Definition: cl_main.cpp:702
memPool_t * vid_genericPool
Definition: cl_main.cpp:87
void CL_ShutdownLua(void)
Shutdown the ui-lua interfacing environment.
Definition: cl_lua.cpp:155
void R_Shutdown(void)
Definition: r_main.cpp:1319
unsigned int CL_GetActorSkinCount(void)
Get number of registered actorskins.
Definition: cl_team.cpp:63
void SCR_UpdateScreen(void)
This is called every frame, and can also be called explicitly to flush text to the screen...
Definition: cl_screen.cpp:320
Events that are send from the client to the server.
QGL_EXTERN GLsizei const GLvoid * data
Definition: r_gl.h:89
void SCR_Init(void)
Definition: cl_screen.cpp:379
void Cmd_TokenizeString(const char *text, bool macroExpand, bool replaceWhitespaces)
Parses the given string into command line tokens.
Definition: cmd.cpp:565
struct net_stream * netStream
Definition: client.h:74
bool CL_PendingHTTPDownloads(void)
See if we&#39;re still busy with some downloads. Called by precacher just before it loads the map since w...
Definition: cl_http.cpp:328
#define MAX_OSPATH
Definition: filesys.h:44
void Com_Printf(const char *const fmt,...)
Definition: common.cpp:386
uiNode_t * UI_GetOption(int dataId)
Definition: ui_data.cpp:324
Header file for inventory handling and Equipment menu.
int CL_GetConfigStringInteger(int index)
static void CL_ClearState(void)
Called after tactical missions to wipe away the tactical-mission-only data.
Definition: cl_main.cpp:235
#define SV_CMD_PRINT
Definition: q_shared.h:593
Header for client menu implementation.
int numMDs
Definition: q_shared.h:572
#define CS_POSITIONS
Definition: q_shared.h:326
char downloadReferer[32]
Definition: client.h:93
cvar_t * masterserver_url
Definition: common.cpp:57
static void CL_InitLocal(void)
Calls all reset functions for all subsystems like production and research also initializes the cvars ...
Definition: cl_main.cpp:854
void GAME_UnloadGame(void)
Definition: cl_game.cpp:900
voidpf void * buf
Definition: ioapi.h:42
#define ERR_FATAL
Definition: common.h:210
#define CVAR_ARCHIVE
Definition: cvar.h:40
void IN_Init(void)
Definition: cl_input.cpp:1212
mapTiles_t * mapTiles
void CL_Drop(void)
Ensures the right menu cvars are set after error drop or map change.
Definition: cl_main.cpp:167
bool UI_ParseUIModel(const char *name, const char **text)
parses the models.ufo and all files where UI models (menu_model) are defined
Definition: ui_parse.cpp:1134
memPool_t * cl_genericPool
Definition: cl_main.cpp:86
void GAME_Drop(void)
Definition: cl_game.cpp:1490
static cvar_t * cl_connecttimeout
Definition: cl_main.cpp:75
#define Q_strvalid(string)
Definition: shared.h:141
connstate_t
Definition: cl_shared.h:75
int Com_GetScriptChecksum(void)
Definition: scripts.cpp:3717
void Com_Error(int code, const char *fmt,...)
Definition: common.cpp:417
This is the structure that should be used for data that is needed for tactical missions only...
void S_Init(void)
Definition: s_main.cpp:172
void TUT_InitStartup(void)
Atomic structure used to define most of the UI.
Definition: ui_nodes.h:80
cvar_t * Cvar_GetFirst(void)
Return the first cvar of the cvar list.
Definition: cvar.cpp:81
#define CL_CMD_COMMAND
Definition: q_shared.h:605
void CL_ParseTipOfTheDay(const char *name, const char **text)
Parse all tip definitions from the script files.
Definition: cl_tip.cpp:80
void CL_InitAfter(void)
Init function for clients - called after menu was initialized and ufo-scripts were parsed...
Definition: cl_main.cpp:737
mapDef_t mds[MAX_MAPDEFS]
Definition: q_shared.h:571
#define REJ_GAME_ALREADY_STARTED
Definition: q_shared.h:585
void LE_Cleanup(void)
Cleanup unused LE inventories that the server sent to the client also free some unused LE memory...
cvar_t * cl_trace_debug
client_static_t cls
Definition: cl_main.cpp:83
void S_Shutdown(void)
Definition: s_main.cpp:275
void GAME_EndBattlescape(void)
This is called when a client quits the battlescape.
Definition: cl_game.cpp:314
#define MAX_STRING_TOKENS
Definition: defines.h:92
void Q_strncpyz(char *dest, const char *src, size_t destsize)
Safe strncpy that ensures a trailing zero.
Definition: shared.cpp:457
mapData_t * SV_GetMapData(void)
Definition: sv_main.cpp:947
void add(const char *, size_t)
Definition: dbuffer.cpp:42
void NET_OOB_Printf(struct net_stream *s, const char *format,...)
Out of band print.
Definition: netpack.cpp:548
cvar_t * cl_le_debug
#define CS_MODELS
Definition: q_shared.h:327
int realtime
Definition: client.h:58
#define UFO_VERSION
Definition: common.h:36
uiNode_t * UI_PushWindow(const char *name, const char *parentName, linkedList_t *params)
Push a window onto the window stack.
Definition: ui_windows.cpp:170
void CL_RequestNextDownload(void)
Definition: cl_main.cpp:602
#define MAX_INFO_STRING
Definition: infostring.h:36
#define ERR_DROP
Definition: common.h:211
static void CL_RContextCvarChange(const char *cvarName, const char *oldValue, const char *newValue, void *data)
Definition: cl_main.cpp:1127
#define OPTIONEXTRADATA(node)
#define DEBUG_CLIENT
Definition: defines.h:59
void CL_ParseSequence(const char *name, const char **text)
Reads the sequence values from given text-pointer.
cvar_t * Cvar_Get(const char *var_name, const char *var_value, int flags, const char *desc)
Init or return a cvar.
Definition: cvar.cpp:342
int NET_ReadString(dbuffer *buf, char *string, size_t length)
Definition: netpack.cpp:302
void CL_HTTP_Cleanup(void)
UFO is exiting or we&#39;re changing servers. Clean up.
Definition: cl_http.cpp:532
rendererData_t refdef
Definition: r_main.cpp:45
#define OBJZERO(obj)
Definition: shared.h:178
#define MAX_VAR
Definition: shared.h:36
void GAME_SetMode(const cgame_export_t *gametype)
Definition: cl_game.cpp:952
void GAME_InitMissionBriefing(const char *title)
Definition: cl_game.cpp:1334
void CL_InitLua(void)
Initializes the ui-lua interfacing environment.
Definition: cl_lua.cpp:130
void SCR_EndLoadingPlaque(void)
Definition: cl_screen.cpp:277
#define REJ_PASSWORD_REQUIRED_OR_INCORRECT
Reject messages that are send to the client from the game module.
Definition: q_shared.h:580
#define CS_OBJECTAMOUNT
Definition: q_shared.h:320
#define NET_STATE_BEGIN
Definition: q_shared.h:609
void GAME_Frame(void)
Called every frame and allows us to hook into the current running game mode.
Definition: cl_game.cpp:1519
#define CS_NAME
Definition: q_shared.h:309
int Cmd_Argc(void)
Return the number of arguments of the current command. "command parameter" will result in a argc of 2...
Definition: cmd.cpp:505
float frametime
Definition: client.h:59
cvar_t * cl_fps
Definition: cl_main.cpp:71
void SEQ_Shutdown(void)
void TOTD_Shutdown(void)
Definition: cl_tip.cpp:104
bool UI_ParseWindow(const char *type, const char *name, const char **text)
Parse a window.
Definition: ui_parse.cpp:1336
static void CL_RImagesCvarChange(const char *cvarName, const char *oldValue, const char *newValue, void *data)
Definition: cl_main.cpp:1132
#define CS_VERSION
Definition: q_shared.h:318
static bool CL_DownloadMap(const char *map)
Definition: cl_main.cpp:529
#define CVAR_NOSET
Definition: cvar.h:43
void Con_SaveConsoleHistory(void)
Stores the console history.
Definition: cl_console.cpp:250
clientBattleScape_t cl
cgame team management headers.
#define NET_STATE_NEW
Definition: q_shared.h:608
#define Mem_CreatePool(name)
Definition: mem.h:32
char const * Q_strstart(char const *str, char const *start)
Matches the start of a string.
Definition: shared.cpp:587
uiNode_t * next
Definition: ui_nodes.h:91
int waitingForStart
Definition: client.h:72
bool CL_CheckOrDownloadFile(const char *filename)
Definition: cl_http.cpp:341
Battlescape radar header.
static bool CL_DownloadUMPMap(const char *tiles)
Definition: cl_main.cpp:498
bool GAME_IsMultiplayer(void)
Definition: cl_game.cpp:299
const char * FS_GetCwd(void)
Return current working dir.
Definition: files.cpp:1570
bool Com_IsUserinfoModified(void)
Definition: cvar.cpp:61
void CL_ViewCalcFieldOfViewX(void)
Calculates refdef&#39;s FOV_X. Should generally be called after any changes are made to the zoom level (v...
Definition: cl_view.cpp:189
char serverport[16]
Definition: client.h:69
int numODs
Definition: q_shared.h:518
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
#define MAX_CONFIGSTRINGS
Definition: q_shared.h:330
memPool_t * vid_lightPool
Definition: cl_main.cpp:89
void CL_ActorTargetAlign_f(void)
Targets to the ground when holding the assigned button.
Definition: cl_actor.cpp:1924
static void CL_SendCommand(void)
Definition: cl_main.cpp:962
static void CL_Connect(void)
Definition: cl_main.cpp:200
#define CL_CMD_ECHO
Definition: q_shared.h:598
static cvar_t * cl_msg
Definition: cl_main.cpp:79
#define RDF_IRGOGGLES
Definition: cl_renderer.h:35
Header for certain screen operations.
void CL_Init(void)
Definition: cl_main.cpp:1141
int32_t svc_ops_t
Definition: common.h:165
cURL header
void Cvar_FixCheatVars(void)
Reset cheat cvar values to default.
Definition: cvar.cpp:1042
Particle system header file.
void CL_Frame(int now, void *data)
Definition: cl_main.cpp:1047
const char * Sys_GetCurrentUser(void)
void CLMN_Shutdown(void)
Definition: cl_menu.cpp:142
bool UI_ParseSprite(const char *name, const char **text)
Definition: ui_parse.cpp:1213
void HUD_InitStartup(void)
Definition: cl_hud.cpp:1597
static void CL_SpawnSoldiers_f(void)
Send the clc_teaminfo command to server.
Definition: cl_main.cpp:474
void WEB_InitStartup(void)
Definition: web_main.cpp:185
void CL_BattlescapeRadarInit(void)
Definition: cl_radar.cpp:147
void S_Frame(void)
Definition: s_main.cpp:70
static void CL_StartMatch_f(void)
Definition: cl_main.cpp:486
#define REJ_BANNED
Definition: q_shared.h:582
cvar_t * s_language
Definition: common.cpp:54
#define CS_UFOCHECKSUM
Definition: q_shared.h:319
int connectTime
Definition: client.h:70
void Cmd_ForwardToServer(void)
adds the current command line as a clc_stringcmd to the client message. things like action...
Definition: cl_main.cpp:98
static void CL_ConnectionlessPacket(dbuffer *msg)
Responses to broadcasts, etc.
Definition: cl_main.cpp:339
static void CL_FreeClientStream(void)
Definition: cl_main.cpp:189
void CLMN_Init(void)
Initialize the menu data hunk, add cvars and commands.
Definition: cl_menu.cpp:129
void Irc_Init(void)
Definition: cl_irc.cpp:1959
cvar_t * cl_selected
Definition: cl_main.cpp:73
void CL_RunHTTPDownloads(void)
This calls curl_multi_perform do actually do stuff. Called every frame while connecting to minimise l...
Definition: cl_http.cpp:752
const char * Com_Parse(const char *data_p[], char *target, size_t size, bool replaceWhitespaces)
Parse a token out of a string.
Definition: parse.cpp:107
static void CL_Reconnect(void)
Definition: cl_main.cpp:177
Definition: scripts.h:49
void LE_Think(void)
Calls the le think function and updates the animation. The animation updated even if the particular l...
static void CL_Quit_f(void)
Definition: cl_main.cpp:155
void SCR_BeginLoadingPlaque(void)
Definition: cl_screen.cpp:269
void Sys_OpenURL(const char *url)
void CL_SetHTTPServer(const char *URL)
A new server is specified, so we nuke all our state.
Definition: cl_http.cpp:225
void CL_ParseLanguages(const char *name, const char **text)
Parse all language definitions from the script files.
void CL_CameraInit(void)
Definition: cl_camera.cpp:391
#define REJ_SERVER_VERSION_MISMATCH
Definition: q_shared.h:584
#define CL_CMD_PING
Definition: q_shared.h:597
#define MAX_QPATH
Definition: filesys.h:40
QGL_EXTERN GLint i
Definition: r_gl.h:113
QGL_EXTERN GLuint GLchar GLuint * len
Definition: r_gl.h:99
void INV_InitStartup(void)
Definition: scripts.h:50
cvar_t * sv_dedicated
Definition: common.cpp:51
void VID_Minimize(void)
Definition: cl_video.cpp:147
void CL_SetClientState(connstate_t state)
Sets the client state.
Definition: cl_main.cpp:1015
UFOAI web interface management. Authentication as well as uploading/downloading stuff to and from you...
QGL_EXTERN GLuint GLsizei GLsizei GLint GLenum GLchar * name
Definition: r_gl.h:110
void NET_WriteByte(dbuffer *buf, byte c)
Definition: netpack.cpp:39
void CL_Shutdown(void)
Saves configuration file and shuts the client systems down.
Definition: cl_main.cpp:1219
void CL_ParseParticle(const char *name, const char **text)
Parses particle definitions from UFO-script files.
#define CS_TILES
Definition: q_shared.h:325
void HUD_Update(void)
Updates console vars for an actor.
Definition: cl_hud.cpp:1428
#define CS_LIGHTMAP
Definition: q_shared.h:321
#define REJ_SERVER_FULL
Definition: q_shared.h:583
static bool isdown
Definition: cl_main.cpp:84
void UI_RegisterOption(int dataId, uiNode_t *option)
Definition: ui_data.cpp:311
static bool CL_CanMultiplayerStart(void)
Definition: cl_main.cpp:550
static int Com_MapDefSort(const void *mapDef1, const void *mapDef2)
Definition: cl_main.cpp:719
static void CL_ForwardToServer_f(void)
Definition: cl_main.cpp:138
const char * Cvar_Userinfo(char *info, size_t infoSize)
Returns an info string containing all the CVAR_USERINFO cvars.
Definition: cvar.cpp:967
void Irc_Logic_Frame(void)
Definition: cl_irc.cpp:1468
HUD related routines.
#define MEMBER_SIZEOF(TYPE, MEMBER)
Definition: scripts.h:34
static void CL_Env_f(void)
Set or print some environment variables via console command.
Definition: cl_main.cpp:122
bool CL_LanguageTryToSet(const char *localeID)
Cycle through all parsed locale mappings and try to set one after another.
void R_FreeWorldImages(void)
Any image that is a mesh or world texture will be removed here.
Definition: r_image.cpp:757
static void CL_OpenURL_f(void)
Opens the specified URL and minimizes the game window. You have to specify the whole url including th...
Definition: cl_main.cpp:838
int CL_ClearBattlescapeEvents(void)
Definition: e_parse.cpp:215
struct cvar_s * next
Definition: cvar.h:84
memPool_t * vid_imagePool
Definition: cl_main.cpp:88
bool NET_StreamIsLoopback(struct net_stream *s)
Definition: net.cpp:910
#define CVAR_R_IMAGES
Definition: cvar.h:47
#define MASTER_SERVER
Definition: common.h:124
void Info_Print(const char *s)
Prints info strings (like userinfo or serverinfo - CVAR_USERINFO, CVAR_SERVERINFO) ...
Definition: infostring.cpp:209
void CL_Disconnect(void)
Sets the cls.state to ca_disconnected and informs the server.
Definition: cl_main.cpp:256
int Q_StringSort(const void *string1, const void *string2)
Compare two strings.
Definition: shared.cpp:385
void PTL_InitStartup(void)
Clears particle data.
int r_numParticles
Definition: r_particle.cpp:30
#define N_(String)
Definition: cl_shared.h:46
dbuffer * NET_ReadMsg(struct net_stream *s)
Reads messages from the network channel and adds them to the dbuffer where you can use the NET_Read* ...
Definition: net.cpp:774
void CIN_Init(void)
void GAME_InitStartup(void)
Definition: cl_game.cpp:1692
void Irc_Shutdown(void)
Definition: cl_irc.cpp:2006
cvar_t * Cvar_Set(const char *varName, const char *value,...)
Sets a cvar value.
Definition: cvar.cpp:615
Primary header for client.
IRC client header for UFO:AI.
const char * Cvar_GetString(const char *varName)
Returns the value of cvar as string.
Definition: cvar.cpp:210
#define Q_streq(a, b)
Definition: shared.h:136
void SCR_RunConsole(void)
Scroll it up or down.
Definition: cl_screen.cpp:222
cvar_t * cl_log_battlescape_events
Definition: e_parse.cpp:47
void IN_Frame(void)
Handle input events like key presses and joystick movement as well as window events.
Definition: cl_input.cpp:946
void GAME_StartMatch(void)
Definition: cl_game.cpp:1422
Not cleared on a map change (static data)
Definition: client.h:54
void TEAM_InitStartup(void)
Definition: cl_team.cpp:339
void Cbuf_Execute(void)
Pulls off terminated lines of text from the command buffer and sends them through Cmd_ExecuteString...
Definition: cmd.cpp:214
void CL_ParseServerMessage(svc_ops_t cmd, dbuffer *msg)
Parses the server sent data from the given buffer.
Definition: cl_parse.cpp:160
#define PROTOCOL_VERSION
Definition: common.h:134
bool modified
Definition: cvar.h:79
Console header file.
void UI_Popup(const char *title, const char *text)
Popup on geoscape.
Definition: ui_popup.cpp:47
#define CS_ENTITYSTRING
Definition: q_shared.h:324
void S_LoadSamples(void)
Wrapper for S_PrecacheSamples to avoid exposing it via s_sample.h.
Definition: s_main.cpp:359
#define ERR_DISCONNECT
Definition: defines.h:112
char servername[MAX_VAR]
Definition: client.h:68
Specifies music API.
This is a cvar definition. Cvars can be user modified and used in our menus e.g.
Definition: cvar.h:71
int Com_ServerState(void)
Check whether we are the server or have a singleplayer tactical mission.
Definition: common.cpp:538
void VID_Init(void)
Definition: cl_video.cpp:159
bool UI_ParseFont(const char *name, const char **text)
Definition: ui_font.cpp:68
Header file for cinematics.
void CL_ViewLoadMedia(void)
Call before entering a new level, or after vid_restart.
Definition: cl_view.cpp:48
cvar_t * sys_priority
Definition: common.cpp:59
bool downloadMaps
Definition: client.h:86
int NET_ReadByte(dbuffer *buf)
Reads a byte from the netchannel.
Definition: netpack.cpp:234
const char * Cmd_Args(void)
Returns a single string containing argv(1) to argv(argc()-1)
Definition: cmd.cpp:526
#define CVAR_SERVERINFO
Definition: cvar.h:42
#define CVAR_R_CONTEXT
Definition: cvar.h:48
void CL_ParticleRun(void)
General system for particle running during the game.
void CM_LoadMap(const char *tiles, bool day, const char *pos, const char *entityString, mapData_t *mapData, mapTiles_t *mapTiles)
Loads in the map and all submodels.
Definition: bsp.cpp:860
int CL_GetClientState(void)
Definition: cl_main.cpp:1007
connstate_t state
Definition: client.h:55
int NET_ReadStringLine(dbuffer *buf, char *string, size_t length)
Definition: netpack.cpp:328
actorSkin_t * CL_AllocateActorSkin(const char *name)
Allocate a skin from the cls structure.
Definition: cl_team.cpp:44
void Com_SetUserinfoModified(bool modified)
Definition: cvar.cpp:56
void HTTP_InitStartup(void)
Definition: cl_http.cpp:788
int reconnectTime
Definition: client.h:71
int CL_Milliseconds(void)
Definition: cl_main.cpp:1207
void UI_DisplayNotice(const char *text, int time, const char *windowName)
Displays a message over all windows.
Definition: ui_draw.cpp:411
int Sys_Milliseconds(void)
Definition: unix_shared.cpp:41
#define SV_CMD_ACK
Definition: q_shared.h:596
void Key_WriteBindings(const char *filename)
Writes lines containing "bind key value".
Definition: cl_keys.cpp:664
void NET_WriteMsg(struct net_stream *s, dbuffer &buf)
Enqueue the buffer in the net stream for ONE client.
Definition: netpack.cpp:569
void S_MumbleLink(void)
Definition: s_mumble.cpp:40
char * string
Definition: cvar.h:73