]> icculus.org git repositories - taylor/freespace2.git/blob - include/multi_ping.h
Initial revision
[taylor/freespace2.git] / include / multi_ping.h
1 /*
2  * $Logfile: /Freespace2/code/Network/multi_ping.h $
3  * $Revision$
4  * $Date$
5  * $Author$
6  *
7  * $Log$
8  * Revision 1.1  2002/05/03 03:28:12  root
9  * Initial revision
10  *  
11  * 
12  * 2     10/07/98 10:53a Dave
13  * Initial checkin.
14  * 
15  * 1     10/07/98 10:50a Dave
16  * 
17  * 3     6/30/98 2:17p Dave
18  * Revised object update system. Removed updates for all weapons. Put
19  * button info back into control info packet.
20  * 
21  * 2     6/12/98 2:49p Dave
22  * Patch 1.02 changes.
23  * 
24  * 1     3/03/98 5:09p Dave
25  *  
26  * $NoKeywords: $
27  */
28
29 #ifndef _MULTIPLAYER_PING_HEADER_FILE
30 #define _MULTIPLAYER_PING_HEADER_FILE
31
32 // ------------------------------------------------------------------------------------
33 // MULTIPLAYER PING DEFINES/VARS
34 //
35
36 struct header;
37 struct net_addr;
38 struct net_player;
39
40 // the max ping we'll store to calculate the average
41 #define MAX_PINGS                                       10
42
43 typedef struct ping_struct {
44         float ping_start;                                                                               // time the current ping was sent out, or -1 if none
45         float ping_times[MAX_PINGS];                                            // ping times for calculating the average
46         int num_pings;                                                                                  // # of pings in the ping_times array
47         int ping_add;                                                                                   // where to add the next ping
48
49         int ping_avg;                                                                                   // in ms, this is the only thing we should be concerned with
50 } ping_struct;
51
52
53 // ------------------------------------------------------------------------------------
54 // MULTIPLAYER PING FUNCTIONS
55 //
56
57 // initialize all player ping times
58 void multi_ping_reset_players();
59
60 // initialize the given ping struct
61 void multi_ping_reset(ping_struct *ps);
62
63 // start a ping - call this when sending a ping packet
64 void multi_ping_start(ping_struct *ps);
65
66 // evaluate a pong return on the given struct
67 void multi_ping_eval_pong(ping_struct *ps);
68
69 // send a ping to a specific player
70 void multi_ping_send(net_player *p);
71
72 // send a ping to the specified address
73 void multi_ping_send(net_addr *addr,ping_struct *ps);
74
75 // send a ping to all players
76 void multi_ping_send_all();
77
78 // get the lowest existing ping in the ping struct, returning -1 if no pings
79 int multi_ping_get_lowest(ping_struct *ps);
80
81 // (average ping + lowest ping)/2
82 int multi_ping_lowest_avg(ping_struct *ps);
83
84 #endif
85