FTEQW
Documentation of the FTE engine source tree.
q2game.h
Go to the documentation of this file.
1/*
2Copyright (C) 1997-2001 Id Software, Inc.
3
4This program is free software; you can redistribute it and/or
5modify it under the terms of the GNU General Public License
6as published by the Free Software Foundation; either version 2
7of the License, or (at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
13See the GNU General Public License for more details.
14
15You should have received a copy of the GNU General Public License
16along with this program; if not, write to the Free Software
17Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19*/
20
21// game.h -- game dll information visible to server
22
23typedef enum multicast_e
24{
31
38
39extern float pm_q2stepheight;
40
41#if defined(Q2SERVER) || defined(Q2CLIENT)
42
43struct trace_s;
44struct q2trace_s;
45struct q2pmove_s;
46
47
48#define MAXTOUCH 32
49typedef struct q2pmove_s
50{
51 // state (in / out)
53
54 // command (in)
56 qboolean snapinitial; // if s has been changed outside pmove
57
58 // results (out)
60 struct edict_s *touchents[MAXTOUCH];
61
62 vec3_t viewangles; // clamped
64
65 vec3_t mins, maxs; // bounding box size
66
70
71 // callbacks to test the world
73 int (VARGS *pointcontents) (vec3_t point);
75
76void VARGS Q2_Pmove (q2pmove_t *pmove);
77
78#endif
79#ifdef Q2SERVER
80
81#define Q2GAME_API_VERSION 3
82
83// edict->svflags
84
85#define SVF_NOCLIENT 0x00000001 // don't send entity to clients, even if it has effects
86#define SVF_DEADMONSTER 0x00000002 // treat as CONTENTS_DEADMONSTER for collision
87#define SVF_MONSTER 0x00000004 // treat as CONTENTS_MONSTER for collision
88
89// edict->solid values
90
91typedef enum
92{
93Q2SOLID_NOT, // no interaction with other objects
94Q2SOLID_TRIGGER, // only touch when inside, after moving
95Q2SOLID_BBOX, // touch on edge
96Q2SOLID_BSP // bsp clip, touch on edge
98
99
100//===============================================================
101
102// link_t is only used for entity area links now
103/*typedef struct link_s
104{
105 struct link_s *prev, *next;
106} link_t;*/
107
108#define Q2MAX_ENT_CLUSTERS 16
109
110
111//typedef struct edict_s edict_t;
112typedef struct gclient_s gclient_t;
113
114
115#ifndef GAME_INCLUDE
116
118{
119 q2player_state_t ps; // communicated by server to clients
120 int ping;
121 // the game dll can add anything it wants after
122 // this point in the structure
123};
124
125#endif
126#if defined(Q2SERVER) || defined(Q2CLIENT)
127typedef struct q2entity_state_s
128{
129 int number; // edict index
130
133 vec3_t old_origin; // for lerping
135 int modelindex2, modelindex3, modelindex4; // weapons, CTF flags, etc
136 int frame;
138 unsigned int effects; // PGM - we're filling it, so it needs to be unsigned
140 int solid; // for client side prediction, 8*(bits 0-4) is x/y radius
141 // 8*(bits 5-9) is z down distance, 8(bits10-15) is z up
142 // gi.linkentity sets this properly
143 int sound; // for looping sounds, to guarantee shutoff
144 int event; // impulse events -- muzzle flashes, footsteps, etc
145 // events only go out for a single frame, they
146 // are automatically cleared each frame
148#endif
149#if defined(Q2SERVER)
150
151
153{
158
159 // FIXME: move these fields to a server private sv_entity_t
160 link_t area; // linked to a division node or leaf
161
162 int num_clusters; // if -1, use headnode instead
163 int clusternums[Q2MAX_ENT_CLUSTERS];
164 int headnode; // unused if num_clusters != -1
166
167 //================================
168
169 int svflags; // SVF_NOCLIENT, SVF_DEADMONSTER, SVF_MONSTER, etc
175
176 // the game dll can add anything it wants after
177 // this point in the structure
178};
179
180#endif // GAME_INCLUDE
181
182//===============================================================
183
184//
185// functions provided by the main engine
186//
187//yes, these are all VARGS, for the calling convention rather than actually being varargs.
188typedef struct
189{
190 // special messages
191 void (VARGS *bprintf) (int printlevel, const char *fmt, ...) LIKEPRINTF(2);
192 void (VARGS *dprintf) (const char *fmt, ...) LIKEPRINTF(1);
193 void (VARGS *cprintf) (q2edict_t *ent, int printlevel, const char *fmt, ...) LIKEPRINTF(3);
194 void (VARGS *centerprintf) (q2edict_t *ent, const char *fmt, ...) LIKEPRINTF(2);
195 void (VARGS *sound) (q2edict_t *ent, int channel, int soundindex, float volume, float attenuation, float timeofs);
196 void (VARGS *positioned_sound) (vec3_t origin, q2edict_t *ent, int channel, int soundinedex, float volume, float attenuation, float timeofs);
197
198 // config strings hold all the index strings, the lightstyles,
199 // and misc data like the sky definition and cdtrack.
200 // All of the current configstrings are sent to clients when
201 // they connect, and changes are sent to all connected clients.
202 void (VARGS *configstring) (int num, const char *string);
203
204 void (VARGS *error) (const char *fmt, ...) LIKEPRINTF(1);
205
206 // the *index functions create configstrings and some internal server state
207 int (VARGS *modelindex) (const char *name);
208 int (VARGS *soundindex) (const char *name);
209 int (VARGS *imageindex) (const char *name);
210
211 void (VARGS *setmodel) (q2edict_t *ent, const char *name);
212
213 // collision detection
215 int (VARGS *pointcontents) (vec3_t point);
216 qboolean (VARGS *inPVS) (vec3_t p1, vec3_t p2);
217 qboolean (VARGS *inPHS) (vec3_t p1, vec3_t p2);
218 void (VARGS *SetAreaPortalState) (unsigned int portalnum, qboolean open);
219 qboolean (VARGS *AreasConnected) (unsigned int area1, unsigned int area2);
220
221 // an entity will never be sent to a client or used for collision
222 // if it is not passed to linkentity. If the size, position, or
223 // solidity changes, it must be relinked.
224 void (VARGS *linkentity) (q2edict_t *ent);
225 void (VARGS *unlinkentity) (q2edict_t *ent); // call before removing an interactive edict
226 int (VARGS *BoxEdicts) (vec3_t mins, vec3_t maxs, q2edict_t **list, int maxcount, int areatype);
227 void (VARGS *Pmove) (q2pmove_t *pmove); // player movement code common with client prediction
228
229 // network messaging
230 void (VARGS *multicast) (vec3_t origin, multicast_t to);
231 void (VARGS *unicast) (q2edict_t *ent, qboolean reliable);
232 void (VARGS *WriteChar) (int c);
233 void (VARGS *WriteByte) (int c);
234 void (VARGS *WriteShort) (int c);
235 void (VARGS *WriteLong) (int c);
236 void (VARGS *WriteFloat) (float f);
237 void (VARGS *WriteString) (const char *s);
238 void (VARGS *WritePosition) (vec3_t pos); // some fractional bits
239 void (VARGS *WriteDir) (vec3_t pos); // single byte encoded, very coarse
240 void (VARGS *WriteAngle) (float f);
241
242 // managed memory allocation
243 void *(VARGS *TagMalloc) (int size, int tag);
244 void (VARGS *TagFree) (void *block);
245 void (VARGS *FreeTags) (int tag);
246
247 // console variable interaction
248 cvar_t *(VARGS *cvar) (const char *var_name, const char *value, int flags);
249 cvar_t *(VARGS *cvar_set) (const char *var_name, const char *value);
250 cvar_t *(VARGS *cvar_forceset) (const char *var_name, const char *value);
251
252 // ClientCommand and ServerCommand parameter access
253 int (VARGS *argc) (void);
254 char *(VARGS *argv) (int n);
255 char *(VARGS *args) (void); // concatenation of all argv >= 1
256
257 // add commands to the server console as if they were typed in
258 // for map changing, etc
259 void (VARGS *AddCommandString) (const char *text);
260
261 void (VARGS *DebugGraph) (float value, int color);
262
263
264 //kmq2 adds pak file stuff, which is certainly useful, but is only half the solution when homedirs are involved.
266
267//
268// functions exported by the game subsystem
269//
270typedef struct
271{
273
274 // the init function will only be called when a game starts,
275 // not each time a level is loaded. Persistant data for clients
276 // and the server can be allocated in init
277 void (VARGS *Init) (void);
278 void (VARGS *Shutdown) (void);
279
280 // each new level entered will cause a call to SpawnEntities
281 void (VARGS *SpawnEntities) (const char *mapname, const char *entstring, const char *spawnpoint);
282
283 // Read/Write Game is for storing persistant cross level information
284 // about the world state and the clients.
285 // WriteGame is called every time a level is exited.
286 // ReadGame is called on a loadgame.
287 void (VARGS *WriteGame) (const char *filename, qboolean autosave);
288 void (VARGS *ReadGame) (const char *filename);
289
290 // ReadLevel is called after the default map information has been
291 // loaded with SpawnEntities
292 void (VARGS *WriteLevel) (const char *filename);
293 void (VARGS *ReadLevel) (const char *filename);
294
295 qboolean (VARGS *ClientConnect) (q2edict_t *ent, char *userinfo);
296 void (VARGS *ClientBegin) (q2edict_t *ent);
297 void (VARGS *ClientUserinfoChanged) (q2edict_t *ent, char *userinfo);
298 void (VARGS *ClientDisconnect) (q2edict_t *ent);
299 void (VARGS *ClientCommand) (q2edict_t *ent);
300 void (VARGS *ClientThink) (q2edict_t *ent, q2usercmd_t *cmd);
301
302 void (VARGS *RunFrame) (void);
303
304 // ServerCommand will be called when an "sv <command>" command is issued on the
305 // server console.
306 // The game can issue gi.argc() / gi.argv() commands to get the rest
307 // of the parameters
308 void (VARGS *ServerCommand) (void);
309
310 //
311 // global variables shared between game and server
312 //
313
314 // The edict array is allocated in the game dll so it
315 // can vary in size from one game to another.
316 //
317 // The size will be fixed when ge->Init() is called
320 int num_edicts; // current number, <= max_edicts
323
325
326
327
328extern game_export_t *ge;
329extern int svq2_maxclients;
330
331#endif
qboolean
Definition: api_menu.h:34
vec_t vec3_t[3]
Definition: api_menu.h:40
void(QDECL *vgui_frame)(void)
entity_t * ent
Definition: com_mesh.c:717
int num
Definition: com_phys_ode.c:314
char * text
Definition: decomp.c:375
s
Definition: execloop.h:53
char filename[64]
Definition: generatebuiltin.c:8
int error
Definition: gl_vidlinuxglx.c:447
static CONST PIXELFORMATDESCRIPTOR *static int
Definition: gl_vidnt.c:222
GLuint GLcharARB * name
Definition: glquake.h:155
GLint size
Definition: glquake.h:157
GLsizei GLboolean const GLfloat * value
Definition: glquake.h:164
static png_size_t start
Definition: image.c:1419
keynum_t pos
Definition: in_sdl.c:105
playermove_t pmove
Definition: pmove.c:24
evalc_t origin
Definition: pr_menu.c:1356
evalc_t mins
Definition: pr_menu.c:1354
evalc_t maxs
Definition: pr_menu.c:1355
struct q2pmove_s q2pmove_t
game_export_t * ge
Definition: svq2_game.c:11
game_export_t * GetGameApi(game_import_t *import)
void VARGS Q2_Pmove(q2pmove_t *pmove)
Definition: q2pmove.c:1247
enum multicast_e multicast_t
q2solid_t
Definition: q2game.h:92
@ Q2SOLID_BSP
Definition: q2game.h:96
@ Q2SOLID_BBOX
Definition: q2game.h:95
@ Q2SOLID_NOT
Definition: q2game.h:93
@ Q2SOLID_TRIGGER
Definition: q2game.h:94
struct gclient_s gclient_t
Definition: q2game.h:112
float pm_q2stepheight
Definition: q2pmove.c:22
int svq2_maxclients
Definition: svq2_game.c:12
struct q2entity_state_s q2entity_state_t
multicast_e
Definition: q2game.h:24
@ MULTICAST_ONE_SPECS
Definition: q2game.h:32
@ MULTICAST_PHS
Definition: q2game.h:26
@ MULTICAST_ALL_R
Definition: q2game.h:28
@ MULTICAST_PVS
Definition: q2game.h:27
@ MULTICAST_ONE_NOSPECS
Definition: q2game.h:35
@ MULTICAST_ONE_R_NOSPECS
Definition: q2game.h:36
@ MULTICAST_ALL
Definition: q2game.h:25
@ MULTICAST_ONE_R_SPECS
Definition: q2game.h:33
@ MULTICAST_INIT
Definition: q2game.h:34
@ MULTICAST_PVS_R
Definition: q2game.h:30
@ MULTICAST_PHS_R
Definition: q2game.h:29
uploadfmt_t fmt
Definition: r_2d.c:48
vec3_t end
Definition: r_d3.c:692
static AL_API ALsizei n
Definition: snd_al.c:161
cvar_t volume
Definition: snd_dma.c:85
Definition: cvar.h:59
Definition: progs.h:65
Definition: q2game.h:271
int apiversion
Definition: q2game.h:272
qboolean(VARGS *ClientConnect)(q2edict_t *ent
void(VARGS *ClientBegin)(q2edict_t *ent)
qboolean autosave
Definition: q2game.h:287
int edict_size
Definition: q2game.h:319
void(VARGS *Init)(void)
q2usercmd_t * cmd
Definition: q2game.h:300
int max_edicts
Definition: q2game.h:321
void(VARGS *ClientDisconnect)(q2edict_t *ent)
void(VARGS *ClientCommand)(q2edict_t *ent)
int num_edicts
Definition: q2game.h:320
void(VARGS *ReadGame)(const char *filename)
void(VARGS *ClientUserinfoChanged)(q2edict_t *ent
void(VARGS *ServerCommand)(void)
const char * entstring
Definition: q2game.h:281
void(VARGS *Shutdown)(void)
void(VARGS *ReadLevel)(const char *filename)
struct q2edict_s * edicts
Definition: q2game.h:318
void(VARGS *RunFrame)(void)
void(VARGS *WriteLevel)(const char *filename)
Definition: q2game.h:189
char *VARGS * args(void)
void(VARGS *linkentity)(q2edict_t *ent)
qboolean(VARGS *inPHS)(vec3_t p1
void(VARGS *WritePosition)(vec3_t pos)
int(VARGS *modelindex)(const char *name)
vec3_t p2
Definition: q2game.h:216
const char * name
Definition: q2game.h:211
cvar_t *VARGS * cvar_set(const char *var_name, const char *value)
void(VARGS *WriteByte)(int c)
void(VARGS *TagFree)(void *block)
void *VARGS * TagMalloc(int size, int tag)
vec3_t vec3_t vec3_t q2edict_t int contentmask
Definition: q2game.h:214
const char * fmt
Definition: q2game.h:191
cvar_t *VARGS * cvar(const char *var_name, const char *value, int flags)
qboolean reliable
Definition: q2game.h:231
void(VARGS *WriteDir)(vec3_t pos)
int(VARGS *argc)(void)
qboolean open
Definition: q2game.h:218
void(VARGS *WriteShort)(int c)
void(VARGS *FreeTags)(int tag)
void(VARGS *WriteChar)(int c)
void(VARGS *WriteAngle)(float f)
void(VARGS *AddCommandString)(const char *text)
int color
Definition: q2game.h:261
int int float float attenuation
Definition: q2game.h:195
int(VARGS *imageindex)(const char *name)
const char LIKEPRINTF(2)
q2edict_t int int float float attenuation
Definition: q2game.h:196
vec3_t q2edict_t int int areatype
Definition: q2game.h:226
int const char * fmt
Definition: q2game.h:193
unsigned int area2
Definition: q2game.h:219
void(VARGS *WriteLong)(int c)
void(VARGS *Pmove)(q2pmove_t *pmove)
void(VARGS *unlinkentity)(q2edict_t *ent)
int(VARGS *pointcontents)(vec3_t point)
void(VARGS *WriteFloat)(float f)
multicast_t to
Definition: q2game.h:230
void(VARGS *WriteString)(const char *s)
const char * string
Definition: q2game.h:202
char *VARGS * argv(int n)
int(VARGS *soundindex)(const char *name)
cvar_t *VARGS * cvar_forceset(const char *var_name, const char *value)
Definition: q2game.h:153
int clusternums[Q2MAX_ENT_CLUSTERS]
Definition: q2game.h:163
vec3_t mins
Definition: q2game.h:170
q2entity_state_t s
Definition: q2game.h:154
int headnode
Definition: q2game.h:164
q2solid_t solid
Definition: q2game.h:172
int svflags
Definition: q2game.h:169
int areanum
Definition: q2game.h:165
vec3_t absmax
Definition: q2game.h:171
link_t area
Definition: q2game.h:160
vec3_t absmin
Definition: q2game.h:171
vec3_t maxs
Definition: q2game.h:170
qboolean inuse
Definition: q2game.h:156
vec3_t size
Definition: q2game.h:171
int areanum2
Definition: q2game.h:165
int linkcount
Definition: q2game.h:157
q2edict_t * owner
Definition: q2game.h:174
int num_clusters
Definition: q2game.h:162
int clipmask
Definition: q2game.h:173
struct q2gclient_s * client
Definition: q2game.h:155
Definition: q2game.h:128
int event
Definition: q2game.h:144
int number
Definition: q2game.h:129
int renderfx
Definition: q2game.h:139
int modelindex2
Definition: q2game.h:135
int solid
Definition: q2game.h:140
int modelindex3
Definition: q2game.h:135
int modelindex4
Definition: q2game.h:135
vec3_t old_origin
Definition: q2game.h:133
vec3_t origin
Definition: q2game.h:131
int skinnum
Definition: q2game.h:137
int frame
Definition: q2game.h:136
unsigned int effects
Definition: q2game.h:138
int sound
Definition: q2game.h:143
vec3_t angles
Definition: q2game.h:132
int modelindex
Definition: q2game.h:134
Definition: q2game.h:118
int ping
Definition: q2game.h:120
q2player_state_t ps
Definition: q2game.h:119
Definition: client.h:122
Definition: q2game.h:50
vec3_t vec3_t vec3_t end
Definition: q2game.h:72
vec3_t viewangles
Definition: q2game.h:62
int watertype
Definition: q2game.h:68
int numtouch
Definition: q2game.h:59
float viewheight
Definition: q2game.h:63
struct edict_s * touchents[MAXTOUCH]
Definition: q2game.h:60
struct edict_s * groundentity
Definition: q2game.h:67
int waterlevel
Definition: q2game.h:69
int(VARGS *pointcontents)(vec3_t point)
qboolean snapinitial
Definition: q2game.h:56
q2trace_t(VARGS *trace)(vec3_t start
q2usercmd_t cmd
Definition: q2game.h:55
q2pmove_state_t s
Definition: q2game.h:52
vec3_t maxs
Definition: q2game.h:65
vec3_t mins
Definition: q2game.h:65
Definition: client.h:103
Definition: world.h:85
Definition: protocol.h:1310
Definition: world.h:61
unsigned int flags
Definition: valid.c:313
struct q2trace_s q2trace_t