UFO: Alien Invasion
cl_game.cpp
Go to the documentation of this file.
1
6/*
7Copyright (C) 2002-2022 UFO: Alien Invasion.
8
9This program is free software; you can redistribute it and/or
10modify it under the terms of the GNU General Public License
11as published by the Free Software Foundation; either version 2
12of the License, or (at your option) any later version.
13
14This program is distributed in the hope that it will be useful,
15but WITHOUT ANY WARRANTY; without even the implied warranty of
16MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17
18See the GNU General Public License for more details.
19
20You should have received a copy of the GNU General Public License
21along with this program; if not, write to the Free Software
22Foundation, 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
60static int numCGameTypes;
61
62static inline const cgame_export_t* GAME_GetCurrentType (void)
63{
64 return cls.gametype;
65}
66
68{
69private:
70 typedef std::set<const struct cvar_s* > GameCvars;
72public:
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{
107private:
108 typedef std::set<const char* > GameCmds;
110public:
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
153static const cgame_api_t gameTypeList[] = {
154 GetCGameMultiplayerAPI,
155 GetCGameCampaignAPI,
156 GetCGameSkirmishAPI
157};
158
159static const char* cgameMenu;
160
161const 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
231const 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
251void 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
276void 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
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
325void 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
338void 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
347void 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
356static 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
361bool 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
370void 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
389{
391}
392
393static 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
405static 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
417static 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
428static char* GAME_StrDup (const char* string)
429{
430 return Mem_PoolStrDup(string, cl_genericPool, 0);
431}
432
433static void GAME_Free (void* ptr)
434{
435 Mem_Free(ptr);
436}
437
438static memPool_t* GAME_CreatePool (const char* name)
439{
440 return Mem_CreatePool(name);
441}
442
443static void GAME_FreePool (memPool_t* pool)
444{
445 Mem_FreePool(pool);
446}
447
448static char* GAME_PoolStrDup (const char* in, memPool_t* pool, const int tagNum)
449{
450 return Mem_PoolStrDup(in, pool, tagNum);
451}
452
453static void GAME_DestroyInventory (Inventory* const inv)
454{
456}
457
458static 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
463static bool GAME_RemoveFromInventory (Inventory* const i, const invDef_t* container, Item* fItem)
464{
465 return cls.i.removeFromInventory(i, container, fItem);
466}
467
468static void GAME_WebUpload (int category, const char* filename)
469{
471}
472
473static void GAME_WebDelete (int category, const char* filename)
474{
476}
477
478static void GAME_WebDownloadFromUser (int category, const char* filename, int userId)
479{
481}
482
483static void GAME_WebListForUser (int category, int userId)
484{
485 WEB_CGameListForUser(GAME_GetCurrentName(), category, userId);
486}
487
489{
491}
492
494{
496}
497
498static 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
533static 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
549static 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
554static void UI_PushWindow_ (const char* name)
555{
557}
558
559static 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
564static 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
574static 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
581static 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
595 cgi->csi = &csi;
596
600
602 cgi->Cmd_AddCommand = Cmd_AddCommand;
603 cgi->Cmd_Argc = Cmd_Argc;
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;
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;
637 cgi->Cvar_GetInteger = Cvar_GetInteger;
638 cgi->Cvar_GetValue = Cvar_GetValue;
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
658 cgi->UI_ExecuteConfunc = UI_ExecuteConfunc;
659 cgi->UI_InitStack = UI_InitStack;
660 cgi->UI_Popup = GAME_UI_Popup;
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;
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
693
694 cgi->NET_StreamSetCallback = NET_StreamSetCallback;
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;
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;
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;
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
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;
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;
873 }
874
875 cgi->cgameType = t;
876
877 return cgi;
878}
879
880static const int TAG_INVENTORY = 17462;
881
882static void GAME_FreeInventory (void* data)
883{
884 Mem_Free(data);
885}
886
887static void* GAME_AllocInventoryMemory (size_t size)
888{
890}
891
892
893static void GAME_FreeAllInventory (void)
894{
896}
897
899
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
945void 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
952void 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
978
979 list = GAME_GetCurrentType();
980 if (list) {
981 Com_Printf("Change gametype to '%s'\n", list->name);
982 /* inventory structure switched/initialized */
985 list->Init();
986 Cvar_FullSet("gamemode", list->menu, CVAR_NOSET);
987 }
988}
989
990static 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
1019static 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
1061static 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
1101static void UI_GetMaps_f (void)
1102{
1103 UI_MapInfo(0);
1104}
1105
1109static void UI_NextMap_f (void)
1110{
1111 UI_MapInfo(1);
1112}
1113
1117static void UI_PreviousMap_f (void)
1118{
1119 UI_MapInfo(-1);
1120}
1121
1122static 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
1159static 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
1167void 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 */
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
1194static 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
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) {
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
1256}
1257
1259{
1260#ifdef HARD_LINKED_CGAME
1261 cgameMenu = t->window;
1262#endif
1263 return GAME_GetCGameAPI(t);
1264}
1265
1269static 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;
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
1326void 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
1341static 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
1354static 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
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
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)
1405
1406 for (int j = 0; j < SKILL_NUM_TYPES + 1; 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
1439 }
1440}
1441
1442const 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
1455static 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
1487void 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
1502void 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);
1561 }
1562 }
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;
1587 }
1588}
1589
1591{
1592 if (!LIST_IsEmpty(cl.chrList)) {
1593 dbuffer msg(12);
1597
1599 }
1600}
1601
1602const char* GAME_GetRelativeSavePath (char* buf, size_t bufSize)
1603{
1604 Com_sprintf(buf, bufSize, "save/%s/", GAME_GetCurrentName());
1605 return buf;
1606}
1607
1608const 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
1624{
1625 const cgame_export_t* list = GAME_GetCurrentType();
1626 if (list && list->NotifyEvent)
1627 list->NotifyEvent(eventType);
1628}
1629
1630bool 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
1652static void GAME_Abort_f (void)
1653{
1654 /* aborting means letting the aliens win */
1655 Cbuf_AddText("sv win %i\n", TEAM_ALIEN);
1656}
1657
1658void 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
1669
1670 UI_InitStack("main", nullptr);
1671 }
1672}
1673
1677static void GAME_Exit_f (void)
1678{
1679 GAME_SetMode(nullptr);
1680
1682}
1683
1687void 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
1699void 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
1712void 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
1725const 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
1783const 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
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);
1855 }
1856
1857 Com_Printf("added %i game modes\n", numCGameTypes);
1858}
1859
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
1884void GAME_Shutdown (void)
1885{
1887 numCGameTypes = 0;
1889 for (int i = 0; i < lengthof(characters); ++i)
1890 characters[1].init();
1891
1894}
bool BEP_Evaluate(const char *expr, BEPEvaluteCallback_t varFuncParam, const void *userdata)
const cgame_export_t *(* cgame_api_t)(const cgame_import_t *)
Definition: cgame.h:389
changeEquipType_t
Definition: cgame.h:92
@ FORWARD
Definition: cgame.h:93
@ BACKWARD
Definition: cgame.h:94
bool CHRSH_IsArmourUseableForTeam(const objDef_t *od, const teamDef_t *teamDef)
Definition: chr_shared.cpp:88
@ ABILITY_POWER
Definition: chr_shared.h:37
@ SKILL_NUM_TYPES
Definition: chr_shared.h:51
@ KILLED_NUM_TYPES
Definition: chr_shared.h:32
char * CL_GetConfigString(int index)
clientBattleScape_t cl
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...
static void UI_MapInfo(int step)
Prints the map info for the server creation dialogue.
Definition: cl_game.cpp:1019
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
void GAME_InitStartup(void)
Definition: cl_game.cpp:1860
static const cgame_export_t * GAME_GetCurrentType(void)
Definition: cl_game.cpp:62
void GAME_EndRoundAnnounce(int playerNum, int team)
Send end round announcements.
Definition: cl_game.cpp:325
void GAME_StartMatch(void)
Definition: cl_game.cpp:1590
character_t * GAME_GetSelectedChr(void)
Returns the currently selected character.
Definition: cl_game.cpp:1746
static void UI_SelectMap_f(void)
Definition: cl_game.cpp:1122
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
void GAME_AddChatMessage(const char *format,...)
Definition: cl_game.cpp:370
static void UI_RequestMapList_f(void)
Definition: cl_game.cpp:1061
static void GAME_Free(void *ptr)
Definition: cl_game.cpp:433
static equipDef_t equipDefStandard
Definition: cl_game.cpp:180
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
equipDef_t * GAME_GetEquipmentDefinition(void)
Definition: cl_game.cpp:1614
bool GAME_ItemIsUseable(const objDef_t *od)
Definition: cl_game.cpp:1295
static const cgame_export_t * GAME_GetCGameAPI_(const cgameType_t *t)
Definition: cl_game.cpp:1258
bool GAME_IsTeamEmpty(void)
Definition: cl_game.cpp:388
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
#define MAX_CGAMETYPES
Definition: cl_game.cpp:58
static void GAME_NET_OOB_Printf2(const char *format,...)
Definition: cl_game.cpp:405
static void UI_PushWindow_(const char *name)
Definition: cl_game.cpp:554
void GAME_Frame(void)
Called every frame and allows us to hook into the current running game mode.
Definition: cl_game.cpp:1687
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
static void UI_MapInfoGetNext(int step)
Definition: cl_game.cpp:990
void GAME_DrawMap(geoscapeData_t *data)
Definition: cl_game.cpp:931
static int numCGameTypes
Definition: cl_game.cpp:60
static void GAME_NetSendInventory(dbuffer *buf, const Inventory *inv)
Definition: cl_game.cpp:1354
static void GAME_FreeAllInventory(void)
Definition: cl_game.cpp:893
static void R_DrawImageCentered(int x, int y, const char *name)
Definition: cl_game.cpp:574
void GAME_NotifyEvent(event_t eventType)
Definition: cl_game.cpp:1623
void GAME_SwitchCurrentSelectedMap(int step)
Definition: cl_game.cpp:912
static void GAME_WebListForUser(int category, int userId)
Definition: cl_game.cpp:483
static const cgame_import_t * GAME_GetImportData(const cgameType_t *t)
Definition: cl_game.cpp:586
static void UI_NextMap_f(void)
Select the next available map.
Definition: cl_game.cpp:1109
void GAME_AppendTeamMember(int memberIndex, const char *teamDefID, const equipDef_t *ed)
Definition: cl_game.cpp:251
static void GAME_SetNextUniqueCharacterNumber(int ucn)
Definition: cl_game.cpp:488
void GAME_Shutdown(void)
Definition: cl_game.cpp:1884
void GAME_UnloadGame(void)
Definition: cl_game.cpp:900
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
static char * GAME_PoolStrDup(const char *in, memPool_t *pool, const int tagNum)
Definition: cl_game.cpp:448
static const int TAG_INVENTORY
Definition: cl_game.cpp:880
const char * GAME_GetAbsoluteSavePath(char *buf, size_t bufSize)
Definition: cl_game.cpp:1608
static void UI_PreviousMap_f(void)
Select the previous available map.
Definition: cl_game.cpp:1117
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
void GAME_InitMissionBriefing(const char *title)
Definition: cl_game.cpp:1502
static void GAME_DestroyInventory(Inventory *const inv)
Definition: cl_game.cpp:453
size_t GAME_GetCharacterArraySize(void)
Definition: cl_game.cpp:226
void GAME_GenerateTeam(const char *teamDefID, const equipDef_t *ed, int teamMembers)
Definition: cl_game.cpp:276
static void GAME_FreeInventory(void *data)
Definition: cl_game.cpp:882
void GAME_DrawMapMarkers(uiNode_t *node)
Definition: cl_game.cpp:938
static void GAME_SetMode_f(void)
Decides which game mode should be set - takes the menu as reference.
Definition: cl_game.cpp:1269
void GAME_SpawnSoldiers(void)
Called during startup of mission to send team info.
Definition: cl_game.cpp:1569
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
static bool GAME_LoadGame(const char *path, const char *name)
Definition: cl_game.cpp:1194
geoscapeData_t geoscapeData
Definition: cl_game.cpp:146
bool GAME_IsMultiplayer(void)
Definition: cl_game.cpp:299
static void GAME_FreePool(memPool_t *pool)
Definition: cl_game.cpp:443
void GAME_MapClick(uiNode_t *node, int x, int y, const vec2_t pos)
Definition: cl_game.cpp:945
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
void GAME_ParseModes(const char *name, const char **text)
Definition: cl_game.cpp:1167
static void GAME_NET_OOB_Printf(struct net_stream *s, const char *format,...)
Definition: cl_game.cpp:393
void GAME_DrawBaseLayoutTooltip(int baseIdx, int x, int y)
Cgame callback to draw tooltip for baselayout UI node.
Definition: cl_game.cpp:1712
static memPool_t * GAME_CreatePool(const char *name)
Definition: cl_game.cpp:438
static void * GAME_AllocInventoryMemory(size_t size)
Definition: cl_game.cpp:887
static void GAME_NetSendItem(dbuffer *buf, const Item *item, containerIndex_t container, int x, int y)
Definition: cl_game.cpp:1341
int GAME_GetChrMaxLoad(const character_t *chr)
Returns the max weight the given character can carry.
Definition: cl_game.cpp:1768
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
static int UI_DrawString_(const char *fontID, align_t align, int x, int y, const char *c)
Definition: cl_game.cpp:549
static void GAME_Abort_f(void)
Let the aliens win the match.
Definition: cl_game.cpp:1652
static void R_UploadAlpha_(const char *name, const byte *alphaData)
Definition: cl_game.cpp:564
const char * GAME_GetTeamDef(void)
Definition: cl_game.cpp:1442
void GAME_ResetCharacters(void)
Reset all characters in the static character array.
Definition: cl_game.cpp:243
static void GAME_WebDownloadFromUser(int category, const char *filename, int userId)
Definition: cl_game.cpp:478
static void GAME_UI_Popup(const char *title, const char *format,...)
Definition: cl_game.cpp:417
static void UI_GetMaps_f(void)
Definition: cl_game.cpp:1101
bool GAME_TeamIsKnown(const teamDef_t *teamDef)
Definition: cl_game.cpp:1630
void GAME_InitUIData(void)
Fills the game mode list entries with the parsed values from the script.
Definition: cl_game.cpp:1840
static void GAME_WebDelete(int category, const char *filename)
Definition: cl_game.cpp:473
const mapDef_t * GAME_GetCurrentSelectedMap(void)
Definition: cl_game.cpp:921
const char * GAME_GetCurrentName(void)
Definition: cl_game.cpp:231
const char * GAME_GetRelativeSavePath(char *buf, size_t bufSize)
Definition: cl_game.cpp:1602
static SharedPtr< GAMECvarListener > cvarListener(new GAMECvarListener())
static bool GAME_Spawn(linkedList_t **chrList)
Definition: cl_game.cpp:1455
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
static bool GAME_RemoveFromInventory(Inventory *const i, const invDef_t *container, Item *fItem)
Definition: cl_game.cpp:463
static void GAME_EquipActor(character_t *const chr, const equipDef_t *ed, const objDef_t *weapon, int maxWeight)
Definition: cl_game.cpp:458
void GAME_EndBattlescape(void)
This is called when a client quits the battlescape.
Definition: cl_game.cpp:314
static cgameType_t cgameTypes[MAX_CGAMETYPES]
Definition: cl_game.cpp:59
static int GAME_GetNextUniqueCharacterNumber(void)
Definition: cl_game.cpp:493
static SharedPtr< GAMECmdListener > cmdListener(new GAMECmdListener())
static void GAME_WebUpload(int category, const char *filename)
Definition: cl_game.cpp:468
bool GAME_HandleServerCommand(const char *command, dbuffer *msg)
Definition: cl_game.cpp:361
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_SetMode(const cgame_export_t *gametype)
Definition: cl_game.cpp:952
static const cgame_export_t * GAME_GetCGameAPI(const cgameType_t *t)
Definition: cl_game.cpp:1216
static void GAME_Exit_f(void)
Quits the current running game by calling the shutdown callback.
Definition: cl_game.cpp:1677
static char * GAME_StrDup(const char *string)
Definition: cl_game.cpp:428
static const value_t cgame_vals[]
Valid equipment definition values from script files.
Definition: cl_game.cpp:1159
static void CL_QueryMasterServer(const char *action, http_callback_t callback)
Definition: cl_game.cpp:356
void GAME_SetServerInfo(const char *server, const char *serverport)
Definition: cl_game.cpp:347
int GAME_GetCurrentTeam(void)
Definition: cl_game.cpp:926
const char * GAME_GetModelForItem(const objDef_t *od, uiModel_t **uiModel)
Get a model for an item.
Definition: cl_game.cpp:1725
void GAME_StartBattlescape(bool isTeamPlay)
Called when the server sends the EV_START event.
Definition: cl_game.cpp:1487
void GAME_ReloadMode(void)
Definition: cl_game.cpp:290
static const char * Com_EParse_(const char **text, const char *errhead, const char *errinfo)
Definition: cl_game.cpp:581
static const inventoryImport_t inventoryImport
Definition: cl_game.cpp:898
void GAME_Drop(void)
Definition: cl_game.cpp:1658
void GAME_CharacterCvars(const character_t *chr)
Definition: cl_game.cpp:1642
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
Shared game type headers.
mapDef_t * Com_GetMapDefByIDX(int index)
linkedList_t * LIST_CopyStructure(linkedList_t *src)
CGAME_HARD_LINKED_FUNCTIONS linkedList_t * LIST_Add(linkedList_t **listDest, void const *data, size_t length)
void LIST_Sort(linkedList_t **list, linkedListSort_t sorter, const void *userData)
void FS_CloseFile(qFILE *f)
void * _Mem_Alloc(size_t size, bool zeroFill, memPool_t *pool, const int tagNum, const char *fileName, const int fileLine)
const cgame_export_t * GetCGameAPI(const cgame_import_t *import)
Singleplayer campaign game type headers.
Multiplayer game type headers.
Skirmish game type headers.
bool GAME_SaveCharacter(xmlNode_t *p, const character_t *chr)
saves a character to a given xml node
void GAME_SaveTeam_f(void)
Stores a team in a specified teamslot.
void GAME_UpdateTeamMenuParameters_f(void)
Displays actor info and equipment and unused items in proper (filter) category.
void GAME_AutoTeam_f(void)
void GAME_SaveTeamState_f(void)
Will remove those actors that should not be used in the team.
void GAME_TeamDelete_f(void)
Removes a user created team.
void GAME_TeamSlotComments_f(void)
Reads the comments from team files.
bool GAME_LoadDefaultTeam(bool force)
void GAME_ActorSelect_f(void)
void GAME_AutoTeam(const char *equipmentDefinitionID, int teamMembers)
void GAME_ToggleActorForTeam_f(void)
This will activate/deactivate the actor for the team.
void GAME_LoadTeam_f(void)
Loads the selected teamslot.
bool GAME_LoadCharacter(xmlNode_t *p, character_t *chr)
Loads a character from a given xml node.
cgame team management headers.
void HUD_InitUI(const char *optionWindowName)
Display the user interface.
Definition: cl_hud.cpp:1572
void HUD_DisplayMessage(const char *text)
Displays a message on the hud.
Definition: cl_hud.cpp:138
itemFilterTypes_t INV_GetFilterTypeID(const char *filterTypeID)
Searches for a filter type name (as used in console functions) and returns the matching itemFilterTyp...
const equipDef_t * INV_GetEquipmentDefinitionByID(const char *name)
Gets equipment definition by id.
const char * INV_GetFilterType(itemFilterTypes_t id)
bool INV_ItemMatchesFilter(const objDef_t *obj, const itemFilterTypes_t filterType)
Checks if the given object/item matched the given filter type.
void INV_ItemDescription(const objDef_t *od)
Prints the description for items (weapons, armour, ...)
@ key_console
Definition: cl_keys.h:183
const char * CL_Translate(const char *t)
le_t * LE_GetNextInUse(le_t *lastLE)
Iterate through the entities that are in use.
bool LE_IsActor(const le_t *le)
Checks whether the given le is a living actor.
#define LE_IsDead(le)
#define LE_IsItem(le)
#define LE_IsAlien(le)
#define LE_IsStunned(le)
int CL_GetClientState(void)
Definition: cl_main.cpp:1007
void CL_Drop(void)
Ensures the right menu cvars are set after error drop or map change.
Definition: cl_main.cpp:167
void CL_SetClientState(connstate_t state)
Sets the client state.
Definition: cl_main.cpp:1015
client_static_t cls
Definition: cl_main.cpp:83
void CL_Disconnect(void)
Sets the cls.state to ca_disconnected and informs the server.
Definition: cl_main.cpp:256
memPool_t * cl_genericPool
Definition: cl_main.cpp:86
int CL_Milliseconds(void)
Definition: cl_main.cpp:1207
const char * CL_PlayerGetName(unsigned int player)
Get the player name.
Definition: cl_parse.cpp:113
int CL_GetPlayerNum(void)
Definition: cl_parse.cpp:103
void R_LoadImage(const char *name, byte **pic, int *width, int *height)
Generic image-data loading fucntion.
Definition: r_image.cpp:152
void R_Color(const vec4_t rgba)
Change the color to given value.
Definition: r_state.cpp:1011
#define _(String)
Definition: cl_shared.h:44
mapDef_t * Com_GetMapDefinitionByID(const char *mapDefID)
Definition: scripts.cpp:3598
#define INVDEF(containerID)
Definition: cl_shared.h:48
void CL_UpdateCharacterValues(const character_t *chr)
Definition: cl_team.cpp:218
linkedList_t * chrDisplayList
List of currently displayed or equipable characters.
Definition: cl_team.cpp:38
const char * CL_ActorGetSkillString(const int skill)
Return the skill string for the given skill level.
Definition: cl_team.cpp:165
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
short numBodyParts(void) const
Definition: chr_shared.cpp:389
Listener for command changes.
Definition: cmd.h:96
Listener for cvar changes.
Definition: cvar.h:98
void onGameModeChange()
Definition: cl_game.cpp:129
GameCmds _cmds
Definition: cl_game.cpp:109
std::set< const char * > GameCmds
Definition: cl_game.cpp:108
void onRemove(const char *cmdName)
Definition: cl_game.cpp:124
void onAdd(const char *cmdName)
Definition: cl_game.cpp:116
void onDelete(const struct cvar_s *cvar)
Definition: cl_game.cpp:85
void onGameModeChange()
Definition: cl_game.cpp:90
void onCreate(const struct cvar_s *cvar)
Definition: cl_game.cpp:78
GameCvars _cvars
Definition: cl_game.cpp:71
std::set< const struct cvar_s * > GameCvars
Definition: cl_game.cpp:70
inventory definition with all its containers
Definition: inv_shared.h:525
int countItems() const
Count the number of items in the inventory (without temp containers)
Definition: inv_shared.cpp:741
void resetTempContainers()
Definition: inv_shared.h:557
Item * getArmour() const
Definition: inv_shared.cpp:990
Item * getContainer2(const containerIndex_t idx) const
Definition: inv_shared.h:546
void destroyInventory(Inventory *const inv)
Destroys inventory.
Definition: inventory.cpp:521
int GetUsedSlots()
Calculate the number of used inventory slots.
Definition: inventory.cpp:966
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
bool removeFromInventory(Inventory *const inv, const invDef_t *container, Item *fItem) __attribute__((warn_unused_result))
Definition: inventory.cpp:152
void EquipActor(character_t *const chr, const equipDef_t *ed, const objDef_t *weapon, int maxWeight)
Definition: inventory.cpp:947
void destroyInventoryInterface(void)
Definition: inventory.cpp:997
item instance data, with linked list capability
Definition: inv_shared.h:402
const objDef_t * ammoDef(void) const
Definition: inv_shared.h:460
int getAmmoLeft() const
Definition: inv_shared.h:466
int getX() const
Definition: inv_shared.h:454
int rotated
Definition: inv_shared.h:412
int getAmount() const
Definition: inv_shared.h:463
const objDef_t * def(void) const
Definition: inv_shared.h:469
int getY() const
Definition: inv_shared.h:457
Item * getNext() const
Definition: inv_shared.h:451
void Cmd_ExecuteString(const char *text,...)
A complete command line has been parsed, so try to execute it.
Definition: cmd.cpp:1007
const char * Cmd_Argv(int arg)
Returns a given argument.
Definition: cmd.cpp:516
void Cmd_AddParamCompleteFunction(const char *cmdName, int(*function)(const char *partial, const char **match))
Definition: cmd.cpp:679
void Cmd_TableAddList(const cmdList_t *cmdList)
Definition: cmd.cpp:853
void Cmd_RemoveCommand(const char *cmdName)
Removes a command from script interface.
Definition: cmd.cpp:786
void Cbuf_Execute(void)
Pulls off terminated lines of text from the command buffer and sends them through Cmd_ExecuteString...
Definition: cmd.cpp:214
void Cmd_RegisterCmdListener(CmdListenerPtr listener)
Registers a command listener.
Definition: cmd.cpp:869
void Cmd_UnRegisterCmdListener(CmdListenerPtr listener)
Unregisters a command listener.
Definition: cmd.cpp:878
const char * Cmd_Args(void)
Returns a single string containing argv(1) to argv(argc()-1)
Definition: cmd.cpp:526
bool Cmd_GenericCompleteFunction(char const *candidate, char const *partial, char const **match)
Definition: cmd.cpp:648
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
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 Cbuf_AddText(const char *format,...)
Adds command text at the end of the buffer.
Definition: cmd.cpp:126
void Cmd_TableRemoveList(const cmdList_t *cmdList)
Definition: cmd.cpp:859
csi_t csi
Definition: common.cpp:39
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
int Com_ServerState(void)
Check whether we are the server or have a singleplayer tactical mission.
Definition: common.cpp:538
void Com_Error(int code, const char *fmt,...)
Definition: common.cpp:417
void Com_SetGameType(void)
Definition: common.cpp:815
void Com_Printf(const char *const fmt,...)
Definition: common.cpp:386
cvar_t * masterserver_url
Definition: common.cpp:57
void Com_Drop(void)
Definition: common.cpp:465
@ clc_stringcmd
Definition: common.h:181
@ clc_teaminfo
Definition: common.h:177
@ clc_initactorstates
Definition: common.h:178
#define CPUSTRING
Definition: common.h:109
void SV_ShutdownWhenEmpty(void)
Will eventually shutdown the server once all clients have disconnected.
Definition: sv_main.cpp:1085
void SV_Shutdown(const char *finalmsg, bool reconnect)
Called when each game quits, before Sys_Quit or Sys_Error.
Definition: sv_main.cpp:1042
#define ERR_DROP
Definition: common.h:211
#define ERR_FATAL
Definition: common.h:210
#define PKGLIBDIR
Definition: config_android.h:8
const cgame_import_t * cgi
cvar_t * Cvar_ForceSet(const char *varName, const char *value)
Will set the variable even if NOSET or LATCH.
Definition: cvar.cpp:604
void Cvar_SetValue(const char *varName, float value)
Expands value to a string and calls Cvar_Set.
Definition: cvar.cpp:671
const char * Cvar_VariableStringOld(const char *varName)
Returns the old value of cvar as string before we changed it.
Definition: cvar.cpp:226
cvar_t * Cvar_Set(const char *varName, const char *value,...)
Sets a cvar value.
Definition: cvar.cpp:615
bool Cvar_Delete(const char *varName)
Function to remove the cvar and free the space.
Definition: cvar.cpp:279
int Cvar_GetInteger(const char *varName)
Returns the int value of a cvar.
Definition: cvar.cpp:194
void Cvar_RegisterCvarListener(CvarListenerPtr listener)
Registers a cvar listener.
Definition: cvar.cpp:406
void Cvar_UnRegisterCvarListener(CvarListenerPtr listener)
Unregisters a cvar listener.
Definition: cvar.cpp:415
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
float Cvar_GetValue(const char *varName)
Returns the float value of a cvar.
Definition: cvar.cpp:125
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
const char * Cvar_GetString(const char *varName)
Returns the value of cvar as string.
Definition: cvar.cpp:210
#define CVAR_NOSET
Definition: cvar.h:43
#define DEBUG_SYSTEM
Definition: defines.h:57
#define MAX_TEAMS
Definition: defines.h:98
#define DEBUG_CLIENT
Definition: defines.h:59
#define DEBUG_COMMANDS
Definition: defines.h:58
#define NONE
Definition: defines.h:68
#define ACTOR_SIZE_2x2
Definition: defines.h:303
#define ACTOR_SIZE_NORMAL
Definition: defines.h:302
#define MAX_ACTIVETEAM
Definition: defines.h:41
const eventRegister_t * CL_GetEvent(const event_t eType)
Definition: e_main.cpp:157
const char * FS_NextPath(const char *prevpath)
Allows enumerating all of the directories in the search path.
Definition: files.cpp:614
void FS_RemoveFile(const char *osPath)
Definition: files.cpp:1692
int FS_CheckFile(const char *fmt,...)
Just returns the filelength and -1 if the file wasn't found.
Definition: files.cpp:298
int FS_LoadFile(const char *path, byte **buffer)
Filenames are relative to the quake search path.
Definition: files.cpp:384
char * FS_NextScriptHeader(const char *files, const char **name, const char **text)
Definition: files.cpp:1196
void FS_FreeFile(void *buffer)
Definition: files.cpp:411
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:1081
int FS_WriteFile(const void *buffer, size_t len, const char *filename)
Definition: files.cpp:1546
int FS_Read(void *buffer, int len, qFILE *f)
Definition: files.cpp:371
int FS_OpenFile(const char *filename, qFILE *file, filemode_t mode)
Finds and opens the file in the search path.
Definition: files.cpp:162
const char * FS_Gamedir(void)
Called to find where to write a file (savegames, etc)
Definition: files.cpp:68
int FS_BuildFileList(const char *fileList)
Build a filelist.
Definition: files.cpp:962
#define MAX_OSPATH
Definition: filesys.h:44
void Sys_Error(const char *error,...)
Definition: g_main.cpp:421
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
void(* http_callback_t)(const char *response, void *userdata)
Definition: http.h:65
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
#define CID_MAX
Definition: inv_shared.h:57
int32_t containerIndex_t
Definition: inv_shared.h:46
@ ACTOR_HAND_NOT_SET
Definition: inv_shared.h:627
voidpf void uLong size
Definition: ioapi.h:42
const char * filename
Definition: ioapi.h:41
voidpf void * buf
Definition: ioapi.h:42
linkedList_t * LIST_GetPointer(linkedList_t *list, const void *data)
Searches for the first occurrence of a given pointer.
Definition: list.cpp:91
void LIST_AddStringSorted(linkedList_t **listDest, const char *data)
Definition: list.cpp:107
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
void * LIST_GetRandom(linkedList_t *list)
Definition: list.cpp:381
void LIST_Delete(linkedList_t **list)
Definition: list.cpp:195
bool LIST_RemoveEntry(linkedList_t **list, linkedList_t *entry)
Removes one entry from the linked list.
Definition: list.cpp:172
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
int LIST_Count(const linkedList_t *list)
Definition: list.cpp:344
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 LIST_Remove(linkedList_t **list, const void *data)
Definition: list.cpp:213
bool LIST_IsEmpty(const linkedList_t *list)
Checks whether the given list is empty.
Definition: list.cpp:335
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
void LIST_PrependString(linkedList_t **listDest, const char *data)
Adds a string as first entry to a linked list.
Definition: list.cpp:127
#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
static struct mdfour * m
Definition: md4.cpp:35
#define Mem_FreePool(pool)
Definition: mem.h:37
#define Mem_Free(ptr)
Definition: mem.h:35
#define Mem_PoolStrDup(in, pool, tagNum)
Definition: mem.h:50
#define Mem_CreatePool(name)
Definition: mem.h:32
#define Mem_FreeTag(pool, tagNum)
Definition: mem.h:36
#define Mem_PoolAlloc(size, pool, tagNum)
Definition: mem.h:41
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 NET_StreamSetCallback(struct net_stream *s, stream_callback_func *func)
Definition: net.cpp:903
dbuffer * NET_ReadMsg(struct net_stream *s)
Reads messages from the network channel and adds them to the dbuffer where you can use the NET_Read* ...
Definition: net.cpp:774
void 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
void NET_StreamSetData(struct net_stream *s, void *data)
Definition: net.cpp:805
void * NET_StreamGetData(struct net_stream *s)
Definition: net.cpp:800
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 NET_DatagramBroadcast(struct datagram_socket *s, const char *buf, int len, int port)
Definition: net.cpp:1159
void NET_StreamFree(struct net_stream *s)
Call NET_StreamFree to dump the whole thing right now.
Definition: net.cpp:817
void NET_DatagramSocketClose(struct datagram_socket *s)
Definition: net.cpp:1182
const char * NET_StreamPeerToName(struct net_stream *s, char *dst, int len, bool appendPort)
Definition: net.cpp:872
int NET_ReadString(dbuffer *buf, char *string, size_t length)
Definition: netpack.cpp:302
void NET_WriteShort(dbuffer *buf, int c)
Definition: netpack.cpp:45
int NET_ReadStringLine(dbuffer *buf, char *string, size_t length)
Definition: netpack.cpp:328
int NET_ReadLong(dbuffer *buf)
Definition: netpack.cpp:282
void NET_WriteMsg(struct net_stream *s, dbuffer &buf)
Enqueue the buffer in the net stream for ONE client.
Definition: netpack.cpp:569
int NET_ReadByte(dbuffer *buf)
Reads a byte from the netchannel.
Definition: netpack.cpp:234
int NET_ReadShort(dbuffer *buf)
Definition: netpack.cpp:242
void NET_WriteByte(dbuffer *buf, byte c)
Definition: netpack.cpp:39
void NET_WriteLong(dbuffer *buf, int c)
Definition: netpack.cpp:52
void NET_OOB_Printf(struct net_stream *s, const char *format,...)
Out of band print.
Definition: netpack.cpp:548
void NET_WriteString(dbuffer *buf, const char *str)
Definition: netpack.cpp:59
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
#define MapDef_ForeachCondition(var, condition)
Definition: q_shared.h:501
event_t
Possible event values.
Definition: q_shared.h:79
@ EV_INV_TRANSFER
Definition: q_shared.h:124
#define TEAM_ALIEN
Definition: q_shared.h:63
#define MapDef_Foreach(var)
Definition: q_shared.h:505
#define STATE_REACTION
Definition: q_shared.h:272
void format(__printf__, 1, 2)))
#define CS_MAPTITLE
Definition: q_shared.h:310
#define CS_VICTORY_CONDITIONS
Definition: q_shared.h:323
#define NET_STATE_STARTMATCH
Definition: q_shared.h:610
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
void R_DrawLine(int *verts, float thickness)
Draws one line with only one start and one end point.
Definition: r_draw.cpp:494
void R_DrawLineStrip(int points, int *verts)
2 dimensional line strip
Definition: r_draw.cpp:477
void R_DrawImage(float x, float y, const image_t *image)
Draws an image or parts of it.
Definition: r_draw.cpp:341
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
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:237
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:180
void R_DrawBloom(void)
handle post-processing bloom
Definition: r_geoscape.cpp:762
QGL_EXTERN GLuint GLchar GLuint * len
Definition: r_gl.h:99
QGL_EXTERN GLuint count
Definition: r_gl.h:99
QGL_EXTERN GLsizei const GLvoid * data
Definition: r_gl.h:89
QGL_EXTERN GLuint index
Definition: r_gl.h:110
QGL_EXTERN GLint i
Definition: r_gl.h:113
QGL_EXTERN GLuint GLsizei GLsizei GLint GLenum GLchar * name
Definition: r_gl.h:110
QGL_EXTERN GLuint GLsizei bufSize
Definition: r_gl.h:110
void R_SoftenTexture(byte *in, int width, int height, int bpp)
Applies blurring to a texture.
Definition: r_image.cpp:391
image_t * R_FindImage(const char *pname, imagetype_t type)
Finds or loads the given image.
Definition: r_image.cpp:603
void R_UploadAlpha(const image_t *image, const byte *alphaData)
Definition: r_image.cpp:423
bool R_ImageExists(const char *pname,...)
Definition: r_image.cpp:681
image_t * R_GetImage(const char *name)
Definition: r_image.cpp:452
@ it_pic
Definition: r_image.h:45
void S_SetSampleRepeatRate(int sampleRepeatRate)
Controls the repeat rate for the same sample.
Definition: s_main.cpp:352
void S_StartLocalSample(const char *s, float volume)
Plays a sample without spatialization.
Definition: s_mix.cpp:184
#define SND_VOLUME_DEFAULT
Definition: s_main.h:42
bool Com_ParseBoolean(const char *token)
Parses a boolean from a string.
Definition: scripts.cpp:986
bool Com_ParseBlock(const char *name, const char **text, void *base, const value_t *values, memPool_t *mempool)
Definition: scripts.cpp:1393
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:2345
const char * Com_GetRandomMapAssemblyNameForCrashedCraft(const char *craftID)
Definition: scripts.cpp:3285
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
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
const char * Com_UFOCrashedTypeToShortName(ufoType_t type)
Translate UFO type to short name when UFO is crashed.
Definition: scripts.cpp:3351
bool Com_ParseBlockToken(const char *name, const char **text, void *base, const value_t *values, memPool_t *mempool, const char *token)
Definition: scripts.cpp:1311
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:3277
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:3362
bool Com_UnregisterConstList(const constListEntry_t constList[])
Unregisters a list of string aliases.
Definition: scripts.cpp:237
bool Com_UnregisterConstVariable(const char *name)
Removes a registered constant from the script mapping hash table.
Definition: scripts.cpp:147
short Com_GetHumanAircraftIdsNum(void)
Definition: scripts.cpp:581
short Com_GetDropShipIdsNum(void)
Definition: scripts.cpp:576
ufoType_t Com_UFOShortNameToID(const char *token)
Translate short name to UFO type.
Definition: scripts.cpp:3329
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
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:3381
short Com_GetUfoIdsNum(void)
Definition: scripts.cpp:571
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
humanAircraftType_t Com_DropShipShortNameToID(const char *token)
Translate DropShip type to short name.
Definition: scripts.cpp:3307
bool Com_ParseList(const char **text, linkedList_t **list)
Definition: scripts.cpp:1363
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
const char * Com_ValueToStr(const void *base, const valueTypes_t type, const int ofs)
Definition: scripts.cpp:1171
const char * Com_UFOTypeToShortName(ufoType_t type)
Translate UFO type to short name.
Definition: scripts.cpp:3342
const char * Com_DropShipTypeToShortName(humanAircraftType_t type)
Translate DropShip type to short name.
Definition: scripts.cpp:3319
void Com_RegisterConstList(const constListEntry_t constList[])
Registers a list of string aliases.
Definition: scripts.cpp:253
int Com_EParseValue(void *base, const char *token, valueTypes_t type, int ofs, size_t size)
Definition: scripts.cpp:964
align_t
We need this here for checking the boundaries from script values.
Definition: scripts.h:89
@ V_NULL
Definition: scripts.h:49
@ V_LIST
Definition: scripts.h:78
@ V_STRING
Definition: scripts.h:58
#define Q_strvalid(string)
Definition: shared.h:141
#define Q_streq(a, b)
Definition: shared.h:136
#define OBJZERO(obj)
Definition: shared.h:178
#define lengthof(x)
Definition: shared.h:105
void Q_strncpyz(char *dest, const char *src, size_t destsize)
Safe strncpy that ensures a trailing zero.
Definition: shared.cpp:457
int Q_vsnprintf(char *str, size_t size, const char *format, va_list ap)
Safe (null terminating) vsnprintf implementation.
Definition: shared.cpp:535
bool Com_sprintf(char *dest, size_t size, const char *fmt,...)
copies formatted string with buffer-size checking
Definition: shared.cpp:494
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
const mapDef_t *EXPORT * MapInfo(int step)
character_t *EXPORT * GetSelectedChr(void)
equipDef_t *EXPORT * GetEquipmentDefinition(void)
const char *EXPORT * GetTeamDef(void)
const char *EXPORT * GetModelForItem(const char *string)
int isMultiplayer
Definition: cgame.h:40
const char * menu
Definition: cgame.h:39
const char * name
Definition: cgame.h:38
void *IMPORT * Alloc(size_t size, bool zeroFill, memPool_t *pool, const int tagNum, const char *fileName, const int fileLine)
const char *IMPORT * Com_DropShipTypeToShortName(humanAircraftType_t type)
const char *IMPORT * Cvar_GetString(const char *varName)
const equipDef_t *IMPORT * GAME_ChangeEquip(const linkedList_t *equipmentList, changeEquipType_t changeType, const char *equipID)
xmlNode_t *IMPORT * XML_GetNode(xmlNode_t *parent, const char *name)
uiNode_t *IMPORT * UI_GetNodeByPath(const char *path)
void *IMPORT * LIST_GetRandom(linkedList_t *list)
uiNode_t *IMPORT * UI_InitOptionIteratorAtIndex(int index, uiNode_t *option, uiOptionIterator_t *iterator)
uiNode_t *IMPORT * UI_OptionIteratorNextOption(uiOptionIterator_t *iterator)
const mapDef_t *IMPORT * GAME_GetCurrentSelectedMap(void)
const char *IMPORT * Com_UFOTypeToShortName(ufoType_t type)
const char *IMPORT * GetAbsoluteSavePath(char *buf, size_t bufSize)
const char *IMPORT * FS_NextFileFromFileList(const char *files)
linkedList_t *IMPORT * LIST_Add(linkedList_t **list, void const *data, size_t length)
const char *IMPORT * CL_PlayerGetName(unsigned int player)
const char *IMPORT * UI_GetFontFromNode(const uiNode_t *const node)
dbuffer *IMPORT * NET_ReadMsg(struct net_stream *s)
byte * r_xviAlpha
Definition: cgame.h:382
uiNode_t *IMPORT * UI_PopupList(const char *title, const char *headline, linkedList_t *entries, const char *clickAction)
const ugv_t *IMPORT * Com_GetUGVByID(const char *ugvID)
Inventory ** ui_inventory
Definition: cgame.h:101
const char *IMPORT * INV_GetFilterType(itemFilterTypes_t id)
linkedList_t *IMPORT * LIST_GetPointer(linkedList_t *list, const void *data)
void *IMPORT * LIST_GetByIdx(linkedList_t *list, int index)
byte * r_radarSourcePic
Definition: cgame.h:384
const char *IMPORT * CL_ActorGetSkillString(const int skill)
const cgameType_t * cgameType
Definition: cgame.h:102
const char *IMPORT * Cmd_Argv(int n)
xmlNode_t *IMPORT * XML_GetPos3(xmlNode_t *parent, const char *name, vec3_t pos)
struct net_stream *IMPORT * NET_Connect(const char *node, const char *service, stream_onclose_func *onclose)
const char *IMPORT * Cvar_VariableStringOld(const char *varName)
const ugv_t *IMPORT * Com_GetUGVByIDSilent(const char *ugvID)
xmlNode_t *IMPORT * XML_GetNextPos2(xmlNode_t *actual, xmlNode_t *parent, const char *name, vec2_t pos)
uiSprite_t *IMPORT * UI_GetSpriteByName(const char *name)
cvar_t *IMPORT * Cvar_ForceSet(const char *varName, const char *value)
xmlNode_t *IMPORT * XML_GetNextNode(xmlNode_t *current, xmlNode_t *parent, const char *name)
uiNode_t *IMPORT * UI_GetOption(int dataId)
struct datagram_socket *IMPORT * NET_DatagramSocketNew(const char *node, const char *service, datagram_callback_func *func)
const char *IMPORT * NET_StreamPeerToName(struct net_stream *s, char *dst, int len, bool appendPort)
xmlNode_t *IMPORT * XML_AddNode(xmlNode_t *parent, const char *name)
const linkedList_t *IMPORT * LIST_ContainsString(const linkedList_t *list, const char *string)
char *IMPORT * FS_NextScriptHeader(const char *files, const char **name, const char **text)
linkedList_t *IMPORT * LIST_CopyStructure(linkedList_t *src)
mapDef_t *IMPORT * Com_GetMapDefinitionByID(const char *mapDefID)
byte * r_radarPic
Definition: cgame.h:383
cvar_t *IMPORT * Cvar_Set(const char *varName, const char *value,...) __attribute__((format(__printf__
const char *IMPORT * Com_GetRandomMapAssemblyNameForCraft(const char *craftID)
const char *IMPORT * Com_UFOCrashedTypeToShortName(ufoType_t type)
const char uiNode_t *IMPORT * UI_AddOption(uiNode_t **tree, const char *name, const char *label, const char *value)
char *IMPORT * GAME_StrDup(const char *string)
const char *IMPORT * Com_EParse(const char **text, const char *errhead, const char *errinfo)
xmlNode_t *IMPORT * XML_GetNextPos3(xmlNode_t *actual, xmlNode_t *parent, const char *name, vec3_t pos)
const equipDef_t *IMPORT * INV_GetEquipmentDefinitionByID(const char *name)
const teamDef_t *IMPORT * Com_GetTeamDefinitionByID(const char *team)
csi_t * csi
Definition: cgame.h:100
const char *IMPORT * Cmd_Args(void)
void *IMPORT * NET_StreamGetData(struct net_stream *s)
const char *IMPORT * Com_ValueToStr(const void *base, const valueTypes_t type, const int ofs)
xmlNode_t *IMPORT * XML_GetDate(xmlNode_t *parent, const char *name, int *day, int *sec)
memPool_t *IMPORT * CreatePool(const char *name)
char *IMPORT * PoolStrDup(const char *in, memPool_t *pool, const int tagNum)
const char *IMPORT * CL_Translate(const char *t)
const char *IMPORT * XML_GetString(xmlNode_t *parent, const char *name)
const char *IMPORT * Com_GetRandomMapAssemblyNameForCrashedCraft(const char *craftID)
struct uiMessageListNodeMessage_s *IMPORT * UI_MessageGetStack(void)
const char *IMPORT * GetRelativeSavePath(char *buf, size_t bufSize)
cvar_t *IMPORT * Cvar_Get(const char *varName, const char *value, int flags, const char *desc)
const char *IMPORT * UI_GetActiveWindowName(void)
const char *IMPORT * Com_GetConstVariable(const char *space, int value)
xmlNode_t *IMPORT * XML_GetPos2(xmlNode_t *parent, const char *name, vec2_t pos)
xmlNode_t *IMPORT * XML_Parse(const char *buffer)
char name[MAX_VAR]
Definition: cgame.h:87
linkedList_t * equipmentList
Definition: cgame.h:88
char window[MAX_VAR]
Definition: cgame.h:86
char id[MAX_VAR]
Definition: cgame.h:85
Describes a character with all its attributes.
Definition: chr_shared.h:388
const teamDef_t * teamDef
Definition: chr_shared.h:413
char head[MAX_VAR]
Definition: chr_shared.h:393
char path[MAX_VAR]
Definition: chr_shared.h:391
chrScoreGlobal_t score
Definition: chr_shared.h:406
actorSizeEnum_t fieldSize
Definition: chr_shared.h:409
woundInfo_t wounds
Definition: chr_shared.h:402
char body[MAX_VAR]
Definition: chr_shared.h:392
char name[MAX_VAR]
Definition: chr_shared.h:390
int stuns[KILLED_NUM_TYPES]
Definition: chr_shared.h:127
int kills[KILLED_NUM_TYPES]
Definition: chr_shared.h:126
int skills[SKILL_NUM_TYPES]
Definition: chr_shared.h:122
int experience[SKILL_NUM_TYPES+1]
Definition: chr_shared.h:120
float frametime
Definition: client.h:59
keydest_t keyDest
Definition: client.h:56
int nextUniqueCharacterNumber
Definition: client.h:99
struct net_stream * netStream
Definition: client.h:74
const struct cgame_export_s * gametype
Definition: client.h:65
int currentSelectedMap
Definition: client.h:80
char serverport[16]
Definition: client.h:69
void * cgameLibrary
Definition: client.h:112
InventoryInterface i
Definition: client.h:101
char servername[MAX_VAR]
Definition: client.h:68
le_t * teamList[MAX_ACTIVETEAM]
linkedList_t * chrList
int numMDs
Definition: q_shared.h:572
equipDef_t eds[MAX_EQUIPDEFS]
Definition: q_shared.h:540
int numEDs
Definition: q_shared.h:541
char * string
Definition: cvar.h:73
Struct that defines one particular event with all its callbacks and data.
Definition: e_main.h:42
const char * formatString
The format string that is used to write and parse this event.
Definition: e_main.h:54
byte r_radarSourcePic[RADAR_WIDTH *RADAR_HEIGHT]
Definition: cl_shared.h:70
byte r_radarPic[RADAR_WIDTH *RADAR_HEIGHT]
Definition: cl_shared.h:67
byte r_xviAlpha[XVI_WIDTH *XVI_HEIGHT]
Definition: cl_shared.h:64
int height
Definition: r_image.h:64
int width
Definition: r_image.h:64
inventory definition for our menus
Definition: inv_shared.h:371
a local entity
int team
teamDef_t * teamDef
Item * getFloorContainer() const
Inventory inv
void * data
Definition: list.h:31
linkedList_t * next
Definition: list.h:32
char * mapTheme
Definition: q_shared.h:464
char * id
Definition: q_shared.h:463
linkedList_t * params
Definition: q_shared.h:465
bool multiplayer
Definition: q_shared.h:474
bool singleplayer
Definition: q_shared.h:481
Defines all attributes of objects used in the inventory.
Definition: inv_shared.h:264
const char * model
Definition: inv_shared.h:269
const char * id
Definition: inv_shared.h:268
bool isArmour() const
Definition: inv_shared.h:346
bool robot
Definition: chr_shared.h:333
const objDef_t * onlyWeapon
Definition: chr_shared.h:336
char id[MAX_VAR]
Definition: chr_shared.h:309
const BodyData * bodyTemplate
Definition: chr_shared.h:350
Defines a type of UGV/Robot.
Definition: chr_shared.h:245
char weapon[MAX_VAR]
Definition: chr_shared.h:248
Model that have more than one part (top and down part of an aircraft)
Definition: ui_node_model.h:47
Atomic structure used to define most of the UI.
Definition: ui_nodes.h:80
int treatmentLevel[BODYPART_MAXTYPE]
Definition: chr_shared.h:363
vec_t vec4_t[4]
Definition: ufotypes.h:40
vec_t vec2_t[2]
Definition: ufotypes.h:38
uiNode_t * UI_InitOptionIteratorAtIndex(int index, uiNode_t *option, uiOptionIterator_t *iterator)
Init an option iterator at an index.
Definition: ui_data.cpp:394
void UI_RegisterOption(int dataId, uiNode_t *option)
Definition: ui_data.cpp:311
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
void UI_ResetData(int dataId)
Reset a shared data. Type became NONE and value became nullptr.
Definition: ui_data.cpp:212
uiNode_t * UI_GetOption(int dataId)
Definition: ui_data.cpp:324
void UI_SortOptions(uiNode_t **first)
Sort options by alphabet.
Definition: ui_data.cpp:273
void UI_RegisterText(int dataId, const char *text)
share a text with a data id
Definition: ui_data.cpp:115
void UI_RegisterLinkedListText(int dataId, linkedList_t *text)
share a linked list of text with a data id
Definition: ui_data.cpp:131
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
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
@ TEXT_MISSIONBRIEFING
Definition: ui_dataids.h:71
@ TEXT_MISSIONBRIEFING_VICTORY_CONDITIONS
Definition: ui_dataids.h:73
@ TEXT_MISSIONBRIEFING_TITLE
Definition: ui_dataids.h:72
void UI_DisplayNotice(const char *text, int time, const char *windowName)
Displays a message over all windows.
Definition: ui_draw.cpp:411
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 UI_ExecuteConfunc(const char *fmt,...)
Executes confunc - just to identify those confuncs in the code - in this frame.
Definition: ui_main.cpp:110
void UI_GetNodeAbsPos(const uiNode_t *node, vec2_t pos)
Returns the absolute position of a node.
Definition: ui_node.cpp:514
Inventory * ui_inventory
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.
void UI_MessageResetStack(void)
void UI_MessageAddStack(struct uiMessageListNodeMessage_s *message)
struct uiMessageListNodeMessage_s * UI_MessageGetStack(void)
uiModel_t * UI_GetUIModel(const char *modelName)
Returns pointer to UI model.
void UI_DrawModelNode(uiNode_t *node, const char *source)
void UI_TextScrollEnd(const char *nodePath)
Scroll to the bottom.
void UI_TextNodeSelectLine(uiNode_t *node, int num)
Change the selected line.
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
void UI_Popup(const char *title, const char *text)
Popup on geoscape.
Definition: ui_popup.cpp:47
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
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
char popupText[UI_MAX_SMALLTEXTLEN]
strings to be used for popup when text is not static
Definition: ui_popup.cpp:37
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
void UI_DrawRect(int x, int y, int w, int h, const vec4_t color, float lineWidth, int pattern)
Definition: ui_render.cpp:42
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
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
uiSprite_t * UI_GetSpriteByName(const char *name)
Return an sprite by is name.
Definition: ui_sprite.cpp:115
int UI_DrawTooltip(const char *string, int x, int y, int maxWidth)
Generic tooltip function.
Definition: ui_tooltip.cpp:40
bool UI_IsWindowOnStack(const char *name)
Check if a named window is on the stack if active windows.
Definition: ui_windows.cpp:373
uiNode_t * UI_PushWindow(const char *name, const char *parentName, linkedList_t *params)
Push a window onto the window stack.
Definition: ui_windows.cpp:170
void UI_PopWindow(bool all)
Pops a window from the window stack.
Definition: ui_windows.cpp:452
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
const char * UI_GetActiveWindowName(void)
Returns the name of the current window.
Definition: ui_windows.cpp:526
bool WEB_CGameUpload(const char *cgameId, int category, const char *filename)
Uploads a file to the server.
Definition: web_cgame.cpp:106
bool WEB_CGameDelete(const char *cgameId, int category, const char *filename)
Deletes a user owned file on the server.
Definition: web_cgame.cpp:152
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
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
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
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 XML_AddFloatValue(xmlNode_t *parent, const char *name, float value)
add a non-zero Float attribute to the XML Node
Definition: xml.cpp:99
double XML_GetDouble(xmlNode_t *parent, const char *name, const double defaultval)
retrieve a Double attribute from an XML Node
Definition: xml.cpp:378
float XML_GetFloat(xmlNode_t *parent, const char *name, const float defaultval)
retrieve a Float attribute from an XML Node
Definition: xml.cpp:364
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 XML_AddByte(xmlNode_t *parent, const char *name, byte value)
add a Byte attribute to the XML Node
Definition: xml.cpp:137
bool XML_GetBool(xmlNode_t *parent, const char *name, const bool defaultval)
retrieve a Boolean attribute from an XML Node
Definition: xml.cpp:288
void XML_AddString(xmlNode_t *parent, const char *name, const char *value)
add a String attribute to the XML Node
Definition: xml.cpp:36
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
long XML_GetLong(xmlNode_t *parent, const char *name, const long defaultval)
retrieve a Long attribute from an XML Node
Definition: xml.cpp:336
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
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 XML_AddShortValue(xmlNode_t *parent, const char *name, short value)
add a non-zero Short attribute to the XML Node
Definition: xml.cpp:172
int XML_GetInt(xmlNode_t *parent, const char *name, const int defaultval)
retrieve an Int attribute from an XML Node
Definition: xml.cpp:308
void XML_AddFloat(xmlNode_t *parent, const char *name, float value)
add a Float attribute to the XML Node
Definition: xml.cpp:87
short XML_GetShort(xmlNode_t *parent, const char *name, const short defaultval)
retrieve a Short attribute from an XML Node
Definition: xml.cpp:322
void XML_AddDouble(xmlNode_t *parent, const char *name, double value)
add a Double attribute to the XML Node
Definition: xml.cpp:110
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
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
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
const char * XML_GetString(xmlNode_t *parent, const char *name)
retrieve a String attribute from an XML Node
Definition: xml.cpp:350
void XML_AddLong(xmlNode_t *parent, const char *name, long value)
add a Long attribute to the XML Node
Definition: xml.cpp:206
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 XML_AddBool(xmlNode_t *parent, const char *name, bool value)
add a Boolean attribute to the XML Node
Definition: xml.cpp:62
xmlNode_t * XML_Parse(const char *buffer)
Definition: xml.cpp:531
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
xmlNode_t * XML_AddNode(xmlNode_t *parent, const char *name)
add a new node to the XML tree
Definition: xml.cpp:277
void XML_AddInt(xmlNode_t *parent, const char *name, int value)
add an Int attribute to the XML Node
Definition: xml.cpp:183
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
void XML_AddShort(xmlNode_t *parent, const char *name, short value)
add a Short attribute to the XML Node
Definition: xml.cpp:160
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
xmlNode_t * XML_GetNode(xmlNode_t *parent, const char *name)
Get first Node of the XML tree by name.
Definition: xml.cpp:487
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
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