UFO: Alien Invasion
Loading...
Searching...
No Matches
cl_game.cpp
Go to the documentation of this file.
1
5
6/*
7Copyright (C) 2002-2025 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"
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"
45#include "../cl_team.h"
46#include "../web/web_cgame.h"
48#include "../cl_inventory.h"
49#include "../../shared/parse.h"
51#include "../renderer/r_draw.h"
54#include "cl_map_callbacks.h"
55
56#include <set>
57#include <string>
58
59#define MAX_CGAMETYPES 16
61static int numCGameTypes;
62
63static inline const cgame_export_t* GAME_GetCurrentType (void)
64{
65 return cls.gametype;
66}
67
69{
70private:
71 typedef std::set<const struct cvar_s* > GameCvars;
73public:
75 {
76 _cvars.clear();
77 }
78
79 void onCreate (const struct cvar_s* cvar)
80 {
81 const cgame_export_t* list = GAME_GetCurrentType();
82 if (list)
83 _cvars.insert(cvar);
84 }
85
86 void onDelete (const struct cvar_s* cvar)
87 {
88 _cvars.erase(cvar);
89 }
90
92 {
93 GameCvars copy = _cvars;
94 for (GameCvars::const_iterator i = copy.begin(); i != copy.end(); ++i) {
95 const struct cvar_s* cvar = *i;
96 if (cvar->flags == 0) {
97 const cgame_export_t* list = GAME_GetCurrentType();
98 Com_DPrintf(DEBUG_CLIENT, "Delete cvar %s because it was created in the context of the cgame %s\n",
99 cvar->name, list ? list->name : "none");
100 Cvar_Delete(cvar->name);
101 }
102 }
103 }
104};
105
107{
108private:
109 typedef std::set<const char* > GameCmds;
111public:
113 {
114 _cmds.clear();
115 }
116
117 void onAdd (const char* cmdName)
118 {
119 const cgame_export_t* list = GAME_GetCurrentType();
120 if (list) {
121 _cmds.insert(cmdName);
122 }
123 }
124
125 void onRemove (const char* cmdName)
126 {
127 _cmds.erase(cmdName);
128 }
129
131 {
132 GameCmds copy = _cmds;
133 for (GameCmds::const_iterator i = copy.begin(); i != copy.end(); ++i) {
134 const char* cmdName = *i;
135 const cgame_export_t* list = GAME_GetCurrentType();
136 Com_DPrintf(DEBUG_COMMANDS, "Remove command %s because it was created in the context of the cgame %s\n",
137 cmdName, list ? list->name : "none");
138 Cmd_RemoveCommand(cmdName);
139 }
140 }
141};
142
145
146/* @todo: remove me - this should be per geoscape node data */
148
149#ifdef HARD_LINKED_CGAME
153
154static const cgame_api_t gameTypeList[] = {
155 GetCGameMultiplayerAPI,
156 GetCGameCampaignAPI,
157 GetCGameSkirmishAPI
158};
159
160static const char* cgameMenu;
161
162const cgame_export_t* GetCGameAPI (const cgame_import_t* import)
163{
164 const size_t len = lengthof(gameTypeList);
165
166 if (cgameMenu == nullptr)
167 return nullptr;
168
169 for (int i = 0; i < len; i++) {
170 const cgame_api_t list = gameTypeList[i];
171 const cgame_export_t* cgame = list(import);
172 if (Q_streq(cgame->menu, cgameMenu)) {
173 return cgame;
174 }
175 }
176
177 return nullptr;
178}
179#endif
180
182
187
198{
200 Com_Error(ERR_DROP, "Out of bounds character access");
201
202 return &characters[index];
203}
204
212{
213 const int size = lengthof(characters);
214 for (int i = 0; i < size; i++) {
215 character_t* chr = &characters[i];
216 if (chr->ucn == ucn)
217 return chr;
218 }
219 return nullptr;
220}
221
228{
229 return lengthof(characters);
230}
231
232const char* GAME_GetCurrentName (void)
233{
234 const cgame_export_t* cgame = GAME_GetCurrentType();
235 if (cgame == nullptr)
236 return nullptr;
237 return cgame->menu;
238}
239
245{
246 for (int i = 0; i < MAX_ACTIVETEAM; i++)
247 characters[i].init();
249 UI_ExecuteConfunc("team_membersclear");
250}
251
252void GAME_AppendTeamMember (int memberIndex, const char* teamDefID, const equipDef_t* ed)
253{
254 if (ed == nullptr)
255 Com_Error(ERR_DROP, "No equipment definition given");
256
257 character_t* chr = GAME_GetCharacter(memberIndex);
258
259 CL_GenerateCharacter(chr, teamDefID);
260
261 const objDef_t* weapon = chr->teamDef->onlyWeapon;
262 if (chr->teamDef->robot && !weapon) {
263 /* This is likely an UGV, try to guess which one and get the weapon */
264 const char* ugvId = strstr(chr->teamDef->id, "ugv");
265 const ugv_t* ugv = Com_GetUGVByIDSilent(ugvId);
266 if (ugv)
267 weapon = INVSH_GetItemByID(ugv->weapon);
268 }
269 /* pack equipment */
270 cls.i.EquipActor(chr, ed, weapon, GAME_GetChrMaxLoad(chr));
271
272 LIST_AddPointer(&chrDisplayList, (void*)chr);
273 UI_ExecuteConfunc("team_memberadd %i \"%s\" \"%s\" \"%s\" %i", memberIndex, chr->name, chr->path, 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{
455 cls.i.destroyInventory(inv);
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{
490 cls.nextUniqueCharacterNumber = ucn;
491}
492
494{
495 return cls.nextUniqueCharacterNumber;
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
594 cgi->ui_inventory = &ui_inventory;
595 cgi->csi = &csi;
596
597 cgi->r_xviAlpha = geoscapeData.r_xviAlpha;
598 cgi->r_radarPic = geoscapeData.r_radarPic;
599 cgi->r_radarSourcePic = geoscapeData.r_radarSourcePic;
600
602 cgi->Cmd_AddCommand = Cmd_AddCommand;
603 cgi->Cmd_Argc = Cmd_Argc;
604 cgi->Cmd_Args = Cmd_Args;
605 cgi->Cmd_Argv = Cmd_Argv;
606 cgi->Cmd_ExecuteString = Cmd_ExecuteString;
607 cgi->Cmd_RemoveCommand = Cmd_RemoveCommand;
608 cgi->Cmd_TableAddList = Cmd_TableAddList;
609 cgi->Cmd_TableRemoveList = Cmd_TableRemoveList;
610 cgi->Cmd_AddParamCompleteFunction = Cmd_AddParamCompleteFunction;
611 cgi->Cmd_GenericCompleteFunction = Cmd_GenericCompleteFunction;
612 cgi->Com_GetMapDefinitionByID = Com_GetMapDefinitionByID;
613
614 cgi->Cbuf_AddText = Cbuf_AddText;
615 cgi->Cbuf_Execute = Cbuf_Execute;
616
617 cgi->LIST_PrependString = LIST_PrependString;
618 cgi->LIST_AddString = LIST_AddString;
619 cgi->LIST_AddStringSorted = LIST_AddStringSorted;
620 cgi->LIST_AddPointer = LIST_AddPointer;
621 cgi->LIST_Add = LIST_Add;
622 cgi->LIST_ContainsString = LIST_ContainsString;
623 cgi->LIST_GetPointer = LIST_GetPointer;
624 cgi->LIST_Delete = LIST_Delete;
625 cgi->LIST_RemoveEntry = LIST_RemoveEntry;
626 cgi->LIST_IsEmpty = LIST_IsEmpty;
627 cgi->LIST_Count = LIST_Count;
628 cgi->LIST_CopyStructure = LIST_CopyStructure;
629 cgi->LIST_GetByIdx = LIST_GetByIdx;
630 cgi->LIST_Remove = LIST_Remove;
631 cgi->LIST_Sort = LIST_Sort;
632 cgi->LIST_GetRandom = LIST_GetRandom;
633
634 cgi->Cvar_Delete = Cvar_Delete;
636 cgi->Cvar_Get = Cvar_Get;
637 cgi->Cvar_GetInteger = Cvar_GetInteger;
638 cgi->Cvar_GetValue = Cvar_GetValue;
639 cgi->Cvar_VariableStringOld = Cvar_VariableStringOld;
640 cgi->Cvar_Set = Cvar_Set;
641 cgi->Cvar_SetValue = Cvar_SetValue;
642 cgi->Cvar_GetString = Cvar_GetString;
643 cgi->Cvar_ForceSet = Cvar_ForceSet;
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;
654 cgi->FS_NextFileFromFileList = FS_NextFileFromFileList;
655 cgi->FS_NextScriptHeader = FS_NextScriptHeader;
656
657 cgi->UI_AddOption = UI_AddOption;
658 cgi->UI_ExecuteConfunc = UI_ExecuteConfunc;
659 cgi->UI_InitStack = UI_InitStack;
660 cgi->UI_Popup = GAME_UI_Popup;
661 cgi->UI_PopupList = UI_PopupList;
662 cgi->UI_PopWindow = UI_PopWindow;
663 cgi->UI_PushWindow = UI_PushWindow_;
664 cgi->UI_RegisterLinkedListText = UI_RegisterLinkedListText;
665 cgi->UI_MessageGetStack = UI_MessageGetStack;
666 cgi->UI_MessageAddStack = UI_MessageAddStack;
667 cgi->UI_MessageResetStack = UI_MessageResetStack;
668 cgi->UI_TextScrollEnd = UI_TextScrollEnd;
669 cgi->UI_RegisterOption = UI_RegisterOption;
670 cgi->UI_RegisterText = UI_RegisterText;
671 cgi->UI_ResetData = UI_ResetData;
672 cgi->UI_UpdateInvisOptions = UI_UpdateInvisOptions;
673 cgi->UI_GetOption = UI_GetOption;
674 cgi->UI_SortOptions = UI_SortOptions;
675 cgi->UI_InitOptionIteratorAtIndex = UI_InitOptionIteratorAtIndex;
676 cgi->UI_OptionIteratorNextOption = UI_OptionIteratorNextOption;
677 cgi->UI_DrawString = UI_DrawString_;
678 cgi->UI_GetFontFromNode = UI_GetFontFromNode;
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;
685 cgi->UI_GetSpriteByName = UI_GetSpriteByName;
686 cgi->UI_ContainerNodeUpdateEquipment = UI_ContainerNodeUpdateEquipment;
687 cgi->UI_GetNodeByPath = UI_GetNodeByPath;
688 cgi->UI_DisplayNotice = UI_DisplayNotice;
689 cgi->UI_GetActiveWindowName = UI_GetActiveWindowName;
690 cgi->UI_TextNodeSelectLine = UI_TextNodeSelectLine;
691
692 cgi->CL_Translate = CL_Translate;
693
694 cgi->NET_StreamSetCallback = NET_StreamSetCallback;
695 cgi->NET_Connect = NET_Connect;
696 cgi->NET_ReadString = NET_ReadString;
697 cgi->NET_ReadStringLine = NET_ReadStringLine;
698 cgi->NET_ReadByte = NET_ReadByte;
699 cgi->NET_ReadShort = NET_ReadShort;
700 cgi->NET_ReadLong = NET_ReadLong;
701 cgi->NET_WriteByte = NET_WriteByte;
702 cgi->NET_WriteShort = NET_WriteShort;
703 cgi->NET_ReadMsg = NET_ReadMsg;
704 cgi->NET_StreamGetData = NET_StreamGetData;
705 cgi->NET_StreamSetData = NET_StreamSetData;
706 cgi->NET_StreamFree = NET_StreamFree;
707 cgi->NET_StreamPeerToName = NET_StreamPeerToName;
708 cgi->NET_SockaddrToStrings = NET_SockaddrToStrings;
709 cgi->NET_DatagramSocketNew = NET_DatagramSocketNew;
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;
719 cgi->Com_DropShipTypeToShortName = Com_DropShipTypeToShortName;
720 cgi->Com_UFOCrashedTypeToShortName = Com_UFOCrashedTypeToShortName;
721 cgi->Com_UFOTypeToShortName = Com_UFOTypeToShortName;
722 cgi->Com_GetRandomMapAssemblyNameForCraft = Com_GetRandomMapAssemblyNameForCraft;
723 cgi->Com_RegisterConstList = Com_RegisterConstList;
724 cgi->Com_UnregisterConstList = Com_UnregisterConstList;
725 cgi->Com_GetConstVariable = Com_GetConstVariable;
726 cgi->Com_GetConstIntFromNamespace = Com_GetConstIntFromNamespace;
727 cgi->Com_GetConstInt = Com_GetConstInt;
728 cgi->Com_EParse = Com_EParse_;
729 cgi->Com_EParseValue = Com_EParseValue;
730 cgi->Com_ParseBoolean = Com_ParseBoolean;
731 cgi->Com_ParseList = Com_ParseList;
732 cgi->Com_ParseBlock = Com_ParseBlock;
733 cgi->Com_ParseBlockToken = Com_ParseBlockToken;
734 cgi->Com_ValueToStr = Com_ValueToStr;
735 cgi->Com_GetTeamDefinitionByID = Com_GetTeamDefinitionByID;
736 cgi->Com_UFOShortNameToID = Com_UFOShortNameToID;
737 cgi->Com_GetUFOIdsNum = Com_GetUfoIdsNum;
738 cgi->Com_GetDropShipIdsNum = Com_GetDropShipIdsNum;
739 cgi->Com_GetHumanAircraftIdsNum = Com_GetHumanAircraftIdsNum;
740 cgi->Com_GetRandomMapAssemblyNameForCrashedCraft = Com_GetRandomMapAssemblyNameForCrashedCraft;
741 cgi->Com_SetGameType = Com_SetGameType;
742 cgi->Com_RegisterConstInt = Com_RegisterConstInt;
743 cgi->Com_UnregisterConstVariable = Com_UnregisterConstVariable;
744 cgi->Com_Drop = Com_Drop;
745 cgi->Com_GetUGVByID = Com_GetUGVByID;
746 cgi->Com_GetUGVByIDSilent = Com_GetUGVByIDSilent;
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;
754 cgi->CL_PlayerGetName = CL_PlayerGetName;
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;
762 cgi->GAME_GetCurrentSelectedMap = GAME_GetCurrentSelectedMap;
763 cgi->GAME_GetCurrentTeam = GAME_GetCurrentTeam;
764 cgi->GAME_StrDup = GAME_StrDup;
765 cgi->GAME_AutoTeam = GAME_AutoTeam;
766 cgi->GAME_ChangeEquip = GAME_ChangeEquip;
767 cgi->GAME_GetCharacterArraySize = GAME_GetCharacterArraySize;
768 cgi->GAME_IsTeamEmpty = GAME_IsTeamEmpty;
769 cgi->GAME_LoadDefaultTeam = GAME_LoadDefaultTeam;
770 cgi->GAME_AppendTeamMember = GAME_AppendTeamMember;
771 cgi->GAME_ReloadMode = GAME_ReloadMode;
772 cgi->GAME_SetServerInfo = GAME_SetServerInfo;
773 cgi->GAME_GetChrMaxLoad = GAME_GetChrMaxLoad;
774 cgi->GAME_LoadCharacter = GAME_LoadCharacter;
775 cgi->GAME_SaveCharacter = GAME_SaveCharacter;
776
777 cgi->Alloc = _Mem_Alloc;
778 cgi->Free = GAME_Free;
779 cgi->CreatePool = GAME_CreatePool;
780 cgi->FreePool = GAME_FreePool;
781 cgi->PoolStrDup = GAME_PoolStrDup;
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
803 cgi->CL_ActorGetSkillString = CL_ActorGetSkillString;
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
812 cgi->INV_GetEquipmentDefinitionByID = INV_GetEquipmentDefinitionByID;
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;
819 cgi->INV_GetFilterType = INV_GetFilterType;
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
827 cgi->GetRelativeSavePath = GAME_GetRelativeSavePath;
828 cgi->GetAbsoluteSavePath = GAME_GetAbsoluteSavePath;
829
830 cgi->BEP_Evaluate = BEP_Evaluate;
831
832 cgi->Sys_Error = Sys_Error;
833
834 cgi->HUD_InitUI = HUD_InitUI;
835 cgi->HUD_DisplayMessage = HUD_DisplayMessage;
836
837 cgi->XML_AddBool = XML_AddBool;
838 cgi->XML_AddBoolValue = XML_AddBoolValue;
839 cgi->XML_AddByte = XML_AddByte;
840 cgi->XML_AddByteValue = XML_AddByteValue;
841 cgi->XML_AddDate = XML_AddDate;
842 cgi->XML_AddDouble = XML_AddDouble;
843 cgi->XML_AddDoubleValue = XML_AddDoubleValue;
844 cgi->XML_AddFloat = XML_AddFloat;
845 cgi->XML_AddFloatValue = XML_AddFloatValue;
846 cgi->XML_AddInt = XML_AddInt;
847 cgi->XML_AddIntValue = XML_AddIntValue;
848 cgi->XML_AddLong = XML_AddLong;
849 cgi->XML_AddLongValue = XML_AddLongValue;
850 cgi->XML_AddNode = XML_AddNode;
851 cgi->XML_AddPos2 = XML_AddPos2;
852 cgi->XML_AddPos3 = XML_AddPos3;
853 cgi->XML_AddShort = XML_AddShort;
854 cgi->XML_AddShortValue = XML_AddShortValue;
855 cgi->XML_AddString = XML_AddString;
856 cgi->XML_AddStringValue = XML_AddStringValue;
857
858 cgi->XML_GetBool = XML_GetBool;
859 cgi->XML_GetInt = XML_GetInt;
860 cgi->XML_GetShort = XML_GetShort;
861 cgi->XML_GetLong = XML_GetLong;
862 cgi->XML_GetString = XML_GetString;
863 cgi->XML_GetFloat = XML_GetFloat;
864 cgi->XML_GetDouble = XML_GetDouble;
865 cgi->XML_Parse = XML_Parse;
866 cgi->XML_GetPos2 = XML_GetPos2;
867 cgi->XML_GetNextPos2 = XML_GetNextPos2;
868 cgi->XML_GetPos3 = XML_GetPos3;
869 cgi->XML_GetNextPos3 = XML_GetNextPos3;
870 cgi->XML_GetDate = XML_GetDate;
871 cgi->XML_GetNode = XML_GetNode;
872 cgi->XML_GetNextNode = XML_GetNextNode;
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
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)
917 cls.currentSelectedMap = csi.numMDs - 1;
918 cls.currentSelectedMap %= csi.numMDs;
919}
920
922{
923 return Com_GetMapDefByIDX(cls.currentSelectedMap);
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
960 LIST_Delete(&cl.chrList);
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 */
983 cls.i.destroyInventoryInterface();
984 cls.i.initInventory(list->name, &csi, &inventoryImport);
985 list->Init();
986 Cvar_FullSet("gamemode", list->menu, CVAR_NOSET);
987 }
988}
989
991static const value_t cgame_vals[] = {
992 {"window", V_STRING, offsetof(cgameType_t, window), 0},
993 {"name", V_STRING, offsetof(cgameType_t, name), 0},
994 {"equipments", V_LIST, offsetof(cgameType_t, equipmentList), 0},
995
996 {nullptr, V_NULL, 0, 0}
997};
998
999void GAME_ParseModes (const char* name, const char** text)
1000{
1001 int i;
1002
1003 /* search for equipments with same name */
1004 for (i = 0; i < numCGameTypes; i++)
1005 if (Q_streq(name, cgameTypes[i].id))
1006 break;
1007
1008 if (i < numCGameTypes) {
1009 Com_Printf("GAME_ParseModes: cgame def \"%s\" with same name found, second ignored\n", name);
1010 return;
1011 }
1012
1013 if (i >= MAX_CGAMETYPES)
1014 Sys_Error("GAME_ParseModes: MAX_CGAMETYPES exceeded");
1015
1016 /* initialize the equipment definition */
1018 OBJZERO(*cgame);
1019
1020 Q_strncpyz(cgame->id, name, sizeof(cgame->id));
1021
1022 Com_ParseBlock(name, text, cgame, cgame_vals, nullptr);
1023}
1024
1026{
1027 const char* name = t->id;
1028#ifndef HARD_LINKED_CGAME
1029 if (cls.cgameLibrary)
1030 Com_Error(ERR_FATAL, "GAME_GetCGameAPI without GAME_UnloadGame");
1031
1032 Com_Printf("------- Loading cgame-%s.%s -------\n", name, SO_EXT);
1033
1034#ifdef PKGLIBDIR
1035 cls.cgameLibrary = Com_LoadLibrary(PKGLIBDIR, name);
1036#endif
1037
1038 /* now run through the search paths */
1039 const char* path = nullptr;
1040 while (!cls.cgameLibrary) {
1041 path = FS_NextPath(path);
1042 if (!path)
1043 /* couldn't find one anywhere */
1044 return nullptr;
1045 else if (cls.cgameLibrary = Com_LoadLibrary(path, name))
1046 break;
1047 }
1048
1049 cgame_api_t GetCGameAPI = (cgame_api_t)(uintptr_t)SDL_LoadFunction(cls.cgameLibrary, "GetCGameAPI");
1050 if (!GetCGameAPI) {
1052 return nullptr;
1053 }
1054#endif
1055
1056 /* sanity checks */
1057 if (!LIST_IsEmpty(t->equipmentList)) {
1058 LIST_Foreach(t->equipmentList, char const, equipID) {
1059 if (INV_GetEquipmentDefinitionByID(equipID) == nullptr)
1060 Sys_Error("Could not find the equipDef '%s' in the cgame mode: '%s'", equipID, name);
1061 }
1062 }
1063
1065}
1066
1068{
1069#ifdef HARD_LINKED_CGAME
1070 cgameMenu = t->window;
1071#endif
1072 return GAME_GetCGameAPI(t);
1073}
1074
1078static void GAME_SetMode_f (void)
1079{
1080 const char* modeName;
1081 if (Cmd_Argc() == 2)
1082 modeName = Cmd_Argv(1);
1083 else
1084 modeName = UI_GetActiveWindowName();
1085
1086 if (modeName[0] == '\0')
1087 return;
1088
1089 for (int i = 0; i < numCGameTypes; i++) {
1090 cgameType_t* t = &cgameTypes[i];
1091 if (Q_streq(t->window, modeName)) {
1092 const cgame_export_t* gametype;
1094
1095 gametype = GAME_GetCGameAPI_(t);
1096 GAME_SetMode(gametype);
1097
1098 return;
1099 }
1100 }
1101 Com_Printf("GAME_SetMode_f: Mode '%s' not found\n", modeName);
1102}
1103
1105{
1106 const cgame_export_t* list = GAME_GetCurrentType();
1107
1108 if (od->isArmour()) {
1109 const char* teamDefID = GAME_GetTeamDef();
1110 const teamDef_t* teamDef = Com_GetTeamDefinitionByID(teamDefID);
1111
1112 /* Don't allow armour for other teams */
1113 if (teamDef != nullptr && !CHRSH_IsArmourUseableForTeam(od, teamDef))
1114 return false;
1115 }
1116
1117 if (list && list->IsItemUseable)
1118 return list->IsItemUseable(od);
1119
1120 return true;
1121}
1122
1135void GAME_HandleResults (dbuffer* msg, int winner, int* numSpawned, int* numAlive, int numKilled[][MAX_TEAMS], int numStunned[][MAX_TEAMS], bool nextmap)
1136{
1137 const cgame_export_t* list = GAME_GetCurrentType();
1138 if (list)
1139 list->Results(msg, winner, numSpawned, numAlive, numKilled, numStunned, nextmap);
1140 else
1141 CL_Drop();
1142}
1143
1150static void GAME_NetSendItem (dbuffer* buf, const Item* item, containerIndex_t container, int x, int y)
1151{
1152 const int ammoIdx = item->ammoDef() ? item->ammoDef()->idx : NONE;
1153 const eventRegister_t* eventData = CL_GetEvent(EV_INV_TRANSFER);
1154 assert(item->def());
1155 Com_DPrintf(DEBUG_CLIENT, "GAME_NetSendItem: Add item %s to container %i (t=%i:a=%i:m=%i) (x=%i:y=%i)\n",
1156 item->def()->id, container, item->def()->idx, item->getAmmoLeft(), ammoIdx, x, y);
1157 NET_WriteFormat(buf, eventData->formatString, item->def()->idx, item->getAmmoLeft(), ammoIdx, container, x, y, item->rotated, item->getAmount());
1158}
1159
1163static void GAME_NetSendInventory (dbuffer* buf, const Inventory* inv)
1164{
1165 const int nr = inv->countItems();
1166
1167 NET_WriteShort(buf, nr);
1168
1169 for (containerIndex_t container = 0; container < CID_MAX; container++) {
1170 if (INVDEF(container)->temp)
1171 continue;
1172 const Item* ic;
1173 for (ic = inv->getContainer2(container); ic; ic = ic->getNext()) {
1174 GAME_NetSendItem(buf, ic, container, ic->getX(), ic->getY());
1175 }
1176 }
1177}
1178
1185{
1186 if (!chr)
1187 Com_Error(ERR_DROP, "No character given");
1188 if (chr->fieldSize != ACTOR_SIZE_2x2 && chr->fieldSize != ACTOR_SIZE_NORMAL)
1189 Com_Error(ERR_DROP, "Invalid character size given for character '%s': %i",
1190 chr->name, chr->fieldSize);
1191 if (chr->teamDef == nullptr)
1192 Com_Error(ERR_DROP, "Character with no teamdef set (%s)", chr->name);
1193
1195 NET_WriteShort(buf, chr->ucn);
1196 NET_WriteString(buf, chr->name);
1197
1198 /* model */
1199 NET_WriteString(buf, chr->path);
1200 NET_WriteString(buf, chr->body);
1201 NET_WriteString(buf, chr->head);
1202 NET_WriteByte(buf, chr->bodySkin);
1203 NET_WriteByte(buf, chr->headSkin);
1204
1205 NET_WriteShort(buf, chr->HP);
1206 NET_WriteShort(buf, chr->maxHP);
1207 NET_WriteByte(buf, chr->teamDef->idx);
1208 NET_WriteByte(buf, chr->gender);
1209 NET_WriteByte(buf, chr->STUN);
1210 NET_WriteByte(buf, chr->morale);
1211
1212 for (int j = 0; j < chr->teamDef->bodyTemplate->numBodyParts(); ++j)
1214
1215 for (int j = 0; j < SKILL_NUM_TYPES + 1; j++)
1217 for (int j = 0; j < SKILL_NUM_TYPES; j++)
1218 NET_WriteByte(buf, chr->score.skills[j]);
1219 for (int j = 0; j < KILLED_NUM_TYPES; j++)
1220 NET_WriteShort(buf, chr->score.kills[j]);
1221 for (int j = 0; j < KILLED_NUM_TYPES; j++)
1222 NET_WriteShort(buf, chr->score.stuns[j]);
1224}
1225
1233{
1234 const int teamSize = LIST_Count(team);
1235
1236 /* header */
1238 NET_WriteByte(buf, teamSize);
1239
1240 LIST_Foreach(team, character_t, chr) {
1241 Inventory* inv = &chr->inv;
1242
1243 /* unlink all temp containers */
1244 inv->resetTempContainers();
1245
1248 }
1249}
1250
1251const char* GAME_GetTeamDef (void)
1252{
1253 const cgame_export_t* list = GAME_GetCurrentType();
1254
1255 if (list && list->GetTeamDef)
1256 return list->GetTeamDef();
1257
1258 const char* teamDefID = Cvar_GetString("cl_teamdef");
1259 if (teamDefID[0] == '\0')
1260 teamDefID = "phalanx";
1261 return teamDefID;
1262}
1263
1264static bool GAME_Spawn (linkedList_t** chrList)
1265{
1266 const size_t size = GAME_GetCharacterArraySize();
1267
1268 /* If there is no active gametype we create a team with default values.
1269 * This is e.g. the case when someone starts a map with the map command */
1270 if (GAME_GetCurrentType() == nullptr || LIST_IsEmpty(chrDisplayList)) {
1271 const char* teamDefID = GAME_GetTeamDef();
1272 const equipDef_t* ed = INV_GetEquipmentDefinitionByID("multiplayer_initial");
1273
1274 /* inventory structure switched/initialized */
1275 cls.i.destroyInventoryInterface();
1276 cls.i.initInventory("client", &csi, &inventoryImport);
1277 GAME_GenerateTeam(teamDefID, ed, size);
1278 }
1279
1280 int count = 0;
1282 if (count > size)
1283 break;
1284 LIST_AddPointer(chrList, (void*)chr);
1285 }
1286
1287 return true;
1288}
1289
1296void GAME_StartBattlescape (bool isTeamPlay)
1297{
1298 const cgame_export_t* list = GAME_GetCurrentType();
1299
1300 Cvar_Set("cl_onbattlescape", "1");
1301
1302 Cvar_Set("cl_maxworldlevel", "%i", cl.mapMaxLevel - 1);
1303 if (list != nullptr && list->StartBattlescape) {
1304 list->StartBattlescape(isTeamPlay);
1305 } else {
1306 HUD_InitUI("missionoptions");
1308 }
1309}
1310
1311void GAME_InitMissionBriefing (const char* title)
1312{
1313 const cgame_export_t* list = GAME_GetCurrentType();
1314
1315 linkedList_t* victoryConditionsMsgIDs = nullptr;
1316 linkedList_t* missionBriefingMsgIDs = nullptr;
1317
1318 /* allow the server to add e.g. the misc_mission victory condition */
1319 const char* serverVictoryMsgID = CL_GetConfigString(CS_VICTORY_CONDITIONS);
1320 if (Q_strvalid(serverVictoryMsgID))
1321 LIST_AddString(&victoryConditionsMsgIDs, serverVictoryMsgID);
1322
1323 UI_PushWindow("mission_briefing");
1324
1325 if (list != nullptr && list->InitMissionBriefing)
1326 list->InitMissionBriefing(&title, &victoryConditionsMsgIDs, &missionBriefingMsgIDs);
1327
1328 /* if the cgame has nothing to contribute here, we will add a default victory condition */
1329 if (LIST_IsEmpty(victoryConditionsMsgIDs))
1330 LIST_AddString(&victoryConditionsMsgIDs, "*msgid:victory_condition_default");
1331
1332 /* if the cgame has nothing to contribute here, we will add a default mission briefing */
1333 if (LIST_IsEmpty(missionBriefingMsgIDs))
1334 LIST_AddString(&missionBriefingMsgIDs, "*msgid:mission_briefing_default");
1335
1336 UI_RegisterLinkedListText(TEXT_MISSIONBRIEFING, missionBriefingMsgIDs);
1339}
1340
1347{
1348 const size_t size = lengthof(cl.teamList);
1349 for (int i = 0; i < size; i++) {
1350 UI_ExecuteConfunc("huddisable %i", i);
1351 }
1352
1353 dbuffer msg;
1354 const cgame_export_t* list = GAME_GetCurrentType();
1355 if (list && list->InitializeBattlescape) {
1356 list->InitializeBattlescape(&msg, team);
1357 } else {
1358 const int teamSize = LIST_Count(team);
1359 dbuffer* m = &msg;
1360
1362 NET_WriteByte(m, teamSize);
1363
1364 LIST_Foreach(team, character_t, chr) {
1365 NET_WriteShort(m, chr->ucn);
1370 }
1371 }
1372 NET_WriteMsg(cls.netStream, msg);
1373}
1374
1379{
1380 const cgame_export_t* list = GAME_GetCurrentType();
1381 bool spawnStatus;
1382
1383 /* this callback is responsible to set up the teamlist */
1384 if (list && list->Spawn)
1385 spawnStatus = list->Spawn(&cl.chrList);
1386 else
1387 spawnStatus = GAME_Spawn(&cl.chrList);
1388
1389 Com_Printf("Used inventory slots: %i\n", cls.i.GetUsedSlots());
1390
1391 if (spawnStatus && !LIST_IsEmpty(cl.chrList)) {
1392 /* send team info */
1393 dbuffer msg;
1394 GAME_SendCurrentTeamSpawningInfo(&msg, cl.chrList);
1395 NET_WriteMsg(cls.netStream, msg);
1396 }
1397}
1398
1400{
1401 if (!LIST_IsEmpty(cl.chrList)) {
1402 dbuffer msg(12);
1405 NET_WriteMsg(cls.netStream, msg);
1406
1408 }
1409}
1410
1411const char* GAME_GetRelativeSavePath (char* buf, size_t bufSize)
1412{
1413 Com_sprintf(buf, bufSize, "save/%s/", GAME_GetCurrentName());
1414 return buf;
1415}
1416
1417const char* GAME_GetAbsoluteSavePath (char* buf, size_t bufSize)
1418{
1419 Com_sprintf(buf, bufSize, "%s/save/%s/", FS_Gamedir(), GAME_GetCurrentName());
1420 return buf;
1421}
1422
1424{
1425 const cgame_export_t* list = GAME_GetCurrentType();
1426
1427 if (list && list->GetEquipmentDefinition != nullptr)
1428 return list->GetEquipmentDefinition();
1429 return &equipDefStandard;
1430}
1431
1433{
1434 const cgame_export_t* list = GAME_GetCurrentType();
1435 if (list && list->NotifyEvent)
1436 list->NotifyEvent(eventType);
1437}
1438
1439bool GAME_TeamIsKnown (const teamDef_t* teamDef)
1440{
1441 const cgame_export_t* list = GAME_GetCurrentType();
1442
1443 if (!teamDef)
1444 return false;
1445
1446 if (list && list->IsTeamKnown != nullptr)
1447 return list->IsTeamKnown(teamDef);
1448 return true;
1449}
1450
1452{
1453 const cgame_export_t* list = GAME_GetCurrentType();
1454 if (list && list->UpdateCharacterValues != nullptr)
1455 list->UpdateCharacterValues(chr);
1456}
1457
1461static void GAME_Abort_f (void)
1462{
1463 /* aborting means letting the aliens win */
1464 Cbuf_AddText("sv win %i\n", TEAM_ALIEN);
1465}
1466
1467void GAME_Drop (void)
1468{
1469 const cgame_export_t* list = GAME_GetCurrentType();
1470
1471 if (list && list->Drop) {
1472 list->Drop();
1473 } else {
1474 SV_Shutdown("Drop", false);
1475 GAME_SetMode(nullptr);
1476
1478
1479 UI_InitStack("main", nullptr);
1480 }
1481}
1482
1486static void GAME_Exit_f (void)
1487{
1488 GAME_SetMode(nullptr);
1489
1491}
1492
1496void GAME_Frame (void)
1497{
1498 /* don't run the cgame in console mode */
1499 if (cls.keyDest == key_console)
1500 return;
1501
1502 const cgame_export_t* list = GAME_GetCurrentType();
1503 if (list && list->RunFrame != nullptr)
1504 list->RunFrame(cls.frametime);
1505}
1506
1507
1508void GAME_DrawBaseLayout (int baseIdx, int x, int y, int totalMarge, int w, int h, int padding, const vec4_t bgcolor, const vec4_t color)
1509{
1510 const cgame_export_t* list = GAME_GetCurrentType();
1511 if (list && list->DrawBaseLayout != nullptr)
1512 list->DrawBaseLayout(baseIdx, x, y, totalMarge, w, h, padding, bgcolor, color);
1513}
1514
1521void GAME_DrawBaseLayoutTooltip (int baseIdx, int x, int y)
1522{
1523 const cgame_export_t* list = GAME_GetCurrentType();
1524 if (list && list->DrawBaseLayoutTooltip != nullptr)
1525 list->DrawBaseLayoutTooltip(baseIdx, x, y);
1526}
1527
1534const char* GAME_GetModelForItem (const objDef_t* od, uiModel_t** uiModel)
1535{
1536 const cgame_export_t* list = GAME_GetCurrentType();
1537 if (list && list->GetModelForItem != nullptr) {
1538 const char* model = list->GetModelForItem(od->id);
1539 if (model != nullptr) {
1540 if (uiModel != nullptr)
1541 *uiModel = UI_GetUIModel(model);
1542 return model;
1543 }
1544 }
1545
1546 if (uiModel != nullptr)
1547 *uiModel = nullptr;
1548 return od->model;
1549}
1550
1556{
1557 const cgame_export_t* list = GAME_GetCurrentType();
1558 if (list && list->GetSelectedChr != nullptr)
1559 return list->GetSelectedChr();
1560
1561 const int ucn = Cvar_GetInteger("mn_ucn");
1562 character_t* chr = nullptr;
1564 if (ucn == chrTmp->ucn) {
1565 chr = chrTmp;
1566 break;
1567 }
1568 }
1569 return chr;
1570}
1571
1578{
1579 if (chr == nullptr)
1580 return NONE;
1581
1582 const cgame_export_t* list = GAME_GetCurrentType();
1583 const int strength = chr->score.skills[ABILITY_POWER];
1584 if (list && list->GetChrMaxLoad != nullptr)
1585 return std::min(strength, list->GetChrMaxLoad(chr));
1586 return strength;
1587}
1588
1592const equipDef_t* GAME_ChangeEquip (const linkedList_t* equipmentList, changeEquipType_t changeType, const char* equipID)
1593{
1594 const equipDef_t* ed;
1595
1596 if (LIST_IsEmpty(equipmentList)) {
1597 ed = INV_GetEquipmentDefinitionByID(equipID);
1598 if (ed == nullptr)
1599 Com_Error(ERR_DROP, "Could not find the equipment definition for '%s'", equipID);
1600 int index = ed - csi.eds;
1601
1602 switch (changeType) {
1603 case BACKWARD:
1604 index--;
1605 if (index < 0)
1606 index = csi.numEDs - 1;
1607 break;
1608 case FORWARD:
1609 index++;
1610 if (index >= csi.numEDs)
1611 index = 0;
1612 break;
1613 default:
1614 break;
1615 }
1616 ed = &csi.eds[index];
1617 } else {
1618 const linkedList_t* entry = LIST_ContainsString(equipmentList, equipID);
1619 if (entry == nullptr) {
1620 equipID = (const char*)equipmentList->data;
1621 } else if (changeType == FORWARD) {
1622 equipID = (const char*)(entry->next != nullptr ? entry->next->data : equipmentList->data);
1623 } else if (changeType == BACKWARD) {
1624 const char* newEntry = nullptr;
1625 const char* prevEntry = nullptr;
1626 LIST_Foreach(equipmentList, char const, tmp) {
1627 if (Q_streq(tmp, equipID)) {
1628 if (prevEntry != nullptr) {
1629 newEntry = prevEntry;
1630 break;
1631 }
1632 }
1633 prevEntry = tmp;
1634 newEntry = tmp;
1635 }
1636 equipID = newEntry;
1637 }
1638 ed = INV_GetEquipmentDefinitionByID(equipID);
1639 if (ed == nullptr)
1640 Com_Error(ERR_DROP, "Could not find the equipment definition for '%s'", equipID);
1641 }
1642
1643 return ed;
1644}
1645
1650{
1651 Com_Printf("----------- game modes -------------\n");
1652 for (int i = 0; i < numCGameTypes; i++) {
1653 const cgameType_t* t = &cgameTypes[i];
1654 const cgame_export_t* e = GAME_GetCGameAPI_(t);
1655 if (e == nullptr)
1656 continue;
1657
1658 if (e->isMultiplayer)
1659 UI_ExecuteConfunc("game_addmode_multiplayer \"%s\" \"%s\"", t->window, t->name);
1660 else
1661 UI_ExecuteConfunc("game_addmode_singleplayer \"%s\" \"%s\"", t->window, t->name);
1662 Com_Printf("added %s\n", t->name);
1664 }
1665
1666 Com_Printf("added %i game modes\n", numCGameTypes);
1667}
1668
1670{
1671 Cmd_AddCommand("game_setmode", GAME_SetMode_f, "Decides with game mode should be set - takes the menu as reference");
1672 Cmd_AddCommand("game_exit", GAME_Exit_f, "Quits the current running game and shutdown the game mode");
1673 Cmd_AddCommand("game_abort", GAME_Abort_f, "Abort the game and let the aliens/opponents win");
1674 Cmd_AddCommand("game_autoteam", GAME_AutoTeam_f, "Assign initial equipment to soldiers");
1675 Cmd_AddCommand("game_toggleactor", GAME_ToggleActorForTeam_f);
1676 Cmd_AddCommand("game_saveteamstate", GAME_SaveTeamState_f);
1677 Cmd_AddCommand("game_saveteam", GAME_SaveTeam_f, "Save a team slot");
1678 Cmd_AddCommand("game_loadteam", GAME_LoadTeam_f, "Load a team slot");
1679 Cmd_AddCommand("game_teamcomments", GAME_TeamSlotComments_f, "Fills the team selection menu with the team names");
1680 Cmd_AddCommand("game_teamupdate", GAME_UpdateTeamMenuParameters_f, "");
1681 Cmd_AddCommand("game_teamdelete", GAME_TeamDelete_f, "Removes a team");
1682 Cmd_AddCommand("game_actorselect", GAME_ActorSelect_f, "Select an actor in the equipment menu");
1683
1686
1688}
1689
1690void GAME_Shutdown (void)
1691{
1693
1695 numCGameTypes = 0;
1697 for (int i = 0; i < lengthof(characters); ++i)
1698 characters[1].init();
1699
1702}
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)
@ 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...
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:1592
void GAME_InitStartup(void)
Definition cl_game.cpp:1669
static const cgame_export_t * GAME_GetCurrentType(void)
Definition cl_game.cpp:63
void GAME_EndRoundAnnounce(int playerNum, int team)
Send end round announcements.
Definition cl_game.cpp:325
void GAME_StartMatch(void)
Definition cl_game.cpp:1399
character_t * GAME_GetSelectedChr(void)
Returns the currently selected character.
Definition cl_game.cpp:1555
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 GAME_Free(void *ptr)
Definition cl_game.cpp:433
static equipDef_t equipDefStandard
Definition cl_game.cpp:181
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:211
equipDef_t * GAME_GetEquipmentDefinition(void)
Definition cl_game.cpp:1423
bool GAME_ItemIsUseable(const objDef_t *od)
Definition cl_game.cpp:1104
static const cgame_export_t * GAME_GetCGameAPI_(const cgameType_t *t)
Definition cl_game.cpp:1067
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:1508
#define MAX_CGAMETYPES
Definition cl_game.cpp:59
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:1496
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
void GAME_DrawMap(geoscapeData_t *data)
Definition cl_game.cpp:931
static int numCGameTypes
Definition cl_game.cpp:61
static void GAME_NetSendInventory(dbuffer *buf, const Inventory *inv)
Definition cl_game.cpp:1163
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:1432
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
void GAME_AppendTeamMember(int memberIndex, const char *teamDefID, const equipDef_t *ed)
Definition cl_game.cpp:252
static void GAME_SetNextUniqueCharacterNumber(int ucn)
Definition cl_game.cpp:488
void GAME_Shutdown(void)
Definition cl_game.cpp:1690
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:1417
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:1135
void GAME_InitMissionBriefing(const char *title)
Definition cl_game.cpp:1311
static void GAME_DestroyInventory(Inventory *const inv)
Definition cl_game.cpp:453
size_t GAME_GetCharacterArraySize(void)
Definition cl_game.cpp:227
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:1078
void GAME_SpawnSoldiers(void)
Called during startup of mission to send team info.
Definition cl_game.cpp:1378
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:186
geoscapeData_t geoscapeData
Definition cl_game.cpp:147
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:197
void GAME_ParseModes(const char *name, const char **text)
Definition cl_game.cpp:999
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:1521
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:1150
int GAME_GetChrMaxLoad(const character_t *chr)
Returns the max weight the given character can carry.
Definition cl_game.cpp:1577
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:1184
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:1461
static void R_UploadAlpha_(const char *name, const byte *alphaData)
Definition cl_game.cpp:564
const char * GAME_GetTeamDef(void)
Definition cl_game.cpp:1251
void GAME_ResetCharacters(void)
Reset all characters in the static character array.
Definition cl_game.cpp:244
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
bool GAME_TeamIsKnown(const teamDef_t *teamDef)
Definition cl_game.cpp:1439
void GAME_InitUIData(void)
Fills the game mode list entries with the parsed values from the script.
Definition cl_game.cpp:1649
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:232
const char * GAME_GetRelativeSavePath(char *buf, size_t bufSize)
Definition cl_game.cpp:1411
static SharedPtr< GAMECvarListener > cvarListener(new GAMECvarListener())
static bool GAME_Spawn(linkedList_t **chrList)
Definition cl_game.cpp:1264
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:1232
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:60
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:1346
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:1025
static void GAME_Exit_f(void)
Quits the current running game by calling the shutdown callback.
Definition cl_game.cpp:1486
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:991
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:1534
void GAME_StartBattlescape(bool isTeamPlay)
Called when the server sends the EV_START event.
Definition cl_game.cpp:1296
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:1467
void GAME_CharacterCvars(const character_t *chr)
Definition cl_game.cpp:1451
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
HUD related routines.
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.
Header file for inventory handling and Equipment menu.
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
void MAP_ShutdownCallbacks(void)
Unregisters UI Callbacks of battlescape map selection.
void MAP_InitCallbacks(void)
Registers UI Callbacks for battlescape map selection.
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
Listener for command changes.
Definition cmd.h:96
Listener for cvar changes.
Definition cvar.h:98
void onGameModeChange()
Definition cl_game.cpp:130
GameCmds _cmds
Definition cl_game.cpp:110
std::set< const char * > GameCmds
Definition cl_game.cpp:109
void onRemove(const char *cmdName)
Definition cl_game.cpp:125
void onAdd(const char *cmdName)
Definition cl_game.cpp:117
void onDelete(const struct cvar_s *cvar)
Definition cl_game.cpp:86
void onGameModeChange()
Definition cl_game.cpp:91
void onCreate(const struct cvar_s *cvar)
Definition cl_game.cpp:79
GameCvars _cvars
Definition cl_game.cpp:72
std::set< const struct cvar_s * > GameCvars
Definition cl_game.cpp:71
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).
void resetTempContainers()
Definition inv_shared.h:557
Item * getArmour() const
Item * getContainer2(const containerIndex_t idx) const
Definition inv_shared.h:546
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
Primary header for client.
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:440
int Com_ServerState(void)
Check whether we are the server or have a singleplayer tactical mission.
Definition common.cpp:578
void * Com_LoadLibrary(const char *path, const char *prefix)
Attempts to load a library using a filename suffix list.
Definition common.cpp:126
void Com_Error(int code, const char *fmt,...)
Definition common.cpp:459
void Com_SetGameType(void)
Definition common.cpp:832
void Com_Printf(const char *const fmt,...)
Definition common.cpp:428
cvar_t * masterserver_url
Definition common.cpp:57
void Com_Drop(void)
Definition common.cpp:507
@ clc_stringcmd
Definition common.h:181
@ clc_teaminfo
Definition common.h:177
@ clc_initactorstates
Definition common.h:178
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
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 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
Filesystem header file.
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:384
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.
#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
Shared parsing functions.
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 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.
void R_Draw2DMapMarkers(const vec2_t screenPos, float direction, const char *model, int skin)
Draw 3D Marker on the 2D geoscape.
void R_DrawBloom(void)
handle post-processing bloom
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:345
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
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
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
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
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
teamDef_t * teamDef
Item * getFloorContainer() const
Inventory inv
void * data
Definition list.h:31
linkedList_t * next
Definition list.h:32
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
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).
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:526
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)
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.
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.
int UI_DrawTooltip(const char *string, int x, int y, int maxWidth)
Generic tooltip function.
bool UI_IsWindowOnStack(const char *name)
Check if a named window is on the stack if active windows.
uiNode_t * UI_PushWindow(const char *name, const char *parentName, linkedList_t *params)
Push a window onto the window stack.
void UI_PopWindow(bool all)
Pops a window from the window stack.
void UI_InitStack(const char *activeWindow, const char *mainWindow)
Init the stack to start with a window, and have an alternative window with ESC.
const char * UI_GetActiveWindowName(void)
Returns the name of the current window.
bool WEB_CGameUpload(const char *cgameId, int category, const char *filename)
Uploads a file to the server.
bool WEB_CGameDelete(const char *cgameId, int category, const char *filename)
Deletes a user owned file on the server.
int WEB_CGameListForUser(const char *cgameId, int category, int userId)
Shows the uploaded files for the particular cgame category and the given userid.
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.
UFOAI web interface management. c(lient)game related stuff.
void XML_AddPos2(xmlNode_t *parent, const char *name, const vec2_t pos)
add a Pos2 data to the XML Tree
Definition xml.cpp:258
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:508
void XML_AddFloatValue(xmlNode_t *parent, const char *name, float value)
add a non-zero Float attribute to the XML Node
Definition xml.cpp:108
double XML_GetDouble(xmlNode_t *parent, const char *name, const double defaultval)
retrieve a Double attribute from an XML Node
Definition xml.cpp:387
float XML_GetFloat(xmlNode_t *parent, const char *name, const float defaultval)
retrieve a Float attribute from an XML Node
Definition xml.cpp:373
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:403
void XML_AddByte(xmlNode_t *parent, const char *name, byte value)
add a Byte attribute to the XML Node
Definition xml.cpp:146
bool XML_GetBool(xmlNode_t *parent, const char *name, const bool defaultval)
retrieve a Boolean attribute from an XML Node
Definition xml.cpp:297
void XML_AddString(xmlNode_t *parent, const char *name, const char *value)
add a String attribute to the XML Node
Definition xml.cpp:45
void XML_AddIntValue(xmlNode_t *parent, const char *name, int value)
add a non-zero Int attribute to the XML Node
Definition xml.cpp:204
long XML_GetLong(xmlNode_t *parent, const char *name, const long defaultval)
retrieve a Long attribute from an XML Node
Definition xml.cpp:345
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:58
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:422
void XML_AddShortValue(xmlNode_t *parent, const char *name, short value)
add a non-zero Short attribute to the XML Node
Definition xml.cpp:181
int XML_GetInt(xmlNode_t *parent, const char *name, const int defaultval)
retrieve an Int attribute from an XML Node
Definition xml.cpp:317
void XML_AddFloat(xmlNode_t *parent, const char *name, float value)
add a Float attribute to the XML Node
Definition xml.cpp:96
short XML_GetShort(xmlNode_t *parent, const char *name, const short defaultval)
retrieve a Short attribute from an XML Node
Definition xml.cpp:331
void XML_AddDouble(xmlNode_t *parent, const char *name, double value)
add a Double attribute to the XML Node
Definition xml.cpp:119
void XML_AddByteValue(xmlNode_t *parent, const char *name, byte value)
add a non-zero Byte attribute to the XML Node
Definition xml.cpp:158
void XML_AddLongValue(xmlNode_t *parent, const char *name, long value)
add a non-zero Long attribute to the XML Node
Definition xml.cpp:229
void XML_AddDoubleValue(xmlNode_t *parent, const char *name, double value)
add a non-zero Double attribute to the XML Node
Definition xml.cpp:133
const char * XML_GetString(xmlNode_t *parent, const char *name)
retrieve a String attribute from an XML Node
Definition xml.cpp:359
void XML_AddLong(xmlNode_t *parent, const char *name, long value)
add a Long attribute to the XML Node
Definition xml.cpp:215
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:440
void XML_AddBool(xmlNode_t *parent, const char *name, bool value)
add a Boolean attribute to the XML Node
Definition xml.cpp:71
xmlNode_t * XML_Parse(const char *buffer)
Definition xml.cpp:544
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:460
xmlNode_t * XML_AddNode(xmlNode_t *parent, const char *name)
add a new node to the XML tree
Definition xml.cpp:286
void XML_AddInt(xmlNode_t *parent, const char *name, int value)
add an Int attribute to the XML Node
Definition xml.cpp:192
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:480
void XML_AddShort(xmlNode_t *parent, const char *name, short value)
add a Short attribute to the XML Node
Definition xml.cpp:169
void XML_AddPos3(xmlNode_t *parent, const char *name, const vec3_t pos)
add a Pos3 data to the XML Tree
Definition xml.cpp:243
xmlNode_t * XML_GetNode(xmlNode_t *parent, const char *name)
Get first Node of the XML tree by name.
Definition xml.cpp:496
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:273
void XML_AddBoolValue(xmlNode_t *parent, const char *name, bool value)
add a non-false Boolean attribute to the XML Node
Definition xml.cpp:83