UFO: Alien Invasion
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
cl_main.cpp
Go to the documentation of this file.
1 
6 /*
7 All original material Copyright (C) 2002-2020 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 {
179  if (cls.reconnectTime == 0 || cls.reconnectTime > CL_Milliseconds())
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 
239  /* wipe the entire cl structure */
240  OBJZERO(cl);
241  cl.cam.zoom = 1.0;
243 
244  /* wipe the particles with every new map */
245  r_numParticles = 0;
246  /* reset ir goggle state with every new map */
248 }
249 
257 void CL_Disconnect (void)
258 {
259  if (cls.state < ca_connecting)
260  return;
261 
262  Com_Printf("Disconnecting...\n");
263 
264  /* send a disconnect message to the server */
265  if (!Com_ServerState()) {
266  dbuffer msg;
269  NET_WriteMsg(cls.netStream, msg);
270  /* make sure, that this is send */
271  NET_Wait(0);
272  }
273 
275  cls.netStream = nullptr;
276 
277  CL_ClearState();
278 
279  S_Stop();
280 
281  R_ShutdownModels(false);
283 
287 }
288 
289 /* it's dangerous to activate this */
290 /*#define ACTIVATE_PACKET_COMMAND*/
291 #ifdef ACTIVATE_PACKET_COMMAND
292 
299 static void CL_Packet_f (void)
300 {
301  if (Cmd_Argc() != 4) {
302  Com_Printf("Usage: %s <destination> <port> <contents>\n", Cmd_Argv(0));
303  return;
304  }
305 
306  struct net_stream* s = NET_Connect(Cmd_Argv(1), Cmd_Argv(2));
307  if (!s) {
308  Com_Printf("Could not connect to %s at port %s\n", Cmd_Argv(1), Cmd_Argv(2));
309  return;
310  }
311 
312  const char* in = Cmd_Argv(3);
313 
314  const int l = strlen(in);
315  char buf[MAX_STRING_TOKENS];
316  char* out = buf;
317 
318  for (int i = 0; i < l; i++) {
319  if (in[i] == '\\' && in[i + 1] == 'n') {
320  *out++ = '\n';
321  i++;
322  } else {
323  *out++ = in[i];
324  }
325  }
326  *out = 0;
327 
328  NET_OOB_Printf(s, "%s %i", out, PROTOCOL_VERSION);
330 }
331 #endif
332 
341 {
342  char s[512];
343  NET_ReadStringLine(msg, s, sizeof(s));
344 
345  Cmd_TokenizeString(s, false);
346 
347  const char* c = Cmd_Argv(0);
348  Com_DPrintf(DEBUG_CLIENT, "server OOB: %s (%s)\n", c, Cmd_Args());
349 
350  /* server connection */
351  if (Q_streq(c, CL_CMD_CLIENT_CONNECT)) {
352  int i;
353  for (i = 1; i < Cmd_Argc(); i++) {
354  if (char const* const p = Q_strstart(Cmd_Argv(i), "dlserver=")) {
355  Com_sprintf(cls.downloadReferer, sizeof(cls.downloadReferer), "ufo://%s", cls.servername);
356  CL_SetHTTPServer(p);
357  if (cls.downloadServer[0])
358  Com_Printf("HTTP downloading enabled, URL: %s\n", cls.downloadServer);
359  }
360  }
361  if (cls.state == ca_connected) {
362  Com_Printf("Dup connect received. Ignored.\n");
363  return;
364  }
365  dbuffer buf(5);
367  NET_WriteString(&buf, NET_STATE_NEW "\n");
368  NET_WriteMsg(cls.netStream, buf);
369  GAME_InitMissionBriefing(_("Loading"));
370  return;
371  }
372 
373  /* remote command from gui front end */
374  if (Q_streq(c, CL_CMD_COMMAND)) {
375  if (!NET_StreamIsLoopback(cls.netStream)) {
376  Com_Printf("Command packet from remote host. Ignored.\n");
377  return;
378  } else {
379  char str[512];
380  NET_ReadString(msg, str, sizeof(str));
381  Cbuf_AddText("%s\n", str);
382  }
383  return;
384  }
385 
386  /* ping from server */
387  if (Q_streq(c, CL_CMD_PING)) {
389  return;
390  }
391 
392  /* echo request from server */
393  if (Q_streq(c, CL_CMD_ECHO)) {
394  NET_OOB_Printf(cls.netStream, "%s", Cmd_Argv(1));
395  return;
396  }
397 
398  /* print */
399  if (Q_streq(c, SV_CMD_PRINT)) {
400  NET_ReadString(msg, popupText, sizeof(popupText));
401  /* special reject messages needs proper handling */
403  UI_PushWindow("serverpassword");
404  if (Q_strvalid(Cvar_GetString("password"))) {
405  Cvar_Set("password", "%s", "");
406  CL_Drop();
407  UI_Popup(_("Connection failure"), _("The password you specified was wrong."));
408  } else {
409  CL_Drop();
410  UI_Popup(_("Connection failure"), _("This server requires a password."));
411  }
412  } else if (strstr(popupText, REJ_SERVER_FULL)) {
413  CL_Drop();
414  UI_Popup(_("Connection failure"), _("This server is full."));
415  } else if (strstr(popupText, REJ_BANNED)) {
416  CL_Drop();
417  UI_Popup(_("Connection failure"), _("You are banned on this server."));
418  } else if (strstr(popupText, REJ_GAME_ALREADY_STARTED)) {
419  CL_Drop();
420  UI_Popup(_("Connection failure"), _("The game has already started."));
421  } else if (strstr(popupText, REJ_SERVER_VERSION_MISMATCH)) {
422  CL_Drop();
423  UI_Popup(_("Connection failure"), _("The server is running a different version of the game."));
424  } else if (strstr(popupText, BAD_RCON_PASSWORD)) {
425  Cvar_Set("rcon_password", "%s", "");
426  UI_Popup(_("Bad rcon password"), _("The rcon password you specified was wrong."));
427  } else if (strstr(popupText, REJ_CONNECTION_REFUSED)) {
428  CL_Drop();
429  UI_Popup(_("Connection failure"), _("The server refused the connection."));
430  } else if (Q_strvalid(popupText)) {
431  UI_Popup(_("Notice"), _(popupText));
432  }
433  return;
434  }
435 
436  if (!GAME_HandleServerCommand(c, msg))
437  Com_Printf("Unknown command received \"%s\"\n", c);
438 }
439 
447 static void CL_ReadPackets (void)
448 {
449  dbuffer* msg;
450  while ((msg = NET_ReadMsg(cls.netStream))) {
451  const svc_ops_t cmd = NET_ReadByte(msg);
452  if (cmd == svc_oob)
454  else
455  CL_ParseServerMessage(cmd, msg);
456  delete msg;
457  }
458 }
459 
464 static void CL_UserInfo_f (void)
465 {
466  Com_Printf("User info settings:\n");
467  char info[MAX_INFO_STRING];
468  Info_Print(Cvar_Userinfo(info, sizeof(info)));
469 }
470 
475 static void CL_SpawnSoldiers_f (void)
476 {
477  if (!CL_OnBattlescape())
478  return;
479 
480  if (cl.spawned)
481  return;
482 
483  cl.spawned = true;
485 }
486 
487 static void CL_StartMatch_f (void)
488 {
489  if (!cl.spawned)
490  return;
491 
492  if (cl.started)
493  return;
494 
495  cl.started = true;
496  GAME_StartMatch();
497 }
498 
499 static bool CL_DownloadUMPMap (const char* tiles)
500 {
501  char name[MAX_VAR];
502  char base[MAX_QPATH];
503  bool startedDownload = false;
504 
505  /* load tiles */
506  while (tiles) {
507  /* get tile name */
508  const char* token = Com_Parse(&tiles);
509  if (!tiles)
510  return startedDownload;
511 
512  /* get base path */
513  if (token[0] == '-') {
514  Q_strncpyz(base, token + 1, sizeof(base));
515  continue;
516  }
517 
518  /* get tile name */
519  if (token[0] == '+')
520  Com_sprintf(name, sizeof(name), "%s%s", base, token + 1);
521  else
522  Q_strncpyz(name, token, sizeof(name));
523 
524  startedDownload |= !CL_CheckOrDownloadFile(va("maps/%s.bsp", name));
525  }
526 
527  return startedDownload;
528 }
529 
530 static bool CL_DownloadMap (const char* map)
531 {
532  bool startedDownload;
533  if (map[0] != '+') {
534  startedDownload = !CL_CheckOrDownloadFile(va("maps/%s.bsp", map));
535  } else {
536  startedDownload = !CL_CheckOrDownloadFile(va("maps/%s.ump", map + 1));
537  if (!startedDownload) {
538  const char* tiles = CL_GetConfigString(CS_TILES);
539  startedDownload = CL_DownloadUMPMap(tiles);
540  }
541  }
542 
543  return startedDownload;
544 }
545 
551 static bool CL_CanMultiplayerStart (void)
552 {
553  const int day = CL_GetConfigStringInteger(CS_LIGHTMAP);
554  const char* serverVersion = CL_GetConfigString(CS_VERSION);
555 
556  /* checksum doesn't match with the one the server gave us via configstring */
557  if (!Q_streq(UFO_VERSION, serverVersion)) {
558  Com_sprintf(popupText, sizeof(popupText), _("Local game version (%s) differs from the server version (%s)"), UFO_VERSION, serverVersion);
559  UI_Popup(_("Error"), popupText);
560  Com_Error(ERR_DISCONNECT, "Local game version (%s) differs from the server version (%s)", UFO_VERSION, serverVersion);
561  /* amount of objects from script files doesn't match */
563  UI_Popup(_("Error"), _("Script files are not the same"));
564  Com_Error(ERR_DISCONNECT, "Script files are not the same");
565  }
566 
567  /* activate the map loading screen for multiplayer, too */
569 
570  /* check download */
571  if (cls.downloadMaps) { /* confirm map */
573  return false;
574  cls.downloadMaps = false;
575  }
576 
577  /* map might still be downloading? */
579  return false;
580 
582  Com_Printf("You are using modified ufo script files - might produce problems\n");
583 
585 
586 #if 0
588  UI_Popup(_("Error"), _("Local map version differs from server"));
589  Com_Error(ERR_DISCONNECT, "Local map version differs from server: %u != '%i'",
591  }
592 #endif
593 
594  return true;
595 }
596 
604 {
605  if (cls.state != ca_connected) {
606  Com_Printf("CL_RequestNextDownload: Not connected (%i)\n", cls.state);
607  return;
608  }
609 
610  /* Use the map data from the server */
613 
614  /* as a multiplayer client we have to load the map here and
615  * check the compatibility with the server */
617  return;
618 
620 
621  dbuffer msg(7);
622  /* send begin */
623  /* this will activate the render process (see client state ca_active) */
625  /* see CL_StartGame */
626  NET_WriteString(&msg, NET_STATE_BEGIN "\n");
627  NET_WriteMsg(cls.netStream, msg);
628 
630 
631  S_MumbleLink();
632 }
633 
634 
640 static void CL_Precache_f (void)
641 {
642  cls.downloadMaps = true;
643 
645 }
646 
647 static void CL_SetRatioFilter_f (void)
648 {
650  uiNode_t* option = firstOption;
651  float requestedRation = atof(Cmd_Argv(1));
652  bool all = false;
653  bool custom = false;
654  const float delta = 0.01;
655 
656  if (Cmd_Argc() != 2) {
657  Com_Printf("Usage: %s <all|floatration>\n", Cmd_Argv(0));
658  return;
659  }
660 
661  if (Q_streq(Cmd_Argv(1), "all"))
662  all = true;
663  else if (Q_streq(Cmd_Argv(1), "custom"))
664  custom = true;
665  else
666  requestedRation = atof(Cmd_Argv(1));
667 
668  while (option) {
669  int width;
670  int height;
671  bool visible = false;
672  const int result = sscanf(OPTIONEXTRADATA(option).label, "%i x %i", &width, &height);
673  if (result != 2)
674  Com_Error(ERR_FATAL, "CL_SetRatioFilter_f: Impossible to decode resolution label.\n");
675  const float ratio = (float)width / (float)height;
676 
677  if (all)
678  visible = true;
679  else if (custom)
681  visible = ratio > 2 || (ratio > 1.7 && ratio < 1.76);
682  else
683  visible = ratio - delta < requestedRation && ratio + delta > requestedRation;
684 
685  option->invis = !visible;
686  option = option->next;
687  }
688 
689  /* the content change */
691 }
692 
694 static const value_t actorskin_vals[] = {
695  {"name", V_STRING, offsetof(actorSkin_t, name), 0},
696  {"singleplayer", V_BOOL, offsetof(actorSkin_t, singleplayer), MEMBER_SIZEOF(actorSkin_t, singleplayer)},
697  {"multiplayer", V_BOOL, offsetof(actorSkin_t, multiplayer), MEMBER_SIZEOF(actorSkin_t, multiplayer)},
698 
699  {nullptr, V_NULL, 0, 0}
700 };
701 
702 
703 static void CL_ParseActorSkin (const char* name, const char** text)
704 {
705  /* NOTE: first skin is special cause we don't get the skin with suffix */
706  if (CL_GetActorSkinCount() == 0) {
707  if (!Q_streq(name, "default") != 0) {
708  Com_Error(ERR_DROP, "CL_ParseActorSkin: First actorskin read from script must be \"default\" skin.");
709  }
710  }
711 
712  actorSkin_t* skin = CL_AllocateActorSkin(name);
713 
714  Com_ParseBlock(name, text, skin, actorskin_vals, nullptr);
715 }
716 
720 static int Com_MapDefSort (const void* mapDef1, const void* mapDef2)
721 {
722  const char* map1 = ((const mapDef_t*)mapDef1)->mapTheme;
723  const char* map2 = ((const mapDef_t*)mapDef2)->mapTheme;
724 
725  /* skip special map chars for rma and base attack */
726  if (map1[0] == '+' || map1[0] == '.')
727  map1++;
728  if (map2[0] == '+' || map2[0] == '.')
729  map2++;
730 
731  return Q_StringSort(map1, map2);
732 }
733 
738 void CL_InitAfter (void)
739 {
740  if (sv_dedicated->integer)
741  return;
742 
743  /* start the music track already while precaching data */
744  S_Frame();
745  S_LoadSamples();
746 
747  /* preload all models for faster access */
749  CL_LanguageInit();
750 
751  CLMN_Init();
752 
753  /* sort the mapdef array */
754  qsort(csi.mds, csi.numMDs, sizeof(mapDef_t), Com_MapDefSort);
755 }
756 
771 bool CL_ParseClientData (const char* type, const char* name, const char** text)
772 {
773 #ifndef COMPILE_UNITTESTS
774  static int progressCurrent = 0;
775 
776  progressCurrent++;
777  if (progressCurrent % 10 == 0)
778  SCR_DrawLoadingScreen(false, std::min(progressCurrent * 30 / 1500, 30));
779 #endif
780 
781  if (Q_streq(type, "window"))
782  return UI_ParseWindow(type, name, text);
783  else if (Q_streq(type, "component"))
784  return UI_ParseComponent(type, name, text);
785  else if (Q_streq(type, "particle"))
786  CL_ParseParticle(name, text);
787  else if (Q_streq(type, "language"))
788  CL_ParseLanguages(name, text);
789  else if (Q_streq(type, "font"))
790  return UI_ParseFont(name, text);
791  else if (Q_streq(type, "tutorial"))
792  TUT_ParseTutorials(name, text);
793  else if (Q_streq(type, "menu_model"))
794  return UI_ParseUIModel(name, text);
795  else if (Q_streq(type, "sprite"))
796  return UI_ParseSprite(name, text);
797  else if (Q_streq(type, "sequence"))
798  CL_ParseSequence(name, text);
799  else if (Q_streq(type, "music"))
800  M_ParseMusic(name, text);
801  else if (Q_streq(type, "actorskin"))
802  CL_ParseActorSkin(name, text);
803  else if (Q_streq(type, "cgame"))
804  GAME_ParseModes(name, text);
805  else if (Q_streq(type, "tip"))
806  CL_ParseTipOfTheDay(name, text);
807  else if (Q_streq(type, "lua"))
808  return UI_ParseAndLoadLuaScript(name, text);
809 
810  return true;
811 }
812 
817 static void CL_ShowConfigstrings_f (void)
818 {
819  for (int i = 0; i < MAX_CONFIGSTRINGS; i++) {
820  const char* configString;
821  /* CS_TILES and CS_POSITIONS can stretch over multiple configstrings,
822  * so don't print the middle parts */
823  if (i > CS_TILES && i < CS_POSITIONS)
824  continue;
825  if (i > CS_POSITIONS && i < CS_MODELS)
826  continue;
827 
828  configString = CL_GetConfigString(i);
829  if (configString[0] == '\0')
830  continue;
831  Com_Printf("configstring[%3i]: %s\n", i, configString);
832  }
833 }
834 
839 static void CL_OpenURL_f (void)
840 {
841  if (Cmd_Argc() != 2) {
842  Com_Printf("usage: %s <url>\n", Cmd_Argv(0));
843  return;
844  }
845 
846  VID_Minimize();
847  Sys_OpenURL(Cmd_Argv(1));
848 }
849 
855 static void CL_InitLocal (void)
856 {
858  cls.realtime = Sys_Milliseconds();
859 
860  /* register our variables */
861  cl_fps = Cvar_Get("cl_fps", "0", CVAR_ARCHIVE, "Show frames per second");
862  cl_log_battlescape_events = Cvar_Get("cl_log_battlescape_events", "1", 0, "Log all battlescape events to events.log");
863  cl_selected = Cvar_Get("cl_selected", "0", CVAR_NOSET, "Current selected soldier");
864  cl_connecttimeout = Cvar_Get("cl_connecttimeout", "25000", CVAR_ARCHIVE, "Connection timeout for multiplayer connects");
865  /* userinfo */
866  cl_name = Cvar_Get("cl_name", Sys_GetCurrentUser(), CVAR_USERINFO | CVAR_ARCHIVE, "Playername");
867  cl_teamnum = Cvar_Get("cl_teamnum", "1", CVAR_USERINFO | CVAR_ARCHIVE, "Preferred teamnum for multiplayer teamplay games");
868  cl_ready = Cvar_Get("cl_ready", "0", CVAR_USERINFO, "Ready indicator in the userinfo for tactical missions");
869  cl_msg = Cvar_Get("cl_msg", "2", CVAR_USERINFO | CVAR_ARCHIVE, "Sets the message level for server messages the client receives");
870  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)");
871 
872  masterserver_url = Cvar_Get("masterserver_url", MASTER_SERVER, CVAR_ARCHIVE, "URL of UFO:AI masterserver");
873 
874  cl_map_debug = Cvar_Get("debug_map", "0", 0, "Activate realtime map debugging options - bitmask. Valid values are 0, 1, 3 and 7");
875  cl_le_debug = Cvar_Get("debug_le", "0", 0, "Activates some local entity debug rendering");
876  cl_trace_debug = Cvar_Get("debug_trace", "0", 0, "Activates some client side trace debug rendering");
877  cl_leshowinvis = Cvar_Get("cl_leshowinvis", "0", CVAR_ARCHIVE, "Show invisible local entities as null models");
878 
879  /* register our commands */
880  Cmd_AddCommand("targetalign", CL_ActorTargetAlign_f, N_("Target your shot to the ground"));
881 
882  Cmd_AddCommand("cl_setratiofilter", CL_SetRatioFilter_f, "Filter the resolution screen list with a ratio");
883 
884  Cmd_AddCommand("cmd", CL_ForwardToServer_f, "Forward to server");
885  Cmd_AddCommand("cl_userinfo", CL_UserInfo_f, "Prints your userinfo string");
886 #ifdef ACTIVATE_PACKET_COMMAND
887  /* this is dangerous to leave in */
888  Cmd_AddCommand("packet", CL_Packet_f, "Dangerous debug function for network testing");
889 #endif
890  Cmd_AddCommand("quit", CL_Quit_f, "Quits the game");
891  Cmd_AddCommand("env", CL_Env_f);
892 
893  Cmd_AddCommand(CL_PRECACHE, CL_Precache_f, "Function that is called at mapload to precache map data");
894  Cmd_AddCommand(CL_SPAWNSOLDIERS, CL_SpawnSoldiers_f, "Spawns the soldiers for the selected teamnum");
895  Cmd_AddCommand(CL_STARTMATCH, CL_StartMatch_f, "Start the match once every player is ready");
896  Cmd_AddCommand("cl_configstrings", CL_ShowConfigstrings_f, "Print client configstrings to game console");
897  Cmd_AddCommand("cl_openurl", CL_OpenURL_f, "Opens the given url in a browser");
898 
899  /* forward to server commands
900  * the only thing this does is allow command completion
901  * to work -- all unknown commands are automatically
902  * forwarded to the server */
903  Cmd_AddCommand("say", nullptr, "Chat command");
904  Cmd_AddCommand("say_team", nullptr, "Team chat command");
905  Cmd_AddCommand("players", nullptr, "List of team and player name");
906 #ifdef DEBUG
907  Cmd_AddCommand("debug_cgrid", Grid_DumpWholeClientMap_f, "Shows the whole client side pathfinding grid of the current loaded map");
908  Cmd_AddCommand("debug_croute", Grid_DumpClientRoutes_f, "Shows the whole client side pathfinding grid of the current loaded map");
909  Cmd_AddCommand("debug_listle", LE_List_f, "Shows a list of current know local entities with type and status");
910  Cmd_AddCommand("debug_listlm", LM_List_f, "Shows a list of current know local models");
911  /* forward commands again */
912  Cmd_AddCommand("debug_edictdestroy", nullptr, "Call the 'destroy' function of a given edict");
913  Cmd_AddCommand("debug_edictuse", nullptr, "Call the 'use' function of a given edict");
914  Cmd_AddCommand("debug_edicttouch", nullptr, "Call the 'touch' function of a given edict");
915  Cmd_AddCommand("debug_killteam", nullptr, "Kills a given team");
916  Cmd_AddCommand("debug_stunteam", nullptr, "Stuns a given team");
917  Cmd_AddCommand("debug_listscore", nullptr, "Shows mission-score entries of all team members");
918  Cmd_AddCommand("debug_statechange", nullptr, "Change the state of an edict");
919 #endif
920 
921  IN_Init();
923  CL_CameraInit();
925 
926  UI_Init();
927  TUT_InitStartup();
928  PTL_InitStartup();
930  WEB_InitStartup();
934  HUD_InitStartup();
935  INV_InitStartup();
937 }
938 
944 static void CL_SendChangedUserinfos (void)
945 {
946  /* send a userinfo update if needed */
947  if (cls.state < ca_connected)
948  return;
949  if (!Com_IsUserinfoModified())
950  return;
951  char info[MAX_INFO_STRING];
952  const char* userInfo = Cvar_Userinfo(info, sizeof(info));
953  dbuffer msg(strlen(userInfo) + 2);
955  NET_WriteString(&msg, userInfo);
956  NET_WriteMsg(cls.netStream, msg);
958 }
959 
963 static void CL_SendCommand (void)
964 {
965  /* get new key events */
967 
968  /* process console commands */
969  Cbuf_Execute();
970 
971  /* send intentions now */
973 
974  /* fix any cheating cvars */
976 
977  switch (cls.state) {
978  case ca_disconnected:
979  /* if the local server is running and we aren't connected then connect */
980  if (Com_ServerState()) {
981  cls.servername[0] = '\0';
982  cls.serverport[0] = '\0';
984  return;
985  }
986  break;
987  case ca_connecting:
988  if (CL_Milliseconds() - cls.connectTime > cl_connecttimeout->integer) {
989  if (GAME_IsMultiplayer())
990  Com_Error(ERR_DROP, "Server is not reachable");
991  }
992  break;
993  case ca_connected:
994  if (cls.waitingForStart) {
995  if (CL_Milliseconds() - cls.waitingForStart > cl_connecttimeout->integer) {
996  Com_Error(ERR_DROP, "Server aborted connection - the server didn't response in %is. You can try to increase the cvar cl_connecttimeout",
997  cl_connecttimeout->integer / 1000);
998  } else {
999  SCR_DrawLoading(100);
1000  }
1001  }
1002  break;
1003  default:
1004  break;
1005  }
1006 }
1007 
1009 {
1010  return cls.state;
1011 }
1012 
1017 {
1018  Com_DPrintf(DEBUG_CLIENT, "CL_SetClientState: Set new state to %i (old was: %i)\n", state, cls.state);
1019  cls.state = state;
1020 
1021  switch (cls.state) {
1022  case ca_uninitialized:
1023  Com_Error(ERR_FATAL, "CL_SetClientState: Don't set state ca_uninitialized\n");
1024  break;
1025  case ca_active:
1026  cls.waitingForStart = 0;
1027  break;
1028  case ca_connecting:
1029  cls.reconnectTime = 0;
1030  CL_Connect();
1031  break;
1032  case ca_disconnected:
1033  cls.waitingForStart = 0;
1034  break;
1035  case ca_connected:
1036  /* wipe the client_state_t struct */
1037  CL_ClearState();
1038  Cvar_Set("cl_ready", "0");
1039  break;
1040  default:
1041  break;
1042  }
1043 }
1044 
1048 void CL_Frame (int now, void* data)
1049 {
1050  static int lastFrame = 0;
1051  int delta;
1052 
1055 
1056  /* decide the simulation time */
1057  delta = now - lastFrame;
1058  if (lastFrame)
1059  cls.frametime = delta / 1000.0;
1060  else
1061  cls.frametime = 0;
1062  cls.realtime = Sys_Milliseconds();
1063  cl.time = now;
1064  lastFrame = now;
1065 
1066  /* frame rate calculation */
1067  if (delta)
1068  cls.framerate = 1000.0 / delta;
1069 
1070  if (cls.state == ca_connected) {
1071  /* we run full speed when connecting */
1073  }
1074 
1075  /* fetch results from server */
1076  CL_ReadPackets();
1077 
1078  CL_SendCommand();
1079 
1080  IN_Frame();
1081 
1082  GAME_Frame();
1083 
1084  /* update camera position */
1085  CL_CameraMove();
1086 
1087  if (cls.state == ca_active)
1088  CL_ParticleRun();
1089 
1090  /* update the screen */
1091  SCR_UpdateScreen();
1092 
1093  /* advance local effects for next frame */
1094  SCR_RunConsole();
1095 
1096  /* LE updates */
1097  LE_Think();
1098 
1099  /* sound frame */
1100  S_Frame();
1101 
1102  /* send a new command message to the server */
1103  CL_SendCommand();
1104 }
1105 
1109 void CL_SlowFrame (int now, void* data)
1110 {
1111  /* language */
1112  if (s_language->modified) {
1114  }
1115 
1116  Irc_Logic_Frame();
1117 
1118  CL_Reconnect();
1119 
1120  HUD_Update();
1121 }
1122 
1123 static void CL_InitMemPools (void)
1124 {
1125  cl_genericPool = Mem_CreatePool("Client: Generic");
1126 }
1127 
1128 static void CL_RContextCvarChange (const char* cvarName, const char* oldValue, const char* newValue, void* data)
1129 {
1130  UI_DisplayNotice(_("This change requires a restart!"), 2000, nullptr);
1131 }
1132 
1133 static void CL_RImagesCvarChange (const char* cvarName, const char* oldValue, const char* newValue, void* data)
1134 {
1135  UI_DisplayNotice(_("This change might require a restart."), 2000, nullptr);
1136 }
1137 
1142 void CL_Init (void)
1143 {
1144  /* i18n through gettext */
1145  char languagePath[MAX_OSPATH];
1146  cvar_t* fs_i18ndir;
1147 
1148  isdown = false;
1149 
1150  if (sv_dedicated->integer)
1151  return; /* nothing running on the client */
1152 
1153  OBJZERO(cls);
1154 
1155  fs_i18ndir = Cvar_Get("fs_i18ndir", "", 0, "System path to language files");
1156  /* i18n through gettext */
1157  setlocale(LC_ALL, "C");
1158 
1159 // MSVC 2013 do not accept LC_MESSAGES
1160 #ifndef _MSC_VER
1161  setlocale(LC_MESSAGES, "");
1162 #endif
1163 
1164  /* use system locale dir if we can't find in gamedir */
1165  if (fs_i18ndir->string[0] != '\0')
1166  Q_strncpyz(languagePath, fs_i18ndir->string, sizeof(languagePath));
1167  else
1168 #ifdef LOCALEDIR
1169  Com_sprintf(languagePath, sizeof(languagePath), LOCALEDIR);
1170 #else
1171  Com_sprintf(languagePath, sizeof(languagePath), "%s/" BASEDIRNAME "/i18n/", FS_GetCwd());
1172 #endif
1173  Com_DPrintf(DEBUG_CLIENT, "...using mo files from %s\n", languagePath);
1174  bindtextdomain(TEXT_DOMAIN, languagePath);
1175  bind_textdomain_codeset(TEXT_DOMAIN, "UTF-8");
1176  /* load language file */
1177  textdomain(TEXT_DOMAIN);
1178 
1179  CL_InitMemPools();
1180 
1181  /* all archived variables will now be loaded */
1182  Con_Init();
1183 
1184  CIN_Init();
1185 
1186  VID_Init();
1187  SCR_DrawLoadingScreen(false, 0);
1188  S_Init();
1189  SCR_Init();
1190 
1191  CL_InitLua();
1192  CL_InitLocal();
1193 
1194  Irc_Init();
1195  CL_ViewInit();
1196 
1197  CL_ClearState();
1198 
1199  /* cvar feedback */
1200  for (const cvar_t* var = Cvar_GetFirst(); var; var = var->next) {
1201  if (var->flags & CVAR_R_CONTEXT)
1203  if (var->flags & CVAR_R_IMAGES)
1205  }
1206 }
1207 
1209 {
1210  return cls.realtime;
1211 }
1212 
1220 void CL_Shutdown (void)
1221 {
1222  if (isdown) {
1223  printf("recursive shutdown\n");
1224  return;
1225  }
1226  isdown = true;
1227 
1228  /* remove cvar feedback */
1229  for (const cvar_t* var = Cvar_GetFirst(); var; var = var->next) {
1230  if (var->flags & CVAR_R_CONTEXT)
1232  if (var->flags & CVAR_R_IMAGES)
1234  }
1235 
1236  CLMN_Shutdown();
1237  GAME_SetMode(nullptr);
1238  GAME_UnloadGame();
1239  CL_HTTP_Cleanup();
1240  Irc_Shutdown();
1242  Key_WriteBindings("keys.cfg");
1243  S_Shutdown();
1244  R_Shutdown();
1245  UI_Shutdown();
1246  CL_ShutdownLua();
1247  CIN_Shutdown();
1248  SEQ_Shutdown();
1249  GAME_Shutdown();
1251  TOTD_Shutdown();
1252  SCR_Shutdown();
1253 }
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:771
bool Com_ParseBlock(const char *name, const char **text, void *base, const value_t *values, memPool_t *mempool)
Definition: scripts.cpp:1415
#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
mapTiles_t * SV_GetMapTiles(void)
Definition: sv_main.cpp:952
static void CL_InitMemPools(void)
Definition: cl_main.cpp:1123
cvar_t * cl_teamnum
Definition: cl_main.cpp:81
static void CL_SetRatioFilter_f(void)
Definition: cl_main.cpp:647
#define CVAR_USERINFO
Definition: cvar.h:41
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
unsigned mapChecksum
Definition: typedefs.h:336
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:464
QGL_EXTERN GLint GLenum type
Definition: r_gl.h:94
#define CL_PRECACHE
Definition: q_shared.h:601
mapDef_t mds[MAX_MAPDEFS]
Definition: q_shared.h:571
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:817
bool UI_ParseAndLoadLuaScript(const char *name, const char **text)
Parses and loads a .ufo file holding a lua script.
Definition: ui_lua.cpp:386
uiNode_t * next
Definition: ui_nodes.h:91
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:1569
static const value_t actorskin_vals[]
valid actorskin descriptors
Definition: cl_main.cpp:694
#define TEXT_DOMAIN
Definition: cl_shared.h:42
const char * va(const char *format,...)
does a varargs printf into a temp buffer, so I don't need to have varargs versions of all text functi...
Definition: shared.cpp:410
#define CL_CMD_CLIENT_CONNECT
Definition: q_shared.h:606
int numMDs
Definition: q_shared.h:572
#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:640
void UI_Shutdown(void)
Reset and free the UI data hunk.
Definition: ui_main.cpp:205
This is a cvar definition. Cvars can be user modified and used in our menus e.g.
Definition: cvar.h:71
#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:944
cvar_t * sv_maxclients
Definition: g_main.cpp:43
#define _(String)
Definition: cl_shared.h:43
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:447
void ACTOR_InitStartup(void)
Definition: cl_actor.cpp:2522
void GAME_Shutdown(void)
Definition: cl_game.cpp:1884
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:1109
#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)
bool downloadMaps
Definition: client.h:86
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:1167
Shared game type headers.
void IN_SendKeyEvents(void)
Definition: cl_input.cpp:1284
static void CL_ParseActorSkin(const char *name, const char **text)
Definition: cl_main.cpp:703
memPool_t * vid_genericPool
Definition: cl_main.cpp:87
void CL_ShutdownLua(void)
Shutdown the ui-lua interfacing environment.
Definition: cl_lua.cpp:151
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.
char downloadServer[512]
Definition: client.h:92
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
bool CL_PendingHTTPDownloads(void)
See if we'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
int numODs
Definition: q_shared.h:518
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.
#define CS_POSITIONS
Definition: q_shared.h:326
int integer
Definition: cvar.h:81
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:855
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
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:1658
struct cvar_s * next
Definition: cvar.h:84
static cvar_t * cl_connecttimeout
Definition: cl_main.cpp:75
#define Q_strvalid(string)
Definition: shared.h:141
connstate_t
Definition: cl_shared.h:74
int Com_GetScriptChecksum(void)
Definition: scripts.cpp:3739
void Com_Error(int code, const char *fmt,...)
Definition: common.cpp:417
void S_Init(void)
Definition: s_main.cpp:172
int connectTime
Definition: client.h:70
void TUT_InitStartup(void)
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:738
#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
mapTiles_t * mapTiles
client_static_t cls
Definition: cl_main.cpp:83
bool invis
Definition: ui_nodes.h:101
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
#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:603
#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:1128
#define OPTIONEXTRADATA(node)
float frametime
Definition: client.h:59
#define DEBUG_CLIENT
Definition: defines.h:59
void CL_ParseSequence(const char *name, const char **text)
Reads the sequence values from given text-pointer.
char serverport[16]
Definition: client.h:69
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'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
int reconnectTime
Definition: client.h:71
void GAME_SetMode(const cgame_export_t *gametype)
Definition: cl_game.cpp:952
void GAME_InitMissionBriefing(const char *title)
Definition: cl_game.cpp:1502
void CL_InitLua(void)
Initializes the ui-lua interfacing environment.
Definition: cl_lua.cpp:126
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:1687
#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
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:1133
#define CS_VERSION
Definition: q_shared.h:318
static bool CL_DownloadMap(const char *map)
Definition: cl_main.cpp:530
#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
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:499
char downloadReferer[32]
Definition: client.h:93
bool GAME_IsMultiplayer(void)
Definition: cl_game.cpp:299
const char * FS_GetCwd(void)
Return current working dir.
Definition: files.cpp:1568
bool Com_IsUserinfoModified(void)
Definition: cvar.cpp:61
void CL_ViewCalcFieldOfViewX(void)
Calculates refdef's FOV_X. Should generally be called after any changes are made to the zoom level (v...
Definition: cl_view.cpp:189
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
struct net_stream * netStream
Definition: client.h:74
int waitingForStart
Definition: client.h:72
#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:963
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.
Atomic structure used to define most of the UI.
Definition: ui_nodes.h:80
void CL_Init(void)
Definition: cl_main.cpp:1142
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:1048
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:475
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:487
#define REJ_BANNED
Definition: q_shared.h:582
cvar_t * s_language
Definition: common.cpp:54
#define CS_UFOCHECKSUM
Definition: q_shared.h:319
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:340
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:751
Not cleared on a map change (static data)
Definition: client.h:54
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
char * string
Definition: cvar.h:73
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:1016
float framerate
Definition: client.h:60
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:1220
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:551
static int Com_MapDefSort(const void *mapDef1, const void *mapDef2)
Definition: cl_main.cpp:720
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:839
int CL_ClearBattlescapeEvents(void)
Definition: e_parse.cpp:215
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:257
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:45
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:1860
GLsizei const GLvoid * data
Definition: r_gl.h:152
void Irc_Shutdown(void)
Definition: cl_irc.cpp:2006
float zoom
Definition: cl_camera.h:39
cvar_t * Cvar_Set(const char *varName, const char *value,...)
Sets a cvar value.
Definition: cvar.cpp:615
connstate_t state
Definition: client.h:55
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
bool modified
Definition: cvar.h:79
void GAME_StartMatch(void)
Definition: cl_game.cpp:1590
char servername[MAX_VAR]
Definition: client.h:68
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
int realtime
Definition: client.h:58
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
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
Specifies music API.
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
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:1008
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:787
int CL_Milliseconds(void)
Definition: cl_main.cpp:1208
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