Annotation of quake2/server/server.h, revision 1.1

1.1     ! root        1: // server.h
        !             2: 
        !             3: 
        !             4: //define       PARANOID                        // speed sapping error checking
        !             5: 
        !             6: #include "../qcommon/qcommon.h"
        !             7: #include "../game/game.h"
        !             8: 
        !             9: //=============================================================================
        !            10: 
        !            11: #define        MAX_MASTERS     8                               // max recipients for heartbeat packets
        !            12: 
        !            13: typedef enum {
        !            14:        ss_dead,                        // no map loaded
        !            15:        ss_loading,                     // spawning level edicts
        !            16:        ss_game,                        // actively running
        !            17:        ss_cinematic,
        !            18:        ss_demo,
        !            19:        ss_pic
        !            20: } server_state_t;
        !            21: // some qc commands are only valid before the server has finished
        !            22: // initializing (precache commands, static sounds / objects, etc)
        !            23: 
        !            24: typedef struct
        !            25: {
        !            26:        server_state_t  state;                  // precache commands are only valid during load
        !            27: 
        !            28:        qboolean        attractloop;            // running cinematics and demos for the local system only
        !            29:        qboolean        loadgame;                       // client begins should reuse existing entity
        !            30: 
        !            31:        unsigned        time;                           // allways sv.framenum * 100 msec
        !            32:        int                     framenum;
        !            33: 
        !            34:        char            name[MAX_QPATH];                        // map name, or cinematic name
        !            35:        struct cmodel_s         *models[MAX_MODELS];
        !            36: 
        !            37:        char            configstrings[MAX_CONFIGSTRINGS][MAX_QPATH];
        !            38:        entity_state_t  baselines[MAX_EDICTS];
        !            39: 
        !            40:        // the multicast buffer is used to send a message to a set of clients
        !            41:        // it is only used to marshall data until SV_Multicast is called
        !            42:        sizebuf_t       multicast;
        !            43:        byte            multicast_buf[MAX_MSGLEN];
        !            44: 
        !            45:        // demo server information
        !            46:        FILE            *demofile;
        !            47:        qboolean        timedemo;               // don't time sync
        !            48: } server_t;
        !            49: 
        !            50: #define EDICT_NUM(n) ((edict_t *)((byte *)ge->edicts + ge->edict_size*(n)))
        !            51: #define NUM_FOR_EDICT(e) ( ((byte *)(e)-(byte *)ge->edicts ) / ge->edict_size)
        !            52: 
        !            53: 
        !            54: typedef enum
        !            55: {
        !            56:        cs_free,                // can be reused for a new connection
        !            57:        cs_zombie,              // client has been disconnected, but don't reuse
        !            58:                                        // connection for a couple seconds
        !            59:        cs_connected,   // has been assigned to a client_t, but not in game yet
        !            60:        cs_spawned              // client is fully in game
        !            61: } client_state_t;
        !            62: 
        !            63: typedef struct
        !            64: {
        !            65:        int                                     areabytes;
        !            66:        byte                            areabits[MAX_MAP_AREAS/8];              // portalarea visibility bits
        !            67:        player_state_t          ps;
        !            68:        int                                     num_entities;
        !            69:        int                                     first_entity;           // into the circular sv_packet_entities[]
        !            70: } client_frame_t;
        !            71: 
        !            72: #define        LATENCY_COUNTS  16
        !            73: #define        RATE_MESSAGES   10
        !            74: 
        !            75: typedef struct client_s
        !            76: {
        !            77:        client_state_t  state;
        !            78: 
        !            79:        char                    userinfo[MAX_INFO_STRING];              // name, etc
        !            80: 
        !            81:        int                             lastframe;                      // for delta compression
        !            82:        usercmd_t               lastcmd;                        // for filling in big drops
        !            83: 
        !            84:        int                             commandMsec;            // every seconds this is reset, if user
        !            85:                                                                                // commands exhaust it, assume time cheating
        !            86: 
        !            87:        int                             frame_latency[LATENCY_COUNTS];
        !            88:        int                             ping;
        !            89: 
        !            90:        int                             message_size[RATE_MESSAGES];    // used to rate drop packets
        !            91:        int                             rate;
        !            92:        int                             surpressCount;          // number of messages rate supressed
        !            93: 
        !            94:        edict_t                 *edict;                         // EDICT_NUM(clientnum+1)
        !            95:        char                    name[32];                       // extracted from userinfo, high bits masked
        !            96:        int                             messagelevel;           // for filtering printed messages
        !            97: 
        !            98:        // The datagram is written to by sound calls, prints, temp ents, etc.
        !            99:        // It can be harmlessly overflowed.
        !           100:        sizebuf_t               datagram;
        !           101:        byte                    datagram_buf[MAX_MSGLEN];
        !           102: 
        !           103:        client_frame_t  frames[UPDATE_BACKUP];  // updates can be delta'd from here
        !           104: 
        !           105:        byte                    *download;                      // file being downloaded
        !           106:        int                             downloadsize;           // total bytes (can't use EOF because of paks)
        !           107:        int                             downloadcount;          // bytes sent
        !           108: 
        !           109:        int                             lastmessage;            // sv.framenum when packet was last received
        !           110:        int                             lastconnect;
        !           111: 
        !           112:        netchan_t               netchan;
        !           113: } client_t;
        !           114: 
        !           115: // a client can leave the server in one of four ways:
        !           116: // dropping properly by quiting or disconnecting
        !           117: // timing out if no valid messages are received for timeout.value seconds
        !           118: // getting kicked off by the server operator
        !           119: // a program error, like an overflowed reliable buffer
        !           120: 
        !           121: //=============================================================================
        !           122: 
        !           123: // MAX_CHALLENGES is made large to prevent a denial
        !           124: // of service attack that could cycle all of them
        !           125: // out before legitimate users connected
        !           126: #define        MAX_CHALLENGES  1024
        !           127: 
        !           128: typedef struct
        !           129: {
        !           130:        netadr_t        adr;
        !           131:        int                     challenge;
        !           132:        int                     time;
        !           133: } challenge_t;
        !           134: 
        !           135: 
        !           136: typedef struct
        !           137: {
        !           138:        qboolean        initialized;                            // sv_init has completed
        !           139:        int                     realtime;                                       // allways increasing, no clamping, etc
        !           140: 
        !           141:        char            mapcmd[MAX_TOKEN_CHARS];        // ie: *intro.cin+base 
        !           142: 
        !           143:        int                     spawncount;                                     // incremented each server start
        !           144:                                                                                        // used to check late spawns
        !           145: 
        !           146:        client_t        *clients;                                       // [maxclients->value];
        !           147:        int                     num_client_entities;            // maxclients->value*UPDATE_BACKUP*MAX_PACKET_ENTITIES
        !           148:        int                     next_client_entities;           // next client_entity to use
        !           149:        entity_state_t  *client_entities;               // [num_client_entities]
        !           150: 
        !           151:        int                     last_heartbeat;
        !           152: 
        !           153:        challenge_t     challenges[MAX_CHALLENGES];     // to prevent invalid IPs from connecting
        !           154: 
        !           155:        // serverrecord values
        !           156:        FILE            *demofile;
        !           157:        sizebuf_t       demo_multicast;
        !           158:        byte            demo_multicast_buf[MAX_MSGLEN];
        !           159: } server_static_t;
        !           160: 
        !           161: //=============================================================================
        !           162: 
        !           163: extern netadr_t        net_from;
        !           164: extern sizebuf_t       net_message;
        !           165: 
        !           166: extern netadr_t        master_adr[MAX_MASTERS];        // address of the master server
        !           167: 
        !           168: extern server_static_t svs;                            // persistant server info
        !           169: extern server_t                sv;                                     // local server
        !           170: 
        !           171: extern cvar_t          *sv_paused;
        !           172: extern cvar_t          *maxclients;
        !           173: extern cvar_t          *sv_noreload;                   // don't reload level state when reentering
        !           174:                                                                                        // development tool
        !           175: extern cvar_t          *sv_enforcetime;
        !           176: 
        !           177: extern client_t        *sv_client;
        !           178: extern edict_t         *sv_player;
        !           179: 
        !           180: //===========================================================
        !           181: 
        !           182: //
        !           183: // sv_main.c
        !           184: //
        !           185: void SV_FinalMessage (char *message, qboolean reconnect);
        !           186: void SV_DropClient (client_t *drop);
        !           187: 
        !           188: int SV_ModelIndex (char *name);
        !           189: int SV_SoundIndex (char *name);
        !           190: int SV_ImageIndex (char *name);
        !           191: 
        !           192: void SV_WriteClientdataToMessage (client_t *client, sizebuf_t *msg);
        !           193: 
        !           194: void SV_ExecuteUserCommand (char *s);
        !           195: void SV_InitOperatorCommands (void);
        !           196: 
        !           197: void SV_SendServerinfo (client_t *client);
        !           198: void SV_UserinfoChanged (client_t *cl);
        !           199: 
        !           200: 
        !           201: void Master_Heartbeat (void);
        !           202: void Master_Packet (void);
        !           203: 
        !           204: //
        !           205: // sv_init.c
        !           206: //
        !           207: void SV_InitGame (void);
        !           208: void SV_Map (qboolean attractloop, char *levelstring, qboolean loadgame);
        !           209: 
        !           210: 
        !           211: //
        !           212: // sv_phys.c
        !           213: //
        !           214: void SV_PrepWorldFrame (void);
        !           215: 
        !           216: //
        !           217: // sv_send.c
        !           218: //
        !           219: typedef enum {RD_NONE, RD_CLIENT, RD_PACKET} redirect_t;
        !           220: #define        SV_OUTPUTBUF_LENGTH     (MAX_MSGLEN - 16)
        !           221: 
        !           222: extern char    sv_outputbuf[SV_OUTPUTBUF_LENGTH];
        !           223: 
        !           224: void SV_FlushRedirect (int sv_redirected, char *outputbuf);
        !           225: 
        !           226: void SV_DemoCompleted (void);
        !           227: void SV_SendClientMessages (void);
        !           228: 
        !           229: void SV_Multicast (vec3_t origin, multicast_t to);
        !           230: void SV_StartSound (vec3_t origin, edict_t *entity, int channel,
        !           231:                                        int soundindex, float volume,
        !           232:                                        float attenuation, float timeofs);
        !           233: void SV_ClientPrintf (client_t *cl, int level, char *fmt, ...);
        !           234: void SV_BroadcastPrintf (int level, char *fmt, ...);
        !           235: void SV_BroadcastCommand (char *fmt, ...);
        !           236: 
        !           237: //
        !           238: // sv_user.c
        !           239: //
        !           240: void SV_Nextserver (void);
        !           241: void SV_ExecuteClientMessage (client_t *cl);
        !           242: 
        !           243: //
        !           244: // sv_ccmds.c
        !           245: //
        !           246: void SV_ReadLevelFile (void);
        !           247: void SV_Status_f (void);
        !           248: 
        !           249: //
        !           250: // sv_ents.c
        !           251: //
        !           252: void SV_WriteFrameToClient (client_t *client, sizebuf_t *msg);
        !           253: void SV_RecordDemoMessage (void);
        !           254: void SV_BuildClientFrame (client_t *client);
        !           255: 
        !           256: 
        !           257: void SV_Error (char *error, ...);
        !           258: 
        !           259: //
        !           260: // sv_game.c
        !           261: //
        !           262: extern game_export_t   *ge;
        !           263: 
        !           264: void SV_InitGameProgs (void);
        !           265: void SV_ShutdownGameProgs (void);
        !           266: void SV_InitEdict (edict_t *e);
        !           267: 
        !           268: 
        !           269: 
        !           270: //============================================================
        !           271: 
        !           272: //
        !           273: // high level object sorting to reduce interaction tests
        !           274: //
        !           275: 
        !           276: void SV_ClearWorld (void);
        !           277: // called after the world model has been loaded, before linking any entities
        !           278: 
        !           279: void SV_UnlinkEdict (edict_t *ent);
        !           280: // call before removing an entity, and before trying to move one,
        !           281: // so it doesn't clip against itself
        !           282: 
        !           283: void SV_LinkEdict (edict_t *ent);
        !           284: // Needs to be called any time an entity changes origin, mins, maxs,
        !           285: // or solid.  Automatically unlinks if needed.
        !           286: // sets ent->v.absmin and ent->v.absmax
        !           287: // sets ent->leafnums[] for pvs determination even if the entity
        !           288: // is not solid
        !           289: 
        !           290: int SV_AreaEdicts (vec3_t mins, vec3_t maxs, edict_t **list, int maxcount, int areatype);
        !           291: // fills in a table of edict pointers with edicts that have bounding boxes
        !           292: // that intersect the given area.  It is possible for a non-axial bmodel
        !           293: // to be returned that doesn't actually intersect the area on an exact
        !           294: // test.
        !           295: // returns the number of pointers filled in
        !           296: // ??? does this allways return the world?
        !           297: 
        !           298: //===================================================================
        !           299: 
        !           300: //
        !           301: // functions that interact with everything apropriate
        !           302: //
        !           303: int SV_PointContents (vec3_t p);
        !           304: // returns the CONTENTS_* value from the world at the given point.
        !           305: // Quake 2 extends this to also check entities, to allow moving liquids
        !           306: 
        !           307: 
        !           308: trace_t SV_Trace (vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end, edict_t *passedict, int contentmask);
        !           309: // mins and maxs are relative
        !           310: 
        !           311: // if the entire move stays in a solid volume, trace.allsolid will be set,
        !           312: // trace.startsolid will be set, and trace.fraction will be 0
        !           313: 
        !           314: // if the starting point is in a solid, it will be allowed to move out
        !           315: // to an open area
        !           316: 
        !           317: // passedict is explicitly excluded from clipping checks (normally NULL)
        !           318: 

unix.superglobalmegacorp.com

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