Annotation of quake2/ctf/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: //ZOID
                     31: #define SVF_PROJECTILE                 0x00000008  // entity is simple projectile, used for network optimization
                     32: // if an entity is projectile, the model index/x/y/z/pitch/yaw are sent, encoded into
                     33: // seven (or eight) bytes.  This is to speed up projectiles.  Currently, only the
                     34: // hyperblaster makes use of this.  use for items that are moving with a constant
                     35: // velocity that don't change direction or model
                     36: //ZOID
                     37: 
                     38: // edict->solid values
                     39: 
                     40: typedef enum
                     41: {
                     42: SOLID_NOT,                     // no interaction with other objects
                     43: SOLID_TRIGGER,         // only touch when inside, after moving
                     44: SOLID_BBOX,                    // touch on edge
                     45: SOLID_BSP                      // bsp clip, touch on edge
                     46: } solid_t;
                     47: 
                     48: //===============================================================
                     49: 
                     50: // link_t is only used for entity area links now
                     51: typedef struct link_s
                     52: {
                     53:        struct link_s   *prev, *next;
                     54: } link_t;
                     55: 
                     56: #define        MAX_ENT_CLUSTERS        16
                     57: 
                     58: 
                     59: typedef struct edict_s edict_t;
                     60: typedef struct gclient_s gclient_t;
                     61: 
                     62: 
                     63: #ifndef GAME_INCLUDE
                     64: 
                     65: struct gclient_s
                     66: {
                     67:        player_state_t  ps;             // communicated by server to clients
                     68:        int                             ping;
                     69:        // the game dll can add anything it wants after
                     70:        // this point in the structure
                     71: };
                     72: 
                     73: 
                     74: struct edict_s
                     75: {
                     76:        entity_state_t  s;
                     77:        struct gclient_s        *client;
                     78:        qboolean        inuse;
                     79:        int                     linkcount;
                     80: 
                     81:        // FIXME: move these fields to a server private sv_entity_t
                     82:        link_t          area;                           // linked to a division node or leaf
                     83:        
                     84:        int                     num_clusters;           // if -1, use headnode instead
                     85:        int                     clusternums[MAX_ENT_CLUSTERS];
                     86:        int                     headnode;                       // unused if num_clusters != -1
                     87:        int                     areanum, areanum2;
                     88: 
                     89:        //================================
                     90: 
                     91:        int                     svflags;                        // SVF_NOCLIENT, SVF_DEADMONSTER, SVF_MONSTER, etc
                     92:        vec3_t          mins, maxs;
                     93:        vec3_t          absmin, absmax, size;
                     94:        solid_t         solid;
                     95:        int                     clipmask;
                     96:        edict_t         *owner;
                     97: 
                     98:        // the game dll can add anything it wants after
                     99:        // this point in the structure
                    100: };
                    101: 
                    102: #endif         // GAME_INCLUDE
                    103: 
                    104: //===============================================================
                    105: 
                    106: //
                    107: // functions provided by the main engine
                    108: //
                    109: typedef struct
                    110: {
                    111:        // special messages
                    112:        void    (*bprintf) (int printlevel, char *fmt, ...);
                    113:        void    (*dprintf) (char *fmt, ...);
                    114:        void    (*cprintf) (edict_t *ent, int printlevel, char *fmt, ...);
                    115:        void    (*centerprintf) (edict_t *ent, char *fmt, ...);
                    116:        void    (*sound) (edict_t *ent, int channel, int soundindex, float volume, float attenuation, float timeofs);
                    117:        void    (*positioned_sound) (vec3_t origin, edict_t *ent, int channel, int soundinedex, float volume, float attenuation, float timeofs);
                    118: 
                    119:        // config strings hold all the index strings, the lightstyles,
                    120:        // and misc data like the sky definition and cdtrack.
                    121:        // All of the current configstrings are sent to clients when
                    122:        // they connect, and changes are sent to all connected clients.
                    123:        void    (*configstring) (int num, char *string);
                    124: 
                    125:        void    (*error) (char *fmt, ...);
                    126: 
                    127:        // the *index functions create configstrings and some internal server state
                    128:        int             (*modelindex) (char *name);
                    129:        int             (*soundindex) (char *name);
                    130:        int             (*imageindex) (char *name);
                    131: 
                    132:        void    (*setmodel) (edict_t *ent, char *name);
                    133: 
                    134:        // collision detection
                    135:        trace_t (*trace) (vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end, edict_t *passent, int contentmask);
                    136:        int             (*pointcontents) (vec3_t point);
                    137:        qboolean        (*inPVS) (vec3_t p1, vec3_t p2);
                    138:        qboolean        (*inPHS) (vec3_t p1, vec3_t p2);
                    139:        void            (*SetAreaPortalState) (int portalnum, qboolean open);
                    140:        qboolean        (*AreasConnected) (int area1, int area2);
                    141: 
                    142:        // an entity will never be sent to a client or used for collision
                    143:        // if it is not passed to linkentity.  If the size, position, or
                    144:        // solidity changes, it must be relinked.
                    145:        void    (*linkentity) (edict_t *ent);
                    146:        void    (*unlinkentity) (edict_t *ent);         // call before removing an interactive edict
                    147:        int             (*BoxEdicts) (vec3_t mins, vec3_t maxs, edict_t **list, int maxcount, int areatype);
                    148:        void    (*Pmove) (pmove_t *pmove);              // player movement code common with client prediction
                    149: 
                    150:        // network messaging
                    151:        void    (*multicast) (vec3_t origin, multicast_t to);
                    152:        void    (*unicast) (edict_t *ent, qboolean reliable);
                    153:        void    (*WriteChar) (int c);
                    154:        void    (*WriteByte) (int c);
                    155:        void    (*WriteShort) (int c);
                    156:        void    (*WriteLong) (int c);
                    157:        void    (*WriteFloat) (float f);
                    158:        void    (*WriteString) (char *s);
                    159:        void    (*WritePosition) (vec3_t pos);  // some fractional bits
                    160:        void    (*WriteDir) (vec3_t pos);               // single byte encoded, very coarse
                    161:        void    (*WriteAngle) (float f);
                    162: 
                    163:        // managed memory allocation
                    164:        void    *(*TagMalloc) (int size, int tag);
                    165:        void    (*TagFree) (void *block);
                    166:        void    (*FreeTags) (int tag);
                    167: 
                    168:        // console variable interaction
                    169:        cvar_t  *(*cvar) (char *var_name, char *value, int flags);
                    170:        cvar_t  *(*cvar_set) (char *var_name, char *value);
                    171:        cvar_t  *(*cvar_forceset) (char *var_name, char *value);
                    172: 
                    173:        // ClientCommand and ServerCommand parameter access
                    174:        int             (*argc) (void);
                    175:        char    *(*argv) (int n);
                    176:        char    *(*args) (void);        // concatenation of all argv >= 1
                    177: 
                    178:        // add commands to the server console as if they were typed in
                    179:        // for map changing, etc
                    180:        void    (*AddCommandString) (char *text);
                    181: 
                    182:        void    (*DebugGraph) (float value, int color);
                    183: } game_import_t;
                    184: 
                    185: //
                    186: // functions exported by the game subsystem
                    187: //
                    188: typedef struct
                    189: {
                    190:        int                     apiversion;
                    191: 
                    192:        // the init function will only be called when a game starts,
                    193:        // not each time a level is loaded.  Persistant data for clients
                    194:        // and the server can be allocated in init
                    195:        void            (*Init) (void);
                    196:        void            (*Shutdown) (void);
                    197: 
                    198:        // each new level entered will cause a call to SpawnEntities
                    199:        void            (*SpawnEntities) (char *mapname, char *entstring, char *spawnpoint);
                    200: 
                    201:        // Read/Write Game is for storing persistant cross level information
                    202:        // about the world state and the clients.
                    203:        // WriteGame is called every time a level is exited.
                    204:        // ReadGame is called on a loadgame.
                    205:        void            (*WriteGame) (char *filename, qboolean autosave);
                    206:        void            (*ReadGame) (char *filename);
                    207: 
                    208:        // ReadLevel is called after the default map information has been
                    209:        // loaded with SpawnEntities
                    210:        void            (*WriteLevel) (char *filename);
                    211:        void            (*ReadLevel) (char *filename);
                    212: 
                    213:        qboolean        (*ClientConnect) (edict_t *ent, char *userinfo);
                    214:        void            (*ClientBegin) (edict_t *ent);
                    215:        void            (*ClientUserinfoChanged) (edict_t *ent, char *userinfo);
                    216:        void            (*ClientDisconnect) (edict_t *ent);
                    217:        void            (*ClientCommand) (edict_t *ent);
                    218:        void            (*ClientThink) (edict_t *ent, usercmd_t *cmd);
                    219: 
                    220:        void            (*RunFrame) (void);
                    221: 
                    222:        // ServerCommand will be called when an "sv <command>" command is issued on the
                    223:        // server console.
                    224:        // The game can issue gi.argc() / gi.argv() commands to get the rest
                    225:        // of the parameters
                    226:        void            (*ServerCommand) (void);
                    227: 
                    228:        //
                    229:        // global variables shared between game and server
                    230:        //
                    231: 
                    232:        // The edict array is allocated in the game dll so it
                    233:        // can vary in size from one game to another.
                    234:        // 
                    235:        // The size will be fixed when ge->Init() is called
                    236:        struct edict_s  *edicts;
                    237:        int                     edict_size;
                    238:        int                     num_edicts;             // current number, <= max_edicts
                    239:        int                     max_edicts;
                    240: } game_export_t;
                    241: 
                    242: 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.