UFO: Alien Invasion
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
g_local.h
Go to the documentation of this file.
1 
6 /*
7 All original material Copyright (C) 2002-2020 UFO: Alien Invasion.
8 
9 Original file from Quake 2 v3.21: quake2-2.31/game/g_local.h
10 Copyright (C) 1997-2001 Id Software, Inc.
11 
12 This program is free software; you can redistribute it and/or
13 modify it under the terms of the GNU General Public License
14 as published by the Free Software Foundation; either version 2
15 of the License, or (at your option) any later version.
16 
17 This program is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
20 
21 See the GNU General Public License for more details.
22 
23 You should have received a copy of the GNU General Public License
24 along with this program; if not, write to the Free Software
25 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26 
27 */
28 
29 #pragma once
30 
31 #include "q_shared.h"
32 #include "inventory.h" /* for InventoryInterface in game_locals_t */
33 #include "../shared/infostring.h"
34 extern "C" {
35 #include <lua.h>
36 }
37 
39 #define _(String) String
40 #define ngettext(x, y, cnt) x
41 
45 #define GAME_INCLUDE
46 #include "game.h"
47 
49 #define GAMEVERSION "baseufo"
50 
51 #define MAX_SPOT_DIST_CAMERA 768
52 #define MAX_SPOT_DIST 4096
53 
55 #define SERVER_FRAME_SECONDS 0.1
56 
58 #define TAG_GAME 765 /* clear when unloading the game library */
59 #define TAG_LEVEL 766 /* clear when loading a new level */
60 
61 #define INVDEF(containerID) (&gi.csi->ids[(containerID)])
62 
63 #define G_FreeTags(tag) gi.FreeTags((tag), __FILE__, __LINE__)
64 #define G_TagMalloc(size, tag) gi.TagMalloc((size), (tag), __FILE__, __LINE__)
65 #define G_MemFree(ptr) gi.TagFree((ptr), __FILE__, __LINE__)
66 
69 typedef struct game_locals_s {
70  Player* players; /* [maxplayers] */
71 
72  /* store latched cvars here that we want to get at often */
75 
78 
80 typedef struct level_locals_s {
81  int framenum;
82  float time;
87  bool routed;
88  bool day;
89  bool hurtAliens;
92  /* intermission state */
99  /* turn statistics */
102  int teamOfs;
112  unsigned num_spawned[MAX_TEAMS];
113  unsigned num_kills[MAX_TEAMS + 1][MAX_TEAMS];
114  unsigned num_stuns[MAX_TEAMS + 1][MAX_TEAMS];
120 
121 
122 extern game_locals_t game;
123 extern level_locals_t level;
124 extern game_import_t gi;
125 extern game_export_t globals;
126 
127 #define G_IsActor(ent) ((ent)->type == ET_ACTOR || (ent)->type == ET_ACTOR2x2)
128 #define G_IsActive(ent) ((ent)->active)
129 #define G_IsCamera(ent) ((ent)->type == ET_CAMERA)
130 #define G_IsActiveCamera(ent) (G_IsCamera(ent) && G_IsActive(ent))
131 #define G_IsSmoke(ent) ((ent)->type == ET_SMOKE)
132 #define G_IsFire(ent) ((ent)->type == ET_FIRE)
133 #define G_IsTriggerNextMap(ent) ((ent)->type == ET_TRIGGER_NEXTMAP)
134 #define G_IsItem(ent) ((ent)->type == ET_ITEM)
135 #define G_IsDoor(ent) ((ent)->type == ET_DOOR || (ent)->type == ET_DOOR_SLIDING)
136 
137 #define G_IsBreakable(ent) ((ent)->flags & FL_DESTROYABLE)
138 #define G_IsBrushModel(ent) ((ent)->type == ET_BREAKABLE || G_IsDoor(ent) || (ent)->type == ET_ROTATING)
139 
140 #define G_IsVisibleOnBattlefield(ent) (G_IsActor((ent)) || G_IsItem(ent) || G_IsCamera(ent) || (ent)->type == ET_PARTICLE)
141 #define G_IsAI(ent) ((ent)->getPlayer().pers.ai)
142 #define G_IsAIPlayer(player) ((player)->pers.ai)
143 #define G_TeamToVisMask(team) (1 << (team))
144 #define G_IsVisibleForTeam(ent, team) ((ent)->visflags & G_TeamToVisMask(team))
145 #define G_IsMultiPlayer() (sv_maxclients->integer > 1)
146 #define G_IsSinglePlayer() (!G_IsMultiPlayer())
147 
148 #define G_IsCivilian(ent) ((ent)->getTeam() == TEAM_CIVILIAN)
149 #define G_IsAlien(ent) ((ent)->getTeam() == TEAM_ALIEN)
150 #define G_IsBlockingMovementActor(ent) (((ent)->type == ET_ACTOR && !G_IsDead(ent)) || ent->type == ET_ACTOR2x2)
151 
152 extern cvar_t* sv_maxentities;
153 extern cvar_t* password;
154 extern cvar_t* sv_needpass;
155 extern cvar_t* sv_dedicated;
156 extern cvar_t* developer;
157 
158 extern cvar_t* logstats;
159 extern FILE* logstatsfile;
160 
161 extern cvar_t* sv_filterban;
162 
163 extern cvar_t* sv_maxvelocity;
164 
165 extern cvar_t* sv_maxclients;
166 extern cvar_t* sv_shot_origin;
167 extern cvar_t* sv_hurtaliens;
171 extern cvar_t* sv_enablemorale;
172 extern cvar_t* sv_roundtimelimit;
173 
174 extern cvar_t* sv_maxteams;
175 
176 extern cvar_t* sv_ai;
177 extern cvar_t* sv_teamplay;
178 
179 extern cvar_t* ai_alienteam;
180 extern cvar_t* ai_civilianteam;
181 extern cvar_t* ai_equipment;
183 extern cvar_t* ai_numcivilians;
185 
186 extern cvar_t* mob_death;
187 extern cvar_t* mob_wound;
188 extern cvar_t* mob_shoot;
189 extern cvar_t* mof_watching;
190 extern cvar_t* mof_teamkill;
191 extern cvar_t* mof_civilian;
192 extern cvar_t* mof_enemy;
193 extern cvar_t* mor_pain;
194 
195 /*everyone gets this times morale damage */
196 extern cvar_t* mor_default;
197 
198 /* at this distance the following two get halfed (exponential scale) */
199 extern cvar_t* mor_distance;
200 
201 /* at this distance the following two get halfed (exponential scale) */
202 extern cvar_t* mor_victim;
203 
204 /* at this distance the following two get halfed (exponential scale) */
205 extern cvar_t* mor_attacker;
206 
207 /* how much the morale depends on the size of the damaged team */
208 extern cvar_t* mon_teamfactor;
209 
210 extern cvar_t* mor_regeneration;
211 extern cvar_t* mor_shaken;
212 extern cvar_t* mor_panic;
213 extern cvar_t* mor_brave;
214 
215 extern cvar_t* m_sanity;
216 extern cvar_t* m_rage;
217 extern cvar_t* m_rage_stop;
218 extern cvar_t* m_panic_stop;
219 
220 extern cvar_t* g_endlessaliens;
221 extern cvar_t* g_ailua;
222 extern cvar_t* g_aihumans;
223 extern cvar_t* g_aidebug;
224 extern cvar_t* g_drawtraces;
225 extern cvar_t* g_nodamage;
226 extern cvar_t* g_notu;
227 extern cvar_t* g_nospawn;
228 extern cvar_t* g_actorspeed;
229 extern cvar_t* g_lastseen;
230 
231 extern cvar_t* flood_msgs;
232 extern cvar_t* flood_persecond;
233 extern cvar_t* flood_waitdelay;
234 
235 extern cvar_t* g_difficulty;
236 
237 /* g_camera */
238 void G_InitCamera(Edict* ent, camera_type_t cameraType, float angle, bool rotate);
239 
240 /* g_cmds.c */
241 void G_ClientCommand(Player& player);
242 #ifdef DEBUG
243 void G_InvList_f(const Player& player);
244 #endif
245 
246 /* g_morale */
247 void G_MoraleBehaviour(int team);
248 #define MORALE_RANDOM( mod ) ( (mod) * (1.0 + 0.3*crand()) )
249 
250 /* g_round */
251 void G_CheckForceEndRound(void);
252 void G_ClientEndRound(Player& player);
253 
254 /* g_stats */
255 void G_SendStats(Edict& ent);
256 void G_SendPlayerStats(const Player& player);
257 
258 /* g_svcmds.c */
259 void G_ServerCommand(void);
260 bool SV_FilterPacket(const char* from);
261 
262 #include "g_events.h"
263 
264 /*============================================================================ */
265 
267 typedef enum {
268  MAT_GLASS, /* default */
272 
275 
277 typedef struct moveinfo_s {
279 } moveinfo_t;
280 
287 #define FL_DESTROYABLE 0x00000004
288 
292 #define FL_GROUPSLAVE 0x00000008
293 
296 #define FL_CLIENTACTION 0x00000010
297 
300 #define FL_TRIGGERED 0x00000100
301 
303 typedef struct AI_s {
304  char type[MAX_QPATH];
305  char subtype[MAX_VAR];
306 } AI_t;
307 
308 typedef struct camera_edict_data_s {
310  bool rotate;
312 
313 #include "g_edict.h"
char mapname[MAX_QPATH]
Definition: g_local.h:85
cvar_t * flood_waitdelay
Definition: g_main.cpp:123
cvar_t * g_lastseen
Definition: g_main.cpp:120
cvar_t * sv_shot_origin
Definition: g_main.cpp:63
float intermissionTime
Definition: g_local.h:93
cvar_t * sv_maxplayersperteam
Definition: g_main.cpp:52
cvar_t * sv_maxsoldiersperplayer
Definition: g_main.cpp:54
cvar_t * g_endlessaliens
Definition: g_main.cpp:111
cvar_t * sv_maxteams
Definition: g_main.cpp:59
Local definitions for game module.
#define MAX_TEAMS
Definition: defines.h:98
cvar_t * m_rage
Definition: g_main.cpp:107
cvar_t * m_sanity
Definition: g_main.cpp:106
bool hurtAliens
Definition: g_local.h:89
Player * players
Definition: g_local.h:70
unsigned num_stuns[MAX_TEAMS+1][MAX_TEAMS]
Definition: g_local.h:114
Common header file.
This is a cvar definition. Cvars can be user modified and used in our menus e.g.
Definition: cvar.h:71
Edict * ai_waypointList
Definition: g_local.h:118
int activeTeam
Definition: g_local.h:101
void G_InitCamera(Edict *ent, camera_type_t cameraType, float angle, bool rotate)
Definition: g_camera.cpp:50
this structure is left intact through an entire game it should be initialized at game library load ti...
Definition: g_local.h:69
bool routed
Definition: g_local.h:87
bool nextMapSwitch
Definition: g_local.h:90
#define FILE
Definition: test_webapi.cpp:30
struct moveinfo_s moveinfo_t
actor movement
void G_ClientEndRound(Player &player)
Definition: g_round.cpp:184
this structure is cleared as each map is entered
Definition: g_local.h:80
InventoryInterface invi
Definition: g_local.h:76
Interface to game library.
int nextEndRound
Definition: g_local.h:103
cvar_t * mob_wound
Definition: g_main.cpp:78
cvar_t * mob_shoot
Definition: g_main.cpp:79
cvar_t * ai_singleplayeraliens
Definition: g_main.cpp:72
cvar_t * g_drawtraces
Definition: g_main.cpp:115
bool SV_FilterPacket(const char *from)
Definition: g_svcmds.cpp:104
void G_MoraleBehaviour(int team)
Applies morale behaviour on actors.
Definition: g_morale.cpp:156
int actualRound
Definition: g_local.h:104
cvar_t * g_notu
Definition: g_main.cpp:117
cvar_t * m_rage_stop
Definition: g_main.cpp:108
unsigned num_kills[MAX_TEAMS+1][MAX_TEAMS]
Definition: g_local.h:113
cvar_t * g_aihumans
Definition: g_main.cpp:113
struct game_locals_s game_locals_t
this structure is left intact through an entire game it should be initialized at game library load ti...
cvar_t * g_ailua
Definition: g_main.cpp:112
game_locals_t game
Definition: g_main.cpp:37
cvar_t * mob_death
Definition: g_main.cpp:77
cvar_t * sv_maxvelocity
int framenum
Definition: g_local.h:81
functions exported by the game subsystem
Definition: game.h:317
cvar_t * mof_teamkill
Definition: g_main.cpp:81
functions provided by the main engine
Definition: game.h:173
int sv_maxentities
Definition: g_local.h:74
cvar_t * sv_filterban
Definition: g_main.cpp:58
cvar_t * g_difficulty
Definition: g_main.cpp:125
game_import_t gi
Definition: g_main.cpp:39
cvar_t * sv_enablemorale
Definition: g_main.cpp:55
int noRandomSpawn
Definition: g_local.h:108
cvar_t * sv_maxsoldiersperteam
Definition: g_main.cpp:53
#define MAX_VAR
Definition: shared.h:36
struct camera_edict_data_s camera_edict_data_t
byte num_spawnpoints[MAX_TEAMS]
Definition: g_local.h:116
struct AI_s AI_t
Artificial intelligence of a character.
void G_ClientCommand(Player &player)
Definition: g_cmds.cpp:423
cvar_t * ai_multiplayeraliens
Definition: g_main.cpp:74
cvar_t * g_actorspeed
Definition: g_main.cpp:119
cvar_t * mor_panic
Definition: g_main.cpp:103
cvar_t * ai_numcivilians
Definition: g_main.cpp:73
edictMaterial_t
e.g. used for breakable objects
Definition: g_local.h:267
cvar_t * ai_alienteam
Definition: g_main.cpp:69
byte num_alive[MAX_TEAMS]
Definition: g_local.h:115
cvar_t * mor_attacker
Definition: g_main.cpp:96
Definition: grid.h:83
cvar_t * mor_regeneration
Definition: g_main.cpp:101
char type[MAX_QPATH]
Definition: g_local.h:304
struct level_locals_s level_locals_t
this structure is cleared as each map is entered
actor movement
Definition: g_local.h:277
cvar_t * logstats
Definition: g_main.cpp:48
cvar_t * flood_msgs
Definition: g_main.cpp:121
cvar_t * g_nospawn
Definition: g_main.cpp:118
cvar_t * mof_watching
Definition: g_main.cpp:80
FILE * logstatsfile
Definition: g_main.cpp:49
cvar_t * password
Definition: g_main.cpp:67
pathing_t * pathingMap
Definition: g_local.h:106
int winningTeam
Definition: g_local.h:96
cvar_t * sv_dedicated
Definition: common.cpp:51
cvar_t * g_aidebug
Definition: g_main.cpp:114
int sv_maxplayersperteam
Definition: g_local.h:73
#define MAX_QPATH
Definition: filesys.h:40
cvar_t * sv_hurtaliens
Definition: g_main.cpp:62
void G_CheckForceEndRound(void)
Check whether a forced turn end should be executed.
Definition: g_round.cpp:39
cvar_t * sv_roundtimelimit
Definition: g_main.cpp:56
cvar_t * sv_needpass
Definition: g_main.cpp:51
cvar_t * developer
Definition: common.cpp:46
int noEquipment
Definition: g_local.h:109
cvar_t * mor_victim
Definition: g_main.cpp:93
camera_type_t
Definition: q_shared.h:178
unsigned num_spawned[MAX_TEAMS]
Definition: g_local.h:112
byte steps
Definition: g_local.h:278
int initialAlienActorsSpawned
Definition: g_local.h:111
cvar_t * ai_civilianteam
Definition: g_main.cpp:70
cvar_t * sv_maxentities
Definition: g_main.cpp:57
void G_ServerCommand(void)
ServerCommand will be called when an "sv" command is issued. The game can issue gi.Cmd_Argc() / gi.Cmd_Argv() commands to get the rest of the parameters.
Definition: g_svcmds.cpp:337
Artificial intelligence of a character.
Definition: g_local.h:303
cvar_t * mor_brave
Definition: g_main.cpp:104
byte num_2x2spawnpoints[MAX_TEAMS]
Definition: g_local.h:117
cvar_t * m_panic_stop
Definition: g_main.cpp:109
cvar_t * mor_pain
Definition: g_main.cpp:84
void G_SendPlayerStats(const Player &player)
Write player stats to network buffer.
Definition: g_stats.cpp:49
int numplayers
Definition: g_local.h:100
char subtype[MAX_VAR]
Definition: g_local.h:305
void G_SendStats(Edict &ent)
Send stats to network buffer.
Definition: g_stats.cpp:34
cvar_t * mor_shaken
Definition: g_main.cpp:102
Definition: g_edict.h:45
cvar_t * mof_civilian
Definition: g_main.cpp:82
char * mapEndCommand
Definition: g_local.h:86
cvar_t * sv_maxclients
Definition: g_main.cpp:43
float roundstartTime
Definition: g_local.h:97
cvar_t * sv_teamplay
Definition: g_main.cpp:61
uint8_t byte
Definition: ufotypes.h:34
camera_type_t cameraType
Definition: g_local.h:309
cvar_t * mof_enemy
Definition: g_main.cpp:83
cvar_t * mor_default
Definition: g_main.cpp:87
Event related headers.
cvar_t * mon_teamfactor
Definition: g_main.cpp:99
cvar_t * sv_ai
Definition: g_main.cpp:60
cvar_t * flood_persecond
Definition: g_main.cpp:122
cvar_t * mor_distance
Definition: g_main.cpp:90
level_locals_t level
Definition: g_main.cpp:38
cvar_t * ai_equipment
Definition: g_main.cpp:71
cvar_t * g_nodamage
Definition: g_main.cpp:116
game_export_t globals
Definition: g_main.cpp:40
float time
Definition: g_local.h:82