Quake-III-Arena

Quake III Arena GPL Source Release
Log | Files | Refs

g_public.h (14365B)


      1 /*
      2 ===========================================================================
      3 Copyright (C) 1999-2005 Id Software, Inc.
      4 
      5 This file is part of Quake III Arena source code.
      6 
      7 Quake III Arena source code is free software; you can redistribute it
      8 and/or modify it under the terms of the GNU General Public License as
      9 published by the Free Software Foundation; either version 2 of the License,
     10 or (at your option) any later version.
     11 
     12 Quake III Arena source code is distributed in the hope that it will be
     13 useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 GNU General Public License for more details.
     16 
     17 You should have received a copy of the GNU General Public License
     18 along with Foobar; if not, write to the Free Software
     19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
     20 ===========================================================================
     21 */
     22 //
     23 
     24 // g_public.h -- game module information visible to server
     25 
     26 #define	GAME_API_VERSION	8
     27 
     28 // entity->svFlags
     29 // the server does not know how to interpret most of the values
     30 // in entityStates (level eType), so the game must explicitly flag
     31 // special server behaviors
     32 #define	SVF_NOCLIENT			0x00000001	// don't send entity to clients, even if it has effects
     33 
     34 // TTimo
     35 // https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=551
     36 #define SVF_CLIENTMASK 0x00000002
     37 
     38 #define SVF_BOT					0x00000008	// set if the entity is a bot
     39 #define	SVF_BROADCAST			0x00000020	// send to all connected clients
     40 #define	SVF_PORTAL				0x00000040	// merge a second pvs at origin2 into snapshots
     41 #define	SVF_USE_CURRENT_ORIGIN	0x00000080	// entity->r.currentOrigin instead of entity->s.origin
     42 											// for link position (missiles and movers)
     43 #define SVF_SINGLECLIENT		0x00000100	// only send to a single client (entityShared_t->singleClient)
     44 #define SVF_NOSERVERINFO		0x00000200	// don't send CS_SERVERINFO updates to this client
     45 											// so that it can be updated for ping tools without
     46 											// lagging clients
     47 #define SVF_CAPSULE				0x00000400	// use capsule for collision detection instead of bbox
     48 #define SVF_NOTSINGLECLIENT		0x00000800	// send entity to everyone but one client
     49 											// (entityShared_t->singleClient)
     50 
     51 
     52 
     53 //===============================================================
     54 
     55 
     56 typedef struct {
     57 	entityState_t	s;				// communicated by server to clients
     58 
     59 	qboolean	linked;				// qfalse if not in any good cluster
     60 	int			linkcount;
     61 
     62 	int			svFlags;			// SVF_NOCLIENT, SVF_BROADCAST, etc
     63 
     64 	// only send to this client when SVF_SINGLECLIENT is set	
     65 	// if SVF_CLIENTMASK is set, use bitmask for clients to send to (maxclients must be <= 32, up to the mod to enforce this)
     66 	int			singleClient;		
     67 
     68 	qboolean	bmodel;				// if false, assume an explicit mins / maxs bounding box
     69 									// only set by trap_SetBrushModel
     70 	vec3_t		mins, maxs;
     71 	int			contents;			// CONTENTS_TRIGGER, CONTENTS_SOLID, CONTENTS_BODY, etc
     72 									// a non-solid entity should set to 0
     73 
     74 	vec3_t		absmin, absmax;		// derived from mins/maxs and origin + rotation
     75 
     76 	// currentOrigin will be used for all collision detection and world linking.
     77 	// it will not necessarily be the same as the trajectory evaluation for the current
     78 	// time, because each entity must be moved one at a time after time is advanced
     79 	// to avoid simultanious collision issues
     80 	vec3_t		currentOrigin;
     81 	vec3_t		currentAngles;
     82 
     83 	// when a trace call is made and passEntityNum != ENTITYNUM_NONE,
     84 	// an ent will be excluded from testing if:
     85 	// ent->s.number == passEntityNum	(don't interact with self)
     86 	// ent->s.ownerNum = passEntityNum	(don't interact with your own missiles)
     87 	// entity[ent->s.ownerNum].ownerNum = passEntityNum	(don't interact with other missiles from owner)
     88 	int			ownerNum;
     89 } entityShared_t;
     90 
     91 
     92 
     93 // the server looks at a sharedEntity, which is the start of the game's gentity_t structure
     94 typedef struct {
     95 	entityState_t	s;				// communicated by server to clients
     96 	entityShared_t	r;				// shared by both the server system and game
     97 } sharedEntity_t;
     98 
     99 
    100 
    101 //===============================================================
    102 
    103 //
    104 // system traps provided by the main engine
    105 //
    106 typedef enum {
    107 	//============== general Quake services ==================
    108 
    109 	G_PRINT,		// ( const char *string );
    110 	// print message on the local console
    111 
    112 	G_ERROR,		// ( const char *string );
    113 	// abort the game
    114 
    115 	G_MILLISECONDS,	// ( void );
    116 	// get current time for profiling reasons
    117 	// this should NOT be used for any game related tasks,
    118 	// because it is not journaled
    119 
    120 	// console variable interaction
    121 	G_CVAR_REGISTER,	// ( vmCvar_t *vmCvar, const char *varName, const char *defaultValue, int flags );
    122 	G_CVAR_UPDATE,	// ( vmCvar_t *vmCvar );
    123 	G_CVAR_SET,		// ( const char *var_name, const char *value );
    124 	G_CVAR_VARIABLE_INTEGER_VALUE,	// ( const char *var_name );
    125 
    126 	G_CVAR_VARIABLE_STRING_BUFFER,	// ( const char *var_name, char *buffer, int bufsize );
    127 
    128 	G_ARGC,			// ( void );
    129 	// ClientCommand and ServerCommand parameter access
    130 
    131 	G_ARGV,			// ( int n, char *buffer, int bufferLength );
    132 
    133 	G_FS_FOPEN_FILE,	// ( const char *qpath, fileHandle_t *file, fsMode_t mode );
    134 	G_FS_READ,		// ( void *buffer, int len, fileHandle_t f );
    135 	G_FS_WRITE,		// ( const void *buffer, int len, fileHandle_t f );
    136 	G_FS_FCLOSE_FILE,		// ( fileHandle_t f );
    137 
    138 	G_SEND_CONSOLE_COMMAND,	// ( const char *text );
    139 	// add commands to the console as if they were typed in
    140 	// for map changing, etc
    141 
    142 
    143 	//=========== server specific functionality =============
    144 
    145 	G_LOCATE_GAME_DATA,		// ( gentity_t *gEnts, int numGEntities, int sizeofGEntity_t,
    146 	//							playerState_t *clients, int sizeofGameClient );
    147 	// the game needs to let the server system know where and how big the gentities
    148 	// are, so it can look at them directly without going through an interface
    149 
    150 	G_DROP_CLIENT,		// ( int clientNum, const char *reason );
    151 	// kick a client off the server with a message
    152 
    153 	G_SEND_SERVER_COMMAND,	// ( int clientNum, const char *fmt, ... );
    154 	// reliably sends a command string to be interpreted by the given
    155 	// client.  If clientNum is -1, it will be sent to all clients
    156 
    157 	G_SET_CONFIGSTRING,	// ( int num, const char *string );
    158 	// config strings hold all the index strings, and various other information
    159 	// that is reliably communicated to all clients
    160 	// All of the current configstrings are sent to clients when
    161 	// they connect, and changes are sent to all connected clients.
    162 	// All confgstrings are cleared at each level start.
    163 
    164 	G_GET_CONFIGSTRING,	// ( int num, char *buffer, int bufferSize );
    165 
    166 	G_GET_USERINFO,		// ( int num, char *buffer, int bufferSize );
    167 	// userinfo strings are maintained by the server system, so they
    168 	// are persistant across level loads, while all other game visible
    169 	// data is completely reset
    170 
    171 	G_SET_USERINFO,		// ( int num, const char *buffer );
    172 
    173 	G_GET_SERVERINFO,	// ( char *buffer, int bufferSize );
    174 	// the serverinfo info string has all the cvars visible to server browsers
    175 
    176 	G_SET_BRUSH_MODEL,	// ( gentity_t *ent, const char *name );
    177 	// sets mins and maxs based on the brushmodel name
    178 
    179 	G_TRACE,	// ( trace_t *results, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, int passEntityNum, int contentmask );
    180 	// collision detection against all linked entities
    181 
    182 	G_POINT_CONTENTS,	// ( const vec3_t point, int passEntityNum );
    183 	// point contents against all linked entities
    184 
    185 	G_IN_PVS,			// ( const vec3_t p1, const vec3_t p2 );
    186 
    187 	G_IN_PVS_IGNORE_PORTALS,	// ( const vec3_t p1, const vec3_t p2 );
    188 
    189 	G_ADJUST_AREA_PORTAL_STATE,	// ( gentity_t *ent, qboolean open );
    190 
    191 	G_AREAS_CONNECTED,	// ( int area1, int area2 );
    192 
    193 	G_LINKENTITY,		// ( gentity_t *ent );
    194 	// an entity will never be sent to a client or used for collision
    195 	// if it is not passed to linkentity.  If the size, position, or
    196 	// solidity changes, it must be relinked.
    197 
    198 	G_UNLINKENTITY,		// ( gentity_t *ent );		
    199 	// call before removing an interactive entity
    200 
    201 	G_ENTITIES_IN_BOX,	// ( const vec3_t mins, const vec3_t maxs, gentity_t **list, int maxcount );
    202 	// EntitiesInBox will return brush models based on their bounding box,
    203 	// so exact determination must still be done with EntityContact
    204 
    205 	G_ENTITY_CONTACT,	// ( const vec3_t mins, const vec3_t maxs, const gentity_t *ent );
    206 	// perform an exact check against inline brush models of non-square shape
    207 
    208 	// access for bots to get and free a server client (FIXME?)
    209 	G_BOT_ALLOCATE_CLIENT,	// ( void );
    210 
    211 	G_BOT_FREE_CLIENT,	// ( int clientNum );
    212 
    213 	G_GET_USERCMD,	// ( int clientNum, usercmd_t *cmd )
    214 
    215 	G_GET_ENTITY_TOKEN,	// qboolean ( char *buffer, int bufferSize )
    216 	// Retrieves the next string token from the entity spawn text, returning
    217 	// false when all tokens have been parsed.
    218 	// This should only be done at GAME_INIT time.
    219 
    220 	G_FS_GETFILELIST,
    221 	G_DEBUG_POLYGON_CREATE,
    222 	G_DEBUG_POLYGON_DELETE,
    223 	G_REAL_TIME,
    224 	G_SNAPVECTOR,
    225 
    226 	G_TRACECAPSULE,	// ( trace_t *results, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, int passEntityNum, int contentmask );
    227 	G_ENTITY_CONTACTCAPSULE,	// ( const vec3_t mins, const vec3_t maxs, const gentity_t *ent );
    228 	
    229 	// 1.32
    230 	G_FS_SEEK,
    231 
    232 	BOTLIB_SETUP = 200,				// ( void );
    233 	BOTLIB_SHUTDOWN,				// ( void );
    234 	BOTLIB_LIBVAR_SET,
    235 	BOTLIB_LIBVAR_GET,
    236 	BOTLIB_PC_ADD_GLOBAL_DEFINE,
    237 	BOTLIB_START_FRAME,
    238 	BOTLIB_LOAD_MAP,
    239 	BOTLIB_UPDATENTITY,
    240 	BOTLIB_TEST,
    241 
    242 	BOTLIB_GET_SNAPSHOT_ENTITY,		// ( int client, int ent );
    243 	BOTLIB_GET_CONSOLE_MESSAGE,		// ( int client, char *message, int size );
    244 	BOTLIB_USER_COMMAND,			// ( int client, usercmd_t *ucmd );
    245 
    246 	BOTLIB_AAS_ENABLE_ROUTING_AREA = 300,
    247 	BOTLIB_AAS_BBOX_AREAS,
    248 	BOTLIB_AAS_AREA_INFO,
    249 	BOTLIB_AAS_ENTITY_INFO,
    250 
    251 	BOTLIB_AAS_INITIALIZED,
    252 	BOTLIB_AAS_PRESENCE_TYPE_BOUNDING_BOX,
    253 	BOTLIB_AAS_TIME,
    254 
    255 	BOTLIB_AAS_POINT_AREA_NUM,
    256 	BOTLIB_AAS_TRACE_AREAS,
    257 
    258 	BOTLIB_AAS_POINT_CONTENTS,
    259 	BOTLIB_AAS_NEXT_BSP_ENTITY,
    260 	BOTLIB_AAS_VALUE_FOR_BSP_EPAIR_KEY,
    261 	BOTLIB_AAS_VECTOR_FOR_BSP_EPAIR_KEY,
    262 	BOTLIB_AAS_FLOAT_FOR_BSP_EPAIR_KEY,
    263 	BOTLIB_AAS_INT_FOR_BSP_EPAIR_KEY,
    264 
    265 	BOTLIB_AAS_AREA_REACHABILITY,
    266 
    267 	BOTLIB_AAS_AREA_TRAVEL_TIME_TO_GOAL_AREA,
    268 
    269 	BOTLIB_AAS_SWIMMING,
    270 	BOTLIB_AAS_PREDICT_CLIENT_MOVEMENT,
    271 
    272 	BOTLIB_EA_SAY = 400,
    273 	BOTLIB_EA_SAY_TEAM,
    274 	BOTLIB_EA_COMMAND,
    275 
    276 	BOTLIB_EA_ACTION,
    277 	BOTLIB_EA_GESTURE,
    278 	BOTLIB_EA_TALK,
    279 	BOTLIB_EA_ATTACK,
    280 	BOTLIB_EA_USE,
    281 	BOTLIB_EA_RESPAWN,
    282 	BOTLIB_EA_CROUCH,
    283 	BOTLIB_EA_MOVE_UP,
    284 	BOTLIB_EA_MOVE_DOWN,
    285 	BOTLIB_EA_MOVE_FORWARD,
    286 	BOTLIB_EA_MOVE_BACK,
    287 	BOTLIB_EA_MOVE_LEFT,
    288 	BOTLIB_EA_MOVE_RIGHT,
    289 
    290 	BOTLIB_EA_SELECT_WEAPON,
    291 	BOTLIB_EA_JUMP,
    292 	BOTLIB_EA_DELAYED_JUMP,
    293 	BOTLIB_EA_MOVE,
    294 	BOTLIB_EA_VIEW,
    295 
    296 	BOTLIB_EA_END_REGULAR,
    297 	BOTLIB_EA_GET_INPUT,
    298 	BOTLIB_EA_RESET_INPUT,
    299 
    300 
    301 	BOTLIB_AI_LOAD_CHARACTER = 500,
    302 	BOTLIB_AI_FREE_CHARACTER,
    303 	BOTLIB_AI_CHARACTERISTIC_FLOAT,
    304 	BOTLIB_AI_CHARACTERISTIC_BFLOAT,
    305 	BOTLIB_AI_CHARACTERISTIC_INTEGER,
    306 	BOTLIB_AI_CHARACTERISTIC_BINTEGER,
    307 	BOTLIB_AI_CHARACTERISTIC_STRING,
    308 
    309 	BOTLIB_AI_ALLOC_CHAT_STATE,
    310 	BOTLIB_AI_FREE_CHAT_STATE,
    311 	BOTLIB_AI_QUEUE_CONSOLE_MESSAGE,
    312 	BOTLIB_AI_REMOVE_CONSOLE_MESSAGE,
    313 	BOTLIB_AI_NEXT_CONSOLE_MESSAGE,
    314 	BOTLIB_AI_NUM_CONSOLE_MESSAGE,
    315 	BOTLIB_AI_INITIAL_CHAT,
    316 	BOTLIB_AI_REPLY_CHAT,
    317 	BOTLIB_AI_CHAT_LENGTH,
    318 	BOTLIB_AI_ENTER_CHAT,
    319 	BOTLIB_AI_STRING_CONTAINS,
    320 	BOTLIB_AI_FIND_MATCH,
    321 	BOTLIB_AI_MATCH_VARIABLE,
    322 	BOTLIB_AI_UNIFY_WHITE_SPACES,
    323 	BOTLIB_AI_REPLACE_SYNONYMS,
    324 	BOTLIB_AI_LOAD_CHAT_FILE,
    325 	BOTLIB_AI_SET_CHAT_GENDER,
    326 	BOTLIB_AI_SET_CHAT_NAME,
    327 
    328 	BOTLIB_AI_RESET_GOAL_STATE,
    329 	BOTLIB_AI_RESET_AVOID_GOALS,
    330 	BOTLIB_AI_PUSH_GOAL,
    331 	BOTLIB_AI_POP_GOAL,
    332 	BOTLIB_AI_EMPTY_GOAL_STACK,
    333 	BOTLIB_AI_DUMP_AVOID_GOALS,
    334 	BOTLIB_AI_DUMP_GOAL_STACK,
    335 	BOTLIB_AI_GOAL_NAME,
    336 	BOTLIB_AI_GET_TOP_GOAL,
    337 	BOTLIB_AI_GET_SECOND_GOAL,
    338 	BOTLIB_AI_CHOOSE_LTG_ITEM,
    339 	BOTLIB_AI_CHOOSE_NBG_ITEM,
    340 	BOTLIB_AI_TOUCHING_GOAL,
    341 	BOTLIB_AI_ITEM_GOAL_IN_VIS_BUT_NOT_VISIBLE,
    342 	BOTLIB_AI_GET_LEVEL_ITEM_GOAL,
    343 	BOTLIB_AI_AVOID_GOAL_TIME,
    344 	BOTLIB_AI_INIT_LEVEL_ITEMS,
    345 	BOTLIB_AI_UPDATE_ENTITY_ITEMS,
    346 	BOTLIB_AI_LOAD_ITEM_WEIGHTS,
    347 	BOTLIB_AI_FREE_ITEM_WEIGHTS,
    348 	BOTLIB_AI_SAVE_GOAL_FUZZY_LOGIC,
    349 	BOTLIB_AI_ALLOC_GOAL_STATE,
    350 	BOTLIB_AI_FREE_GOAL_STATE,
    351 
    352 	BOTLIB_AI_RESET_MOVE_STATE,
    353 	BOTLIB_AI_MOVE_TO_GOAL,
    354 	BOTLIB_AI_MOVE_IN_DIRECTION,
    355 	BOTLIB_AI_RESET_AVOID_REACH,
    356 	BOTLIB_AI_RESET_LAST_AVOID_REACH,
    357 	BOTLIB_AI_REACHABILITY_AREA,
    358 	BOTLIB_AI_MOVEMENT_VIEW_TARGET,
    359 	BOTLIB_AI_ALLOC_MOVE_STATE,
    360 	BOTLIB_AI_FREE_MOVE_STATE,
    361 	BOTLIB_AI_INIT_MOVE_STATE,
    362 
    363 	BOTLIB_AI_CHOOSE_BEST_FIGHT_WEAPON,
    364 	BOTLIB_AI_GET_WEAPON_INFO,
    365 	BOTLIB_AI_LOAD_WEAPON_WEIGHTS,
    366 	BOTLIB_AI_ALLOC_WEAPON_STATE,
    367 	BOTLIB_AI_FREE_WEAPON_STATE,
    368 	BOTLIB_AI_RESET_WEAPON_STATE,
    369 
    370 	BOTLIB_AI_GENETIC_PARENTS_AND_CHILD_SELECTION,
    371 	BOTLIB_AI_INTERBREED_GOAL_FUZZY_LOGIC,
    372 	BOTLIB_AI_MUTATE_GOAL_FUZZY_LOGIC,
    373 	BOTLIB_AI_GET_NEXT_CAMP_SPOT_GOAL,
    374 	BOTLIB_AI_GET_MAP_LOCATION_GOAL,
    375 	BOTLIB_AI_NUM_INITIAL_CHATS,
    376 	BOTLIB_AI_GET_CHAT_MESSAGE,
    377 	BOTLIB_AI_REMOVE_FROM_AVOID_GOALS,
    378 	BOTLIB_AI_PREDICT_VISIBLE_POSITION,
    379 
    380 	BOTLIB_AI_SET_AVOID_GOAL_TIME,
    381 	BOTLIB_AI_ADD_AVOID_SPOT,
    382 	BOTLIB_AAS_ALTERNATIVE_ROUTE_GOAL,
    383 	BOTLIB_AAS_PREDICT_ROUTE,
    384 	BOTLIB_AAS_POINT_REACHABILITY_AREA_INDEX,
    385 
    386 	BOTLIB_PC_LOAD_SOURCE,
    387 	BOTLIB_PC_FREE_SOURCE,
    388 	BOTLIB_PC_READ_TOKEN,
    389 	BOTLIB_PC_SOURCE_FILE_AND_LINE
    390 
    391 } gameImport_t;
    392 
    393 
    394 //
    395 // functions exported by the game subsystem
    396 //
    397 typedef enum {
    398 	GAME_INIT,	// ( int levelTime, int randomSeed, int restart );
    399 	// init and shutdown will be called every single level
    400 	// The game should call G_GET_ENTITY_TOKEN to parse through all the
    401 	// entity configuration text and spawn gentities.
    402 
    403 	GAME_SHUTDOWN,	// (void);
    404 
    405 	GAME_CLIENT_CONNECT,	// ( int clientNum, qboolean firstTime, qboolean isBot );
    406 	// return NULL if the client is allowed to connect, otherwise return
    407 	// a text string with the reason for denial
    408 
    409 	GAME_CLIENT_BEGIN,				// ( int clientNum );
    410 
    411 	GAME_CLIENT_USERINFO_CHANGED,	// ( int clientNum );
    412 
    413 	GAME_CLIENT_DISCONNECT,			// ( int clientNum );
    414 
    415 	GAME_CLIENT_COMMAND,			// ( int clientNum );
    416 
    417 	GAME_CLIENT_THINK,				// ( int clientNum );
    418 
    419 	GAME_RUN_FRAME,					// ( int levelTime );
    420 
    421 	GAME_CONSOLE_COMMAND,			// ( void );
    422 	// ConsoleCommand will be called when a command has been issued
    423 	// that is not recognized as a builtin function.
    424 	// The game can issue trap_argc() / trap_argv() commands to get the command
    425 	// and parameters.  Return qfalse if the game doesn't recognize it as a command.
    426 
    427 	BOTAI_START_FRAME				// ( int time );
    428 } gameExport_t;
    429