Annotation of quakeworld/client/net.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: // net.h -- quake's interface to the networking layer
        !            21: 
        !            22: #define        PORT_ANY        -1
        !            23: 
        !            24: typedef struct
        !            25: {
        !            26:        byte    ip[4];
        !            27:        unsigned short  port;
        !            28:        unsigned short  pad;
        !            29: } netadr_t;
        !            30: 
        !            31: extern netadr_t        net_local_adr;
        !            32: extern netadr_t        net_from;               // address of who sent the packet
        !            33: extern sizebuf_t       net_message;
        !            34: 
        !            35: extern cvar_t  hostname;
        !            36: 
        !            37: extern int             net_socket;
        !            38: 
        !            39: void           NET_Init (int port);
        !            40: void           NET_Shutdown (void);
        !            41: qboolean       NET_GetPacket (void);
        !            42: void           NET_SendPacket (int length, void *data, netadr_t to);
        !            43: 
        !            44: qboolean       NET_CompareAdr (netadr_t a, netadr_t b);
        !            45: qboolean       NET_CompareBaseAdr (netadr_t a, netadr_t b);
        !            46: char           *NET_AdrToString (netadr_t a);
        !            47: char           *NET_BaseAdrToString (netadr_t a);
        !            48: qboolean       NET_StringToAdr (char *s, netadr_t *a);
        !            49: qboolean NET_IsClientLegal(netadr_t *adr);
        !            50: 
        !            51: //============================================================================
        !            52: 
        !            53: #define        OLD_AVG         0.99            // total = oldtotal*OLD_AVG + new*(1-OLD_AVG)
        !            54: 
        !            55: #define        MAX_LATENT      32
        !            56: 
        !            57: typedef struct
        !            58: {
        !            59:        qboolean        fatal_error;
        !            60: 
        !            61:        float           last_received;          // for timeouts
        !            62: 
        !            63: // the statistics are cleared at each client begin, because
        !            64: // the server connecting process gives a bogus picture of the data
        !            65:        float           frame_latency;          // rolling average
        !            66:        float           frame_rate;
        !            67: 
        !            68:        int                     drop_count;                     // dropped packets, cleared each level
        !            69:        int                     good_count;                     // cleared each level
        !            70: 
        !            71:        netadr_t        remote_address;
        !            72:        int                     qport;
        !            73: 
        !            74: // bandwidth estimator
        !            75:        double          cleartime;                      // if realtime > nc->cleartime, free to go
        !            76:        double          rate;                           // seconds / byte
        !            77: 
        !            78: // sequencing variables
        !            79:        int                     incoming_sequence;
        !            80:        int                     incoming_acknowledged;
        !            81:        int                     incoming_reliable_acknowledged; // single bit
        !            82: 
        !            83:        int                     incoming_reliable_sequence;             // single bit, maintained local
        !            84: 
        !            85:        int                     outgoing_sequence;
        !            86:        int                     reliable_sequence;                      // single bit
        !            87:        int                     last_reliable_sequence;         // sequence number of last send
        !            88: 
        !            89: // reliable staging and holding areas
        !            90:        sizebuf_t       message;                // writing buffer to send to server
        !            91:        byte            message_buf[MAX_MSGLEN];
        !            92: 
        !            93:        int                     reliable_length;
        !            94:        byte            reliable_buf[MAX_MSGLEN];       // unacked reliable message
        !            95: 
        !            96: // time and size data to calculate bandwidth
        !            97:        int                     outgoing_size[MAX_LATENT];
        !            98:        double          outgoing_time[MAX_LATENT];
        !            99: } netchan_t;
        !           100: 
        !           101: extern int     net_drop;               // packets dropped before this one
        !           102: 
        !           103: void Netchan_Init (void);
        !           104: void Netchan_Transmit (netchan_t *chan, int length, byte *data);
        !           105: void Netchan_OutOfBand (netadr_t adr, int length, byte *data);
        !           106: void Netchan_OutOfBandPrint (netadr_t adr, char *format, ...);
        !           107: qboolean Netchan_Process (netchan_t *chan);
        !           108: void Netchan_Setup (netchan_t *chan, netadr_t adr, int qport);
        !           109: 
        !           110: qboolean Netchan_CanPacket (netchan_t *chan);
        !           111: qboolean Netchan_CanReliable (netchan_t *chan);
        !           112: 

unix.superglobalmegacorp.com

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