1 /*
2 ===========================================================================
3 Copyright (C) 1999 - 2005, Id Software, Inc.
4 Copyright (C) 2000 - 2013, Raven Software, Inc.
5 Copyright (C) 2001 - 2013, Activision, Inc.
6 Copyright (C) 2013 - 2015, OpenJK contributors
7 
8 This file is part of the OpenJK source code.
9 
10 OpenJK is free software; you can redistribute it and/or modify it
11 under the terms of the GNU General Public License version 2 as
12 published by the Free Software Foundation.
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.  See the
17 GNU General Public License for more details.
18 
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, see <http://www.gnu.org/licenses/>.
21 ===========================================================================
22 */
23 
24 #pragma once
25 
26 #define	CGAME_API_VERSION		2
27 
28 #define	CMD_BACKUP			64
29 #define	CMD_MASK			(CMD_BACKUP - 1)
30 // allow a lot of command backups for very fast systems
31 // multiple commands may be combined into a single packet, so this
32 // needs to be larger than PACKET_BACKUP
33 
34 
35 #define	MAX_ENTITIES_IN_SNAPSHOT	256
36 
37 // snapshots are a view of the server at a given time
38 
39 // Snapshots are generated at regular time intervals by the server,
40 // but they may not be sent if a client's rate level is exceeded, or
41 // they may be dropped by the network.
42 typedef struct snapshot_s {
43 	int				snapFlags;			// SNAPFLAG_RATE_DELAYED, etc
44 	int				ping;
45 
46 	int				serverTime;		// server time the message is valid for (in msec)
47 
48 	byte			areamask[MAX_MAP_AREA_BYTES];		// portalarea visibility bits
49 
50 	playerState_t	ps;						// complete information about the current player at this time
51 	playerState_t	vps; //vehicle I'm riding's playerstate (if applicable) -rww
52 
53 	int				numEntities;			// all of the entities that need to be presented
54 	entityState_t	entities[MAX_ENTITIES_IN_SNAPSHOT];	// at the time of this snapshot
55 
56 	int				numServerCommands;		// text based server commands to execute when this
57 	int				serverCommandSequence;	// snapshot becomes current
58 } snapshot_t;
59 
60 typedef enum cgameEvent_e {
61 	CGAME_EVENT_NONE=0,
62 	CGAME_EVENT_TEAMMENU,
63 	CGAME_EVENT_SCOREBOARD,
64 	CGAME_EVENT_EDITHUD
65 } cgameEvent_t;
66 
67 typedef struct autoMapInput_s {
68 	float		up;
69 	float		down;
70 	float		yaw;
71 	float		pitch;
72 	qboolean	goToDefaults;
73 } autoMapInput_t;
74 
75 // CG_POINT_CONTENTS
76 typedef struct TCGPointContents_s {
77 	vec3_t		mPoint;			// input
78 	int			mPassEntityNum;	// input
79 } TCGPointContents;
80 
81 // CG_GET_BOLT_POS
82 typedef struct TCGGetBoltData_s {
83 	vec3_t		mOrigin;		// output
84 	vec3_t		mAngles;		// output
85 	vec3_t		mScale;			// output
86 	int			mEntityNum;		// input
87 } TCGGetBoltData;
88 
89 // CG_IMPACT_MARK
90 typedef struct TCGImpactMark_s {
91 	int		mHandle;
92 	vec3_t	mPoint;
93 	vec3_t	mAngle;
94 	float	mRotation;
95 	float	mRed;
96 	float	mGreen;
97 	float	mBlue;
98 	float	mAlphaStart;
99 	float	mSizeStart;
100 } TCGImpactMark;
101 
102 // CG_GET_LERP_ORIGIN
103 // CG_GET_LERP_ANGLES
104 // CG_GET_MODEL_SCALE
105 typedef struct TCGVectorData_s {
106 	int			mEntityNum;		// input
107 	vec3_t		mPoint;			// output
108 } TCGVectorData;
109 
110 // CG_TRACE/CG_G2TRACE
111 typedef struct TCGTrace_s {
112 	trace_t mResult;					// output
113 	vec3_t	mStart, mMins, mMaxs, mEnd;	// input
114 	int		mSkipNumber, mMask;			// input
115 } TCGTrace;
116 
117 // CG_G2MARK
118 typedef struct TCGG2Mark_s {
119 	int			shader;
120 	float		size;
121 	vec3_t		start, dir;
122 } TCGG2Mark;
123 
124 // CG_INCOMING_CONSOLE_COMMAND
125 typedef struct TCGIncomingConsoleCommand_s {
126 	char conCommand[1024];
127 } TCGIncomingConsoleCommand;
128 
129 // CG_FX_CAMERASHAKE
130 typedef struct TCGCameraShake_s {
131 	vec3_t	mOrigin;					// input
132 	float	mIntensity;					// input
133 	int		mRadius;					// input
134 	int		mTime;						// input
135 } TCGCameraShake;
136 
137 // CG_MISC_ENT
138 typedef struct TCGMiscEnt_s {
139 	char	mModel[MAX_QPATH];			// input
140 	vec3_t	mOrigin, mAngles, mScale;	// input
141 } TCGMiscEnt;
142 
143 typedef struct TCGPositionOnBolt_s {
144 	refEntity_t		ent;				// output
145 	void			*ghoul2;			// input
146 	int				modelIndex;			// input
147 	int				boltIndex;			// input
148 	vec3_t			origin;				// input
149 	vec3_t			angles;				// input
150 	vec3_t			modelScale;			// input
151 } TCGPositionOnBolt;
152 
153 //ragdoll callback structs -rww
154 #define RAG_CALLBACK_NONE				0
155 #define RAG_CALLBACK_DEBUGBOX			1
156 typedef struct ragCallbackDebugBox_s {
157 	vec3_t			mins;
158 	vec3_t			maxs;
159 	int				duration;
160 } ragCallbackDebugBox_t;
161 
162 #define RAG_CALLBACK_DEBUGLINE			2
163 typedef struct ragCallbackDebugLine_s {
164 	vec3_t			start;
165 	vec3_t			end;
166 	int				time;
167 	int				color;
168 	int				radius;
169 } ragCallbackDebugLine_t;
170 
171 #define RAG_CALLBACK_BONESNAP			3
172 typedef struct ragCallbackBoneSnap_s {
173 	char			boneName[128]; //name of the bone in question
174 	int				entNum; //index of entity who owns the bone in question
175 } ragCallbackBoneSnap_t;
176 
177 #define RAG_CALLBACK_BONEIMPACT			4
178 typedef struct ragCallbackBoneImpact_s {
179 	char			boneName[128]; //name of the bone in question
180 	int				entNum; //index of entity who owns the bone in question
181 } ragCallbackBoneImpact_t;
182 
183 #define RAG_CALLBACK_BONEINSOLID		5
184 typedef struct ragCallbackBoneInSolid_s {
185 	vec3_t			bonePos; //world coordinate position of the bone
186 	int				entNum; //index of entity who owns the bone in question
187 	int				solidCount; //higher the count, the longer we've been in solid (the worse off we are)
188 } ragCallbackBoneInSolid_t;
189 
190 #define RAG_CALLBACK_TRACELINE			6
191 typedef struct ragCallbackTraceLine_s {
192 	trace_t			tr;
193 	vec3_t			start;
194 	vec3_t			end;
195 	vec3_t			mins;
196 	vec3_t			maxs;
197 	int				ignore;
198 	int				mask;
199 } ragCallbackTraceLine_t;
200 
201 #define	MAX_CG_SHARED_BUFFER_SIZE		2048
202 
203 typedef enum cgameImportLegacy_e {
204 	CG_PRINT = 0,
205 	CG_ERROR,
206 	CG_MILLISECONDS,
207 	CG_PRECISIONTIMER_START,
208 	CG_PRECISIONTIMER_END,
209 	CG_CVAR_REGISTER,
210 	CG_CVAR_UPDATE,
211 	CG_CVAR_SET,
212 	CG_CVAR_VARIABLESTRINGBUFFER,
213 	CG_CVAR_GETHIDDENVALUE,
214 	CG_ARGC,
215 	CG_ARGV,
216 	CG_ARGS,
217 	CG_FS_FOPENFILE,
218 	CG_FS_READ,
219 	CG_FS_WRITE,
220 	CG_FS_FCLOSEFILE,
221 	CG_FS_GETFILELIST,
222 	CG_SENDCONSOLECOMMAND,
223 	CG_ADDCOMMAND,
224 	CG_REMOVECOMMAND,
225 	CG_SENDCLIENTCOMMAND,
226 	CG_UPDATESCREEN,
227 	CG_CM_LOADMAP,
228 	CG_CM_NUMINLINEMODELS,
229 	CG_CM_INLINEMODEL,
230 	CG_CM_TEMPBOXMODEL,
231 	CG_CM_TEMPCAPSULEMODEL,
232 	CG_CM_POINTCONTENTS,
233 	CG_CM_TRANSFORMEDPOINTCONTENTS,
234 	CG_CM_BOXTRACE,
235 	CG_CM_CAPSULETRACE,
236 	CG_CM_TRANSFORMEDBOXTRACE,
237 	CG_CM_TRANSFORMEDCAPSULETRACE,
238 	CG_CM_MARKFRAGMENTS,
239 	CG_S_GETVOICEVOLUME,
240 	CG_S_MUTESOUND,
241 	CG_S_STARTSOUND,
242 	CG_S_STARTLOCALSOUND,
243 	CG_S_CLEARLOOPINGSOUNDS,
244 	CG_S_ADDLOOPINGSOUND,
245 	CG_S_UPDATEENTITYPOSITION,
246 	CG_S_ADDREALLOOPINGSOUND,
247 	CG_S_STOPLOOPINGSOUND,
248 	CG_S_RESPATIALIZE,
249 	CG_S_SHUTUP,
250 	CG_S_REGISTERSOUND,
251 	CG_S_STARTBACKGROUNDTRACK,
252 	CG_S_UPDATEAMBIENTSET,
253 	CG_AS_PARSESETS,
254 	CG_AS_ADDPRECACHEENTRY,
255 	CG_S_ADDLOCALSET,
256 	CG_AS_GETBMODELSOUND,
257 	CG_R_LOADWORLDMAP,
258 	CG_R_REGISTERMODEL,
259 	CG_R_REGISTERSKIN,
260 	CG_R_REGISTERSHADER,
261 	CG_R_REGISTERSHADERNOMIP,
262 	CG_R_REGISTERFONT,
263 	CG_R_FONT_STRLENPIXELS,
264 	CG_R_FONT_STRLENCHARS,
265 	CG_R_FONT_STRHEIGHTPIXELS,
266 	CG_R_FONT_DRAWSTRING,
267 	CG_LANGUAGE_ISASIAN,
268 	CG_LANGUAGE_USESSPACES,
269 	CG_ANYLANGUAGE_READCHARFROMSTRING,
270 
271 	CGAME_MEMSET = 100,
272 	CGAME_MEMCPY,
273 	CGAME_STRNCPY,
274 	CGAME_SIN,
275 	CGAME_COS,
276 	CGAME_ATAN2,
277 	CGAME_SQRT,
278 	CGAME_MATRIXMULTIPLY,
279 	CGAME_ANGLEVECTORS,
280 	CGAME_PERPENDICULARVECTOR,
281 	CGAME_FLOOR,
282 	CGAME_CEIL,
283 	CGAME_TESTPRINTINT,
284 	CGAME_TESTPRINTFLOAT,
285 	CGAME_ACOS,
286 	CGAME_ASIN,
287 
288 	CG_R_CLEARSCENE = 200,
289 	CG_R_CLEARDECALS,
290 	CG_R_ADDREFENTITYTOSCENE,
291 	CG_R_ADDPOLYTOSCENE,
292 	CG_R_ADDPOLYSTOSCENE,
293 	CG_R_ADDDECALTOSCENE,
294 	CG_R_LIGHTFORPOINT,
295 	CG_R_ADDLIGHTTOSCENE,
296 	CG_R_ADDADDITIVELIGHTTOSCENE,
297 	CG_R_RENDERSCENE,
298 	CG_R_SETCOLOR,
299 	CG_R_DRAWSTRETCHPIC,
300 	CG_R_MODELBOUNDS,
301 	CG_R_LERPTAG,
302 	CG_R_DRAWROTATEPIC,
303 	CG_R_DRAWROTATEPIC2,
304 	CG_R_SETRANGEFOG,
305 	CG_R_SETREFRACTIONPROP,
306 	CG_R_REMAP_SHADER,
307 	CG_R_GET_LIGHT_STYLE,
308 	CG_R_SET_LIGHT_STYLE,
309 	CG_R_GET_BMODEL_VERTS,
310 	CG_R_GETDISTANCECULL,
311 	CG_R_GETREALRES,
312 	CG_R_AUTOMAPELEVADJ,
313 	CG_R_INITWIREFRAMEAUTO,
314 	CG_FX_ADDLINE,
315 	CG_GETGLCONFIG,
316 	CG_GETGAMESTATE,
317 	CG_GETCURRENTSNAPSHOTNUMBER,
318 	CG_GETSNAPSHOT,
319 	CG_GETDEFAULTSTATE,
320 	CG_GETSERVERCOMMAND,
321 	CG_GETCURRENTCMDNUMBER,
322 	CG_GETUSERCMD,
323 	CG_SETUSERCMDVALUE,
324 	CG_SETCLIENTFORCEANGLE,
325 	CG_SETCLIENTTURNEXTENT,
326 	CG_OPENUIMENU,
327 	CG_TESTPRINTINT,
328 	CG_TESTPRINTFLOAT,
329 	CG_MEMORY_REMAINING,
330 	CG_KEY_ISDOWN,
331 	CG_KEY_GETCATCHER,
332 	CG_KEY_SETCATCHER,
333 	CG_KEY_GETKEY,
334  	CG_PC_ADD_GLOBAL_DEFINE,
335 	CG_PC_LOAD_SOURCE,
336 	CG_PC_FREE_SOURCE,
337 	CG_PC_READ_TOKEN,
338 	CG_PC_SOURCE_FILE_AND_LINE,
339 	CG_PC_LOAD_GLOBAL_DEFINES,
340 	CG_PC_REMOVE_ALL_GLOBAL_DEFINES,
341 	CG_S_STOPBACKGROUNDTRACK,
342 	CG_REAL_TIME,
343 	CG_SNAPVECTOR,
344 	CG_CIN_PLAYCINEMATIC,
345 	CG_CIN_STOPCINEMATIC,
346 	CG_CIN_RUNCINEMATIC,
347 	CG_CIN_DRAWCINEMATIC,
348 	CG_CIN_SETEXTENTS,
349 	CG_GET_ENTITY_TOKEN,
350 	CG_R_INPVS,
351 	CG_FX_REGISTER_EFFECT,
352 	CG_FX_PLAY_EFFECT,
353 	CG_FX_PLAY_ENTITY_EFFECT,
354 	CG_FX_PLAY_EFFECT_ID,
355 	CG_FX_PLAY_PORTAL_EFFECT_ID,
356 	CG_FX_PLAY_ENTITY_EFFECT_ID,
357 	CG_FX_PLAY_BOLTED_EFFECT_ID,
358 	CG_FX_ADD_SCHEDULED_EFFECTS,
359 	CG_FX_INIT_SYSTEM,
360 	CG_FX_SET_REFDEF,
361 	CG_FX_FREE_SYSTEM,
362 	CG_FX_ADJUST_TIME,
363 	CG_FX_DRAW_2D_EFFECTS,
364 	CG_FX_RESET,
365 	CG_FX_ADDPOLY,
366 	CG_FX_ADDBEZIER,
367 	CG_FX_ADDPRIMITIVE,
368 	CG_FX_ADDSPRITE,
369 	CG_FX_ADDELECTRICITY,
370 	CG_SP_GETSTRINGTEXTSTRING,
371 	CG_ROFF_CLEAN,
372 	CG_ROFF_UPDATE_ENTITIES,
373 	CG_ROFF_CACHE,
374 	CG_ROFF_PLAY,
375 	CG_ROFF_PURGE_ENT,
376 	CG_TRUEMALLOC,
377 	CG_TRUEFREE,
378 	CG_G2_LISTSURFACES,
379 	CG_G2_LISTBONES,
380 	CG_G2_SETMODELS,
381 	CG_G2_HAVEWEGHOULMODELS,
382 	CG_G2_GETBOLT,
383 	CG_G2_GETBOLT_NOREC,
384 	CG_G2_GETBOLT_NOREC_NOROT,
385 	CG_G2_INITGHOUL2MODEL,
386 	CG_G2_SETSKIN,
387 	CG_G2_COLLISIONDETECT,
388 	CG_G2_COLLISIONDETECTCACHE,
389 	CG_G2_CLEANMODELS,
390 	CG_G2_ANGLEOVERRIDE,
391 	CG_G2_PLAYANIM,
392 	CG_G2_GETBONEANIM,
393 	CG_G2_GETBONEFRAME,
394 	CG_G2_GETGLANAME,
395 	CG_G2_COPYGHOUL2INSTANCE,
396 	CG_G2_COPYSPECIFICGHOUL2MODEL,
397 	CG_G2_DUPLICATEGHOUL2INSTANCE,
398 	CG_G2_HASGHOUL2MODELONINDEX,
399 	CG_G2_REMOVEGHOUL2MODEL,
400 	CG_G2_SKINLESSMODEL,
401 	CG_G2_GETNUMGOREMARKS,
402 	CG_G2_ADDSKINGORE,
403 	CG_G2_CLEARSKINGORE,
404 	CG_G2_SIZE,
405 	CG_G2_ADDBOLT,
406 	CG_G2_ATTACHENT,
407 	CG_G2_SETBOLTON,
408 	CG_G2_SETROOTSURFACE,
409 	CG_G2_SETSURFACEONOFF,
410 	CG_G2_SETNEWORIGIN,
411 	CG_G2_DOESBONEEXIST,
412 	CG_G2_GETSURFACERENDERSTATUS,
413 	CG_G2_GETTIME,
414 	CG_G2_SETTIME,
415 	CG_G2_ABSURDSMOOTHING,
416 	CG_G2_SETRAGDOLL,
417 	CG_G2_ANIMATEG2MODELS,
418 	CG_G2_RAGPCJCONSTRAINT,
419 	CG_G2_RAGPCJGRADIENTSPEED,
420 	CG_G2_RAGEFFECTORGOAL,
421 	CG_G2_GETRAGBONEPOS,
422 	CG_G2_RAGEFFECTORKICK,
423 	CG_G2_RAGFORCESOLVE,
424 	CG_G2_SETBONEIKSTATE,
425 	CG_G2_IKMOVE,
426 	CG_G2_REMOVEBONE,
427 	CG_G2_ATTACHINSTANCETOENTNUM,
428 	CG_G2_CLEARATTACHEDINSTANCE,
429 	CG_G2_CLEANENTATTACHMENTS,
430 	CG_G2_OVERRIDESERVER,
431 	CG_G2_GETSURFACENAME,
432 	CG_SET_SHARED_BUFFER,
433 	CG_CM_REGISTER_TERRAIN,
434 	CG_RMG_INIT,
435 	CG_RE_INIT_RENDERER_TERRAIN,
436 	CG_R_WEATHER_CONTENTS_OVERRIDE,
437 	CG_R_WORLDEFFECTCOMMAND,
438 	CG_WE_ADDWEATHERZONE
439 } cgameImportLegacy_t;
440 
441 typedef enum cgameExportLegacy_e {
442 	CG_INIT,
443 	CG_SHUTDOWN,
444 	CG_CONSOLE_COMMAND,
445 	CG_DRAW_ACTIVE_FRAME,
446 	CG_CROSSHAIR_PLAYER,
447 	CG_LAST_ATTACKER,
448 	CG_KEY_EVENT,
449 	CG_MOUSE_EVENT,
450 	CG_EVENT_HANDLING,
451 	CG_POINT_CONTENTS,
452 	CG_GET_LERP_ORIGIN,
453 	CG_GET_LERP_DATA,
454 	CG_GET_GHOUL2,
455 	CG_GET_MODEL_LIST,
456 	CG_CALC_LERP_POSITIONS,
457 	CG_TRACE,
458 	CG_G2TRACE,
459 	CG_G2MARK,
460 	CG_RAG_CALLBACK,
461 	CG_INCOMING_CONSOLE_COMMAND,
462 	CG_GET_USEABLE_FORCE,
463 	CG_GET_ORIGIN,
464 	CG_GET_ANGLES,
465 	CG_GET_ORIGIN_TRAJECTORY,
466 	CG_GET_ANGLE_TRAJECTORY,
467 	CG_ROFF_NOTETRACK_CALLBACK,
468 	CG_IMPACT_MARK,
469 	CG_MAP_CHANGE,
470 	CG_AUTOMAP_INPUT,
471 	CG_MISC_ENT,
472 	CG_GET_SORTED_FORCE_POWER,
473 	CG_FX_CAMERASHAKE,
474 } cgameExportLegacy_t;
475 
476 typedef struct cgameImport_s {
477 	// common
478 	void			(*Print)								( const char *msg, ... );
479 	NORETURN_PTR void (*Error)( int level, const char *fmt, ... );
480 	void			(*SnapVector)							( float *v );
481 	int				(*MemoryRemaining)						( void );
482 	void			(*RegisterSharedMemory)					( char *memory );
483 	void			(*TrueMalloc)							( void **ptr, int size );
484 	void			(*TrueFree)								( void **ptr );
485 
486 	// timing
487 	int				(*Milliseconds)							( void );
488 	int				(*RealTime)								( qtime_t *qtime );
489 	void			(*PrecisionTimerStart)					( void **timer );
490 	int				(*PrecisionTimerEnd)					( void *timer );
491 
492 	// cvar
493 	void			(*Cvar_Register)						( vmCvar_t *vmCvar, const char *varName, const char *defaultValue, uint32_t flags );
494 	void			(*Cvar_Set)								( const char *var_name, const char *value );
495 	void			(*Cvar_Update)							( vmCvar_t *vmCvar );
496 	void			(*Cvar_VariableStringBuffer)			( const char *var_name, char *buffer, int bufsize );
497 
498 	// command
499 	void			(*AddCommand)							( const char *cmd_name );
500 	int				(*Cmd_Argc)								( void );
501 	void			(*Cmd_Args)								( char *buffer, int bufferLength );
502 	void			(*Cmd_Argv)								( int arg, char *buffer, int bufferLength );
503 	void			(*RemoveCommand)						( const char *cmd_name );
504 	void			(*SendClientCommand)					( const char *cmd );
505 	void			(*SendConsoleCommand)					( const char *text );
506 
507 	// filesystem
508 	void			(*FS_Close)								( fileHandle_t f );
509 	int				(*FS_GetFileList)						( const char *path, const char *extension, char *listbuf, int bufsize );
510 	int				(*FS_Open)								( const char *qpath, fileHandle_t *f, fsMode_t mode );
511 	int				(*FS_Read)								( void *buffer, int len, fileHandle_t f );
512 	int				(*FS_Write)								( const void *buffer, int len, fileHandle_t f );
513 
514 	// screen
515 	void			(*UpdateScreen)							( void );
516 
517 	// clip model
518 	clipHandle_t	(*CM_InlineModel)						( int index );
519 	void			(*CM_LoadMap)							( const char *mapname, qboolean subBSP );
520 	int				(*CM_NumInlineModels)					( void );
521 	int				(*CM_PointContents)						( const vec3_t p, clipHandle_t model );
522 	int				(*CM_RegisterTerrain)					( const char *config );
523 	clipHandle_t	(*CM_TempModel)							( const vec3_t mins, const vec3_t maxs, int capsule );
524 	void			(*CM_Trace)								( trace_t *results, const vec3_t start, const vec3_t end, const vec3_t mins, const vec3_t maxs, clipHandle_t model, int brushmask, int capsule );
525 	int				(*CM_TransformedPointContents)			( const vec3_t p, clipHandle_t model, const vec3_t origin, const vec3_t angles );
526 	void			(*CM_TransformedTrace)					( trace_t *results, const vec3_t start, const vec3_t end, const vec3_t mins, const vec3_t maxs, clipHandle_t model, int brushmask, const vec3_t origin, const vec3_t angles, int capsule );
527 	void			(*RMG_Init)								( int terrainID, const char *terrainInfo );
528 
529 	// sound
530 	int				(*S_AddLocalSet)						( const char *name, vec3_t listener_origin, vec3_t origin, int entID, int time );
531 	void			(*S_AddLoopingSound)					( int entityNum, const vec3_t origin, const vec3_t velocity, sfxHandle_t sfx );
532 	void			(*S_ClearLoopingSounds)					( void );
533 	int				(*S_GetVoiceVolume)						( int entID );
534 	void			(*S_MuteSound)							( int entityNum, int entchannel );
535 	sfxHandle_t		(*S_RegisterSound)						( const char *sample );
536 	void			(*S_Respatialize)						( int entityNum, const vec3_t origin, matrix3_t axis, int inwater );
537 	void			(*S_Shutup)								( qboolean shutup );
538 	void			(*S_StartBackgroundTrack)				( const char *intro, const char *loop, qboolean bReturnWithoutStarting );
539 	void			(*S_StartLocalSound)					( sfxHandle_t sfx, int channelNum );
540 	void			(*S_StartSound)							( const vec3_t origin, int entnum, int entchannel, sfxHandle_t sfx );
541 	void			(*S_StopBackgroundTrack)				( void );
542 	void			(*S_StopLoopingSound)					( int entityNum );
543 	void			(*S_UpdateEntityPosition)				( int entityNum, const vec3_t origin );
544 	void			(*S_UpdateAmbientSet)					( const char *name, vec3_t origin ) ;
545 
546 	// ambient sound
547 	void			(*AS_AddPrecacheEntry)					( const char *name );
548 	sfxHandle_t		(*AS_GetBModelSound)					( const char *name, int stage );
549 	void			(*AS_ParseSets)							( void );
550 
551 	// renderer
552 	void			(*R_AddAdditiveLightToScene)			( const vec3_t org, float intensity, float r, float g, float b );
553 	void			(*R_AddDecalToScene)					( qhandle_t shader, const vec3_t origin, const vec3_t dir, float orientation, float r, float g, float b, float a, qboolean alphaFade, float radius, qboolean temporary );
554 	void			(*R_AddLightToScene)					( const vec3_t org, float intensity, float r, float g, float b );
555 	void			(*R_AddPolysToScene)					( qhandle_t hShader , int numVerts, const polyVert_t *verts, int num );
556 	void			(*R_AddRefEntityToScene)				( const refEntity_t *re );
557 	unsigned int	(*R_AnyLanguage_ReadCharFromString)		( const char *psText, int *piAdvanceCount, qboolean *pbIsTrailingPunctuation );
558 	void			(*R_AutomapElevationAdjustment)			( float newHeight );
559 	void			(*R_ClearDecals)						( void );
560 	void			(*R_ClearScene)							( void );
561 	void			(*R_DrawStretchPic)						( float x, float y, float w, float h, float s1, float t1, float s2, float t2, qhandle_t hShader );	// 0 = white
562 	void			(*R_DrawRotatePic)						( float x, float y, float w, float h, float s1, float t1, float s2, float t2, float a1, qhandle_t hShader );	// 0 = white
563 	void			(*R_DrawRotatePic2)						( float x, float y, float w, float h, float s1, float t1, float s2, float t2, float a1, qhandle_t hShader );	// 0 = white
564 	void			(*R_Font_DrawString)					( int ox, int oy, const char *text, const float *rgba, const int setIndex, int iCharLimit, const float scale );
565 	int				(*R_Font_HeightPixels)					( const int iFontIndex, const float scale );
566 	int				(*R_Font_StrLenChars)					( const char *text );
567 	int				(*R_Font_StrLenPixels)					( const char *text, const int iFontIndex, const float scale );
568 	void			(*R_GetBModelVerts)						( int bmodelIndex, vec3_t *vec, vec3_t normal );
569 	float			(*R_GetDistanceCull)					( void );
570 	qboolean		(*R_GetEntityToken)						( char *buffer, int size );
571 	void			(*R_GetLightStyle)						( int style, color4ub_t color );
572 	void			(*R_GetRealRes)							( int *w, int *h );
573 	qboolean		(*R_InitializeWireframeAutomap)			( void );
574 	qboolean		(*R_InPVS)								( const vec3_t p1, const vec3_t p2, byte *mask );
575 	qboolean		(*R_Language_IsAsian)					( void );
576 	qboolean		(*R_Language_UsesSpaces)				( void );
577 	int				(*R_LerpTag)							( orientation_t *tag,  qhandle_t model, int startFrame, int endFrame, float frac, const char *tagName );
578 	int				(*R_LightForPoint)						( vec3_t point, vec3_t ambientLight, vec3_t directedLight, vec3_t lightDir );
579 	void			(*R_LoadWorld)							( const char *name );
580 	int				(*R_MarkFragments)						( int numPoints, const vec3_t *points, const vec3_t projection, int maxPoints, vec3_t pointBuffer, int maxFragments, markFragment_t *fragmentBuffer );
581 	void			(*R_ModelBounds)						( qhandle_t model, vec3_t mins, vec3_t maxs );
582 	qhandle_t		(*R_RegisterFont)						( const char *fontName );
583 	qhandle_t		(*R_RegisterModel)						( const char *name );
584 	qhandle_t		(*R_RegisterShader)						( const char *name );
585 	qhandle_t		(*R_RegisterShaderNoMip)				( const char *name );
586 	qhandle_t		(*R_RegisterSkin)						( const char *name );
587 	void			(*R_RemapShader)						( const char *oldShader, const char *newShader, const char *offsetTime );
588 	void			(*R_RenderScene)						( const refdef_t *fd );
589 	void			(*R_SetColor)							( const float *rgba );	// NULL = 1,1,1,1
590 	void			(*R_SetLightStyle)						( int style, int color );
591 	void			(*R_SetRangedFog)						( float range );
592 	void			(*R_SetRefractionProperties)			( float distortionAlpha, float distortionStretch, qboolean distortionPrePost, qboolean distortionNegate );
593 	void			(*R_WorldEffectCommand)					( const char *cmd );
594 	void			(*RE_InitRendererTerrain)				( const char *info );
595 	void			(*WE_AddWeatherZone)					( vec3_t mins, vec3_t maxs );
596 
597 	// client
598 	void			(*GetCurrentSnapshotNumber)				( int *snapshotNumber, int *serverTime );
599 	int				(*GetCurrentCmdNumber)					( void );
600 	qboolean		(*GetDefaultState)						( int index, entityState_t *state );
601 	void			(*GetGameState)							( gameState_t *gs );
602 	void			(*GetGlconfig)							( glconfig_t *glconfig );
603 	qboolean		(*GetServerCommand)						( int serverCommandNumber );
604 	qboolean		(*GetSnapshot)							( int snapshotNumber, snapshot_t *snapshot );
605 	qboolean		(*GetUserCmd)							( int cmdNumber, usercmd_t *ucmd );
606 	void			(*OpenUIMenu)							( int menu );
607 	void			(*SetClientForceAngle)					( int time, vec3_t angle );
608 	void			(*SetUserCmdValue)						( int stateValue, float sensitivityScale, float mPitchOverride, float mYawOverride, float mSensitivityOverride, int fpSel, int invenSel, qboolean fighterControls );
609 
610 	// keys
611 	int				(*Key_GetCatcher)						( void );
612 	int				(*Key_GetKey)							( const char *binding );
613 	qboolean		(*Key_IsDown)							( int keynum );
614 	void			(*Key_SetCatcher)						( int catcher );
615 
616 	// preprocessor (botlib_export->PC_***)
617 	int				(*PC_AddGlobalDefine)					( char *string );
618 	int				(*PC_FreeSource)						( int handle );
619 	int				(*PC_LoadGlobalDefines)					( const char *filename );
620 	int				(*PC_LoadSource)						( const char *filename );
621 	int				(*PC_ReadToken)							( int handle, pc_token_t *pc_token );
622 	void			(*PC_RemoveAllGlobalDefines)			( void );
623 	int				(*PC_SourceFileAndLine)					( int handle, char *filename, int *line );
624 
625 	// cinematics
626 	void			(*CIN_DrawCinematic)					( int handle );
627 	int				(*CIN_PlayCinematic)					( const char *arg, int x, int y, int w, int h, int systemBits );
628 	e_status		(*CIN_RunCinematic)						( int handle );
629 	void			(*CIN_SetExtents)						( int handle, int x, int y, int w, int h );
630 	e_status		(*CIN_StopCinematic)					( int handle );
631 
632 	// FX
633 	void			(*FX_AddLine)							( vec3_t start, vec3_t end, float size1, float size2, float sizeParm, float alpha1, float alpha2, float alphaParm, vec3_t sRGB, vec3_t eRGB, float rgbParm, int killTime, qhandle_t shader, int flags );
634 	int				(*FX_RegisterEffect)					( const char *file );
635 	void			(*FX_PlayEffect)						( const char *file, vec3_t org, vec3_t fwd, int vol, int rad );
636 	void			(*FX_PlayEffectID)						( int id, vec3_t org, vec3_t fwd, int vol, int rad, qboolean isPortal );
637 	void			(*FX_PlayEntityEffectID)				( int id, vec3_t org, matrix3_t axis, const int boltInfo, const int entNum, int vol, int rad );
638 	qboolean		(*FX_PlayBoltedEffectID)				( int id, vec3_t org, void *pGhoul2, const int boltNum, const int entNum, const int modelNum, int iLooptime, qboolean isRelative );
639 	void			(*FX_AddScheduledEffects)				( qboolean portal );
640 	int				(*FX_InitSystem)						( refdef_t *refdef );
641 	void			(*FX_SetRefDef)							( refdef_t *refdef );
642 	qboolean		(*FX_FreeSystem)						( void );
643 	void			(*FX_AdjustTime)						( int time );
644 	void			(*FX_Draw2DEffects)						( float screenXScale, float screenYScale );
645 	void			(*FX_AddPoly)							( addpolyArgStruct_t *p );
646 	void			(*FX_AddBezier)							( addbezierArgStruct_t *p );
647 	void			(*FX_AddPrimitive)						( effectTrailArgStruct_t *p );
648 	void			(*FX_AddSprite)							( addspriteArgStruct_t *p );
649 	void			(*FX_AddElectricity)					( addElectricityArgStruct_t *p );
650 
651 	// stringed
652 	qboolean		(*SE_GetStringTextString)				( const char *text, char *buffer, int bufferLength );
653 
654 	// roff
655 	qboolean		(*ROFF_Clean)							( void );
656 	void			(*ROFF_UpdateEntities)					( void );
657 	int				(*ROFF_Cache)							( char *file );
658 	qboolean		(*ROFF_Play)							( int entID, int roffID, qboolean doTranslation );
659 	qboolean		(*ROFF_Purge_Ent)						( int entID );
660 
661 	// ghoul2
662 	void			(*G2_ListModelSurfaces)					( void *ghlInfo );
663 	void			(*G2_ListModelBones)					( void *ghlInfo, int frame );
664 	void			(*G2_SetGhoul2ModelIndexes)				( void *ghoul2, qhandle_t *modelList, qhandle_t *skinList );
665 	qboolean		(*G2_HaveWeGhoul2Models)				( void *ghoul2 );
666 	qboolean		(*G2API_GetBoltMatrix)					( void *ghoul2, const int modelIndex, const int boltIndex, mdxaBone_t *matrix, const vec3_t angles, const vec3_t position, const int frameNum, qhandle_t *modelList, vec3_t scale );
667 	qboolean		(*G2API_GetBoltMatrix_NoReconstruct)	( void *ghoul2, const int modelIndex, const int boltIndex, mdxaBone_t *matrix, const vec3_t angles, const vec3_t position, const int frameNum, qhandle_t *modelList, vec3_t scale );
668 	qboolean		(*G2API_GetBoltMatrix_NoRecNoRot)		( void *ghoul2, const int modelIndex, const int boltIndex, mdxaBone_t *matrix, const vec3_t angles, const vec3_t position, const int frameNum, qhandle_t *modelList, vec3_t scale );
669 	int				(*G2API_InitGhoul2Model)				( void **ghoul2Ptr, const char *fileName, int modelIndex, qhandle_t customSkin, qhandle_t customShader, int modelFlags, int lodBias );
670 	qboolean		(*G2API_SetSkin)						( void *ghoul2, int modelIndex, qhandle_t customSkin, qhandle_t renderSkin );
671 	void			(*G2API_CollisionDetect)				( CollisionRecord_t *collRecMap, void* ghoul2, const vec3_t angles, const vec3_t position, int frameNumber, int entNum, vec3_t rayStart, vec3_t rayEnd, vec3_t scale, int traceFlags, int useLod, float fRadius );
672 	void			(*G2API_CollisionDetectCache)			( CollisionRecord_t *collRecMap, void* ghoul2, const vec3_t angles, const vec3_t position,int frameNumber, int entNum, vec3_t rayStart, vec3_t rayEnd, vec3_t scale, int traceFlags, int useLod, float fRadius );
673 	void			(*G2API_CleanGhoul2Models)				( void **ghoul2Ptr );
674 	qboolean		(*G2API_SetBoneAngles)					( void *ghoul2, int modelIndex, const char *boneName, const vec3_t angles, const int flags, const int up, const int right, const int forward, qhandle_t *modelList, int blendTime , int currentTime );
675 	qboolean		(*G2API_SetBoneAnim)					( void *ghoul2, const int modelIndex, const char *boneName, const int startFrame, const int endFrame, const int flags, const float animSpeed, const int currentTime, const float setFrame, const int blendTime );
676 	qboolean		(*G2API_GetBoneAnim)					( void *ghoul2, const char *boneName, const int currentTime, float *currentFrame, int *startFrame, int *endFrame, int *flags, float *animSpeed, int *modelList, const int modelIndex );
677 	qboolean		(*G2API_GetBoneFrame)					( void *ghoul2, const char *boneName, const int currentTime, float *currentFrame, int *modelList, const int modelIndex );
678 	void			(*G2API_GetGLAName)						( void *ghoul2, int modelIndex, char *fillBuf );
679 	int				(*G2API_CopyGhoul2Instance)				( void *g2From, void *g2To, int modelIndex );
680 	void			(*G2API_CopySpecificGhoul2Model)		( void *g2From, int modelFrom, void *g2To, int modelTo );
681 	void			(*G2API_DuplicateGhoul2Instance)		( void *g2From, void **g2To );
682 	qboolean		(*G2API_HasGhoul2ModelOnIndex)			( void *ghlInfo, int modelIndex );
683 	qboolean		(*G2API_RemoveGhoul2Model)				( void *ghlInfo, int modelIndex );
684 	qboolean		(*G2API_SkinlessModel)					( void *ghlInfo, int modelIndex );
685 	int				(*G2API_GetNumGoreMarks)				( void *ghlInfo, int modelIndex );
686 	void			(*G2API_AddSkinGore)					( void *ghlInfo, SSkinGoreData *gore );
687 	void			(*G2API_ClearSkinGore)					( void *ghlInfo );
688 	int				(*G2API_Ghoul2Size)						( void *ghlInfo );
689 	int				(*G2API_AddBolt)						( void *ghoul2, int modelIndex, const char *boneName );
690 	qboolean		(*G2API_AttachEnt)						( int *boltInfo, void *ghlInfoTo, int toBoltIndex, int entNum, int toModelNum );
691 	void			(*G2API_SetBoltInfo)					( void *ghoul2, int modelIndex, int boltInfo );
692 	qboolean		(*G2API_SetRootSurface)					( void *ghoul2, const int modelIndex, const char *surfaceName );
693 	qboolean		(*G2API_SetSurfaceOnOff)				( void *ghoul2, const char *surfaceName, const int flags );
694 	qboolean		(*G2API_SetNewOrigin)					( void *ghoul2, const int boltIndex );
695 	qboolean		(*G2API_DoesBoneExist)					( void *ghoul2, int modelIndex, const char *boneName );
696 	int				(*G2API_GetSurfaceRenderStatus)			( void *ghoul2, const int modelIndex, const char *surfaceName );
697 	int				(*G2API_GetTime)						( void );
698 	void			(*G2API_SetTime)						( int time, int clock );
699 	void			(*G2API_AbsurdSmoothing)				( void *ghoul2, qboolean status );
700 	void			(*G2API_SetRagDoll)						( void *ghoul2, sharedRagDollParams_t *params );
701 	void			(*G2API_AnimateG2Models)				( void *ghoul2, int time, sharedRagDollUpdateParams_t *params );
702 	qboolean		(*G2API_RagPCJConstraint)				( void *ghoul2, const char *boneName, vec3_t min, vec3_t max );
703 	qboolean		(*G2API_RagPCJGradientSpeed)			( void *ghoul2, const char *boneName, const float speed );
704 	qboolean		(*G2API_RagEffectorGoal)				( void *ghoul2, const char *boneName, vec3_t pos );
705 	qboolean		(*G2API_GetRagBonePos)					( void *ghoul2, const char *boneName, vec3_t pos, vec3_t entAngles, vec3_t entPos, vec3_t entScale );
706 	qboolean		(*G2API_RagEffectorKick)				( void *ghoul2, const char *boneName, vec3_t velocity );
707 	qboolean		(*G2API_RagForceSolve)					( void *ghoul2, qboolean force );
708 	qboolean		(*G2API_SetBoneIKState)					( void *ghoul2, int time, const char *boneName, int ikState, sharedSetBoneIKStateParams_t *params );
709 	qboolean		(*G2API_IKMove)							( void *ghoul2, int time, sharedIKMoveParams_t *params );
710 	qboolean		(*G2API_RemoveBone)						( void *ghoul2, const char *boneName, int modelIndex );
711 	void			(*G2API_AttachInstanceToEntNum)			( void *ghoul2, int entityNum, qboolean server );
712 	void			(*G2API_ClearAttachedInstance)			( int entityNum );
713 	void			(*G2API_CleanEntAttachments)			( void );
714 	qboolean		(*G2API_OverrideServer)					( void *serverInstance );
715 	void			(*G2API_GetSurfaceName)					( void *ghoul2, int surfNumber, int modelIndex, char *fillBuf );
716 
717 	struct {
718 		float			(*R_Font_StrLenPixels)					( const char *text, const int iFontIndex, const float scale );
719 	} ext;
720 } cgameImport_t;
721 
722 typedef struct cgameExport_s {
723 	void			(*Init)						( int serverMessageNum, int serverCommandSequence, int clientNum );
724 	void			(*Shutdown)					( void );
725 	qboolean		(*ConsoleCommand)			( void );
726 	void			(*DrawActiveFrame)			( int serverTime, stereoFrame_t stereoView, qboolean demoPlayback );
727 	int				(*CrosshairPlayer)			( void );
728 	int				(*LastAttacker)				( void );
729 	void			(*KeyEvent)					( int key, qboolean down );
730 	void			(*MouseEvent)				( int x, int y );
731 	void			(*EventHandling)			( int type );
732 	int				(*PointContents)			( void );
733 	void			(*GetLerpOrigin)			( void );
734 	void			(*GetLerpData)				( void );
735 	void			(*Trace)					( void );
736 	void			(*G2Trace)					( void );
737 	void			(*G2Mark)					( void );
738 	int				(*RagCallback)				( int callType );
739 	qboolean		(*IncomingConsoleCommand)	( void );
740 	qboolean		(*NoUseableForce)			( void );
741 	void			(*GetOrigin)				( int entID, vec3_t out );
742 	void			(*GetAngles)				( int entID, vec3_t out );
743 	trajectory_t *	(*GetOriginTrajectory)		( int entID );
744 	trajectory_t *	(*GetAngleTrajectory)		( int entID );
745 	void			(*ROFF_NotetrackCallback)	( int entID, const char *notetrack );
746 	void			(*MapChange)				( void );
747 	void			(*AutomapInput)				( void );
748 	void			(*MiscEnt)					( void );
749 	void			(*CameraShake)				( void );
750 } cgameExport_t;
751 
752 //linking of cgame library
753 typedef cgameExport_t* (QDECL *GetCGameAPI_t)( int apiVersion, cgameImport_t *import );
754