UFO: Alien Invasion
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
cl_game.cpp
Go to the documentation of this file.
1 
6 /*
7 Copyright (C) 2002-2020 UFO: Alien Invasion.
8 
9 This program is free software; you can redistribute it and/or
10 modify it under the terms of the GNU General Public License
11 as published by the Free Software Foundation; either version 2
12 of the License, or (at your option) any later version.
13 
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17 
18 See the GNU General Public License for more details.
19 
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 
24 */
25 
26 #include "cl_game.h"
27 #include "../client.h"
28 #include "../cl_language.h"
29 #include "cl_game_team.h"
30 #include "../battlescape/cl_localentity.h"
31 #include "../battlescape/cl_hud.h"
32 #include "../battlescape/cl_parse.h"
33 #include "../ui/ui_main.h"
34 #include "../ui/ui_draw.h"
35 #include "../ui/ui_nodes.h"
36 #include "../ui/ui_popup.h"
37 #include "../ui/ui_render.h"
38 #include "../ui/ui_windows.h"
39 #include "../ui/ui_sprite.h"
40 #include "../ui/ui_font.h"
41 #include "../ui/ui_tooltip.h"
42 #include "../ui/node/ui_node_container.h"
43 #include "../ui/node/ui_node_messagelist.h"
44 #include "../ui/node/ui_node_model.h"
45 #include "../cl_team.h"
46 #include "../web/web_cgame.h"
47 #include "../battlescape/events/e_main.h"
48 #include "../cl_inventory.h"
49 #include "../../shared/parse.h"
50 #include "../../common/filesys.h"
51 #include "../renderer/r_draw.h"
52 #include "../renderer/r_framebuffer.h"
53 #include "../renderer/r_geoscape.h"
54 
55 #include <set>
56 #include <string>
57 
58 #define MAX_CGAMETYPES 16
60 static int numCGameTypes;
61 
62 static inline const cgame_export_t* GAME_GetCurrentType (void)
63 {
64  return cls.gametype;
65 }
66 
68 {
69 private:
70  typedef std::set<const struct cvar_s* > GameCvars;
71  GameCvars _cvars;
72 public:
74  {
75  _cvars.clear();
76  }
77 
78  void onCreate (const struct cvar_s* cvar)
79  {
80  const cgame_export_t* list = GAME_GetCurrentType();
81  if (list)
82  _cvars.insert(cvar);
83  }
84 
85  void onDelete (const struct cvar_s* cvar)
86  {
87  _cvars.erase(cvar);
88  }
89 
91  {
92  GameCvars copy = _cvars;
93  for (GameCvars::const_iterator i = copy.begin(); i != copy.end(); ++i) {
94  const struct cvar_s* cvar = *i;
95  if (cvar->flags == 0) {
96  const cgame_export_t* list = GAME_GetCurrentType();
97  Com_DPrintf(DEBUG_CLIENT, "Delete cvar %s because it was created in the context of the cgame %s\n",
98  cvar->name, list ? list->name : "none");
99  Cvar_Delete(cvar->name);
100  }
101  }
102  }
103 };
104 
106 {
107 private:
108  typedef std::set<const char* > GameCmds;
109  GameCmds _cmds;
110 public:
112  {
113  _cmds.clear();
114  }
115 
116  void onAdd (const char* cmdName)
117  {
118  const cgame_export_t* list = GAME_GetCurrentType();
119  if (list) {
120  _cmds.insert(cmdName);
121  }
122  }
123 
124  void onRemove (const char* cmdName)
125  {
126  _cmds.erase(cmdName);
127  }
128 
130  {
131  GameCmds copy = _cmds;
132  for (GameCmds::const_iterator i = copy.begin(); i != copy.end(); ++i) {
133  const char* cmdName = *i;
134  const cgame_export_t* list = GAME_GetCurrentType();
135  Com_DPrintf(DEBUG_COMMANDS, "Remove command %s because it was created in the context of the cgame %s\n",
136  cmdName, list ? list->name : "none");
137  Cmd_RemoveCommand(cmdName);
138  }
139  }
140 };
141 
144 
145 /* @todo: remove me - this should be per geoscape node data */
147 
148 #ifdef HARD_LINKED_CGAME
152 
153 static const cgame_api_t gameTypeList[] = {
154  GetCGameMultiplayerAPI,
155  GetCGameCampaignAPI,
156  GetCGameSkirmishAPI
157 };
158 
159 static const char* cgameMenu;
160 
161 const cgame_export_t* GetCGameAPI (const cgame_import_t* import)
162 {
163  const size_t len = lengthof(gameTypeList);
164 
165  if (cgameMenu == nullptr)
166  return nullptr;
167 
168  for (int i = 0; i < len; i++) {
169  const cgame_api_t list = gameTypeList[i];
170  const cgame_export_t* cgame = list(import);
171  if (Q_streq(cgame->menu, cgameMenu)) {
172  return cgame;
173  }
174  }
175 
176  return nullptr;
177 }
178 #endif
179 
181 
186 
197 {
198  if (index < 0 || index >= lengthof(characters))
199  Com_Error(ERR_DROP, "Out of bounds character access");
200 
201  return &characters[index];
202 }
203 
211 {
212  const int size = lengthof(characters);
213  for (int i = 0; i < size; i++) {
214  character_t* chr = &characters[i];
215  if (chr->ucn == ucn)
216  return chr;
217  }
218  return nullptr;
219 }
220 
227 {
228  return lengthof(characters);
229 }
230 
231 const char* GAME_GetCurrentName (void)
232 {
233  const cgame_export_t* cgame = GAME_GetCurrentType();
234  if (cgame == nullptr)
235  return nullptr;
236  return cgame->menu;
237 }
244 {
245  for (int i = 0; i < MAX_ACTIVETEAM; i++)
246  characters[i].init();
248  UI_ExecuteConfunc("team_membersclear");
249 }
250 
251 void GAME_AppendTeamMember (int memberIndex, const char* teamDefID, const equipDef_t* ed)
252 {
253  if (ed == nullptr)
254  Com_Error(ERR_DROP, "No equipment definition given");
255 
256  character_t* chr = GAME_GetCharacter(memberIndex);
257 
258  CL_GenerateCharacter(chr, teamDefID);
259 
260  const objDef_t* weapon = chr->teamDef->onlyWeapon;
261  if (chr->teamDef->robot && !weapon) {
262  /* This is likely an UGV, try to guess which one and get the weapon */
263  const char* ugvId = strstr(chr->teamDef->id, "ugv");
264  const ugv_t* ugv = Com_GetUGVByIDSilent(ugvId);
265  if (ugv)
266  weapon = INVSH_GetItemByID(ugv->weapon);
267  }
268  /* pack equipment */
269  cls.i.EquipActor(chr, ed, weapon, GAME_GetChrMaxLoad(chr));
270 
271  LIST_AddPointer(&chrDisplayList, (void*)chr);
272 
273  UI_ExecuteConfunc("team_memberadd %i \"%s\" \"%s\" %i", memberIndex, chr->name, chr->head, chr->headSkin);
274 }
275 
276 void GAME_GenerateTeam (const char* teamDefID, const equipDef_t* ed, int teamMembers)
277 {
278  if (teamMembers > GAME_GetCharacterArraySize())
279  Com_Error(ERR_DROP, "More than the allowed amount of team members");
280 
281  if (ed == nullptr)
282  Com_Error(ERR_DROP, "No equipment definition given");
283 
285 
286  for (int i = 0; i < teamMembers; i++)
287  GAME_AppendTeamMember(i, teamDefID, ed);
288 }
289 
290 void GAME_ReloadMode (void)
291 {
292  const cgame_export_t* list = GAME_GetCurrentType();
293  if (list != nullptr) {
294  GAME_SetMode(nullptr);
295  GAME_SetMode(list);
296  }
297 }
298 
300 {
301  const cgame_export_t* list = GAME_GetCurrentType();
302  if (list != nullptr) {
303  const bool isMultiplayer = list->isMultiplayer == 1;
304  return isMultiplayer;
305  }
306 
307  return false;
308 }
309 
315 {
316  Cvar_Set("cl_onbattlescape", "0");
317  Com_Printf("Used inventory slots after battle: %i\n", cls.i.GetUsedSlots());
318 }
319 
325 void GAME_EndRoundAnnounce (int playerNum, int team)
326 {
328  const cgame_export_t* list = GAME_GetCurrentType();
329  if (list != nullptr && list->EndRoundAnnounce)
330  list->EndRoundAnnounce(playerNum, team);
331 }
332 
338 void GAME_DisplayItemInfo (uiNode_t* node, const char* string)
339 {
340  const cgame_export_t* list = GAME_GetCurrentType();
341  if (list != nullptr && list->GetModelForItem) {
342  const char* model = list->GetModelForItem(string);
343  UI_DrawModelNode(node, model);
344  }
345 }
346 
347 void GAME_SetServerInfo (const char* server, const char* serverport)
348 {
349  Q_strncpyz(cls.servername, server, sizeof(cls.servername));
350  Q_strncpyz(cls.serverport, serverport, sizeof(cls.serverport));
351 }
352 
356 static void CL_QueryMasterServer (const char* action, http_callback_t callback)
357 {
358  HTTP_GetURL(va("%s/ufo/masterserver.php?%s", masterserver_url->string, action), callback);
359 }
360 
361 bool GAME_HandleServerCommand (const char* command, dbuffer* msg)
362 {
363  const cgame_export_t* list = GAME_GetCurrentType();
364  if (!list || list->HandleServerCommand == nullptr)
365  return false;
366 
367  return list->HandleServerCommand(command, msg);
368 }
369 
370 void GAME_AddChatMessage (const char* format, ...)
371 {
372  va_list argptr;
373  char string[4096];
374 
375  const cgame_export_t* list = GAME_GetCurrentType();
376  if (!list || list->AddChatMessage == nullptr)
377  return;
378 
380 
381  va_start(argptr, format);
382  Q_vsnprintf(string, sizeof(string), format, argptr);
383  va_end(argptr);
384 
385  list->AddChatMessage(string);
386 }
387 
388 bool GAME_IsTeamEmpty (void)
389 {
391 }
392 
393 static void GAME_NET_OOB_Printf (struct net_stream* s, const char* format, ...)
394 {
395  va_list argptr;
396  char string[4096];
397 
398  va_start(argptr, format);
399  Q_vsnprintf(string, sizeof(string), format, argptr);
400  va_end(argptr);
401 
402  NET_OOB_Printf(s, "%s", string);
403 }
404 
405 static void GAME_NET_OOB_Printf2 (const char* format, ...)
406 {
407  va_list argptr;
408  char string[4096];
409 
410  va_start(argptr, format);
411  Q_vsnprintf(string, sizeof(string), format, argptr);
412  va_end(argptr);
413 
414  NET_OOB_Printf(cls.netStream, "%s", string);
415 }
416 
417 static void GAME_UI_Popup (const char* title, const char* format, ...)
418 {
419  va_list argptr;
420 
421  va_start(argptr, format);
422  Q_vsnprintf(popupText, sizeof(popupText), format, argptr);
423  va_end(argptr);
424 
425  UI_Popup(title, popupText);
426 }
427 
428 static char* GAME_StrDup (const char* string)
429 {
430  return Mem_PoolStrDup(string, cl_genericPool, 0);
431 }
432 
433 static void GAME_Free (void* ptr)
434 {
435  Mem_Free(ptr);
436 }
437 
438 static memPool_t* GAME_CreatePool (const char* name)
439 {
440  return Mem_CreatePool(name);
441 }
442 
443 static void GAME_FreePool (memPool_t* pool)
444 {
445  Mem_FreePool(pool);
446 }
447 
448 static char* GAME_PoolStrDup (const char* in, memPool_t* pool, const int tagNum)
449 {
450  return Mem_PoolStrDup(in, pool, tagNum);
451 }
452 
453 static void GAME_DestroyInventory (Inventory* const inv)
454 {
455  cls.i.destroyInventory(inv);
456 }
457 
458 static void GAME_EquipActor (character_t* const chr, const equipDef_t* ed, const objDef_t* weapon, int maxWeight)
459 {
460  cls.i.EquipActor(chr, ed, weapon, maxWeight);
461 }
462 
463 static bool GAME_RemoveFromInventory (Inventory* const i, const invDef_t* container, Item* fItem)
464 {
465  return cls.i.removeFromInventory(i, container, fItem);
466 }
467 
468 static void GAME_WebUpload (int category, const char* filename)
469 {
470  WEB_CGameUpload(GAME_GetCurrentName(), category, filename);
471 }
472 
473 static void GAME_WebDelete (int category, const char* filename)
474 {
475  WEB_CGameDelete(GAME_GetCurrentName(), category, filename);
476 }
477 
478 static void GAME_WebDownloadFromUser (int category, const char* filename, int userId)
479 {
480  WEB_CGameDownloadFromUser(GAME_GetCurrentName(), category, filename, userId);
481 }
482 
483 static void GAME_WebListForUser (int category, int userId)
484 {
485  WEB_CGameListForUser(GAME_GetCurrentName(), category, userId);
486 }
487 
489 {
491 }
492 
494 {
496 }
497 
498 static void GAME_CollectItems (void* data, int won, void (*collectItem)(void*, const objDef_t*, int), void (*collectAmmo) (void* , const Item*), void (*ownitems) (const Inventory*))
499 {
500  le_t* le = nullptr;
501  while ((le = LE_GetNextInUse(le))) {
502  /* Winner collects everything on the floor, and everything carried
503  * by surviving actors. Loser only gets what their living team
504  * members carry. */
505  if (LE_IsItem(le)) {
506  if (won) {
507  Item* i = le->getFloorContainer();
508  for ( ; i; i = i->getNext()) {
509  collectItem(data, i->def(), 1);
510  if (i->isReloadable() && i->getAmmoLeft() > 0)
511  collectAmmo(data, i);
512  }
513  }
514  } else if (LE_IsActor(le)) {
515  /* The items are already dropped to floor and are available
516  * as ET_ITEM if the actor is dead; or the actor is not ours. */
517  /* First of all collect armour of dead or stunned actors (if won). */
518  if (won && LE_IsDead(le)) {
519  Item* item = le->inv.getArmour();
520  if (item)
521  collectItem(data, item->def(), 1);
522  } else if (le->team == cls.team && !LE_IsDead(le)) {
523  /* Finally, the living actor from our team. */
524  ownitems(&le->inv);
525  }
526  }
527  }
528 }
529 
533 static void GAME_CollectAliens (void* data, void (*collect)(void*, const teamDef_t*, int, bool))
534 {
535  le_t* le = nullptr;
536 
537  while ((le = LE_GetNextInUse(le))) {
538  if (LE_IsActor(le) && LE_IsAlien(le)) {
539  assert(le->teamDef);
540 
541  if (LE_IsStunned(le))
542  collect(data, le->teamDef, 1, false);
543  else if (LE_IsDead(le))
544  collect(data, le->teamDef, 1, true);
545  }
546  }
547 }
548 
549 static int UI_DrawString_ (const char* fontID, align_t align, int x, int y, const char* c)
550 {
551  return UI_DrawString(fontID, align, x, y, 0, 0, 0, c);
552 }
553 
554 static void UI_PushWindow_ (const char* name)
555 {
556  UI_PushWindow(name);
557 }
558 
559 static void UI_DrawNormImageByName_ (bool flip, float x, float y, float w, float h, float sh, float th, float sl, float tl, const char* name)
560 {
561  UI_DrawNormImageByName(flip, x, y, w, h, sh, th, sl, tl, name);
562 }
563 
564 static void R_UploadAlpha_ (const char* name, const byte* alphaData)
565 {
566  image_t* image = R_GetImage(name);
567  if (!image) {
568  Com_Printf("Could not find image '%s'\n", name);
569  return;
570  }
571  R_UploadAlpha(image, alphaData);
572 }
573 
574 static void R_DrawImageCentered (int x, int y, const char* name)
575 {
576  image_t* image = R_FindImage(name, it_pic);
577  if (image)
578  R_DrawImage(x - image->width / 2, y - image->height / 2, image);
579 }
580 
581 static const char* Com_EParse_ (const char** text, const char* errhead, const char* errinfo)
582 {
583  return Com_EParse(text, errhead, errinfo);
584 }
585 
587 {
588  static cgame_import_t gameImport;
589  static cgame_import_t* cgi = nullptr;
590 
591  if (cgi == nullptr) {
592  cgi = &gameImport;
593 
594  cgi->ui_inventory = &ui_inventory;
595  cgi->csi = &csi;
596 
597  cgi->r_xviAlpha = geoscapeData.r_xviAlpha;
598  cgi->r_radarPic = geoscapeData.r_radarPic;
599  cgi->r_radarSourcePic = geoscapeData.r_radarSourcePic;
600 
602  cgi->Cmd_AddCommand = Cmd_AddCommand;
603  cgi->Cmd_Argc = Cmd_Argc;
604  cgi->Cmd_Args = Cmd_Args;
605  cgi->Cmd_Argv = Cmd_Argv;
606  cgi->Cmd_ExecuteString = Cmd_ExecuteString;
607  cgi->Cmd_RemoveCommand = Cmd_RemoveCommand;
608  cgi->Cmd_TableAddList = Cmd_TableAddList;
609  cgi->Cmd_TableRemoveList = Cmd_TableRemoveList;
610  cgi->Cmd_AddParamCompleteFunction = Cmd_AddParamCompleteFunction;
611  cgi->Cmd_GenericCompleteFunction = Cmd_GenericCompleteFunction;
613 
614  cgi->Cbuf_AddText = Cbuf_AddText;
615  cgi->Cbuf_Execute = Cbuf_Execute;
616 
617  cgi->LIST_PrependString = LIST_PrependString;
618  cgi->LIST_AddString = LIST_AddString;
619  cgi->LIST_AddStringSorted = LIST_AddStringSorted;
620  cgi->LIST_AddPointer = LIST_AddPointer;
621  cgi->LIST_Add = LIST_Add;
624  cgi->LIST_Delete = LIST_Delete;
625  cgi->LIST_RemoveEntry = LIST_RemoveEntry;
626  cgi->LIST_IsEmpty = LIST_IsEmpty;
627  cgi->LIST_Count = LIST_Count;
630  cgi->LIST_Remove = LIST_Remove;
631  cgi->LIST_Sort = LIST_Sort;
633 
634  cgi->Cvar_Delete = Cvar_Delete;
636  cgi->Cvar_Get = Cvar_Get;
637  cgi->Cvar_GetInteger = Cvar_GetInteger;
638  cgi->Cvar_GetValue = Cvar_GetValue;
640  cgi->Cvar_Set = Cvar_Set;
641  cgi->Cvar_SetValue = Cvar_SetValue;
644 
645  cgi->FS_CloseFile = FS_CloseFile;
646  cgi->FS_FreeFile = FS_FreeFile;
647  cgi->FS_OpenFile = FS_OpenFile;
648  cgi->FS_LoadFile = FS_LoadFile;
649  cgi->FS_CheckFile = FS_CheckFile;
650  cgi->FS_WriteFile = FS_WriteFile;
651  cgi->FS_RemoveFile = FS_RemoveFile;
652  cgi->FS_Read = FS_Read;
653  cgi->FS_BuildFileList = FS_BuildFileList;
656 
657  cgi->UI_AddOption = UI_AddOption;
658  cgi->UI_ExecuteConfunc = UI_ExecuteConfunc;
659  cgi->UI_InitStack = UI_InitStack;
660  cgi->UI_Popup = GAME_UI_Popup;
661  cgi->UI_PopupList = UI_PopupList;
662  cgi->UI_PopWindow = UI_PopWindow;
663  cgi->UI_PushWindow = UI_PushWindow_;
664  cgi->UI_RegisterLinkedListText = UI_RegisterLinkedListText;
666  cgi->UI_MessageAddStack = UI_MessageAddStack;
667  cgi->UI_MessageResetStack = UI_MessageResetStack;
668  cgi->UI_TextScrollEnd = UI_TextScrollEnd;
669  cgi->UI_RegisterOption = UI_RegisterOption;
670  cgi->UI_RegisterText = UI_RegisterText;
671  cgi->UI_ResetData = UI_ResetData;
672  cgi->UI_UpdateInvisOptions = UI_UpdateInvisOptions;
673  cgi->UI_GetOption = UI_GetOption;
674  cgi->UI_SortOptions = UI_SortOptions;
677  cgi->UI_DrawString = UI_DrawString_;
679  cgi->UI_DrawNormImageByName = UI_DrawNormImageByName_;
680  cgi->UI_DrawRect = UI_DrawRect;
681  cgi->UI_DrawFill = UI_DrawFill;
682  cgi->UI_DrawTooltip = UI_DrawTooltip;
683  cgi->UI_GetNodeAbsPos = UI_GetNodeAbsPos;
684  cgi->UI_PopupButton = UI_PopupButton;
686  cgi->UI_ContainerNodeUpdateEquipment = UI_ContainerNodeUpdateEquipment;
688  cgi->UI_DisplayNotice = UI_DisplayNotice;
690  cgi->UI_TextNodeSelectLine = UI_TextNodeSelectLine;
691 
692  cgi->CL_Translate = CL_Translate;
693 
694  cgi->NET_StreamSetCallback = NET_StreamSetCallback;
695  cgi->NET_Connect = NET_Connect;
696  cgi->NET_ReadString = NET_ReadString;
697  cgi->NET_ReadStringLine = NET_ReadStringLine;
698  cgi->NET_ReadByte = NET_ReadByte;
699  cgi->NET_ReadShort = NET_ReadShort;
700  cgi->NET_ReadLong = NET_ReadLong;
701  cgi->NET_WriteByte = NET_WriteByte;
702  cgi->NET_WriteShort = NET_WriteShort;
703  cgi->NET_ReadMsg = NET_ReadMsg;
705  cgi->NET_StreamSetData = NET_StreamSetData;
706  cgi->NET_StreamFree = NET_StreamFree;
708  cgi->NET_SockaddrToStrings = NET_SockaddrToStrings;
710  cgi->NET_DatagramBroadcast = NET_DatagramBroadcast;
711  cgi->NET_DatagramSocketClose = NET_DatagramSocketClose;
712  cgi->NET_OOB_Printf = GAME_NET_OOB_Printf;
713  cgi->NET_OOB_Printf2 = GAME_NET_OOB_Printf2;
714 
715  cgi->Com_ServerState = Com_ServerState;
716  cgi->Com_Printf = Com_Printf;
717  cgi->Com_DPrintf = Com_DPrintf;
718  cgi->Com_Error = Com_Error;
723  cgi->Com_RegisterConstList = Com_RegisterConstList;
724  cgi->Com_UnregisterConstList = Com_UnregisterConstList;
726  cgi->Com_GetConstIntFromNamespace = Com_GetConstIntFromNamespace;
727  cgi->Com_GetConstInt = Com_GetConstInt;
728  cgi->Com_EParse = Com_EParse_;
729  cgi->Com_EParseValue = Com_EParseValue;
730  cgi->Com_ParseBoolean = Com_ParseBoolean;
731  cgi->Com_ParseList = Com_ParseList;
732  cgi->Com_ParseBlock = Com_ParseBlock;
733  cgi->Com_ParseBlockToken = Com_ParseBlockToken;
736  cgi->Com_UFOShortNameToID = Com_UFOShortNameToID;
737  cgi->Com_GetUFOIdsNum = Com_GetUfoIdsNum;
738  cgi->Com_GetDropShipIdsNum = Com_GetDropShipIdsNum;
739  cgi->Com_GetHumanAircraftIdsNum = Com_GetHumanAircraftIdsNum;
741  cgi->Com_SetGameType = Com_SetGameType;
742  cgi->Com_RegisterConstInt = Com_RegisterConstInt;
743  cgi->Com_UnregisterConstVariable = Com_UnregisterConstVariable;
744  cgi->Com_Drop = Com_Drop;
747  cgi->Com_DropShipShortNameToID = Com_DropShipShortNameToID;
748 
749  cgi->SV_ShutdownWhenEmpty = SV_ShutdownWhenEmpty;
750  cgi->SV_Shutdown = SV_Shutdown;
751 
752  cgi->CL_Drop = CL_Drop;
753  cgi->CL_Milliseconds = CL_Milliseconds;
755  cgi->CL_GetPlayerNum = CL_GetPlayerNum;
756  cgi->CL_SetClientState = CL_SetClientState;
757  cgi->CL_GetClientState = CL_GetClientState;
758  cgi->CL_Disconnect = CL_Disconnect;
759  cgi->CL_QueryMasterServer = CL_QueryMasterServer;
760 
761  cgi->GAME_SwitchCurrentSelectedMap = GAME_SwitchCurrentSelectedMap;
763  cgi->GAME_GetCurrentTeam = GAME_GetCurrentTeam;
764  cgi->GAME_StrDup = GAME_StrDup;
765  cgi->GAME_AutoTeam = GAME_AutoTeam;
767  cgi->GAME_GetCharacterArraySize = GAME_GetCharacterArraySize;
768  cgi->GAME_IsTeamEmpty = GAME_IsTeamEmpty;
769  cgi->GAME_LoadDefaultTeam = GAME_LoadDefaultTeam;
770  cgi->GAME_AppendTeamMember = GAME_AppendTeamMember;
771  cgi->GAME_ReloadMode = GAME_ReloadMode;
772  cgi->GAME_SetServerInfo = GAME_SetServerInfo;
773  cgi->GAME_GetChrMaxLoad = GAME_GetChrMaxLoad;
774  cgi->GAME_LoadCharacter = GAME_LoadCharacter;
775  cgi->GAME_SaveCharacter = GAME_SaveCharacter;
776 
777  cgi->Alloc = _Mem_Alloc;
778  cgi->Free = GAME_Free;
780  cgi->FreePool = GAME_FreePool;
782 
783  cgi->R_LoadImage = R_LoadImage;
784  cgi->R_SoftenTexture = R_SoftenTexture;
785  cgi->R_ImageExists = R_ImageExists;
786  cgi->R_Color = R_Color;
787  cgi->R_DrawLineStrip = R_DrawLineStrip;
788  cgi->R_DrawLine = R_DrawLine;
789  cgi->R_DrawFill = R_DrawFill;
790  cgi->R_DrawRect = R_DrawRect;
791  cgi->R_DrawBloom = R_DrawBloom;
792  cgi->R_Draw2DMapMarkers = R_Draw2DMapMarkers;
793  cgi->R_Draw3DMapMarkers = R_Draw3DMapMarkers;
794  cgi->R_UploadAlpha = R_UploadAlpha_;
795  cgi->R_DrawImageCentered = R_DrawImageCentered;
796 
797  cgi->S_SetSampleRepeatRate = S_SetSampleRepeatRate;
798  cgi->S_StartLocalSample = S_StartLocalSample;
799 
800  cgi->CL_GenerateCharacter = CL_GenerateCharacter;
801  cgi->CL_OnBattlescape = CL_OnBattlescape;
802 
804  cgi->CL_UpdateCharacterValues = CL_UpdateCharacterValues;
805 
806  cgi->SetNextUniqueCharacterNumber = GAME_SetNextUniqueCharacterNumber;
807  cgi->GetNextUniqueCharacterNumber = GAME_GetNextUniqueCharacterNumber;
808 
809  cgi->CollectItems = GAME_CollectItems;
810  cgi->CollectAliens = GAME_CollectAliens;
811 
813  cgi->INV_DestroyInventory = GAME_DestroyInventory;
814  cgi->INV_EquipActor = GAME_EquipActor;
815  cgi->INV_RemoveFromInventory = GAME_RemoveFromInventory;
816 
817  cgi->INV_ItemDescription = INV_ItemDescription;
818  cgi->INV_ItemMatchesFilter = INV_ItemMatchesFilter;
820  cgi->INV_GetFilterTypeID = INV_GetFilterTypeID;
821 
822  cgi->WEB_Upload = GAME_WebUpload;
823  cgi->WEB_Delete = GAME_WebDelete;
824  cgi->WEB_DownloadFromUser = GAME_WebDownloadFromUser;
825  cgi->WEB_ListForUser = GAME_WebListForUser;
826 
829 
830  cgi->BEP_Evaluate = BEP_Evaluate;
831 
832  cgi->Sys_Error = Sys_Error;
833 
834  cgi->HUD_InitUI = HUD_InitUI;
835  cgi->HUD_DisplayMessage = HUD_DisplayMessage;
836 
837  cgi->XML_AddBool = XML_AddBool;
838  cgi->XML_AddBoolValue = XML_AddBoolValue;
839  cgi->XML_AddByte = XML_AddByte;
840  cgi->XML_AddByteValue = XML_AddByteValue;
841  cgi->XML_AddDate = XML_AddDate;
842  cgi->XML_AddDouble = XML_AddDouble;
843  cgi->XML_AddDoubleValue = XML_AddDoubleValue;
844  cgi->XML_AddFloat = XML_AddFloat;
845  cgi->XML_AddFloatValue = XML_AddFloatValue;
846  cgi->XML_AddInt = XML_AddInt;
847  cgi->XML_AddIntValue = XML_AddIntValue;
848  cgi->XML_AddLong = XML_AddLong;
849  cgi->XML_AddLongValue = XML_AddLongValue;
850  cgi->XML_AddNode = XML_AddNode;
851  cgi->XML_AddPos2 = XML_AddPos2;
852  cgi->XML_AddPos3 = XML_AddPos3;
853  cgi->XML_AddShort = XML_AddShort;
854  cgi->XML_AddShortValue = XML_AddShortValue;
855  cgi->XML_AddString = XML_AddString;
856  cgi->XML_AddStringValue = XML_AddStringValue;
857 
858  cgi->XML_GetBool = XML_GetBool;
859  cgi->XML_GetInt = XML_GetInt;
860  cgi->XML_GetShort = XML_GetShort;
861  cgi->XML_GetLong = XML_GetLong;
863  cgi->XML_GetFloat = XML_GetFloat;
864  cgi->XML_GetDouble = XML_GetDouble;
865  cgi->XML_Parse = XML_Parse;
866  cgi->XML_GetPos2 = XML_GetPos2;
868  cgi->XML_GetPos3 = XML_GetPos3;
870  cgi->XML_GetDate = XML_GetDate;
871  cgi->XML_GetNode = XML_GetNode;
873  }
874 
875  cgi->cgameType = t;
876 
877  return cgi;
878 }
879 
880 static const int TAG_INVENTORY = 17462;
881 
882 static void GAME_FreeInventory (void* data)
883 {
884  Mem_Free(data);
885 }
886 
887 static void* GAME_AllocInventoryMemory (size_t size)
888 {
889  return Mem_PoolAlloc(size, cl_genericPool, TAG_INVENTORY);
890 }
891 
892 
893 static void GAME_FreeAllInventory (void)
894 {
895  Mem_FreeTag(cl_genericPool, TAG_INVENTORY);
896 }
897 
899 
900 void GAME_UnloadGame (void)
901 {
902 #ifndef HARD_LINKED_CGAME
903  if (cls.cgameLibrary) {
904  GAME_SetMode(nullptr);
905  Com_Printf("Unload the cgame library\n");
906  SDL_UnloadObject(cls.cgameLibrary);
907  cls.cgameLibrary = nullptr;
908  }
909 #endif
910 }
911 
913 {
914  cls.currentSelectedMap += step;
915 
916  if (cls.currentSelectedMap < 0)
919 }
920 
922 {
924 }
925 
927 {
928  return cls.team;
929 }
930 
932 {
933  const cgame_export_t* list = GAME_GetCurrentType();
934  if (list && list->MapDraw)
935  list->MapDraw(data);
936 }
937 
939 {
940  const cgame_export_t* list = GAME_GetCurrentType();
941  if (list && list->MapDrawMarkers)
942  list->MapDrawMarkers(node);
943 }
944 
945 void GAME_MapClick (uiNode_t* node, int x, int y, const vec2_t pos)
946 {
947  const cgame_export_t* list = GAME_GetCurrentType();
948  if (list && list->MapClick)
949  list->MapClick(node, x, y, pos);
950 }
951 
952 void GAME_SetMode (const cgame_export_t* gametype)
953 {
954  const cgame_export_t* list;
955 
956  if (cls.gametype == gametype)
957  return;
958 
961  Cvar_FullSet("gamemode", "", CVAR_NOSET);
962 
963  list = GAME_GetCurrentType();
964  if (list) {
965  Com_Printf("Shutdown gametype '%s'\n", list->name);
966  list->Shutdown();
967  cvarListener->onGameModeChange();
968  cmdListener->onGameModeChange();
969 
970  /* we dont need to go back to "main" stack if we are already on this stack */
971  if (!UI_IsWindowOnStack("main"))
972  UI_InitStack("main", "");
973  }
974 
975  cls.gametype = gametype;
976 
977  CL_Disconnect();
978 
979  list = GAME_GetCurrentType();
980  if (list) {
981  Com_Printf("Change gametype to '%s'\n", list->name);
982  /* inventory structure switched/initialized */
984  cls.i.initInventory(list->name, &csi, &inventoryImport);
985  list->Init();
986  Cvar_FullSet("gamemode", list->menu, CVAR_NOSET);
987  }
988 }
989 
990 static void UI_MapInfoGetNext (int step)
991 {
992  int ref = cls.currentSelectedMap;
993 
994  for (;;) {
995  cls.currentSelectedMap += step;
996  if (cls.currentSelectedMap < 0)
999 
1001 
1002  /* avoid infinite loop */
1003  if (ref == cls.currentSelectedMap)
1004  break;
1005  /* special purpose maps are not startable without the specific context */
1006  if (md->mapTheme[0] == '.')
1007  continue;
1008 
1009  if (md->mapTheme[0] != '+' && FS_CheckFile("maps/%s.bsp", md->mapTheme) != -1)
1010  break;
1011  if (md->mapTheme[0] == '+' && FS_CheckFile("maps/%s.ump", md->mapTheme + 1) != -1)
1012  break;
1013  }
1014 }
1015 
1019 static void UI_MapInfo (int step)
1020 {
1021  const cgame_export_t* list = GAME_GetCurrentType();
1022 
1023  if (!list)
1024  return;
1025 
1026  if (!csi.numMDs)
1027  return;
1028 
1029  UI_MapInfoGetNext(step);
1030 
1031  const mapDef_t* md = list->MapInfo(step);
1032  if (!md)
1033  return;
1034 
1035  const char* mapname = md->mapTheme;
1036  /* skip random map char. */
1037  Cvar_Set("mn_svmapid", "%s", md->id);
1038  if (mapname[0] == '+') {
1039  Cvar_Set("mn_svmapname", "%s %s", md->mapTheme, md->params ? (const char*)LIST_GetRandom(md->params) : "");
1040  mapname++;
1041  } else {
1042  Cvar_Set("mn_svmapname", "%s", md->mapTheme);
1043  }
1044 
1045  if (R_ImageExists("pics/maps/shots/%s", mapname))
1046  Cvar_Set("mn_mappic", "maps/shots/%s", mapname);
1047  else
1048  Cvar_Set("mn_mappic", "maps/shots/default");
1049 
1050  if (R_ImageExists("pics/maps/shots/%s_2", mapname))
1051  Cvar_Set("mn_mappic2", "maps/shots/%s_2", mapname);
1052  else
1053  Cvar_Set("mn_mappic2", "maps/shots/default");
1054 
1055  if (R_ImageExists("pics/maps/shots/%s_3", mapname))
1056  Cvar_Set("mn_mappic3", "maps/shots/%s_3", mapname);
1057  else
1058  Cvar_Set("mn_mappic3", "maps/shots/default");
1059 }
1060 
1061 static void UI_RequestMapList_f (void)
1062 {
1063  if (Cmd_Argc() != 2) {
1064  Com_Printf("Usage: %s <callback>\n", Cmd_Argv(0));
1065  return;
1066  }
1067 
1068  if (!csi.numMDs)
1069  return;
1070 
1071  const char* callbackCmd = Cmd_Argv(1);
1072 
1073  Cbuf_AddText("%s begin\n", callbackCmd);
1074 
1075  const mapDef_t* md;
1076  const bool multiplayer = GAME_IsMultiplayer();
1077  MapDef_ForeachCondition(md, multiplayer ? md->multiplayer : md->singleplayer) {
1078  const char* preview;
1079 
1080  /* special purpose maps are not startable without the specific context */
1081  if (md->mapTheme[0] == '.')
1082  continue;
1083 
1084  /* do we have the map file? */
1085  if (md->mapTheme[0] != '+' && FS_CheckFile("maps/%s.bsp", md->mapTheme) == -1)
1086  continue;
1087  if (md->mapTheme[0] == '+' && FS_CheckFile("maps/%s.ump", md->mapTheme + 1) == -1)
1088  continue;
1089 
1090  preview = md->mapTheme;
1091  if (preview[0] == '+')
1092  preview++;
1093  if (!R_ImageExists("pics/maps/shots/%s", preview))
1094  preview = "default";
1095 
1096  Cbuf_AddText("%s add \"%s\" \"%s\"\n", callbackCmd, md->id, preview);
1097  }
1098  Cbuf_AddText("%s end\n", callbackCmd);
1099 }
1100 
1101 static void UI_GetMaps_f (void)
1102 {
1103  UI_MapInfo(0);
1104 }
1105 
1109 static void UI_NextMap_f (void)
1110 {
1111  UI_MapInfo(1);
1112 }
1113 
1117 static void UI_PreviousMap_f (void)
1118 {
1119  UI_MapInfo(-1);
1120 }
1121 
1122 static void UI_SelectMap_f (void)
1123 {
1124  if (Cmd_Argc() != 2) {
1125  Com_Printf("Usage: %s <mapname>\n", Cmd_Argv(0));
1126  return;
1127  }
1128 
1129  if (!csi.numMDs)
1130  return;
1131 
1132  const char* mapname = Cmd_Argv(1);
1133  int i = 0;
1134  const mapDef_t* md;
1135 
1136  MapDef_Foreach(md) {
1137  i++;
1138  if (!Q_streq(md->mapTheme, mapname))
1139  continue;
1140  cls.currentSelectedMap = i - 1;
1141  UI_MapInfo(0);
1142  return;
1143  }
1144 
1145  i = 0;
1146  MapDef_Foreach(md) {
1147  i++;
1148  if (!Q_streq(md->id, mapname))
1149  continue;
1150  cls.currentSelectedMap = i - 1;
1151  UI_MapInfo(0);
1152  return;
1153  }
1154 
1155  Com_Printf("Could not find map %s\n", mapname);
1156 }
1157 
1159 static const value_t cgame_vals[] = {
1160  {"window", V_STRING, offsetof(cgameType_t, window), 0},
1161  {"name", V_STRING, offsetof(cgameType_t, name), 0},
1162  {"equipments", V_LIST, offsetof(cgameType_t, equipmentList), 0},
1163 
1164  {nullptr, V_NULL, 0, 0}
1165 };
1166 
1167 void GAME_ParseModes (const char* name, const char** text)
1168 {
1169  int i;
1170 
1171  /* search for equipments with same name */
1172  for (i = 0; i < numCGameTypes; i++)
1173  if (Q_streq(name, cgameTypes[i].id))
1174  break;
1175 
1176  if (i < numCGameTypes) {
1177  Com_Printf("GAME_ParseModes: cgame def \"%s\" with same name found, second ignored\n", name);
1178  return;
1179  }
1180 
1181  if (i >= MAX_CGAMETYPES)
1182  Sys_Error("GAME_ParseModes: MAX_CGAMETYPES exceeded");
1183 
1184  /* initialize the equipment definition */
1185  cgameType_t* cgame = &cgameTypes[numCGameTypes++];
1186  OBJZERO(*cgame);
1187 
1188  Q_strncpyz(cgame->id, name, sizeof(cgame->id));
1189 
1190  Com_ParseBlock(name, text, cgame, cgame_vals, nullptr);
1191 }
1192 
1193 #ifndef HARD_LINKED_CGAME
1194 static bool GAME_LoadGame (const char* path, const char* name)
1195 {
1196  char fullPath[MAX_OSPATH];
1197 
1198  Com_sprintf(fullPath, sizeof(fullPath), "%s/cgame-%s_" CPUSTRING ".%s", path, name, SO_EXT);
1199  cls.cgameLibrary = SDL_LoadObject(fullPath);
1200  if (!cls.cgameLibrary) {
1201  Com_sprintf(fullPath, sizeof(fullPath), "%s/cgame-%s.%s", path, name, SO_EXT);
1202  cls.cgameLibrary = SDL_LoadObject(fullPath);
1203  }
1204 
1205  if (cls.cgameLibrary) {
1206  Com_Printf("found at '%s'\n", path);
1207  return true;
1208  } else {
1209  Com_Printf("not found at '%s'\n", path);
1210  Com_DPrintf(DEBUG_SYSTEM, "%s\n", SDL_GetError());
1211  return false;
1212  }
1213 }
1214 #endif
1215 
1217 {
1218  const char* name = t->id;
1219 #ifndef HARD_LINKED_CGAME
1220  if (cls.cgameLibrary)
1221  Com_Error(ERR_FATAL, "GAME_GetCGameAPI without GAME_UnloadGame");
1222 
1223  Com_Printf("------- Loading cgame-%s.%s -------\n", name, SO_EXT);
1224 
1225 #ifdef PKGLIBDIR
1226  GAME_LoadGame(PKGLIBDIR, name);
1227 #endif
1228 
1229  /* now run through the search paths */
1230  const char* path = nullptr;
1231  while (!cls.cgameLibrary) {
1232  path = FS_NextPath(path);
1233  if (!path)
1234  /* couldn't find one anywhere */
1235  return nullptr;
1236  else if (GAME_LoadGame(path, name))
1237  break;
1238  }
1239 
1240  cgame_api_t GetCGameAPI = (cgame_api_t)(uintptr_t)SDL_LoadFunction(cls.cgameLibrary, "GetCGameAPI");
1241  if (!GetCGameAPI) {
1242  GAME_UnloadGame();
1243  return nullptr;
1244  }
1245 #endif
1246 
1247  /* sanity checks */
1248  if (!LIST_IsEmpty(t->equipmentList)) {
1249  LIST_Foreach(t->equipmentList, char const, equipID) {
1250  if (INV_GetEquipmentDefinitionByID(equipID) == nullptr)
1251  Sys_Error("Could not find the equipDef '%s' in the cgame mode: '%s'", equipID, name);
1252  }
1253  }
1254 
1255  return GetCGameAPI(GAME_GetImportData(t));
1256 }
1257 
1259 {
1260 #ifdef HARD_LINKED_CGAME
1261  cgameMenu = t->window;
1262 #endif
1263  return GAME_GetCGameAPI(t);
1264 }
1265 
1269 static void GAME_SetMode_f (void)
1270 {
1271  const char* modeName;
1272  if (Cmd_Argc() == 2)
1273  modeName = Cmd_Argv(1);
1274  else
1275  modeName = UI_GetActiveWindowName();
1276 
1277  if (modeName[0] == '\0')
1278  return;
1279 
1280  for (int i = 0; i < numCGameTypes; i++) {
1281  cgameType_t* t = &cgameTypes[i];
1282  if (Q_streq(t->window, modeName)) {
1283  const cgame_export_t* gametype;
1284  GAME_UnloadGame();
1285 
1286  gametype = GAME_GetCGameAPI_(t);
1287  GAME_SetMode(gametype);
1288 
1289  return;
1290  }
1291  }
1292  Com_Printf("GAME_SetMode_f: Mode '%s' not found\n", modeName);
1293 }
1294 
1296 {
1297  const cgame_export_t* list = GAME_GetCurrentType();
1298 
1299  if (od->isArmour()) {
1300  const char* teamDefID = GAME_GetTeamDef();
1301  const teamDef_t* teamDef = Com_GetTeamDefinitionByID(teamDefID);
1302 
1303  /* Don't allow armour for other teams */
1304  if (teamDef != nullptr && !CHRSH_IsArmourUseableForTeam(od, teamDef))
1305  return false;
1306  }
1307 
1308  if (list && list->IsItemUseable)
1309  return list->IsItemUseable(od);
1310 
1311  return true;
1312 }
1313 
1326 void GAME_HandleResults (dbuffer* msg, int winner, int* numSpawned, int* numAlive, int numKilled[][MAX_TEAMS], int numStunned[][MAX_TEAMS], bool nextmap)
1327 {
1328  const cgame_export_t* list = GAME_GetCurrentType();
1329  if (list)
1330  list->Results(msg, winner, numSpawned, numAlive, numKilled, numStunned, nextmap);
1331  else
1332  CL_Drop();
1333 }
1334 
1341 static void GAME_NetSendItem (dbuffer* buf, const Item* item, containerIndex_t container, int x, int y)
1342 {
1343  const int ammoIdx = item->ammoDef() ? item->ammoDef()->idx : NONE;
1344  const eventRegister_t* eventData = CL_GetEvent(EV_INV_TRANSFER);
1345  assert(item->def());
1346  Com_DPrintf(DEBUG_CLIENT, "GAME_NetSendItem: Add item %s to container %i (t=%i:a=%i:m=%i) (x=%i:y=%i)\n",
1347  item->def()->id, container, item->def()->idx, item->getAmmoLeft(), ammoIdx, x, y);
1348  NET_WriteFormat(buf, eventData->formatString, item->def()->idx, item->getAmmoLeft(), ammoIdx, container, x, y, item->rotated, item->getAmount());
1349 }
1350 
1354 static void GAME_NetSendInventory (dbuffer* buf, const Inventory* inv)
1355 {
1356  const int nr = inv->countItems();
1357 
1358  NET_WriteShort(buf, nr);
1359 
1360  for (containerIndex_t container = 0; container < CID_MAX; container++) {
1361  if (INVDEF(container)->temp)
1362  continue;
1363  const Item* ic;
1364  for (ic = inv->getContainer2(container); ic; ic = ic->getNext()) {
1365  GAME_NetSendItem(buf, ic, container, ic->getX(), ic->getY());
1366  }
1367  }
1368 }
1369 
1375 static void GAME_NetSendCharacter (dbuffer* buf, const character_t* chr)
1376 {
1377  if (!chr)
1378  Com_Error(ERR_DROP, "No character given");
1379  if (chr->fieldSize != ACTOR_SIZE_2x2 && chr->fieldSize != ACTOR_SIZE_NORMAL)
1380  Com_Error(ERR_DROP, "Invalid character size given for character '%s': %i",
1381  chr->name, chr->fieldSize);
1382  if (chr->teamDef == nullptr)
1383  Com_Error(ERR_DROP, "Character with no teamdef set (%s)", chr->name);
1384 
1385  NET_WriteByte(buf, chr->fieldSize);
1386  NET_WriteShort(buf, chr->ucn);
1387  NET_WriteString(buf, chr->name);
1388 
1389  /* model */
1390  NET_WriteString(buf, chr->path);
1391  NET_WriteString(buf, chr->body);
1392  NET_WriteString(buf, chr->head);
1393  NET_WriteByte(buf, chr->bodySkin);
1394  NET_WriteByte(buf, chr->headSkin);
1395 
1396  NET_WriteShort(buf, chr->HP);
1397  NET_WriteShort(buf, chr->maxHP);
1398  NET_WriteByte(buf, chr->teamDef->idx);
1399  NET_WriteByte(buf, chr->gender);
1400  NET_WriteByte(buf, chr->STUN);
1401  NET_WriteByte(buf, chr->morale);
1402 
1403  for (int j = 0; j < chr->teamDef->bodyTemplate->numBodyParts(); ++j)
1404  NET_WriteByte(buf, chr->wounds.treatmentLevel[j]);
1405 
1406  for (int j = 0; j < SKILL_NUM_TYPES + 1; j++)
1407  NET_WriteLong(buf, chr->score.experience[j]);
1408  for (int j = 0; j < SKILL_NUM_TYPES; j++)
1409  NET_WriteByte(buf, chr->score.skills[j]);
1410  for (int j = 0; j < KILLED_NUM_TYPES; j++)
1411  NET_WriteShort(buf, chr->score.kills[j]);
1412  for (int j = 0; j < KILLED_NUM_TYPES; j++)
1413  NET_WriteShort(buf, chr->score.stuns[j]);
1415 }
1416 
1424 {
1425  const int teamSize = LIST_Count(team);
1426 
1427  /* header */
1429  NET_WriteByte(buf, teamSize);
1430 
1431  LIST_Foreach(team, character_t, chr) {
1432  Inventory* inv = &chr->inv;
1433 
1434  /* unlink all temp containers */
1435  inv->resetTempContainers();
1436 
1437  GAME_NetSendCharacter(buf, chr);
1438  GAME_NetSendInventory(buf, inv);
1439  }
1440 }
1441 
1442 const char* GAME_GetTeamDef (void)
1443 {
1444  const cgame_export_t* list = GAME_GetCurrentType();
1445 
1446  if (list && list->GetTeamDef)
1447  return list->GetTeamDef();
1448 
1449  const char* teamDefID = Cvar_GetString("cl_teamdef");
1450  if (teamDefID[0] == '\0')
1451  teamDefID = "phalanx";
1452  return teamDefID;
1453 }
1454 
1455 static bool GAME_Spawn (linkedList_t** chrList)
1456 {
1457  const size_t size = GAME_GetCharacterArraySize();
1458 
1459  /* If there is no active gametype we create a team with default values.
1460  * This is e.g. the case when someone starts a map with the map command */
1461  if (GAME_GetCurrentType() == nullptr || LIST_IsEmpty(chrDisplayList)) {
1462  const char* teamDefID = GAME_GetTeamDef();
1463  const equipDef_t* ed = INV_GetEquipmentDefinitionByID("multiplayer_initial");
1464 
1465  /* inventory structure switched/initialized */
1467  cls.i.initInventory("client", &csi, &inventoryImport);
1468  GAME_GenerateTeam(teamDefID, ed, size);
1469  }
1470 
1471  int count = 0;
1473  if (count > size)
1474  break;
1475  LIST_AddPointer(chrList, (void*)chr);
1476  }
1477 
1478  return true;
1479 }
1480 
1487 void GAME_StartBattlescape (bool isTeamPlay)
1488 {
1489  const cgame_export_t* list = GAME_GetCurrentType();
1490 
1491  Cvar_Set("cl_onbattlescape", "1");
1492 
1493  Cvar_Set("cl_maxworldlevel", "%i", cl.mapMaxLevel - 1);
1494  if (list != nullptr && list->StartBattlescape) {
1495  list->StartBattlescape(isTeamPlay);
1496  } else {
1497  HUD_InitUI("missionoptions");
1499  }
1500 }
1501 
1502 void GAME_InitMissionBriefing (const char* title)
1503 {
1504  const cgame_export_t* list = GAME_GetCurrentType();
1505 
1506  linkedList_t* victoryConditionsMsgIDs = nullptr;
1507  linkedList_t* missionBriefingMsgIDs = nullptr;
1508 
1509  /* allow the server to add e.g. the misc_mission victory condition */
1510  const char* serverVictoryMsgID = CL_GetConfigString(CS_VICTORY_CONDITIONS);
1511  if (Q_strvalid(serverVictoryMsgID))
1512  LIST_AddString(&victoryConditionsMsgIDs, serverVictoryMsgID);
1513 
1514  UI_PushWindow("mission_briefing");
1515 
1516  if (list != nullptr && list->InitMissionBriefing)
1517  list->InitMissionBriefing(&title, &victoryConditionsMsgIDs, &missionBriefingMsgIDs);
1518 
1519  /* if the cgame has nothing to contribute here, we will add a default victory condition */
1520  if (LIST_IsEmpty(victoryConditionsMsgIDs))
1521  LIST_AddString(&victoryConditionsMsgIDs, "*msgid:victory_condition_default");
1522 
1523  /* if the cgame has nothing to contribute here, we will add a default mission briefing */
1524  if (LIST_IsEmpty(missionBriefingMsgIDs))
1525  LIST_AddString(&missionBriefingMsgIDs, "*msgid:mission_briefing_default");
1526 
1527  UI_RegisterLinkedListText(TEXT_MISSIONBRIEFING, missionBriefingMsgIDs);
1530 }
1531 
1538 {
1539  const size_t size = lengthof(cl.teamList);
1540  for (int i = 0; i < size; i++) {
1541  UI_ExecuteConfunc("huddisable %i", i);
1542  }
1543 
1544  dbuffer msg;
1545  const cgame_export_t* list = GAME_GetCurrentType();
1546  if (list && list->InitializeBattlescape) {
1547  list->InitializeBattlescape(&msg, team);
1548  } else {
1549  const int teamSize = LIST_Count(team);
1550  dbuffer* m = &msg;
1551 
1553  NET_WriteByte(m, teamSize);
1554 
1555  LIST_Foreach(team, character_t, chr) {
1556  NET_WriteShort(m, chr->ucn);
1559  NET_WriteShort(m, NONE);
1560  NET_WriteShort(m, NONE);
1561  }
1562  }
1563  NET_WriteMsg(cls.netStream, msg);
1564 }
1565 
1570 {
1571  const cgame_export_t* list = GAME_GetCurrentType();
1572  bool spawnStatus;
1573 
1574  /* this callback is responsible to set up the teamlist */
1575  if (list && list->Spawn)
1576  spawnStatus = list->Spawn(&cl.chrList);
1577  else
1578  spawnStatus = GAME_Spawn(&cl.chrList);
1579 
1580  Com_Printf("Used inventory slots: %i\n", cls.i.GetUsedSlots());
1581 
1582  if (spawnStatus && !LIST_IsEmpty(cl.chrList)) {
1583  /* send team info */
1584  dbuffer msg;
1586  NET_WriteMsg(cls.netStream, msg);
1587  }
1588 }
1589 
1590 void GAME_StartMatch (void)
1591 {
1592  if (!LIST_IsEmpty(cl.chrList)) {
1593  dbuffer msg(12);
1596  NET_WriteMsg(cls.netStream, msg);
1597 
1599  }
1600 }
1601 
1602 const char* GAME_GetRelativeSavePath (char* buf, size_t bufSize)
1603 {
1604  Com_sprintf(buf, bufSize, "save/%s/", GAME_GetCurrentName());
1605  return buf;
1606 }
1607 
1608 const char* GAME_GetAbsoluteSavePath (char* buf, size_t bufSize)
1609 {
1610  Com_sprintf(buf, bufSize, "%s/save/%s/", FS_Gamedir(), GAME_GetCurrentName());
1611  return buf;
1612 }
1613 
1615 {
1616  const cgame_export_t* list = GAME_GetCurrentType();
1617 
1618  if (list && list->GetEquipmentDefinition != nullptr)
1619  return list->GetEquipmentDefinition();
1620  return &equipDefStandard;
1621 }
1622 
1623 void GAME_NotifyEvent (event_t eventType)
1624 {
1625  const cgame_export_t* list = GAME_GetCurrentType();
1626  if (list && list->NotifyEvent)
1627  list->NotifyEvent(eventType);
1628 }
1629 
1630 bool GAME_TeamIsKnown (const teamDef_t* teamDef)
1631 {
1632  const cgame_export_t* list = GAME_GetCurrentType();
1633 
1634  if (!teamDef)
1635  return false;
1636 
1637  if (list && list->IsTeamKnown != nullptr)
1638  return list->IsTeamKnown(teamDef);
1639  return true;
1640 }
1641 
1643 {
1644  const cgame_export_t* list = GAME_GetCurrentType();
1645  if (list && list->UpdateCharacterValues != nullptr)
1646  list->UpdateCharacterValues(chr);
1647 }
1648 
1652 static void GAME_Abort_f (void)
1653 {
1654  /* aborting means letting the aliens win */
1655  Cbuf_AddText("sv win %i\n", TEAM_ALIEN);
1656 }
1657 
1658 void GAME_Drop (void)
1659 {
1660  const cgame_export_t* list = GAME_GetCurrentType();
1661 
1662  if (list && list->Drop) {
1663  list->Drop();
1664  } else {
1665  SV_Shutdown("Drop", false);
1666  GAME_SetMode(nullptr);
1667 
1668  GAME_UnloadGame();
1669 
1670  UI_InitStack("main", nullptr);
1671  }
1672 }
1673 
1677 static void GAME_Exit_f (void)
1678 {
1679  GAME_SetMode(nullptr);
1680 
1681  GAME_UnloadGame();
1682 }
1683 
1687 void GAME_Frame (void)
1688 {
1689  /* don't run the cgame in console mode */
1690  if (cls.keyDest == key_console)
1691  return;
1692 
1693  const cgame_export_t* list = GAME_GetCurrentType();
1694  if (list && list->RunFrame != nullptr)
1695  list->RunFrame(cls.frametime);
1696 }
1697 
1698 
1699 void GAME_DrawBaseLayout (int baseIdx, int x, int y, int totalMarge, int w, int h, int padding, const vec4_t bgcolor, const vec4_t color)
1700 {
1701  const cgame_export_t* list = GAME_GetCurrentType();
1702  if (list && list->DrawBaseLayout != nullptr)
1703  list->DrawBaseLayout(baseIdx, x, y, totalMarge, w, h, padding, bgcolor, color);
1704 }
1705 
1712 void GAME_DrawBaseLayoutTooltip (int baseIdx, int x, int y)
1713 {
1714  const cgame_export_t* list = GAME_GetCurrentType();
1715  if (list && list->DrawBaseLayoutTooltip != nullptr)
1716  list->DrawBaseLayoutTooltip(baseIdx, x, y);
1717 }
1718 
1725 const char* GAME_GetModelForItem (const objDef_t* od, uiModel_t** uiModel)
1726 {
1727  const cgame_export_t* list = GAME_GetCurrentType();
1728  if (list && list->GetModelForItem != nullptr) {
1729  const char* model = list->GetModelForItem(od->id);
1730  if (model != nullptr) {
1731  if (uiModel != nullptr)
1732  *uiModel = UI_GetUIModel(model);
1733  return model;
1734  }
1735  }
1736 
1737  if (uiModel != nullptr)
1738  *uiModel = nullptr;
1739  return od->model;
1740 }
1741 
1747 {
1748  const cgame_export_t* list = GAME_GetCurrentType();
1749  if (list && list->GetSelectedChr != nullptr)
1750  return list->GetSelectedChr();
1751 
1752  const int ucn = Cvar_GetInteger("mn_ucn");
1753  character_t* chr = nullptr;
1755  if (ucn == chrTmp->ucn) {
1756  chr = chrTmp;
1757  break;
1758  }
1759  }
1760  return chr;
1761 }
1762 
1769 {
1770  if (chr == nullptr)
1771  return NONE;
1772 
1773  const cgame_export_t* list = GAME_GetCurrentType();
1774  const int strength = chr->score.skills[ABILITY_POWER];
1775  if (list && list->GetChrMaxLoad != nullptr)
1776  return std::min(strength, list->GetChrMaxLoad(chr));
1777  return strength;
1778 }
1779 
1783 const equipDef_t* GAME_ChangeEquip (const linkedList_t* equipmentList, changeEquipType_t changeType, const char* equipID)
1784 {
1785  const equipDef_t* ed;
1786 
1787  if (LIST_IsEmpty(equipmentList)) {
1788  ed = INV_GetEquipmentDefinitionByID(equipID);
1789  if (ed == nullptr)
1790  Com_Error(ERR_DROP, "Could not find the equipment definition for '%s'", equipID);
1791  int index = ed - csi.eds;
1792 
1793  switch (changeType) {
1794  case BACKWARD:
1795  index--;
1796  if (index < 0)
1797  index = csi.numEDs - 1;
1798  break;
1799  case FORWARD:
1800  index++;
1801  if (index >= csi.numEDs)
1802  index = 0;
1803  break;
1804  default:
1805  break;
1806  }
1807  ed = &csi.eds[index];
1808  } else {
1809  const linkedList_t* entry = LIST_ContainsString(equipmentList, equipID);
1810  if (entry == nullptr) {
1811  equipID = (const char*)equipmentList->data;
1812  } else if (changeType == FORWARD) {
1813  equipID = (const char*)(entry->next != nullptr ? entry->next->data : equipmentList->data);
1814  } else if (changeType == BACKWARD) {
1815  const char* newEntry = nullptr;
1816  const char* prevEntry = nullptr;
1817  LIST_Foreach(equipmentList, char const, tmp) {
1818  if (Q_streq(tmp, equipID)) {
1819  if (prevEntry != nullptr) {
1820  newEntry = prevEntry;
1821  break;
1822  }
1823  }
1824  prevEntry = tmp;
1825  newEntry = tmp;
1826  }
1827  equipID = newEntry;
1828  }
1829  ed = INV_GetEquipmentDefinitionByID(equipID);
1830  if (ed == nullptr)
1831  Com_Error(ERR_DROP, "Could not find the equipment definition for '%s'", equipID);
1832  }
1833 
1834  return ed;
1835 }
1836 
1840 void GAME_InitUIData (void)
1841 {
1842  Com_Printf("----------- game modes -------------\n");
1843  for (int i = 0; i < numCGameTypes; i++) {
1844  const cgameType_t* t = &cgameTypes[i];
1845  const cgame_export_t* e = GAME_GetCGameAPI_(t);
1846  if (e == nullptr)
1847  continue;
1848 
1849  if (e->isMultiplayer)
1850  UI_ExecuteConfunc("game_addmode_multiplayer \"%s\" \"%s\"", t->window, t->name);
1851  else
1852  UI_ExecuteConfunc("game_addmode_singleplayer \"%s\" \"%s\"", t->window, t->name);
1853  Com_Printf("added %s\n", t->name);
1854  GAME_UnloadGame();
1855  }
1856 
1857  Com_Printf("added %i game modes\n", numCGameTypes);
1858 }
1859 
1860 void GAME_InitStartup (void)
1861 {
1862  Cmd_AddCommand("game_setmode", GAME_SetMode_f, "Decides with game mode should be set - takes the menu as reference");
1863  Cmd_AddCommand("game_exit", GAME_Exit_f, "Quits the current running game and shutdown the game mode");
1864  Cmd_AddCommand("game_abort", GAME_Abort_f, "Abort the game and let the aliens/opponents win");
1865  Cmd_AddCommand("game_autoteam", GAME_AutoTeam_f, "Assign initial equipment to soldiers");
1866  Cmd_AddCommand("game_toggleactor", GAME_ToggleActorForTeam_f);
1867  Cmd_AddCommand("game_saveteamstate", GAME_SaveTeamState_f);
1868  Cmd_AddCommand("game_saveteam", GAME_SaveTeam_f, "Save a team slot");
1869  Cmd_AddCommand("game_loadteam", GAME_LoadTeam_f, "Load a team slot");
1870  Cmd_AddCommand("game_teamcomments", GAME_TeamSlotComments_f, "Fills the team selection menu with the team names");
1871  Cmd_AddCommand("game_teamupdate", GAME_UpdateTeamMenuParameters_f, "");
1872  Cmd_AddCommand("game_teamdelete", GAME_TeamDelete_f, "Removes a team");
1873  Cmd_AddCommand("game_actorselect", GAME_ActorSelect_f, "Select an actor in the equipment menu");
1874  Cmd_AddCommand("mn_getmaps", UI_GetMaps_f, "The initial map to show");
1875  Cmd_AddCommand("mn_nextmap", UI_NextMap_f, "Switch to the next valid map for the selected gametype");
1876  Cmd_AddCommand("mn_prevmap", UI_PreviousMap_f, "Switch to the previous valid map for the selected gametype");
1877  Cmd_AddCommand("mn_selectmap", UI_SelectMap_f, "Switch to the map given by the parameter - may be invalid for the current gametype");
1878  Cmd_AddCommand("mn_requestmaplist", UI_RequestMapList_f, "Request to send the list of available maps for the current gametype to a command.");
1879 
1882 }
1883 
1884 void GAME_Shutdown (void)
1885 {
1886  OBJZERO(cgameTypes);
1887  numCGameTypes = 0;
1888  OBJZERO(equipDefStandard);
1889  for (int i = 0; i < lengthof(characters); ++i)
1890  characters[1].init();
1891 
1894 }
#define CS_MAPTITLE
Definition: q_shared.h:310
static void UI_PushWindow_(const char *name)
Definition: cl_game.cpp:554
void Cmd_UnRegisterCmdListener(CmdListenerPtr listener)
Unregisters a command listener.
Definition: cmd.cpp:878
equipDef_t * GAME_GetEquipmentDefinition(void)
Definition: cl_game.cpp:1614
uiNode_t *IMPORT * UI_PopupList(const char *title, const char *headline, linkedList_t *entries, const char *clickAction)
int currentSelectedMap
Definition: client.h:80
#define LE_IsStunned(le)
const objDef_t * onlyWeapon
Definition: chr_shared.h:325
bool Com_ParseBlock(const char *name, const char **text, void *base, const value_t *values, memPool_t *mempool)
Definition: scripts.cpp:1415
const char * Cmd_Argv(int arg)
Returns a given argument.
Definition: cmd.cpp:516
void GAME_GenerateTeam(const char *teamDefID, const equipDef_t *ed, int teamMembers)
Definition: cl_game.cpp:276
static void * GAME_AllocInventoryMemory(size_t size)
Definition: cl_game.cpp:887
void Cmd_AddCommand(const char *cmdName, xcommand_t function, const char *desc)
Add a new command to the script interface.
Definition: cmd.cpp:744
void GAME_AddChatMessage(const char *format,...)
Definition: cl_game.cpp:370
xmlNode_t * XML_GetPos2(xmlNode_t *parent, const char *name, vec2_t pos)
retrieve the first Pos2 data from an XML Node
Definition: xml.cpp:394
void CL_UpdateCharacterValues(const character_t *chr)
Definition: cl_team.cpp:218
void *IMPORT * Alloc(size_t size, bool zeroFill, memPool_t *pool, const int tagNum, const char *fileName, const int fileLine)
static SharedPtr< GAMECvarListener > cvarListener(new GAMECvarListener())
short XML_GetShort(xmlNode_t *parent, const char *name, const short defaultval)
retrieve a Short attribute from an XML Node
Definition: xml.cpp:322
const char * FS_NextFileFromFileList(const char *files)
Returns the next file that is found in the virtual filesystem identified by the given file pattern...
Definition: files.cpp:1079
char path[MAX_VAR]
Definition: chr_shared.h:372
void destroyInventory(Inventory *const inv)
Destroys inventory.
Definition: inventory.cpp:521
#define ACTOR_SIZE_2x2
Definition: defines.h:303
uiNode_t *IMPORT * UI_GetNodeByPath(const char *path)
int Q_vsnprintf(char *str, size_t size, const char *format, va_list ap)
Safe (null terminating) vsnprintf implementation.
Definition: shared.cpp:535
void R_SoftenTexture(byte *in, int width, int height, int bpp)
Applies blurring to a texture.
Definition: r_image.cpp:391
bool Com_UnregisterConstVariable(const char *name)
Removes a registered constant from the script mapping hash table.
Definition: scripts.cpp:147
void Sys_Error(const char *error,...)
Definition: g_main.cpp:421
teamDef_t * teamDef
struct uiMessageListNodeMessage_s *IMPORT * UI_MessageGetStack(void)
int numEDs
Definition: q_shared.h:541
short Com_GetDropShipIdsNum(void)
Definition: scripts.cpp:579
void NET_SockaddrToStrings(struct datagram_socket *s, struct sockaddr *addr, char *node, size_t nodelen, char *service, size_t servicelen)
Convert sockaddr to string.
Definition: net.cpp:1212
bool Com_GetConstIntFromNamespace(const char *space, const char *variable, int *value)
Searches whether a given value was registered as a string to int mapping.
Definition: scripts.cpp:103
bool GAME_SaveCharacter(xmlNode_t *p, const character_t *chr)
saves a character to a given xml node
chrScoreGlobal_t score
Definition: chr_shared.h:387
int FS_CheckFile(const char *fmt,...)
Just returns the filelength and -1 if the file wasn't found.
Definition: files.cpp:298
char popupText[UI_MAX_SMALLTEXTLEN]
strings to be used for popup when text is not static
Definition: ui_popup.cpp:37
itemFilterTypes_t INV_GetFilterTypeID(const char *filterTypeID)
Searches for a filter type name (as used in console functions) and returns the matching itemFilterTyp...
void Cmd_RemoveCommand(const char *cmdName)
Removes a command from script interface.
Definition: cmd.cpp:786
const char * Com_GetRandomMapAssemblyNameForCrashedCraft(const char *craftID)
Definition: scripts.cpp:3307
const objDef_t * INVSH_GetItemByID(const char *id)
Returns the item that belongs to the given id or nullptr if it wasn't found.
Definition: inv_shared.cpp:282
void R_DrawImage(float x, float y, const image_t *image)
Draws an image or parts of it.
Definition: r_draw.cpp:341
char id[MAX_VAR]
Definition: chr_shared.h:298
bool INV_ItemMatchesFilter(const objDef_t *obj, const itemFilterTypes_t filterType)
Checks if the given object/item matched the given filter type.
void LIST_PrependString(linkedList_t **listDest, const char *data)
Adds a string as first entry to a linked list.
Definition: list.cpp:127
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 UI_RegisterLinkedListText(int dataId, linkedList_t *text)
share a linked list of text with a data id
Definition: ui_data.cpp:131
void XML_AddStringValue(xmlNode_t *parent, const char *name, const char *value)
add a non-empty String attribute to the XML Node
Definition: xml.cpp:49
#define MAX_TEAMS
Definition: defines.h:98
static void GAME_WebDelete(int category, const char *filename)
Definition: cl_game.cpp:473
void UI_MessageAddStack(struct uiMessageListNodeMessage_s *message)
GameCmds _cmds
Definition: cl_game.cpp:109
linkedList_t * chrList
int FS_OpenFile(const char *filename, qFILE *file, filemode_t mode)
Finds and opens the file in the search path.
Definition: files.cpp:162
InventoryInterface i
Definition: client.h:101
void UI_RegisterText(int dataId, const char *text)
share a text with a data id
Definition: ui_data.cpp:115
char * id
Definition: q_shared.h:463
void R_DrawLineStrip(int points, int *verts)
2 dimensional line strip
Definition: r_draw.cpp:477
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...
void UI_SortOptions(uiNode_t **first)
Sort options by alphabet.
Definition: ui_data.cpp:273
#define LE_IsItem(le)
#define TEAM_ALIEN
Definition: q_shared.h:63
void GAME_SpawnSoldiers(void)
Called during startup of mission to send team info.
Definition: cl_game.cpp:1569
#define CPUSTRING
Definition: common.h:109
float XML_GetFloat(xmlNode_t *parent, const char *name, const float defaultval)
retrieve a Float attribute from an XML Node
Definition: xml.cpp:364
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
int getAmmoLeft() const
Definition: inv_shared.h:466
int numMDs
Definition: q_shared.h:572
struct datagram_socket * NET_DatagramSocketNew(const char *node, const char *service, datagram_callback_func *func)
Opens a datagram socket (UDP)
Definition: net.cpp:1102
void LIST_AddStringSorted(linkedList_t **listDest, const char *data)
Definition: list.cpp:107
const teamDef_t * teamDef
Definition: chr_shared.h:394
void * LIST_GetByIdx(linkedList_t *list, int index)
Get an entry of a linked list by its index in the list.
Definition: list.cpp:362
static void GAME_DestroyInventory(Inventory *const inv)
Definition: cl_game.cpp:453
uiNode_t * UI_GetNodeByPath(const char *path)
Return a node by a path name (names with dot separation) It is a simplification facade over UI_ReadNo...
Definition: ui_nodes.cpp:313
byte * r_xviAlpha
Definition: cgame.h:382
bool robot
Definition: chr_shared.h:322
This is a cvar definition. Cvars can be user modified and used in our menus e.g.
Definition: cvar.h:71
void XML_AddDoubleValue(xmlNode_t *parent, const char *name, double value)
add a non-zero Double attribute to the XML Node
Definition: xml.cpp:124
int experience[SKILL_NUM_TYPES+1]
Definition: chr_shared.h:120
void GAME_TeamDelete_f(void)
Removes a user created team.
static int GAME_GetNextUniqueCharacterNumber(void)
Definition: cl_game.cpp:493
const char * GAME_GetAbsoluteSavePath(char *buf, size_t bufSize)
Definition: cl_game.cpp:1608
#define _(String)
Definition: cl_shared.h:43
char * CL_GetConfigString(int index)
int XML_GetInt(xmlNode_t *parent, const char *name, const int defaultval)
retrieve an Int attribute from an XML Node
Definition: xml.cpp:308
uiNode_t *IMPORT * UI_OptionIteratorNextOption(uiOptionIterator_t *iterator)
double XML_GetDouble(xmlNode_t *parent, const char *name, const double defaultval)
retrieve a Double attribute from an XML Node
Definition: xml.cpp:378
void * data
Definition: list.h:31
static void GAME_FreeAllInventory(void)
Definition: cl_game.cpp:893
void * _Mem_Alloc(size_t size, bool zeroFill, memPool_t *pool, const int tagNum, const char *fileName, const int fileLine)
Item * getContainer2(const containerIndex_t idx) const
Definition: inv_shared.h:546
static void R_DrawImageCentered(int x, int y, const char *name)
Definition: cl_game.cpp:574
void SV_ShutdownWhenEmpty(void)
Will eventually shutdown the server once all clients have disconnected.
Definition: sv_main.cpp:1085
void GAME_Shutdown(void)
Definition: cl_game.cpp:1884
char *IMPORT * FS_NextScriptHeader(const char *files, const char **name, const char **text)
void GAME_ReloadMode(void)
Definition: cl_game.cpp:290
#define STATE_REACTION
Definition: q_shared.h:272
csi_t csi
Definition: common.cpp:39
void *IMPORT * LIST_GetRandom(linkedList_t *list)
bool Com_sprintf(char *dest, size_t size, const char *fmt,...)
copies formatted string with buffer-size checking
Definition: shared.cpp:494
const char * UI_GetActiveWindowName(void)
Returns the name of the current window.
Definition: ui_windows.cpp:526
Defines a type of UGV/Robot.
Definition: chr_shared.h:234
void UI_DrawModelNode(uiNode_t *node, const char *source)
#define Mem_PoolAlloc(size, pool, tagNum)
Definition: mem.h:41
int nextUniqueCharacterNumber
Definition: client.h:99
bool GAME_HandleServerCommand(const char *command, dbuffer *msg)
Definition: cl_game.cpp:361
void XML_AddDate(xmlNode_t *parent, const char *name, const int day, const int sec)
add a date data to the XML Tree
Definition: xml.cpp:264
const char * filename
Definition: ioapi.h:41
void Cbuf_AddText(const char *format,...)
Adds command text at the end of the buffer.
Definition: cmd.cpp:126
csi_t * csi
Definition: cgame.h:100
void UI_UpdateInvisOptions(uiNode_t *option, const linkedList_t *stringList)
Unhide those options that are stored in the linked list and hide the others.
Definition: ui_data.cpp:297
uiNode_t *IMPORT * UI_InitOptionIteratorAtIndex(int index, uiNode_t *option, uiOptionIterator_t *iterator)
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
void XML_AddPos3(xmlNode_t *parent, const char *name, const vec3_t pos)
add a Pos3 data to the XML Tree
Definition: xml.cpp:234
Shared game type headers.
void GAME_SetServerInfo(const char *server, const char *serverport)
Definition: cl_game.cpp:347
void GAME_StartBattlescape(bool isTeamPlay)
Called when the server sends the EV_START event.
Definition: cl_game.cpp:1487
xmlNode_t *IMPORT * XML_GetPos3(xmlNode_t *parent, const char *name, vec3_t pos)
const objDef_t * def(void) const
Definition: inv_shared.h:469
Inventory ** ui_inventory
Definition: cgame.h:101
static char * GAME_PoolStrDup(const char *in, memPool_t *pool, const int tagNum)
Definition: cl_game.cpp:448
#define DEBUG_SYSTEM
Definition: defines.h:57
void FS_RemoveFile(const char *osPath)
Definition: files.cpp:1690
void XML_AddFloatValue(xmlNode_t *parent, const char *name, float value)
add a non-zero Float attribute to the XML Node
Definition: xml.cpp:99
equipDef_t eds[MAX_EQUIPDEFS]
Definition: q_shared.h:540
const char *IMPORT * GetAbsoluteSavePath(char *buf, size_t bufSize)
void Cvar_UnRegisterCvarListener(CvarListenerPtr listener)
Unregisters a cvar listener.
Definition: cvar.cpp:415
const char * CL_ActorGetSkillString(const int skill)
Return the skill string for the given skill level.
Definition: cl_team.cpp:165
static void UI_NextMap_f(void)
Select the next available map.
Definition: cl_game.cpp:1109
uiNode_t * UI_PopupList(const char *title, const char *headline, linkedList_t *entries, const char *clickAction)
Generates a popup that contains a list of selectable choices.
Definition: ui_popup.cpp:62
const char *EXPORT * GetModelForItem(const char *string)
#define LE_IsAlien(le)
int FS_LoadFile(const char *path, byte **buffer)
Filenames are relative to the quake search path.
Definition: files.cpp:384
void NET_StreamFree(struct net_stream *s)
Call NET_StreamFree to dump the whole thing right now.
Definition: net.cpp:817
void onDelete(const struct cvar_s *cvar)
Definition: cl_game.cpp:85
int countItems() const
Count the number of items in the inventory (without temp containers)
Definition: inv_shared.cpp:741
int stuns[KILLED_NUM_TYPES]
Definition: chr_shared.h:127
void UI_ContainerNodeUpdateEquipment(Inventory *inv, const equipDef_t *ed)
Fills the ground container of the ui_inventory with unused items from a given equipment definition...
static const char * Com_EParse_(const char **text, const char *errhead, const char *errinfo)
Definition: cl_game.cpp:581
int NET_ReadLong(dbuffer *buf)
Definition: netpack.cpp:282
char *IMPORT * GAME_StrDup(const char *string)
static void GAME_SendCurrentTeamSpawningInfo(dbuffer *buf, linkedList_t *team)
Stores a team-list (chr-list) info to buffer (which might be a network buffer, too).
Definition: cl_game.cpp:1423
const struct cgame_export_s * gametype
Definition: client.h:65
#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
void GAME_AppendTeamMember(int memberIndex, const char *teamDefID, const equipDef_t *ed)
Definition: cl_game.cpp:251
bool Cmd_GenericCompleteFunction(char const *candidate, char const *partial, char const **match)
Definition: cmd.cpp:648
const char *IMPORT * GetRelativeSavePath(char *buf, size_t bufSize)
const char * Com_DropShipTypeToShortName(humanAircraftType_t type)
Translate DropShip type to short name.
Definition: scripts.cpp:3341
xmlNode_t *IMPORT * XML_Parse(const char *buffer)
Definition: r_image.h:45
const char *IMPORT * UI_GetFontFromNode(const uiNode_t *const node)
Item * getArmour() const
Definition: inv_shared.cpp:990
int FS_BuildFileList(const char *fileList)
Build a filelist.
Definition: files.cpp:960
int GAME_GetCurrentTeam(void)
Definition: cl_game.cpp:926
void resetTempContainers()
Definition: inv_shared.h:557
std::set< const struct cvar_s * > GameCvars
Definition: cl_game.cpp:70
Item * getNext() const
Definition: inv_shared.h:451
int width
Definition: r_image.h:64
void LIST_Delete(linkedList_t **list)
Definition: list.cpp:195
Defines all attributes of objects used in the inventory.
Definition: inv_shared.h:264
const char *IMPORT * Com_DropShipTypeToShortName(humanAircraftType_t type)
void Com_RegisterConstList(const constListEntry_t constList[])
Registers a list of string aliases.
Definition: scripts.cpp:253
uiSprite_t *IMPORT * UI_GetSpriteByName(const char *name)
void(* http_callback_t)(const char *response, void *userdata)
Definition: http.h:65
static bool GAME_LoadGame(const char *path, const char *name)
Definition: cl_game.cpp:1194
void GAME_TeamSlotComments_f(void)
Reads the comments from team files.
const equipDef_t * INV_GetEquipmentDefinitionByID(const char *name)
Gets equipment definition by id.
cvar_t * masterserver_url
Definition: common.cpp:57
void UI_InitStack(const char *activeWindow, const char *mainWindow)
Init the stack to start with a window, and have an alternative window with ESC.
Definition: ui_windows.cpp:354
bool LE_IsActor(const le_t *le)
Checks whether the given le is a living actor.
const char * Com_GetRandomMapAssemblyNameForCraft(const char *craftID)
Returns the name of an aircraft or an ufo that is used in the ump files for the random map assembly...
Definition: scripts.cpp:3299
voidpf void * buf
Definition: ioapi.h:42
void GAME_UnloadGame(void)
Definition: cl_game.cpp:900
#define ERR_FATAL
Definition: common.h:210
const teamDef_t * Com_GetTeamDefinitionByID(const char *team)
Returns the teamDef pointer for the searched team id - or nullptr if not found in the teamDef array...
Definition: scripts.cpp:2367
int GAME_GetChrMaxLoad(const character_t *chr)
Returns the max weight the given character can carry.
Definition: cl_game.cpp:1768
void GAME_AutoTeam_f(void)
void GAME_NotifyEvent(event_t eventType)
Definition: cl_game.cpp:1623
bool singleplayer
Definition: q_shared.h:481
xmlNode_t * XML_GetPos3(xmlNode_t *parent, const char *name, vec3_t pos)
retrieve the first Pos3 data from an XML Node
Definition: xml.cpp:431
void Cmd_TableRemoveList(const cmdList_t *cmdList)
Definition: cmd.cpp:859
void CL_Drop(void)
Ensures the right menu cvars are set after error drop or map change.
Definition: cl_main.cpp:167
static void UI_DrawNormImageByName_(bool flip, float x, float y, float w, float h, float sh, float th, float sl, float tl, const char *name)
Definition: cl_game.cpp:559
xmlNode_t * XML_GetNextPos3(xmlNode_t *actual, xmlNode_t *parent, const char *name, vec3_t pos)
retrieve the next Pos3 data from an XML Node
Definition: xml.cpp:451
const ugv_t * Com_GetUGVByIDSilent(const char *ugvID)
Searches an UGV definition by a given script id and returns the pointer to the global data...
Definition: scripts.cpp:3384
bool GAME_LoadCharacter(xmlNode_t *p, character_t *chr)
Loads a character from a given xml node.
int LIST_Count(const linkedList_t *list)
Definition: list.cpp:344
int Cvar_GetInteger(const char *varName)
Returns the int value of a cvar.
Definition: cvar.cpp:194
static void GAME_EquipActor(character_t *const chr, const equipDef_t *ed, const objDef_t *weapon, int maxWeight)
Definition: cl_game.cpp:458
const char *IMPORT * Cvar_GetString(const char *varName)
void XML_AddPos2(xmlNode_t *parent, const char *name, const vec2_t pos)
add a Pos2 data to the XML Tree
Definition: xml.cpp:249
memPool_t * cl_genericPool
Definition: cl_main.cpp:86
void GAME_Drop(void)
Definition: cl_game.cpp:1658
int flags
Definition: cvar.h:78
const linkedList_t *IMPORT * LIST_ContainsString(const linkedList_t *list, const char *string)
#define Q_strvalid(string)
Definition: shared.h:141
const char * XML_GetString(xmlNode_t *parent, const char *name)
retrieve a String attribute from an XML Node
Definition: xml.cpp:350
void R_Color(const vec4_t rgba)
Change the color to given value.
Definition: r_state.cpp:1011
void * NET_StreamGetData(struct net_stream *s)
Definition: net.cpp:800
bool BEP_Evaluate(const char *expr, BEPEvaluteCallback_t varFuncParam, const void *userdata)
static bool GAME_Spawn(linkedList_t **chrList)
Definition: cl_game.cpp:1455
#define PKGLIBDIR
Definition: config_android.h:8
void Com_Error(int code, const char *fmt,...)
Definition: common.cpp:417
const char *IMPORT * Cmd_Args(void)
const char *IMPORT * Com_UFOCrashedTypeToShortName(ufoType_t type)
image_t * R_FindImage(const char *pname, imagetype_t type)
Finds or loads the given image.
Definition: r_image.cpp:603
const char *IMPORT * CL_PlayerGetName(unsigned int player)
void Cmd_ExecuteString(const char *text,...)
A complete command line has been parsed, so try to execute it.
Definition: cmd.cpp:1007
static void GAME_CollectAliens(void *data, void(*collect)(void *, const teamDef_t *, int, bool))
Collecting stunned and dead alien bodies after the mission.
Definition: cl_game.cpp:533
byte r_xviAlpha[XVI_WIDTH *XVI_HEIGHT]
Definition: cl_shared.h:63
xmlNode_t * XML_AddNode(xmlNode_t *parent, const char *name)
add a new node to the XML tree
Definition: xml.cpp:277
void onGameModeChange()
Definition: cl_game.cpp:129
static void GAME_Exit_f(void)
Quits the current running game by calling the shutdown callback.
Definition: cl_game.cpp:1677
void R_Draw3DMapMarkers(const vec2_t nodePos, const vec2_t nodeSize, const vec3_t rotate, const vec2_t pos, float direction, float earthRadius, const char *model, int skin)
Draw 3D Marker on the 3D geoscape.
Definition: r_geoscape.cpp:235
void R_Draw2DMapMarkers(const vec2_t screenPos, float direction, const char *model, int skin)
Draw 3D Marker on the 2D geoscape.
Definition: r_geoscape.cpp:178
uiNode_t * UI_OptionIteratorNextOption(uiOptionIterator_t *iterator)
Find the next element from the iterator Iterator skipCollapsed and skipInvisible attribute can contro...
Definition: ui_data.cpp:430
const char * FS_Gamedir(void)
Called to find where to write a file (savegames, etc)
Definition: files.cpp:68
client_static_t cls
Definition: cl_main.cpp:83
item instance data, with linked list capability
Definition: inv_shared.h:402
static int UI_DrawString_(const char *fontID, align_t align, int x, int y, const char *c)
Definition: cl_game.cpp:549
void GAME_EndBattlescape(void)
This is called when a client quits the battlescape.
Definition: cl_game.cpp:314
void Q_strncpyz(char *dest, const char *src, size_t destsize)
Safe strncpy that ensures a trailing zero.
Definition: shared.cpp:457
xmlNode_t *IMPORT * XML_GetDate(xmlNode_t *parent, const char *name, int *day, int *sec)
struct uiMessageListNodeMessage_s * UI_MessageGetStack(void)
void NET_OOB_Printf(struct net_stream *s, const char *format,...)
Out of band print.
Definition: netpack.cpp:548
cvar_t *IMPORT * Cvar_Set(const char *varName, const char *value,...) __attribute__((format(__printf__
inventory definition with all its containers
Definition: inv_shared.h:525
bool LIST_Remove(linkedList_t **list, const void *data)
Definition: list.cpp:213
void GAME_DrawMapMarkers(uiNode_t *node)
Definition: cl_game.cpp:938
void XML_AddInt(xmlNode_t *parent, const char *name, int value)
add an Int attribute to the XML Node
Definition: xml.cpp:183
const char * GAME_GetModelForItem(const objDef_t *od, uiModel_t **uiModel)
Get a model for an item.
Definition: cl_game.cpp:1725
linkedList_t * equipmentList
Definition: cgame.h:88
void XML_AddString(xmlNode_t *parent, const char *name, const char *value)
add a String attribute to the XML Node
Definition: xml.cpp:36
align_t
We need this here for checking the boundaries from script values.
Definition: scripts.h:90
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
static bool GAME_RemoveFromInventory(Inventory *const i, const invDef_t *container, Item *fItem)
Definition: cl_game.cpp:463
#define ERR_DROP
Definition: common.h:211
void GAME_ActorSelect_f(void)
int treatmentLevel[BODYPART_MAXTYPE]
Definition: chr_shared.h:352
const char *IMPORT * FS_NextFileFromFileList(const char *files)
float frametime
Definition: client.h:59
#define DEBUG_CLIENT
Definition: defines.h:59
void XML_AddFloat(xmlNode_t *parent, const char *name, float value)
add a Float attribute to the XML Node
Definition: xml.cpp:87
const equipDef_t *IMPORT * GAME_ChangeEquip(const linkedList_t *equipmentList, changeEquipType_t changeType, const char *equipID)
static void GAME_Free(void *ptr)
Definition: cl_game.cpp:433
const image_t * UI_DrawNormImageByName(bool flip, float x, float y, float w, float h, float sh, float th, float sl, float tl, const char *name)
Draws an image or parts of it.
Definition: ui_render.cpp:203
char serverport[16]
Definition: client.h:69
void UI_ResetData(int dataId)
Reset a shared data. Type became NONE and value became nullptr.
Definition: ui_data.cpp:212
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
static void GAME_WebListForUser(int category, int userId)
Definition: cl_game.cpp:483
GLsizei size
Definition: r_gl.h:152
void LIST_AddString(linkedList_t **listDest, const char *data)
Adds an string to a new or to an already existing linked list. The string is copied here...
Definition: list.cpp:139
#define OBJZERO(obj)
Definition: shared.h:178
const equipDef_t *IMPORT * INV_GetEquipmentDefinitionByID(const char *name)
Definition: scripts.h:79
void GAME_SwitchCurrentSelectedMap(int step)
Definition: cl_game.cpp:912
geoscapeData_t geoscapeData
Definition: cl_game.cpp:146
float Cvar_GetValue(const char *varName)
Returns the float value of a cvar.
Definition: cvar.cpp:125
#define MapDef_ForeachCondition(var, condition)
Definition: q_shared.h:501
void EquipActor(character_t *const chr, const equipDef_t *ed, const objDef_t *weapon, int maxWeight)
Definition: inventory.cpp:947
mapDef_t * Com_GetMapDefByIDX(int index)
static void GAME_CollectItems(void *data, int won, void(*collectItem)(void *, const objDef_t *, int), void(*collectAmmo)(void *, const Item *), void(*ownitems)(const Inventory *))
Definition: cl_game.cpp:498
const mapDef_t *EXPORT * MapInfo(int step)
void GAME_SetMode(const cgame_export_t *gametype)
Definition: cl_game.cpp:952
void XML_AddBool(xmlNode_t *parent, const char *name, bool value)
add a Boolean attribute to the XML Node
Definition: xml.cpp:62
void GAME_InitMissionBriefing(const char *title)
Definition: cl_game.cpp:1502
void XML_AddLong(xmlNode_t *parent, const char *name, long value)
add a Long attribute to the XML Node
Definition: xml.cpp:206
static void GAME_WebDownloadFromUser(int category, const char *filename, int userId)
Definition: cl_game.cpp:478
const char * model
Definition: inv_shared.h:269
mapDef_t *IMPORT * Com_GetMapDefinitionByID(const char *mapDefID)
static void UI_MapInfo(int step)
Prints the map info for the server creation dialogue.
Definition: cl_game.cpp:1019
static character_t characters[MAX_ACTIVETEAM]
static character array that can be used by a game mode to store the needed character values...
Definition: cl_game.cpp:185
void LIST_Sort(linkedList_t **list, linkedListSort_t sorter, const void *userData)
character_t *EXPORT * GetSelectedChr(void)
int kills[KILLED_NUM_TYPES]
Definition: chr_shared.h:126
void Cvar_RegisterCvarListener(CvarListenerPtr listener)
Registers a cvar listener.
Definition: cvar.cpp:406
dbuffer *IMPORT * NET_ReadMsg(struct net_stream *s)
std::set< const char * > GameCmds
Definition: cl_game.cpp:108
character_t * GAME_GetCharacterByUCN(int ucn)
Returns a character that can be used to store the game type specific character values.
Definition: cl_game.cpp:210
void GAME_ResetCharacters(void)
Reset all characters in the static character array.
Definition: cl_game.cpp:243
void initInventory(const char *name, const csi_t *csi, const inventoryImport_t *import)
Initializes the inventory definition by linking the ->next pointers properly.
Definition: inventory.cpp:986
memPool_t *IMPORT * CreatePool(const char *name)
bool multiplayer
Definition: q_shared.h:474
void GAME_Frame(void)
Called every frame and allows us to hook into the current running game mode.
Definition: cl_game.cpp:1687
void UI_MessageResetStack(void)
short Com_GetUfoIdsNum(void)
Definition: scripts.cpp:574
static void UI_RequestMapList_f(void)
Definition: cl_game.cpp:1061
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
const cgame_import_t * cgi
byte * r_radarSourcePic
Definition: cgame.h:384
int UI_DrawTooltip(const char *string, int x, int y, int maxWidth)
Generic tooltip function.
Definition: ui_tooltip.cpp:40
const eventRegister_t * CL_GetEvent(const event_t eType)
Definition: e_main.cpp:157
Singleplayer campaign game type headers.
const char * Cvar_VariableStringOld(const char *varName)
Returns the old value of cvar as string before we changed it.
Definition: cvar.cpp:226
event_t
Possible event values.
Definition: q_shared.h:79
Multiplayer game type headers.
void R_UploadAlpha(const image_t *image, const byte *alphaData)
Definition: r_image.cpp:423
bool UI_IsWindowOnStack(const char *name)
Check if a named window is on the stack if active windows.
Definition: ui_windows.cpp:373
changeEquipType_t
Definition: cgame.h:92
void NET_WriteLong(dbuffer *buf, int c)
Definition: netpack.cpp:52
const char *IMPORT * Com_UFOTypeToShortName(ufoType_t type)
static SharedPtr< GAMECmdListener > cmdListener(new GAMECmdListener())
char head[MAX_VAR]
Definition: chr_shared.h:374
#define CVAR_NOSET
Definition: cvar.h:43
const char * Com_ValueToStr(const void *base, const valueTypes_t type, const int ofs)
Definition: scripts.cpp:1189
int NET_ReadShort(dbuffer *buf)
Definition: netpack.cpp:242
const char *IMPORT * Com_GetConstVariable(const char *space, int value)
clientBattleScape_t cl
cgame team management headers.
const char * Com_EParse(const char **text, const char *errhead, const char *errinfo, char *target, size_t size)
Parsing function that prints an error message when there is no text in the buffer.
Definition: scripts.cpp:277
#define Mem_CreatePool(name)
Definition: mem.h:32
static void GAME_InitializeBattlescape(linkedList_t *team)
This is called if actors are spawned (or at least the spawning commands were send to the server)...
Definition: cl_game.cpp:1537
void GAME_DrawBaseLayout(int baseIdx, int x, int y, int totalMarge, int w, int h, int padding, const vec4_t bgcolor, const vec4_t color)
Definition: cl_game.cpp:1699
char window[MAX_VAR]
Definition: cgame.h:86
void UI_TextScrollEnd(const char *nodePath)
Scroll to the bottom.
void XML_AddShortValue(xmlNode_t *parent, const char *name, short value)
add a non-zero Short attribute to the XML Node
Definition: xml.cpp:172
static void R_UploadAlpha_(const char *name, const byte *alphaData)
Definition: cl_game.cpp:564
int FS_WriteFile(const void *buffer, size_t len, const char *filename)
Definition: files.cpp:1544
bool GAME_IsMultiplayer(void)
Definition: cl_game.cpp:299
void FS_CloseFile(qFILE *f)
const mapDef_t * GAME_GetCurrentSelectedMap(void)
Definition: cl_game.cpp:921
const char * Com_UFOTypeToShortName(ufoType_t type)
Translate UFO type to short name.
Definition: scripts.cpp:3364
void GAME_InitUIData(void)
Fills the game mode list entries with the parsed values from the script.
Definition: cl_game.cpp:1840
void CL_GenerateCharacter(character_t *chr, const char *teamDefName)
Generates the skills and inventory for a character and for a 2x2 unit.
Definition: cl_team.cpp:235
Item * getFloorContainer() const
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 getAmount() const
Definition: inv_shared.h:463
#define INVDEF(containerID)
Definition: cl_shared.h:47
const char *IMPORT * INV_GetFilterType(itemFilterTypes_t id)
#define NET_STATE_STARTMATCH
Definition: q_shared.h:610
const linkedList_t * LIST_ContainsString(const linkedList_t *list, const char *string)
Searches for the first occurrence of a given string.
Definition: list.cpp:73
linkedList_t * LIST_CopyStructure(linkedList_t *src)
ufoType_t Com_UFOShortNameToID(const char *token)
Translate short name to UFO type.
Definition: scripts.cpp:3351
linkedList_t *IMPORT * LIST_CopyStructure(linkedList_t *src)
byte * r_radarPic
Definition: cgame.h:383
bool GAME_TeamIsKnown(const teamDef_t *teamDef)
Definition: cl_game.cpp:1630
const char * CL_PlayerGetName(unsigned int player)
Get the player name.
Definition: cl_parse.cpp:113
void S_SetSampleRepeatRate(int sampleRepeatRate)
Controls the repeat rate for the same sample.
Definition: s_main.cpp:352
void GAME_LoadTeam_f(void)
Loads the selected teamslot.
void NET_WriteFormat(dbuffer *buf, const char *format,...)
The user-friendly version of NET_WriteFormat that writes variable arguments to buffer according to fo...
Definition: netpack.cpp:207
mapDef_t * Com_GetMapDefinitionByID(const char *mapDefID)
Definition: scripts.cpp:3620
Atomic structure used to define most of the UI.
Definition: ui_nodes.h:80
cvar_t *IMPORT * Cvar_Get(const char *varName, const char *value, int flags, const char *desc)
static void GAME_NetSendItem(dbuffer *buf, const Item *item, containerIndex_t container, int x, int y)
Definition: cl_game.cpp:1341
void onAdd(const char *cmdName)
Definition: cl_game.cpp:116
bool LIST_RemoveEntry(linkedList_t **list, linkedList_t *entry)
Removes one entry from the linked list.
Definition: list.cpp:172
#define Mem_FreePool(pool)
Definition: mem.h:37
const char * formatString
The format string that is used to write and parse this event.
Definition: e_main.h:54
character_t * GAME_GetSelectedChr(void)
Returns the currently selected character.
Definition: cl_game.cpp:1746
Struct that defines one particular event with all its callbacks and data.
Definition: e_main.h:42
int WEB_CGameListForUser(const char *cgameId, int category, int userId)
Shows the uploaded files for the particular cgame category and the given userid.
Definition: web_cgame.cpp:310
void Com_RegisterConstInt(const char *name, int value)
Register mappings between script strings and enum values for values of the type V_INT.
Definition: scripts.cpp:198
void XML_AddShort(xmlNode_t *parent, const char *name, short value)
add a Short attribute to the XML Node
Definition: xml.cpp:160
uiNode_t * UI_InitOptionIteratorAtIndex(int index, uiNode_t *option, uiOptionIterator_t *iterator)
Init an option iterator at an index.
Definition: ui_data.cpp:394
linkedList_t * chrDisplayList
List of currently displayed or equipable characters.
Definition: cl_team.cpp:38
const mapDef_t *IMPORT * GAME_GetCurrentSelectedMap(void)
long XML_GetLong(xmlNode_t *parent, const char *name, const long defaultval)
retrieve a Long attribute from an XML Node
Definition: xml.cpp:336
const char *IMPORT * CL_ActorGetSkillString(const int skill)
Definition: cgame.h:94
static void GAME_NET_OOB_Printf(struct net_stream *s, const char *format,...)
Definition: cl_game.cpp:393
void UI_GetNodeAbsPos(const uiNode_t *node, vec2_t pos)
Returns the absolute position of a node.
Definition: ui_node.cpp:514
bool Cvar_Delete(const char *varName)
Function to remove the cvar and free the space.
Definition: cvar.cpp:279
bool GAME_LoadDefaultTeam(bool force)
const char *IMPORT * NET_StreamPeerToName(struct net_stream *s, char *dst, int len, bool appendPort)
QGL_EXTERN GLuint index
Definition: r_gl.h:110
uiModel_t * UI_GetUIModel(const char *modelName)
Returns pointer to UI model.
character_t * GAME_GetCharacter(int index)
Returns a character that can be used to store the game type specific character values.
Definition: cl_game.cpp:196
char id[MAX_VAR]
Definition: cgame.h:85
QGL_EXTERN GLuint count
Definition: r_gl.h:99
void S_StartLocalSample(const char *s, float volume)
Plays a sample without spatialization.
Definition: s_mix.cpp:184
char name[MAX_VAR]
Definition: cgame.h:87
CGAME_HARD_LINKED_FUNCTIONS linkedList_t * LIST_Add(linkedList_t **listDest, void const *data, size_t length)
static const cgame_import_t * GAME_GetImportData(const cgameType_t *t)
Definition: cl_game.cpp:586
a local entity
woundInfo_t wounds
Definition: chr_shared.h:383
void R_DrawLine(int *verts, float thickness)
Draws one line with only one start and one end point.
Definition: r_draw.cpp:494
le_t * LE_GetNextInUse(le_t *lastLE)
Iterate through the entities that are in use.
static void GAME_NetSendCharacter(dbuffer *buf, const character_t *chr)
Send the character information to the server that is needed to spawn the soldiers of the player...
Definition: cl_game.cpp:1375
Inventory inv
int32_t containerIndex_t
Definition: inv_shared.h:46
void R_LoadImage(const char *name, byte **pic, int *width, int *height)
Generic image-data loading fucntion.
Definition: r_image.cpp:152
struct net_stream *IMPORT * NET_Connect(const char *node, const char *service, stream_onclose_func *onclose)
static void UI_SelectMap_f(void)
Definition: cl_game.cpp:1122
GameCvars _cvars
Definition: cl_game.cpp:71
void *IMPORT * NET_StreamGetData(struct net_stream *s)
static const value_t cgame_vals[]
Valid equipment definition values from script files.
Definition: cl_game.cpp:1159
const char * GAME_GetCurrentName(void)
Definition: cl_game.cpp:231
cvar_t * Cvar_FullSet(const char *varName, const char *value, int flags)
Sets a cvar from console with the given flags.
Definition: cvar.cpp:640
const char * Com_GetConstVariable(const char *space, int value)
Searches the mapping variable for a given integer value and a namespace.
Definition: scripts.cpp:122
char * mapTheme
Definition: q_shared.h:464
void INV_ItemDescription(const objDef_t *od)
Prints the description for items (weapons, armour, ...)
int Com_EParseValue(void *base, const char *token, valueTypes_t type, int ofs, size_t size)
Definition: scripts.cpp:978
void GAME_SaveTeam_f(void)
Stores a team in a specified teamslot.
byte r_radarSourcePic[RADAR_WIDTH *RADAR_HEIGHT]
Definition: cl_shared.h:69
bool XML_GetBool(xmlNode_t *parent, const char *name, const bool defaultval)
retrieve a Boolean attribute from an XML Node
Definition: xml.cpp:288
xmlNode_t *IMPORT * XML_GetPos2(xmlNode_t *parent, const char *name, vec2_t pos)
Definition: scripts.h:49
Definition: cgame.h:93
void XML_AddBoolValue(xmlNode_t *parent, const char *name, bool value)
add a non-false Boolean attribute to the XML Node
Definition: xml.cpp:74
void onRemove(const char *cmdName)
Definition: cl_game.cpp:124
const char *IMPORT * Com_GetRandomMapAssemblyNameForCraft(const char *craftID)
void GAME_ToggleActorForTeam_f(void)
This will activate/deactivate the actor for the team.
void NET_StreamSetData(struct net_stream *s, void *data)
Definition: net.cpp:805
void XML_AddByte(xmlNode_t *parent, const char *name, byte value)
add a Byte attribute to the XML Node
Definition: xml.cpp:137
void * cgameLibrary
Definition: client.h:112
Skirmish game type headers.
int FS_Read(void *buffer, int len, qFILE *f)
Definition: files.cpp:371
short numBodyParts(void) const
Definition: chr_shared.cpp:388
bool isReloadable() const
Definition: inv_shared.h:479
uiNode_t *IMPORT * UI_GetOption(int dataId)
Inventory * ui_inventory
const ugv_t *IMPORT * Com_GetUGVByID(const char *ugvID)
bool Com_ParseList(const char **text, linkedList_t **list)
Definition: scripts.cpp:1385
const cgame_export_t * GetCGameAPI(const cgame_import_t *import)
#define Mem_FreeTag(pool, tagNum)
Definition: mem.h:36
static void GAME_WebUpload(int category, const char *filename)
Definition: cl_game.cpp:468
static void GAME_SetNextUniqueCharacterNumber(int ucn)
Definition: cl_game.cpp:488
size_t GAME_GetCharacterArraySize(void)
Definition: cl_game.cpp:226
QGL_EXTERN GLint i
Definition: r_gl.h:113
Listener for command changes.
Definition: cmd.h:96
QGL_EXTERN GLuint GLchar GLuint * len
Definition: r_gl.h:99
const char * CL_Translate(const char *t)
const cgameType_t * cgameType
Definition: cgame.h:102
const char * UI_GetFontFromNode(const uiNode_t *const node)
Return the font for a specific node or default font.
Definition: ui_font.cpp:145
void GAME_UpdateTeamMenuParameters_f(void)
Displays actor info and equipment and unused items in proper (filter) category.
xmlNode_t * XML_GetDate(xmlNode_t *parent, const char *name, int *day, int *sec)
retrieve the date data from an XML Node
Definition: xml.cpp:471
char * string
Definition: cvar.h:73
void NET_DatagramBroadcast(struct datagram_socket *s, const char *buf, int len, int port)
Definition: net.cpp:1159
void CL_SetClientState(connstate_t state)
Sets the client state.
Definition: cl_main.cpp:1016
void NET_DatagramSocketClose(struct datagram_socket *s)
Definition: net.cpp:1182
#define LE_IsDead(le)
bool WEB_CGameUpload(const char *cgameId, int category, const char *filename)
Uploads a file to the server.
Definition: web_cgame.cpp:106
xmlNode_t *IMPORT * XML_GetNextNode(xmlNode_t *current, xmlNode_t *parent, const char *name)
xmlNode_t * XML_GetNextPos2(xmlNode_t *actual, xmlNode_t *parent, const char *name, vec2_t pos)
retrieve the next Pos2 data from an XML Node
Definition: xml.cpp:413
void GAME_AutoTeam(const char *equipmentDefinitionID, int teamMembers)
const char *IMPORT * UI_GetActiveWindowName(void)
bool GAME_IsTeamEmpty(void)
Definition: cl_game.cpp:388
const char *IMPORT * Com_GetRandomMapAssemblyNameForCrashedCraft(const char *craftID)
static void CL_QueryMasterServer(const char *action, http_callback_t callback)
Definition: cl_game.cpp:356
char * FS_NextScriptHeader(const char *files, const char **name, const char **text)
Definition: files.cpp:1194
void GAME_HandleResults(dbuffer *msg, int winner, int *numSpawned, int *numAlive, int numKilled[][MAX_TEAMS], int numStunned[][MAX_TEAMS], bool nextmap)
After a mission was finished this function is called.
Definition: cl_game.cpp:1326
xmlNode_t *IMPORT * XML_GetNextPos3(xmlNode_t *actual, xmlNode_t *parent, const char *name, vec3_t pos)
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 onGameModeChange()
Definition: cl_game.cpp:90
struct datagram_socket *IMPORT * NET_DatagramSocketNew(const char *node, const char *service, datagram_callback_func *func)
const BodyData * bodyTemplate
Definition: chr_shared.h:339
static void UI_MapInfoGetNext(int step)
Definition: cl_game.cpp:990
int height
Definition: r_image.h:64
#define CS_VICTORY_CONDITIONS
Definition: q_shared.h:323
#define CID_MAX
Definition: inv_shared.h:57
void XML_AddDouble(xmlNode_t *parent, const char *name, double value)
add a Double attribute to the XML Node
Definition: xml.cpp:110
void GAME_DisplayItemInfo(uiNode_t *node, const char *string)
Shows game type specific item information (if it's not resolvable via objDef_t).
Definition: cl_game.cpp:338
#define Mem_Free(ptr)
Definition: mem.h:35
void GAME_EndRoundAnnounce(int playerNum, int team)
Send end round announcements.
Definition: cl_game.cpp:325
void UI_RegisterOption(int dataId, uiNode_t *option)
Definition: ui_data.cpp:311
void HUD_InitUI(const char *optionWindowName)
Display the user interface.
Definition: cl_hud.cpp:1572
bool isArmour() const
Definition: inv_shared.h:346
linkedList_t * LIST_GetPointer(linkedList_t *list, const void *data)
Searches for the first occurrence of a given pointer.
Definition: list.cpp:91
#define MAX_ACTIVETEAM
Definition: defines.h:41
void UI_PopWindow(bool all)
Pops a window from the window stack.
Definition: ui_windows.cpp:452
void Cmd_RegisterCmdListener(CmdListenerPtr listener)
Registers a command listener.
Definition: cmd.cpp:869
void GAME_CharacterCvars(const character_t *chr)
Definition: cl_game.cpp:1642
const objDef_t * ammoDef(void) const
Definition: inv_shared.h:460
int CL_GetPlayerNum(void)
Definition: cl_parse.cpp:103
#define LIST_Foreach(list, type, var)
Iterates over a linked list, it's safe to delete the returned entry from the list while looping over ...
Definition: list.h:41
void Com_SetGameType(void)
Definition: common.cpp:815
int isMultiplayer
Definition: cgame.h:40
inventory definition for our menus
Definition: inv_shared.h:371
vec_t vec2_t[2]
Definition: ufotypes.h:38
linkedList_t * next
Definition: list.h:32
const char *IMPORT * CL_Translate(const char *t)
xmlNode_t * XML_GetNode(xmlNode_t *parent, const char *name)
Get first Node of the XML tree by name.
Definition: xml.cpp:487
void Cmd_AddParamCompleteFunction(const char *cmdName, int(*function)(const char *partial, const char **match))
Definition: cmd.cpp:679
void R_DrawRect(int x, int y, int w, int h, const vec4_t color, float lineWidth, int pattern)
Draws a rect to the screen. Also has support for stippled rendering of the rect.
Definition: r_draw.cpp:390
char weapon[MAX_VAR]
Definition: chr_shared.h:237
xmlNode_t *IMPORT * XML_AddNode(xmlNode_t *parent, const char *name)
const teamDef_t *IMPORT * Com_GetTeamDefinitionByID(const char *team)
uiNode_t * UI_AddOption(uiNode_t **tree, const char *name, const char *label, const char *value)
Append an option to an option list.
Definition: ui_data.cpp:172
int UI_DrawString(const char *fontID, align_t align, int x, int y, int absX, int maxWidth, int lineHeight, const char *c, int boxHeight, int scrollPos, int *curLine, bool increaseLine, longlines_t method)
Definition: ui_render.cpp:371
int getX() const
Definition: inv_shared.h:454
const char *IMPORT * Com_EParse(const char **text, const char *errhead, const char *errinfo)
bool WEB_CGameDelete(const char *cgameId, int category, const char *filename)
Deletes a user owned file on the server.
Definition: web_cgame.cpp:152
void UI_DrawRect(int x, int y, int w, int h, const vec4_t color, float lineWidth, int pattern)
Definition: ui_render.cpp:42
void onCreate(const struct cvar_s *cvar)
Definition: cl_game.cpp:78
void CL_Disconnect(void)
Sets the cls.state to ca_disconnected and informs the server.
Definition: cl_main.cpp:257
char name[MAX_VAR]
Definition: chr_shared.h:371
#define MapDef_Foreach(var)
Definition: q_shared.h:505
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
cvar_t * Cvar_ForceSet(const char *varName, const char *value)
Will set the variable even if NOSET or LATCH.
Definition: cvar.cpp:604
bool HTTP_GetURL(const char *url, http_callback_t callback, void *userdata, const char *postfields)
Downloads the given url and return the data to the callback (optional)
Definition: http.cpp:374
#define lengthof(x)
Definition: shared.h:105
static void GAME_NET_OOB_Printf2(const char *format,...)
Definition: cl_game.cpp:405
void R_DrawBloom(void)
handle post-processing bloom
Definition: r_geoscape.cpp:760
void GAME_InitStartup(void)
Definition: cl_game.cpp:1860
const char * menu
Definition: cgame.h:39
int rotated
Definition: inv_shared.h:412
equipDef_t *EXPORT * GetEquipmentDefinition(void)
static int numCGameTypes
Definition: cl_game.cpp:60
const char *IMPORT * Cvar_VariableStringOld(const char *varName)
GLsizei const GLvoid * data
Definition: r_gl.h:152
const char * NET_StreamPeerToName(struct net_stream *s, char *dst, int len, bool appendPort)
Definition: net.cpp:872
cvar_t * Cvar_Set(const char *varName, const char *value,...)
Sets a cvar value.
Definition: cvar.cpp:615
const char * Cvar_GetString(const char *varName)
Returns the value of cvar as string.
Definition: cvar.cpp:210
#define NONE
Definition: defines.h:68
#define Q_streq(a, b)
Definition: shared.h:136
static void GAME_UI_Popup(const char *title, const char *format,...)
Definition: cl_game.cpp:417
#define Mem_PoolStrDup(in, pool, tagNum)
Definition: mem.h:50
le_t * teamList[MAX_ACTIVETEAM]
void R_DrawFill(int x, int y, int w, int h, const vec4_t color)
Fills a box of pixels with a single color.
Definition: r_draw.cpp:188
bool GAME_ItemIsUseable(const objDef_t *od)
Definition: cl_game.cpp:1295
const cgame_export_t *(* cgame_api_t)(const cgame_import_t *)
Definition: cgame.h:389
void UI_DrawFill(int x, int y, int w, int h, const vec4_t color)
Fills a box of pixels with a single color.
Definition: ui_render.cpp:37
Model that have more than one part (top and down part of an aircraft)
Definition: ui_node_model.h:47
bool LIST_IsEmpty(const linkedList_t *list)
Checks whether the given list is empty.
Definition: list.cpp:335
char *IMPORT * PoolStrDup(const char *in, memPool_t *pool, const int tagNum)
int team
void GAME_StartMatch(void)
Definition: cl_game.cpp:1590
void XML_AddIntValue(xmlNode_t *parent, const char *name, int value)
add a non-zero Int attribute to the XML Node
Definition: xml.cpp:195
char servername[MAX_VAR]
Definition: client.h:68
void *IMPORT * LIST_GetByIdx(linkedList_t *list, int index)
void NET_StreamSetCallback(struct net_stream *s, stream_callback_func *func)
Definition: net.cpp:903
void Cbuf_Execute(void)
Pulls off terminated lines of text from the command buffer and sends them through Cmd_ExecuteString...
Definition: cmd.cpp:214
uiSprite_t * UI_GetSpriteByName(const char *name)
Return an sprite by is name.
Definition: ui_sprite.cpp:115
static char * GAME_StrDup(const char *string)
Definition: cl_game.cpp:428
void GAME_DrawBaseLayoutTooltip(int baseIdx, int x, int y)
Cgame callback to draw tooltip for baselayout UI node.
Definition: cl_game.cpp:1712
Listener for cvar changes.
Definition: cvar.h:98
image_t * R_GetImage(const char *name)
Definition: r_image.cpp:452
const char uiNode_t *IMPORT * UI_AddOption(uiNode_t **tree, const char *name, const char *label, const char *value)
xmlNode_t *IMPORT * XML_GetNextPos2(xmlNode_t *actual, xmlNode_t *parent, const char *name, vec2_t pos)
void destroyInventoryInterface(void)
Definition: inventory.cpp:999
linkedList_t *IMPORT * LIST_GetPointer(linkedList_t *list, const void *data)
const char * INV_GetFilterType(itemFilterTypes_t id)
#define ACTOR_SIZE_NORMAL
Definition: defines.h:302
byte r_radarPic[RADAR_WIDTH *RADAR_HEIGHT]
Definition: cl_shared.h:66
const char * GAME_GetRelativeSavePath(char *buf, size_t bufSize)
Definition: cl_game.cpp:1602
void UI_Popup(const char *title, const char *text)
Popup on geoscape.
Definition: ui_popup.cpp:47
void Cvar_SetValue(const char *varName, float value)
Expands value to a string and calls Cvar_Set.
Definition: cvar.cpp:671
humanAircraftType_t Com_DropShipShortNameToID(const char *token)
Translate DropShip type to short name.
Definition: scripts.cpp:3329
linkedList_t *IMPORT * LIST_Add(linkedList_t **list, void const *data, size_t length)
const char * name
Definition: cgame.h:38
void GAME_DrawMap(geoscapeData_t *data)
Definition: cl_game.cpp:931
static void GAME_SetMode_f(void)
Decides which game mode should be set - takes the menu as reference.
Definition: cl_game.cpp:1269
static void GAME_FreePool(memPool_t *pool)
Definition: cl_game.cpp:443
uint8_t byte
Definition: ufotypes.h:34
static void GAME_Abort_f(void)
Let the aliens win the match.
Definition: cl_game.cpp:1652
void GAME_SaveTeamState_f(void)
Will remove those actors that should not be used in the team.
QGL_EXTERN GLuint GLsizei bufSize
Definition: r_gl.h:110
actorSizeEnum_t fieldSize
Definition: chr_shared.h:390
static const cgame_export_t * GAME_GetCGameAPI(const cgameType_t *t)
Definition: cl_game.cpp:1216
const char * GAME_GetTeamDef(void)
Definition: cl_game.cpp:1442
const equipDef_t * GAME_ChangeEquip(const linkedList_t *equipmentList, changeEquipType_t changeType, const char *equipID)
Changed the given cvar to the next/prev equipment definition.
Definition: cl_game.cpp:1783
static equipDef_t equipDefStandard
Definition: cl_game.cpp:180
int Com_ServerState(void)
Check whether we are the server or have a singleplayer tactical mission.
Definition: common.cpp:538
int skills[SKILL_NUM_TYPES]
Definition: chr_shared.h:122
static const cgame_export_t * GAME_GetCGameAPI_(const cgameType_t *t)
Definition: cl_game.cpp:1258
char body[MAX_VAR]
Definition: chr_shared.h:373
static struct mdfour * m
Definition: md4.cpp:35
void XML_AddByteValue(xmlNode_t *parent, const char *name, byte value)
add a non-zero Byte attribute to the XML Node
Definition: xml.cpp:149
static void UI_GetMaps_f(void)
Definition: cl_game.cpp:1101
static void GAME_NetSendInventory(dbuffer *buf, const Inventory *inv)
Definition: cl_game.cpp:1354
const char *IMPORT * Cmd_Argv(int n)
cvar_t *IMPORT * Cvar_ForceSet(const char *varName, const char *value)
xmlNode_t * XML_GetNextNode(xmlNode_t *current, xmlNode_t *parent, const char *name)
Get next Node of the XML tree by name.
Definition: xml.cpp:499
void * LIST_GetRandom(linkedList_t *list)
Definition: list.cpp:381
void Com_Drop(void)
Definition: common.cpp:465
const char * Com_UFOCrashedTypeToShortName(ufoType_t type)
Translate UFO type to short name when UFO is crashed.
Definition: scripts.cpp:3373
void UI_TextNodeSelectLine(uiNode_t *node, int num)
Change the selected line.
static cgameType_t cgameTypes[MAX_CGAMETYPES]
Definition: cl_game.cpp:59
bool CHRSH_IsArmourUseableForTeam(const objDef_t *od, const teamDef_t *teamDef)
Definition: chr_shared.cpp:87
#define MAX_CGAMETYPES
Definition: cl_game.cpp:58
void NET_WriteShort(dbuffer *buf, int c)
Definition: netpack.cpp:45
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
static const cgame_export_t * GAME_GetCurrentType(void)
Definition: cl_game.cpp:62
static void GAME_FreeInventory(void *data)
Definition: cl_game.cpp:882
static const inventoryImport_t inventoryImport
Definition: cl_game.cpp:898
#define DEBUG_COMMANDS
Definition: defines.h:58
const char * id
Definition: inv_shared.h:268
void XML_AddLongValue(xmlNode_t *parent, const char *name, long value)
add a non-zero Long attribute to the XML Node
Definition: xml.cpp:220
const char *IMPORT * XML_GetString(xmlNode_t *parent, const char *name)
int getY() const
Definition: inv_shared.h:457
bool Com_ParseBlockToken(const char *name, const char **text, void *base, const value_t *values, memPool_t *mempool, const char *token)
Definition: scripts.cpp:1333
xmlNode_t *IMPORT * XML_GetNode(xmlNode_t *parent, const char *name)
static memPool_t * GAME_CreatePool(const char *name)
Definition: cl_game.cpp:438
bool Com_GetConstInt(const char *name, int *value)
Searches whether a given value was registered as a string to int mapping.
Definition: scripts.cpp:74
int CL_GetClientState(void)
Definition: cl_main.cpp:1008
const ugv_t *IMPORT * Com_GetUGVByIDSilent(const char *ugvID)
char * name
Definition: cvar.h:72
bool Com_UnregisterConstList(const constListEntry_t constList[])
Unregisters a list of string aliases.
Definition: scripts.cpp:237
void format(__printf__, 1, 2)))
int NET_ReadStringLine(dbuffer *buf, char *string, size_t length)
Definition: netpack.cpp:328
void LIST_AddPointer(linkedList_t **listDest, void *data)
Adds just a pointer to a new or to an already existing linked list.
Definition: list.cpp:153
bool R_ImageExists(const char *pname,...)
Definition: r_image.cpp:681
keydest_t keyDest
Definition: client.h:56
xmlNode_t * XML_Parse(const char *buffer)
Definition: xml.cpp:531
void SV_Shutdown(const char *finalmsg, bool reconnect)
Called when each game quits, before Sys_Quit or Sys_Error.
Definition: sv_main.cpp:1042
const ugv_t * Com_GetUGVByID(const char *ugvID)
Searches an UGV definition by a given script id and returns the pointer to the global data...
Definition: scripts.cpp:3403
const char *EXPORT * GetTeamDef(void)
void HUD_DisplayMessage(const char *text)
Displays a message on the hud.
Definition: cl_hud.cpp:138
bool removeFromInventory(Inventory *const inv, const invDef_t *container, Item *fItem) __attribute__((warn_unused_result))
Definition: inventory.cpp:152
short Com_GetHumanAircraftIdsNum(void)
Definition: scripts.cpp:584
int CL_Milliseconds(void)
Definition: cl_main.cpp:1208
void Cmd_TableAddList(const cmdList_t *cmdList)
Definition: cmd.cpp:853
void FS_FreeFile(void *buffer)
Definition: files.cpp:411
void UI_DisplayNotice(const char *text, int time, const char *windowName)
Displays a message over all windows.
Definition: ui_draw.cpp:411
void GAME_MapClick(uiNode_t *node, int x, int y, const vec2_t pos)
Definition: cl_game.cpp:945
bool WEB_CGameDownloadFromUser(const char *cgameId, int category, const char *filename, int userId)
Downloads a file from the server and store it in the user directory.
Definition: web_cgame.cpp:187
#define SND_VOLUME_DEFAULT
Definition: s_main.h:42
const char *IMPORT * Com_ValueToStr(const void *base, const valueTypes_t type, const int ofs)
void UI_ExecuteConfunc(const char *fmt,...)
Executes confunc - just to identify those confuncs in the code - in this frame.
Definition: ui_main.cpp:110
const char * FS_NextPath(const char *prevpath)
Allows enumerating all of the directories in the search path.
Definition: files.cpp:614
bool Com_ParseBoolean(const char *token)
Parses a boolean from a string.
Definition: scripts.cpp:1000
int GetUsedSlots()
Calculate the number of used inventory slots.
Definition: inventory.cpp:966
static void UI_PreviousMap_f(void)
Select the previous available map.
Definition: cl_game.cpp:1117
static const int TAG_INVENTORY
Definition: cl_game.cpp:880
void UI_PopupButton(const char *title, const char *text, const char *clickAction1, const char *clickText1, const char *tooltip1, const char *clickAction2, const char *clickText2, const char *tooltip2, const char *clickAction3, const char *clickText3, const char *tooltip3)
Generates a popup that contains up to 3 buttons.
Definition: ui_popup.cpp:147
vec_t vec4_t[4]
Definition: ufotypes.h:40
linkedList_t * params
Definition: q_shared.h:465
void NET_WriteMsg(struct net_stream *s, dbuffer &buf)
Enqueue the buffer in the net stream for ONE client.
Definition: netpack.cpp:569
Describes a character with all its attributes.
Definition: chr_shared.h:369