Annotation of quake2/game/game.h, revision 1.1.1.2

1.1.1.2 ! root        1: /*
        !             2: Copyright (C) 1997-2001 Id Software, Inc.
        !             3: 
        !             4: This program is free software; you can redistribute it and/or
        !             5: modify it under the terms of the GNU General Public License
        !             6: as published by the Free Software Foundation; either version 2
        !             7: of the License, or (at your option) any later version.
        !             8: 
        !             9: This program is distributed in the hope that it will be useful,
        !            10: but WITHOUT ANY WARRANTY; without even the implied warranty of
        !            11: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
        !            12: 
        !            13: See the GNU General Public License for more details.
        !            14: 
        !            15: You should have received a copy of the GNU General Public License
        !            16: along with this program; if not, write to the Free Software
        !            17: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
        !            18: 
        !            19: */
1.1       root       20: 
                     21: // game.h -- game dll information visible to server
                     22: 
                     23: #define        GAME_API_VERSION        3
                     24: 
                     25: // edict->svflags
                     26: 
                     27: #define        SVF_NOCLIENT                    0x00000001      // don't send entity to clients, even if it has effects
                     28: #define        SVF_DEADMONSTER                 0x00000002      // treat as CONTENTS_DEADMONSTER for collision
                     29: #define        SVF_MONSTER                             0x00000004      // treat as CONTENTS_MONSTER for collision
                     30: 
                     31: // edict->solid values
                     32: 
                     33: typedef enum
                     34: {
                     35: SOLID_NOT,                     // no interaction with other objects
                     36: SOLID_TRIGGER,         // only touch when inside, after moving
                     37: SOLID_BBOX,                    // touch on edge
                     38: SOLID_BSP                      // bsp clip, touch on edge
                     39: } solid_t;
                     40: 
                     41: //===============================================================
                     42: 
                     43: // link_t is only used for entity area links now
                     44: typedef struct link_s
                     45: {
                     46:        struct link_s   *prev, *next;
                     47: } link_t;
                     48: 
                     49: #define        MAX_ENT_CLUSTERS        16
                     50: 
                     51: 
                     52: typedef struct edict_s edict_t;
                     53: typedef struct gclient_s gclient_t;
                     54: 
                     55: 
                     56: #ifndef GAME_INCLUDE
                     57: 
                     58: struct gclient_s
                     59: {
                     60:        player_state_t  ps;             // communicated by server to clients
                     61:        int                             ping;
                     62:        // the game dll can add anything it wants after
                     63:        // this point in the structure
                     64: };
                     65: 
                     66: 
                     67: struct edict_s
                     68: {
                     69:        entity_state_t  s;
                     70:        struct gclient_s        *client;
                     71:        qboolean        inuse;
                     72:        int                     linkcount;
                     73: 
                     74:        // FIXME: move these fields to a server private sv_entity_t
                     75:        link_t          area;                           // linked to a division node or leaf
                     76:        
                     77:        int                     num_clusters;           // if -1, use headnode instead
                     78:        int                     clusternums[MAX_ENT_CLUSTERS];
                     79:        int                     headnode;                       // unused if num_clusters != -1
                     80:        int                     areanum, areanum2;
                     81: 
                     82:        //================================
                     83: 
                     84:        int                     svflags;                        // SVF_NOCLIENT, SVF_DEADMONSTER, SVF_MONSTER, etc
                     85:        vec3_t          mins, maxs;
                     86:        vec3_t          absmin, absmax, size;
                     87:        solid_t         solid;
                     88:        int                     clipmask;
                     89:        edict_t         *owner;
                     90: 
                     91:        // the game dll can add anything it wants after
                     92:        // this point in the structure
                     93: };
                     94: 
                     95: #endif         // GAME_INCLUDE
                     96: 
                     97: //===============================================================
                     98: 
                     99: //
                    100: // functions provided by the main engine
                    101: //
                    102: typedef struct
                    103: {
                    104:        // special messages
                    105:        void    (*bprintf) (int printlevel, char *fmt, ...);
                    106:        void    (*dprintf) (char *fmt, ...);
                    107:        void    (*cprintf) (edict_t *ent, int printlevel, char *fmt, ...);
                    108:        void    (*centerprintf) (edict_t *ent, char *fmt, ...);
                    109:        void    (*sound) (edict_t *ent, int channel, int soundindex, float volume, float attenuation, float timeofs);
                    110:        void    (*positioned_sound) (vec3_t origin, edict_t *ent, int channel, int soundinedex, float volume, float attenuation, float timeofs);
                    111: 
                    112:        // config strings hold all the index strings, the lightstyles,
                    113:        // and misc data like the sky definition and cdtrack.
                    114:        // All of the current configstrings are sent to clients when
                    115:        // they connect, and changes are sent to all connected clients.
                    116:        void    (*configstring) (int num, char *string);
                    117: 
                    118:        void    (*error) (char *fmt, ...);
                    119: 
                    120:        // the *index functions create configstrings and some internal server state
                    121:        int             (*modelindex) (char *name);
                    122:        int             (*soundindex) (char *name);
                    123:        int             (*imageindex) (char *name);
                    124: 
                    125:        void    (*setmodel) (edict_t *ent, char *name);
                    126: 
                    127:        // collision detection
                    128:        trace_t (*trace) (vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end, edict_t *passent, int contentmask);
                    129:        int             (*pointcontents) (vec3_t point);
                    130:        qboolean        (*inPVS) (vec3_t p1, vec3_t p2);
                    131:        qboolean        (*inPHS) (vec3_t p1, vec3_t p2);
                    132:        void            (*SetAreaPortalState) (int portalnum, qboolean open);
                    133:        qboolean        (*AreasConnected) (int area1, int area2);
                    134: 
                    135:        // an entity will never be sent to a client or used for collision
                    136:        // if it is not passed to linkentity.  If the size, position, or
                    137:        // solidity changes, it must be relinked.
                    138:        void    (*linkentity) (edict_t *ent);
                    139:        void    (*unlinkentity) (edict_t *ent);         // call before removing an interactive edict
                    140:        int             (*BoxEdicts) (vec3_t mins, vec3_t maxs, edict_t **list, int maxcount, int areatype);
                    141:        void    (*Pmove) (pmove_t *pmove);              // player movement code common with client prediction
                    142: 
                    143:        // network messaging
                    144:        void    (*multicast) (vec3_t origin, multicast_t to);
                    145:        void    (*unicast) (edict_t *ent, qboolean reliable);
                    146:        void    (*WriteChar) (int c);
                    147:        void    (*WriteByte) (int c);
                    148:        void    (*WriteShort) (int c);
                    149:        void    (*WriteLong) (int c);
                    150:        void    (*WriteFloat) (float f);
                    151:        void    (*WriteString) (char *s);
                    152:        void    (*WritePosition) (vec3_t pos);  // some fractional bits
                    153:        void    (*WriteDir) (vec3_t pos);               // single byte encoded, very coarse
                    154:        void    (*WriteAngle) (float f);
                    155: 
                    156:        // managed memory allocation
                    157:        void    *(*TagMalloc) (int size, int tag);
                    158:        void    (*TagFree) (void *block);
                    159:        void    (*FreeTags) (int tag);
                    160: 
                    161:        // console variable interaction
                    162:        cvar_t  *(*cvar) (char *var_name, char *value, int flags);
                    163:        cvar_t  *(*cvar_set) (char *var_name, char *value);
                    164:        cvar_t  *(*cvar_forceset) (char *var_name, char *value);
                    165: 
                    166:        // ClientCommand and ServerCommand parameter access
                    167:        int             (*argc) (void);
                    168:        char    *(*argv) (int n);
                    169:        char    *(*args) (void);        // concatenation of all argv >= 1
                    170: 
                    171:        // add commands to the server console as if they were typed in
                    172:        // for map changing, etc
                    173:        void    (*AddCommandString) (char *text);
                    174: 
                    175:        void    (*DebugGraph) (float value, int color);
                    176: } game_import_t;
                    177: 
                    178: //
                    179: // functions exported by the game subsystem
                    180: //
                    181: typedef struct
                    182: {
                    183:        int                     apiversion;
                    184: 
                    185:        // the init function will only be called when a game starts,
                    186:        // not each time a level is loaded.  Persistant data for clients
                    187:        // and the server can be allocated in init
                    188:        void            (*Init) (void);
                    189:        void            (*Shutdown) (void);
                    190: 
                    191:        // each new level entered will cause a call to SpawnEntities
                    192:        void            (*SpawnEntities) (char *mapname, char *entstring, char *spawnpoint);
                    193: 
                    194:        // Read/Write Game is for storing persistant cross level information
                    195:        // about the world state and the clients.
                    196:        // WriteGame is called every time a level is exited.
                    197:        // ReadGame is called on a loadgame.
                    198:        void            (*WriteGame) (char *filename, qboolean autosave);
                    199:        void            (*ReadGame) (char *filename);
                    200: 
                    201:        // ReadLevel is called after the default map information has been
                    202:        // loaded with SpawnEntities
                    203:        void            (*WriteLevel) (char *filename);
                    204:        void            (*ReadLevel) (char *filename);
                    205: 
                    206:        qboolean        (*ClientConnect) (edict_t *ent, char *userinfo);
                    207:        void            (*ClientBegin) (edict_t *ent);
                    208:        void            (*ClientUserinfoChanged) (edict_t *ent, char *userinfo);
                    209:        void            (*ClientDisconnect) (edict_t *ent);
                    210:        void            (*ClientCommand) (edict_t *ent);
                    211:        void            (*ClientThink) (edict_t *ent, usercmd_t *cmd);
                    212: 
                    213:        void            (*RunFrame) (void);
                    214: 
                    215:        // ServerCommand will be called when an "sv <command>" command is issued on the
                    216:        // server console.
                    217:        // The game can issue gi.argc() / gi.argv() commands to get the rest
                    218:        // of the parameters
                    219:        void            (*ServerCommand) (void);
                    220: 
                    221:        //
                    222:        // global variables shared between game and server
                    223:        //
                    224: 
                    225:        // The edict array is allocated in the game dll so it
                    226:        // can vary in size from one game to another.
                    227:        // 
                    228:        // The size will be fixed when ge->Init() is called
                    229:        struct edict_s  *edicts;
                    230:        int                     edict_size;
                    231:        int                     num_edicts;             // current number, <= max_edicts
                    232:        int                     max_edicts;
                    233: } game_export_t;
                    234: 
                    235: game_export_t *GetGameApi (game_import_t *import);

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.