Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

g_public.h

Go to the documentation of this file.
00001 /*
00002 ===========================================================================
00003 Copyright (C) 1999-2005 Id Software, Inc.
00004 
00005 This file is part of Quake III Arena source code.
00006 
00007 Quake III Arena source code is free software; you can redistribute it
00008 and/or modify it under the terms of the GNU General Public License as
00009 published by the Free Software Foundation; either version 2 of the License,
00010 or (at your option) any later version.
00011 
00012 Quake III Arena source code is distributed in the hope that it will be
00013 useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 GNU General Public License for more details.
00016 
00017 You should have received a copy of the GNU General Public License
00018 along with Foobar; if not, write to the Free Software
00019 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00020 ===========================================================================
00021 */
00022 //
00023 
00024 // g_public.h -- game module information visible to server
00025 
00026 #define GAME_API_VERSION    8
00027 
00028 // entity->svFlags
00029 // the server does not know how to interpret most of the values
00030 // in entityStates (level eType), so the game must explicitly flag
00031 // special server behaviors
00032 #define SVF_NOCLIENT            0x00000001  // don't send entity to clients, even if it has effects
00033 
00034 // TTimo
00035 // https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=551
00036 #define SVF_CLIENTMASK 0x00000002
00037 
00038 #define SVF_BOT                 0x00000008  // set if the entity is a bot
00039 #define SVF_BROADCAST           0x00000020  // send to all connected clients
00040 #define SVF_PORTAL              0x00000040  // merge a second pvs at origin2 into snapshots
00041 #define SVF_USE_CURRENT_ORIGIN  0x00000080  // entity->r.currentOrigin instead of entity->s.origin
00042                                             // for link position (missiles and movers)
00043 #define SVF_SINGLECLIENT        0x00000100  // only send to a single client (entityShared_t->singleClient)
00044 #define SVF_NOSERVERINFO        0x00000200  // don't send CS_SERVERINFO updates to this client
00045                                             // so that it can be updated for ping tools without
00046                                             // lagging clients
00047 #define SVF_CAPSULE             0x00000400  // use capsule for collision detection instead of bbox
00048 #define SVF_NOTSINGLECLIENT     0x00000800  // send entity to everyone but one client
00049                                             // (entityShared_t->singleClient)
00050 
00051 
00052 
00053 //===============================================================
00054 
00055 
00056 typedef struct {
00057     entityState_t   s;              // communicated by server to clients
00058 
00059     qboolean    linked;             // qfalse if not in any good cluster
00060     int         linkcount;
00061 
00062     int         svFlags;            // SVF_NOCLIENT, SVF_BROADCAST, etc
00063 
00064     // only send to this client when SVF_SINGLECLIENT is set    
00065     // if SVF_CLIENTMASK is set, use bitmask for clients to send to (maxclients must be <= 32, up to the mod to enforce this)
00066     int         singleClient;       
00067 
00068     qboolean    bmodel;             // if false, assume an explicit mins / maxs bounding box
00069                                     // only set by trap_SetBrushModel
00070     vec3_t      mins, maxs;
00071     int         contents;           // CONTENTS_TRIGGER, CONTENTS_SOLID, CONTENTS_BODY, etc
00072                                     // a non-solid entity should set to 0
00073 
00074     vec3_t      absmin, absmax;     // derived from mins/maxs and origin + rotation
00075 
00076     // currentOrigin will be used for all collision detection and world linking.
00077     // it will not necessarily be the same as the trajectory evaluation for the current
00078     // time, because each entity must be moved one at a time after time is advanced
00079     // to avoid simultanious collision issues
00080     vec3_t      currentOrigin;
00081     vec3_t      currentAngles;
00082 
00083     // when a trace call is made and passEntityNum != ENTITYNUM_NONE,
00084     // an ent will be excluded from testing if:
00085     // ent->s.number == passEntityNum   (don't interact with self)
00086     // ent->s.ownerNum = passEntityNum  (don't interact with your own missiles)
00087     // entity[ent->s.ownerNum].ownerNum = passEntityNum (don't interact with other missiles from owner)
00088     int         ownerNum;
00089 } entityShared_t;
00090 
00091 
00092 
00093 // the server looks at a sharedEntity, which is the start of the game's gentity_t structure
00094 typedef struct {
00095     entityState_t   s;              // communicated by server to clients
00096     entityShared_t  r;              // shared by both the server system and game
00097 } sharedEntity_t;
00098 
00099 
00100 
00101 //===============================================================
00102 
00103 //
00104 // system traps provided by the main engine
00105 //
00106 typedef enum {
00107     //============== general Quake services ==================
00108 
00109     G_PRINT,        // ( const char *string );
00110     // print message on the local console
00111 
00112     G_ERROR,        // ( const char *string );
00113     // abort the game
00114 
00115     G_MILLISECONDS, // ( void );
00116     // get current time for profiling reasons
00117     // this should NOT be used for any game related tasks,
00118     // because it is not journaled
00119 
00120     // console variable interaction
00121     G_CVAR_REGISTER,    // ( vmCvar_t *vmCvar, const char *varName, const char *defaultValue, int flags );
00122     G_CVAR_UPDATE,  // ( vmCvar_t *vmCvar );
00123     G_CVAR_SET,     // ( const char *var_name, const char *value );
00124     G_CVAR_VARIABLE_INTEGER_VALUE,  // ( const char *var_name );
00125 
00126     G_CVAR_VARIABLE_STRING_BUFFER,  // ( const char *var_name, char *buffer, int bufsize );
00127 
00128     G_ARGC,         // ( void );
00129     // ClientCommand and ServerCommand parameter access
00130 
00131     G_ARGV,         // ( int n, char *buffer, int bufferLength );
00132 
00133     G_FS_FOPEN_FILE,    // ( const char *qpath, fileHandle_t *file, fsMode_t mode );
00134     G_FS_READ,      // ( void *buffer, int len, fileHandle_t f );
00135     G_FS_WRITE,     // ( const void *buffer, int len, fileHandle_t f );
00136     G_FS_FCLOSE_FILE,       // ( fileHandle_t f );
00137 
00138     G_SEND_CONSOLE_COMMAND, // ( const char *text );
00139     // add commands to the console as if they were typed in
00140     // for map changing, etc
00141 
00142 
00143     //=========== server specific functionality =============
00144 
00145     G_LOCATE_GAME_DATA,     // ( gentity_t *gEnts, int numGEntities, int sizeofGEntity_t,
00146     //                          playerState_t *clients, int sizeofGameClient );
00147     // the game needs to let the server system know where and how big the gentities
00148     // are, so it can look at them directly without going through an interface
00149 
00150     G_DROP_CLIENT,      // ( int clientNum, const char *reason );
00151     // kick a client off the server with a message
00152 
00153     G_SEND_SERVER_COMMAND,  // ( int clientNum, const char *fmt, ... );
00154     // reliably sends a command string to be interpreted by the given
00155     // client.  If clientNum is -1, it will be sent to all clients
00156 
00157     G_SET_CONFIGSTRING, // ( int num, const char *string );
00158     // config strings hold all the index strings, and various other information
00159     // that is reliably communicated to all clients
00160     // All of the current configstrings are sent to clients when
00161     // they connect, and changes are sent to all connected clients.
00162     // All confgstrings are cleared at each level start.
00163 
00164     G_GET_CONFIGSTRING, // ( int num, char *buffer, int bufferSize );
00165 
00166     G_GET_USERINFO,     // ( int num, char *buffer, int bufferSize );
00167     // userinfo strings are maintained by the server system, so they
00168     // are persistant across level loads, while all other game visible
00169     // data is completely reset
00170 
00171     G_SET_USERINFO,     // ( int num, const char *buffer );
00172 
00173     G_GET_SERVERINFO,   // ( char *buffer, int bufferSize );
00174     // the serverinfo info string has all the cvars visible to server browsers
00175 
00176     G_SET_BRUSH_MODEL,  // ( gentity_t *ent, const char *name );
00177     // sets mins and maxs based on the brushmodel name
00178 
00179     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 );
00180     // collision detection against all linked entities
00181 
00182     G_POINT_CONTENTS,   // ( const vec3_t point, int passEntityNum );
00183     // point contents against all linked entities
00184 
00185     G_IN_PVS,           // ( const vec3_t p1, const vec3_t p2 );
00186 
00187     G_IN_PVS_IGNORE_PORTALS,    // ( const vec3_t p1, const vec3_t p2 );
00188 
00189     G_ADJUST_AREA_PORTAL_STATE, // ( gentity_t *ent, qboolean open );
00190 
00191     G_AREAS_CONNECTED,  // ( int area1, int area2 );
00192 
00193     G_LINKENTITY,       // ( gentity_t *ent );
00194     // an entity will never be sent to a client or used for collision
00195     // if it is not passed to linkentity.  If the size, position, or
00196     // solidity changes, it must be relinked.
00197 
00198     G_UNLINKENTITY,     // ( gentity_t *ent );      
00199     // call before removing an interactive entity
00200 
00201     G_ENTITIES_IN_BOX,  // ( const vec3_t mins, const vec3_t maxs, gentity_t **list, int maxcount );
00202     // EntitiesInBox will return brush models based on their bounding box,
00203     // so exact determination must still be done with EntityContact
00204 
00205     G_ENTITY_CONTACT,   // ( const vec3_t mins, const vec3_t maxs, const gentity_t *ent );
00206     // perform an exact check against inline brush models of non-square shape
00207 
00208     // access for bots to get and free a server client (FIXME?)
00209     G_BOT_ALLOCATE_CLIENT,  // ( void );
00210 
00211     G_BOT_FREE_CLIENT,  // ( int clientNum );
00212 
00213     G_GET_USERCMD,  // ( int clientNum, usercmd_t *cmd )
00214 
00215     G_GET_ENTITY_TOKEN, // qboolean ( char *buffer, int bufferSize )
00216     // Retrieves the next string token from the entity spawn text, returning
00217     // false when all tokens have been parsed.
00218     // This should only be done at GAME_INIT time.
00219 
00220     G_FS_GETFILELIST,
00221     G_DEBUG_POLYGON_CREATE,
00222     G_DEBUG_POLYGON_DELETE,
00223     G_REAL_TIME,
00224     G_SNAPVECTOR,
00225 
00226     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 );
00227     G_ENTITY_CONTACTCAPSULE,    // ( const vec3_t mins, const vec3_t maxs, const gentity_t *ent );
00228     
00229     // 1.32
00230     G_FS_SEEK,
00231 
00232     BOTLIB_SETUP = 200,             // ( void );
00233     BOTLIB_SHUTDOWN,                // ( void );
00234     BOTLIB_LIBVAR_SET,
00235     BOTLIB_LIBVAR_GET,
00236     BOTLIB_PC_ADD_GLOBAL_DEFINE,
00237     BOTLIB_START_FRAME,
00238     BOTLIB_LOAD_MAP,
00239     BOTLIB_UPDATENTITY,
00240     BOTLIB_TEST,
00241 
00242     BOTLIB_GET_SNAPSHOT_ENTITY,     // ( int client, int ent );
00243     BOTLIB_GET_CONSOLE_MESSAGE,     // ( int client, char *message, int size );
00244     BOTLIB_USER_COMMAND,            // ( int client, usercmd_t *ucmd );
00245 
00246     BOTLIB_AAS_ENABLE_ROUTING_AREA = 300,
00247     BOTLIB_AAS_BBOX_AREAS,
00248     BOTLIB_AAS_AREA_INFO,
00249     BOTLIB_AAS_ENTITY_INFO,
00250 
00251     BOTLIB_AAS_INITIALIZED,
00252     BOTLIB_AAS_PRESENCE_TYPE_BOUNDING_BOX,
00253     BOTLIB_AAS_TIME,
00254 
00255     BOTLIB_AAS_POINT_AREA_NUM,
00256     BOTLIB_AAS_TRACE_AREAS,
00257 
00258     BOTLIB_AAS_POINT_CONTENTS,
00259     BOTLIB_AAS_NEXT_BSP_ENTITY,
00260     BOTLIB_AAS_VALUE_FOR_BSP_EPAIR_KEY,
00261     BOTLIB_AAS_VECTOR_FOR_BSP_EPAIR_KEY,
00262     BOTLIB_AAS_FLOAT_FOR_BSP_EPAIR_KEY,
00263     BOTLIB_AAS_INT_FOR_BSP_EPAIR_KEY,
00264 
00265     BOTLIB_AAS_AREA_REACHABILITY,
00266 
00267     BOTLIB_AAS_AREA_TRAVEL_TIME_TO_GOAL_AREA,
00268 
00269     BOTLIB_AAS_SWIMMING,
00270     BOTLIB_AAS_PREDICT_CLIENT_MOVEMENT,
00271 
00272     BOTLIB_EA_SAY = 400,
00273     BOTLIB_EA_SAY_TEAM,
00274     BOTLIB_EA_COMMAND,
00275 
00276     BOTLIB_EA_ACTION,
00277     BOTLIB_EA_GESTURE,
00278     BOTLIB_EA_TALK,
00279     BOTLIB_EA_ATTACK,
00280     BOTLIB_EA_USE,
00281     BOTLIB_EA_RESPAWN,
00282     BOTLIB_EA_CROUCH,
00283     BOTLIB_EA_MOVE_UP,
00284     BOTLIB_EA_MOVE_DOWN,
00285     BOTLIB_EA_MOVE_FORWARD,
00286     BOTLIB_EA_MOVE_BACK,
00287     BOTLIB_EA_MOVE_LEFT,
00288     BOTLIB_EA_MOVE_RIGHT,
00289 
00290     BOTLIB_EA_SELECT_WEAPON,
00291     BOTLIB_EA_JUMP,
00292     BOTLIB_EA_DELAYED_JUMP,
00293     BOTLIB_EA_MOVE,
00294     BOTLIB_EA_VIEW,
00295 
00296     BOTLIB_EA_END_REGULAR,
00297     BOTLIB_EA_GET_INPUT,
00298     BOTLIB_EA_RESET_INPUT,
00299 
00300 
00301     BOTLIB_AI_LOAD_CHARACTER = 500,
00302     BOTLIB_AI_FREE_CHARACTER,
00303     BOTLIB_AI_CHARACTERISTIC_FLOAT,
00304     BOTLIB_AI_CHARACTERISTIC_BFLOAT,
00305     BOTLIB_AI_CHARACTERISTIC_INTEGER,
00306     BOTLIB_AI_CHARACTERISTIC_BINTEGER,
00307     BOTLIB_AI_CHARACTERISTIC_STRING,
00308 
00309     BOTLIB_AI_ALLOC_CHAT_STATE,
00310     BOTLIB_AI_FREE_CHAT_STATE,
00311     BOTLIB_AI_QUEUE_CONSOLE_MESSAGE,
00312     BOTLIB_AI_REMOVE_CONSOLE_MESSAGE,
00313     BOTLIB_AI_NEXT_CONSOLE_MESSAGE,
00314     BOTLIB_AI_NUM_CONSOLE_MESSAGE,
00315     BOTLIB_AI_INITIAL_CHAT,
00316     BOTLIB_AI_REPLY_CHAT,
00317     BOTLIB_AI_CHAT_LENGTH,
00318     BOTLIB_AI_ENTER_CHAT,
00319     BOTLIB_AI_STRING_CONTAINS,
00320     BOTLIB_AI_FIND_MATCH,
00321     BOTLIB_AI_MATCH_VARIABLE,
00322     BOTLIB_AI_UNIFY_WHITE_SPACES,
00323     BOTLIB_AI_REPLACE_SYNONYMS,
00324     BOTLIB_AI_LOAD_CHAT_FILE,
00325     BOTLIB_AI_SET_CHAT_GENDER,
00326     BOTLIB_AI_SET_CHAT_NAME,
00327 
00328     BOTLIB_AI_RESET_GOAL_STATE,
00329     BOTLIB_AI_RESET_AVOID_GOALS,
00330     BOTLIB_AI_PUSH_GOAL,
00331     BOTLIB_AI_POP_GOAL,
00332     BOTLIB_AI_EMPTY_GOAL_STACK,
00333     BOTLIB_AI_DUMP_AVOID_GOALS,
00334     BOTLIB_AI_DUMP_GOAL_STACK,
00335     BOTLIB_AI_GOAL_NAME,
00336     BOTLIB_AI_GET_TOP_GOAL,
00337     BOTLIB_AI_GET_SECOND_GOAL,
00338     BOTLIB_AI_CHOOSE_LTG_ITEM,
00339     BOTLIB_AI_CHOOSE_NBG_ITEM,
00340     BOTLIB_AI_TOUCHING_GOAL,
00341     BOTLIB_AI_ITEM_GOAL_IN_VIS_BUT_NOT_VISIBLE,
00342     BOTLIB_AI_GET_LEVEL_ITEM_GOAL,
00343     BOTLIB_AI_AVOID_GOAL_TIME,
00344     BOTLIB_AI_INIT_LEVEL_ITEMS,
00345     BOTLIB_AI_UPDATE_ENTITY_ITEMS,
00346     BOTLIB_AI_LOAD_ITEM_WEIGHTS,
00347     BOTLIB_AI_FREE_ITEM_WEIGHTS,
00348     BOTLIB_AI_SAVE_GOAL_FUZZY_LOGIC,
00349     BOTLIB_AI_ALLOC_GOAL_STATE,
00350     BOTLIB_AI_FREE_GOAL_STATE,
00351 
00352     BOTLIB_AI_RESET_MOVE_STATE,
00353     BOTLIB_AI_MOVE_TO_GOAL,
00354     BOTLIB_AI_MOVE_IN_DIRECTION,
00355     BOTLIB_AI_RESET_AVOID_REACH,
00356     BOTLIB_AI_RESET_LAST_AVOID_REACH,
00357     BOTLIB_AI_REACHABILITY_AREA,
00358     BOTLIB_AI_MOVEMENT_VIEW_TARGET,
00359     BOTLIB_AI_ALLOC_MOVE_STATE,
00360     BOTLIB_AI_FREE_MOVE_STATE,
00361     BOTLIB_AI_INIT_MOVE_STATE,
00362 
00363     BOTLIB_AI_CHOOSE_BEST_FIGHT_WEAPON,
00364     BOTLIB_AI_GET_WEAPON_INFO,
00365     BOTLIB_AI_LOAD_WEAPON_WEIGHTS,
00366     BOTLIB_AI_ALLOC_WEAPON_STATE,
00367     BOTLIB_AI_FREE_WEAPON_STATE,
00368     BOTLIB_AI_RESET_WEAPON_STATE,
00369 
00370     BOTLIB_AI_GENETIC_PARENTS_AND_CHILD_SELECTION,
00371     BOTLIB_AI_INTERBREED_GOAL_FUZZY_LOGIC,
00372     BOTLIB_AI_MUTATE_GOAL_FUZZY_LOGIC,
00373     BOTLIB_AI_GET_NEXT_CAMP_SPOT_GOAL,
00374     BOTLIB_AI_GET_MAP_LOCATION_GOAL,
00375     BOTLIB_AI_NUM_INITIAL_CHATS,
00376     BOTLIB_AI_GET_CHAT_MESSAGE,
00377     BOTLIB_AI_REMOVE_FROM_AVOID_GOALS,
00378     BOTLIB_AI_PREDICT_VISIBLE_POSITION,
00379 
00380     BOTLIB_AI_SET_AVOID_GOAL_TIME,
00381     BOTLIB_AI_ADD_AVOID_SPOT,
00382     BOTLIB_AAS_ALTERNATIVE_ROUTE_GOAL,
00383     BOTLIB_AAS_PREDICT_ROUTE,
00384     BOTLIB_AAS_POINT_REACHABILITY_AREA_INDEX,
00385 
00386     BOTLIB_PC_LOAD_SOURCE,
00387     BOTLIB_PC_FREE_SOURCE,
00388     BOTLIB_PC_READ_TOKEN,
00389     BOTLIB_PC_SOURCE_FILE_AND_LINE
00390 
00391 } gameImport_t;
00392 
00393 
00394 //
00395 // functions exported by the game subsystem
00396 //
00397 typedef enum {
00398     GAME_INIT,  // ( int levelTime, int randomSeed, int restart );
00399     // init and shutdown will be called every single level
00400     // The game should call G_GET_ENTITY_TOKEN to parse through all the
00401     // entity configuration text and spawn gentities.
00402 
00403     GAME_SHUTDOWN,  // (void);
00404 
00405     GAME_CLIENT_CONNECT,    // ( int clientNum, qboolean firstTime, qboolean isBot );
00406     // return NULL if the client is allowed to connect, otherwise return
00407     // a text string with the reason for denial
00408 
00409     GAME_CLIENT_BEGIN,              // ( int clientNum );
00410 
00411     GAME_CLIENT_USERINFO_CHANGED,   // ( int clientNum );
00412 
00413     GAME_CLIENT_DISCONNECT,         // ( int clientNum );
00414 
00415     GAME_CLIENT_COMMAND,            // ( int clientNum );
00416 
00417     GAME_CLIENT_THINK,              // ( int clientNum );
00418 
00419     GAME_RUN_FRAME,                 // ( int levelTime );
00420 
00421     GAME_CONSOLE_COMMAND,           // ( void );
00422     // ConsoleCommand will be called when a command has been issued
00423     // that is not recognized as a builtin function.
00424     // The game can issue trap_argc() / trap_argv() commands to get the command
00425     // and parameters.  Return qfalse if the game doesn't recognize it as a command.
00426 
00427     BOTAI_START_FRAME               // ( int time );
00428 } gameExport_t;
00429 

Generated on Thu Aug 25 12:37:32 2005 for Quake III Arena by  doxygen 1.3.9.1