1 /**
2  * @file
3  * @brief Shared game type headers
4  */
5 
6 /*
7 Copyright (C) 2002-2013 UFO: Alien Invasion.
8 
9 This program is free software; you can redistribute it and/or
10 modify it under the terms of the GNU General Public License
11 as published by the Free Software Foundation; either version 2
12 of the License, or (at your option) any later version.
13 
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17 
18 See the GNU General Public License for more details.
19 
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
23 
24 */
25 
26 #pragma once
27 
28 #include "../cl_shared.h"
29 #include "../ui/ui_nodes.h"
30 
31 #include "cgame.h"
32 
33 extern geoscapeData_t geoscapeData;
34 struct cgame_export_s;
35 
36 #define GAME_IsSingleplayer()	(!GAME_IsMultiplayer())
37 bool GAME_IsMultiplayer(void);
38 void GAME_ParseModes(const char* name, const char** text);
39 void GAME_InitStartup(void);
40 void GAME_Shutdown(void);
41 void GAME_InitUIData(void);
42 void GAME_UnloadGame(void);
43 void GAME_SetMode(const struct cgame_export_s* gametype);
44 void GAME_ReloadMode(void);
45 void GAME_Init(bool load);
46 void GAME_DisplayItemInfo(uiNode_t* node, const char* string);
47 bool GAME_ItemIsUseable(const objDef_t* od);
48 void GAME_HandleResults(dbuffer* msg, int winner, int* numSpawned, int* numAlive, int numKilled[][MAX_TEAMS], int numStunned[][MAX_TEAMS], bool nextmap);
49 void GAME_SpawnSoldiers(void);
50 void GAME_StartMatch(void);
51 const char* GAME_GetRelativeSavePath(char* buf, size_t bufSize);
52 const char* GAME_GetAbsoluteSavePath(char* buf, size_t bufSize);
53 equipDef_t* GAME_GetEquipmentDefinition(void);
54 bool GAME_HandleServerCommand(const char* command, dbuffer* msg);
55 void GAME_AddChatMessage(const char* format, ...);
56 void GAME_CharacterCvars(const character_t* chr);
57 character_t* GAME_GetCharacter(int index);
58 character_t* GAME_GetCharacterByUCN(int ucn);
59 size_t GAME_GetCharacterArraySize(void);
60 const char* GAME_GetCurrentName(void);
61 void GAME_ResetCharacters(void);
62 void GAME_GenerateTeam(const char* teamDefID, const equipDef_t* ed, int teamMembers);
63 void GAME_AppendTeamMember(int memberIndex, const char* teamDefID, const equipDef_t* ed);
64 void GAME_StartBattlescape(bool isTeamPlay);
65 void GAME_InitMissionBriefing(const char* title);
66 void GAME_EndBattlescape(void);
67 void GAME_EndRoundAnnounce(int playerNum, int team);
68 bool GAME_TeamIsKnown(const teamDef_t* teamDef);
69 void GAME_NotifyEvent(event_t eventType);
70 const char* GAME_GetTeamDef(void);
71 void GAME_Drop(void);
72 void GAME_Frame(void);
73 void GAME_HandleBaseClick(int baseIdx, int key, int row, int col);
74 void GAME_DrawBase(int baseIdx, int x, int y, int w, int h, int col, int row, bool hover, int overlap);
75 void GAME_DrawBaseTooltip(int baseIdx, int x, int y, int col, int row);
76 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);
77 const char* GAME_GetModelForItem(const objDef_t* od, struct uiModel_s** menuModel);
78 const mapDef_t* GAME_GetCurrentSelectedMap(void);
79 void GAME_SwitchCurrentSelectedMap(int step);
80 bool GAME_IsTeamEmpty(void);
81 int GAME_GetCurrentTeam(void);
82 void GAME_DrawMap(geoscapeData_t* data);
83 void GAME_DrawMapMarkers(uiNode_t* node);
84 void GAME_MapClick(uiNode_t* node, int x, int y, const vec2_t pos);
85 void GAME_SetServerInfo(const char* server, const char* serverport);
86 character_t* GAME_GetSelectedChr(void);
87 int GAME_GetChrMaxLoad(const character_t* chr);
88 
89 const equipDef_t* GAME_ChangeEquip(const linkedList_t* equipmentList, changeEquipType_t changeType, const char* equipID);
90 
91 #ifndef HARD_LINKED_CGAME
92 /* this is only here so the functions in the shared code can link */
93 #define CGAME_HARD_LINKED_FUNCTIONS \
94 void Sys_Error (const char* error, ...) \
95 { \
96 	va_list argptr; \
97 	char text[1024]; \
98 	va_start(argptr, error); \
99 	Q_vsnprintf(text, sizeof(text), error, argptr); \
100 	va_end(argptr); \
101 	cgi->Sys_Error("%s", text); \
102 } \
103 \
104 void Com_Printf (const char* msg, ...) \
105 { \
106 	va_list argptr; \
107 	char text[1024]; \
108 	va_start(argptr, msg); \
109 	Q_vsnprintf(text, sizeof(text), msg, argptr); \
110 	va_end(argptr); \
111 	cgi->Com_Printf("%s", text); \
112 } \
113 \
114 void Com_DPrintf (int level, const char* msg, ...) \
115 { \
116 	va_list argptr; \
117 	char text[1024]; \
118 	va_start(argptr, msg); \
119 	Q_vsnprintf(text, sizeof(text), msg, argptr); \
120 	va_end(argptr); \
121 	cgi->Com_DPrintf(level, "%s", text); \
122 }
123 #else
124 #define CGAME_HARD_LINKED_FUNCTIONS
125 #endif
126