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

1.1     ! root        1: /*
        !             2: Copyright (C) 1996-1997 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: */
        !            20: // server.h
        !            21: 
        !            22: #define        QW_SERVER
        !            23: 
        !            24: #define        MAX_MASTERS     8                               // max recipients for heartbeat packets
        !            25: 
        !            26: #define        MAX_SIGNON_BUFFERS      8
        !            27: 
        !            28: typedef enum {
        !            29:        ss_dead,                        // no map loaded
        !            30:        ss_loading,                     // spawning level edicts
        !            31:        ss_active                       // actively running
        !            32: } server_state_t;
        !            33: // some qc commands are only valid before the server has finished
        !            34: // initializing (precache commands, static sounds / objects, etc)
        !            35: 
        !            36: typedef struct
        !            37: {
        !            38:        qboolean        active;                         // false when server is going down
        !            39:        server_state_t  state;                  // precache commands are only valid during load
        !            40: 
        !            41:        double          time;
        !            42:        
        !            43:        int                     lastcheck;                      // used by PF_checkclient
        !            44:        double          lastchecktime;          // for monster ai 
        !            45: 
        !            46:        qboolean        paused;                         // are we paused?
        !            47: 
        !            48:        //check player/eyes models for hacks
        !            49:        unsigned        model_player_checksum;
        !            50:        unsigned        eyes_player_checksum;
        !            51:        
        !            52:        char            name[64];                       // map name
        !            53:        char            modelname[MAX_QPATH];           // maps/<name>.bsp, for model_precache[0]
        !            54:        struct model_s  *worldmodel;
        !            55:        char            *model_precache[MAX_MODELS];    // NULL terminated
        !            56:        char            *sound_precache[MAX_SOUNDS];    // NULL terminated
        !            57:        char            *lightstyles[MAX_LIGHTSTYLES];
        !            58:        struct model_s          *models[MAX_MODELS];
        !            59: 
        !            60:        int                     num_edicts;                     // increases towards MAX_EDICTS
        !            61:        edict_t         *edicts;                        // can NOT be array indexed, because
        !            62:                                                                        // edict_t is variable sized, but can
        !            63:                                                                        // be used to reference the world ent
        !            64: 
        !            65:        byte            *pvs, *phs;                     // fully expanded and decompressed
        !            66: 
        !            67:        // added to every client's unreliable buffer each frame, then cleared
        !            68:        sizebuf_t       datagram;
        !            69:        byte            datagram_buf[MAX_DATAGRAM];
        !            70: 
        !            71:        // added to every client's reliable buffer each frame, then cleared
        !            72:        sizebuf_t       reliable_datagram;
        !            73:        byte            reliable_datagram_buf[MAX_MSGLEN];
        !            74: 
        !            75:        // the multicast buffer is used to send a message to a set of clients
        !            76:        sizebuf_t       multicast;
        !            77:        byte            multicast_buf[MAX_MSGLEN];
        !            78: 
        !            79:        // the master buffer is used for building log packets
        !            80:        sizebuf_t       master;
        !            81:        byte            master_buf[MAX_DATAGRAM];
        !            82: 
        !            83:        // the signon buffer will be sent to each client as they connect
        !            84:        // includes the entity baselines, the static entities, etc
        !            85:        // large levels will have >MAX_DATAGRAM sized signons, so 
        !            86:        // multiple signon messages are kept
        !            87:        sizebuf_t       signon;
        !            88:        int                     num_signon_buffers;
        !            89:        int                     signon_buffer_size[MAX_SIGNON_BUFFERS];
        !            90:        byte            signon_buffers[MAX_SIGNON_BUFFERS][MAX_DATAGRAM];
        !            91: } server_t;
        !            92: 
        !            93: 
        !            94: #define        NUM_SPAWN_PARMS                 16
        !            95: 
        !            96: typedef enum
        !            97: {
        !            98:        cs_free,                // can be reused for a new connection
        !            99:        cs_zombie,              // client has been disconnected, but don't reuse
        !           100:                                        // connection for a couple seconds
        !           101:        cs_connected,   // has been assigned to a client_t, but not in game yet
        !           102:        cs_spawned              // client is fully in game
        !           103: } client_state_t;
        !           104: 
        !           105: typedef struct
        !           106: {
        !           107:        // received from client
        !           108: 
        !           109:        // reply
        !           110:        double                          senttime;
        !           111:        float                           ping_time;
        !           112:        packet_entities_t       entities;
        !           113: } client_frame_t;
        !           114: 
        !           115: #define MAX_BACK_BUFFERS 4
        !           116: 
        !           117: typedef struct client_s
        !           118: {
        !           119:        client_state_t  state;
        !           120: 
        !           121:        int                             spectator;                      // non-interactive
        !           122: 
        !           123:        qboolean                sendinfo;                       // at end of frame, send info to all
        !           124:                                                                                // this prevents malicious multiple broadcasts
        !           125:        float                   lastnametime;           // time of last name change
        !           126:        int                             lastnamecount;          // time of last name change
        !           127:        unsigned                checksum;                       // checksum for calcs
        !           128:        qboolean                drop;                           // lose this guy next opportunity
        !           129:        int                             lossage;                        // loss percentage
        !           130: 
        !           131:        int                             userid;                                                 // identifying number
        !           132:        char                    userinfo[MAX_INFO_STRING];              // infostring
        !           133: 
        !           134:        usercmd_t               lastcmd;                        // for filling in big drops and partial predictions
        !           135:        double                  localtime;                      // of last message
        !           136:        int                             oldbuttons;
        !           137: 
        !           138:        float                   maxspeed;                       // localized maxspeed
        !           139:        float                   entgravity;                     // localized ent gravity
        !           140: 
        !           141:        edict_t                 *edict;                         // EDICT_NUM(clientnum+1)
        !           142:        char                    name[32];                       // for printing to other people
        !           143:                                                                                // extracted from userinfo
        !           144:        int                             messagelevel;           // for filtering printed messages
        !           145: 
        !           146:        // the datagram is written to after every frame, but only cleared
        !           147:        // when it is sent out to the client.  overflow is tolerated.
        !           148:        sizebuf_t               datagram;
        !           149:        byte                    datagram_buf[MAX_DATAGRAM];
        !           150: 
        !           151:        // back buffers for client reliable data
        !           152:        sizebuf_t       backbuf;
        !           153:        int                     num_backbuf;
        !           154:        int                     backbuf_size[MAX_BACK_BUFFERS];
        !           155:        byte            backbuf_data[MAX_BACK_BUFFERS][MAX_MSGLEN];
        !           156: 
        !           157:        double                  connection_started;     // or time of disconnect for zombies
        !           158:        qboolean                send_message;           // set on frames a datagram arived on
        !           159: 
        !           160: // spawn parms are carried from level to level
        !           161:        float                   spawn_parms[NUM_SPAWN_PARMS];
        !           162: 
        !           163: // client known data for deltas        
        !           164:        int                             old_frags;
        !           165:        
        !           166:        int                             stats[MAX_CL_STATS];
        !           167: 
        !           168: 
        !           169:        client_frame_t  frames[UPDATE_BACKUP];  // updates can be deltad from here
        !           170: 
        !           171:        FILE                    *download;                      // file being downloaded
        !           172:        int                             downloadsize;           // total bytes
        !           173:        int                             downloadcount;          // bytes sent
        !           174: 
        !           175:        int                             spec_track;                     // entnum of player tracking
        !           176: 
        !           177:        double                  whensaid[10];       // JACK: For floodprots
        !           178:        int                     whensaidhead;       // Head value for floodprots
        !           179:        double                  lockedtill;
        !           180: 
        !           181:        qboolean                upgradewarn;            // did we warn him?
        !           182: 
        !           183:        FILE                    *upload;
        !           184:        char                    uploadfn[MAX_QPATH];
        !           185:        netadr_t                snap_from;
        !           186:        qboolean                remote_snap;
        !           187:  
        !           188: //===== NETWORK ============
        !           189:        int                             chokecount;
        !           190:        int                             delta_sequence;         // -1 = no compression
        !           191:        netchan_t               netchan;
        !           192: } client_t;
        !           193: 
        !           194: // a client can leave the server in one of four ways:
        !           195: // dropping properly by quiting or disconnecting
        !           196: // timing out if no valid messages are received for timeout.value seconds
        !           197: // getting kicked off by the server operator
        !           198: // a program error, like an overflowed reliable buffer
        !           199: 
        !           200: //=============================================================================
        !           201: 
        !           202: 
        !           203: #define        STATFRAMES      100
        !           204: typedef struct
        !           205: {
        !           206:        double  active;
        !           207:        double  idle;
        !           208:        int             count;
        !           209:        int             packets;
        !           210: 
        !           211:        double  latched_active;
        !           212:        double  latched_idle;
        !           213:        int             latched_packets;
        !           214: } svstats_t;
        !           215: 
        !           216: // MAX_CHALLENGES is made large to prevent a denial
        !           217: // of service attack that could cycle all of them
        !           218: // out before legitimate users connected
        !           219: #define        MAX_CHALLENGES  1024
        !           220: 
        !           221: typedef struct
        !           222: {
        !           223:        netadr_t        adr;
        !           224:        int                     challenge;
        !           225:        int                     time;
        !           226: } challenge_t;
        !           227: 
        !           228: typedef struct
        !           229: {
        !           230:        int                     spawncount;                     // number of servers spawned since start,
        !           231:                                                                        // used to check late spawns
        !           232:        client_t        clients[MAX_CLIENTS];
        !           233:        int                     serverflags;            // episode completion information
        !           234:        
        !           235:        double          last_heartbeat;
        !           236:        int                     heartbeat_sequence;
        !           237:        svstats_t       stats;
        !           238: 
        !           239:        char            info[MAX_SERVERINFO_STRING];
        !           240: 
        !           241:        // log messages are used so that fraglog processes can get stats
        !           242:        int                     logsequence;    // the message currently being filled
        !           243:        double          logtime;                // time of last swap
        !           244:        sizebuf_t       log[2];
        !           245:        byte            log_buf[2][MAX_DATAGRAM];
        !           246: 
        !           247:        challenge_t     challenges[MAX_CHALLENGES];     // to prevent invalid IPs from connecting
        !           248: } server_static_t;
        !           249: 
        !           250: //=============================================================================
        !           251: 
        !           252: // edict->movetype values
        !           253: #define        MOVETYPE_NONE                   0               // never moves
        !           254: #define        MOVETYPE_ANGLENOCLIP    1
        !           255: #define        MOVETYPE_ANGLECLIP              2
        !           256: #define        MOVETYPE_WALK                   3               // gravity
        !           257: #define        MOVETYPE_STEP                   4               // gravity, special edge handling
        !           258: #define        MOVETYPE_FLY                    5
        !           259: #define        MOVETYPE_TOSS                   6               // gravity
        !           260: #define        MOVETYPE_PUSH                   7               // no clip to world, push and crush
        !           261: #define        MOVETYPE_NOCLIP                 8
        !           262: #define        MOVETYPE_FLYMISSILE             9               // extra size to monsters
        !           263: #define        MOVETYPE_BOUNCE                 10
        !           264: 
        !           265: // edict->solid values
        !           266: #define        SOLID_NOT                               0               // no interaction with other objects
        !           267: #define        SOLID_TRIGGER                   1               // touch on edge, but not blocking
        !           268: #define        SOLID_BBOX                              2               // touch on edge, block
        !           269: #define        SOLID_SLIDEBOX                  3               // touch on edge, but not an onground
        !           270: #define        SOLID_BSP                               4               // bsp clip, touch on edge, block
        !           271: 
        !           272: // edict->deadflag values
        !           273: #define        DEAD_NO                                 0
        !           274: #define        DEAD_DYING                              1
        !           275: #define        DEAD_DEAD                               2
        !           276: 
        !           277: #define        DAMAGE_NO                               0
        !           278: #define        DAMAGE_YES                              1
        !           279: #define        DAMAGE_AIM                              2
        !           280: 
        !           281: // edict->flags
        !           282: #define        FL_FLY                                  1
        !           283: #define        FL_SWIM                                 2
        !           284: #define        FL_GLIMPSE                              4
        !           285: #define        FL_CLIENT                               8
        !           286: #define        FL_INWATER                              16
        !           287: #define        FL_MONSTER                              32
        !           288: #define        FL_GODMODE                              64
        !           289: #define        FL_NOTARGET                             128
        !           290: #define        FL_ITEM                                 256
        !           291: #define        FL_ONGROUND                             512
        !           292: #define        FL_PARTIALGROUND                1024    // not all corners are valid
        !           293: #define        FL_WATERJUMP                    2048    // player jumping out of water
        !           294: 
        !           295: // entity effects
        !           296: 
        !           297: //define       EF_BRIGHTFIELD                  1
        !           298: //define       EF_MUZZLEFLASH                  2
        !           299: #define        EF_BRIGHTLIGHT                  4
        !           300: #define        EF_DIMLIGHT                     8
        !           301: 
        !           302: 
        !           303: #define        SPAWNFLAG_NOT_EASY                      256
        !           304: #define        SPAWNFLAG_NOT_MEDIUM            512
        !           305: #define        SPAWNFLAG_NOT_HARD                      1024
        !           306: #define        SPAWNFLAG_NOT_DEATHMATCH        2048
        !           307: 
        !           308: #define        MULTICAST_ALL                   0
        !           309: #define        MULTICAST_PHS                   1
        !           310: #define        MULTICAST_PVS                   2
        !           311: 
        !           312: #define        MULTICAST_ALL_R                 3
        !           313: #define        MULTICAST_PHS_R                 4
        !           314: #define        MULTICAST_PVS_R                 5
        !           315: 
        !           316: //============================================================================
        !           317: 
        !           318: extern cvar_t  sv_mintic, sv_maxtic;
        !           319: extern cvar_t  sv_maxspeed;
        !           320: 
        !           321: extern netadr_t        master_adr[MAX_MASTERS];        // address of the master server
        !           322: 
        !           323: extern cvar_t  spawn;
        !           324: extern cvar_t  teamplay;
        !           325: extern cvar_t  deathmatch;
        !           326: extern cvar_t  fraglimit;
        !           327: extern cvar_t  timelimit;
        !           328: 
        !           329: extern server_static_t svs;                            // persistant server info
        !           330: extern server_t                sv;                                     // local server
        !           331: 
        !           332: extern client_t        *host_client;
        !           333: 
        !           334: extern edict_t         *sv_player;
        !           335: 
        !           336: extern char            localmodels[MAX_MODELS][5];     // inline model names for precache
        !           337: 
        !           338: extern char            localinfo[MAX_LOCALINFO_STRING+1];
        !           339: 
        !           340: extern int                     host_hunklevel;
        !           341: extern FILE            *sv_logfile;
        !           342: extern FILE            *sv_fraglogfile;
        !           343: 
        !           344: //===========================================================
        !           345: 
        !           346: //
        !           347: // sv_main.c
        !           348: //
        !           349: void SV_Shutdown (void);
        !           350: void SV_Frame (float time);
        !           351: void SV_FinalMessage (char *message);
        !           352: void SV_DropClient (client_t *drop);
        !           353: 
        !           354: int SV_CalcPing (client_t *cl);
        !           355: void SV_FullClientUpdate (client_t *client, sizebuf_t *buf);
        !           356: 
        !           357: int SV_ModelIndex (char *name);
        !           358: 
        !           359: qboolean SV_CheckBottom (edict_t *ent);
        !           360: qboolean SV_movestep (edict_t *ent, vec3_t move, qboolean relink);
        !           361: 
        !           362: void SV_WriteClientdataToMessage (client_t *client, sizebuf_t *msg);
        !           363: 
        !           364: void SV_MoveToGoal (void);
        !           365: 
        !           366: void SV_SaveSpawnparms (void);
        !           367: 
        !           368: void SV_Physics_Client (edict_t        *ent);
        !           369: 
        !           370: void SV_ExecuteUserCommand (char *s);
        !           371: void SV_InitOperatorCommands (void);
        !           372: 
        !           373: void SV_SendServerinfo (client_t *client);
        !           374: void SV_ExtractFromUserinfo (client_t *cl);
        !           375: 
        !           376: 
        !           377: void Master_Heartbeat (void);
        !           378: void Master_Packet (void);
        !           379: 
        !           380: //
        !           381: // sv_init.c
        !           382: //
        !           383: void SV_SpawnServer (char *server);
        !           384: void SV_FlushSignon (void);
        !           385: 
        !           386: 
        !           387: //
        !           388: // sv_phys.c
        !           389: //
        !           390: void SV_ProgStartFrame (void);
        !           391: void SV_Physics (void);
        !           392: void SV_CheckVelocity (edict_t *ent);
        !           393: void SV_AddGravity (edict_t *ent, float scale);
        !           394: qboolean SV_RunThink (edict_t *ent);
        !           395: void SV_Physics_Toss (edict_t *ent);
        !           396: void SV_RunNewmis (void);
        !           397: void SV_Impact (edict_t *e1, edict_t *e2);
        !           398: void SV_SetMoveVars(void);
        !           399: 
        !           400: //
        !           401: // sv_send.c
        !           402: //
        !           403: void SV_SendClientMessages (void);
        !           404: 
        !           405: void SV_Multicast (vec3_t origin, int to);
        !           406: void SV_StartSound (edict_t *entity, int channel, char *sample, int volume,
        !           407:     float attenuation);
        !           408: void SV_ClientPrintf (client_t *cl, int level, char *fmt, ...);
        !           409: void SV_BroadcastPrintf (int level, char *fmt, ...);
        !           410: void SV_BroadcastCommand (char *fmt, ...);
        !           411: void SV_SendMessagesToAll (void);
        !           412: void SV_FindModelNumbers (void);
        !           413: 
        !           414: //
        !           415: // sv_user.c
        !           416: //
        !           417: void SV_ExecuteClientMessage (client_t *cl);
        !           418: void SV_UserInit (void);
        !           419: void SV_TogglePause (const char *msg);
        !           420: 
        !           421: 
        !           422: //
        !           423: // svonly.c
        !           424: //
        !           425: typedef enum {RD_NONE, RD_CLIENT, RD_PACKET} redirect_t;
        !           426: void SV_BeginRedirect (redirect_t rd);
        !           427: void SV_EndRedirect (void);
        !           428: 
        !           429: //
        !           430: // sv_ccmds.c
        !           431: //
        !           432: void SV_Status_f (void);
        !           433: 
        !           434: //
        !           435: // sv_ents.c
        !           436: //
        !           437: void SV_WriteEntitiesToClient (client_t *client, sizebuf_t *msg);
        !           438: 
        !           439: //
        !           440: // sv_nchan.c
        !           441: //
        !           442: 
        !           443: void ClientReliableCheckBlock(client_t *cl, int maxsize);
        !           444: void ClientReliable_FinishWrite(client_t *cl);
        !           445: void ClientReliableWrite_Begin(client_t *cl, int c, int maxsize);
        !           446: void ClientReliableWrite_Angle(client_t *cl, float f);
        !           447: void ClientReliableWrite_Angle16(client_t *cl, float f);
        !           448: void ClientReliableWrite_Byte(client_t *cl, int c);
        !           449: void ClientReliableWrite_Char(client_t *cl, int c);
        !           450: void ClientReliableWrite_Float(client_t *cl, float f);
        !           451: void ClientReliableWrite_Coord(client_t *cl, float f);
        !           452: void ClientReliableWrite_Long(client_t *cl, int c);
        !           453: void ClientReliableWrite_Short(client_t *cl, int c);
        !           454: void ClientReliableWrite_String(client_t *cl, char *s);
        !           455: void ClientReliableWrite_SZ(client_t *cl, void *data, int len);
        !           456: 

unix.superglobalmegacorp.com

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