2 * $Logfile: /Freespace2/code/Network/multi_ping.h $
8 * Revision 1.1 2002/05/03 03:28:12 root
12 * 2 10/07/98 10:53a Dave
15 * 1 10/07/98 10:50a Dave
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.
21 * 2 6/12/98 2:49p Dave
24 * 1 3/03/98 5:09p Dave
29 #ifndef _MULTIPLAYER_PING_HEADER_FILE
30 #define _MULTIPLAYER_PING_HEADER_FILE
32 // ------------------------------------------------------------------------------------
33 // MULTIPLAYER PING DEFINES/VARS
40 // the max ping we'll store to calculate the average
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
49 int ping_avg; // in ms, this is the only thing we should be concerned with
53 // ------------------------------------------------------------------------------------
54 // MULTIPLAYER PING FUNCTIONS
57 // initialize all player ping times
58 void multi_ping_reset_players();
60 // initialize the given ping struct
61 void multi_ping_reset(ping_struct *ps);
63 // start a ping - call this when sending a ping packet
64 void multi_ping_start(ping_struct *ps);
66 // evaluate a pong return on the given struct
67 void multi_ping_eval_pong(ping_struct *ps);
69 // send a ping to a specific player
70 void multi_ping_send(net_player *p);
72 // send a ping to the specified address
73 void multi_ping_send(net_addr *addr,ping_struct *ps);
75 // send a ping to all players
76 void multi_ping_send_all();
78 // get the lowest existing ping in the ping struct, returning -1 if no pings
79 int multi_ping_get_lowest(ping_struct *ps);
81 // (average ping + lowest ping)/2
82 int multi_ping_lowest_avg(ping_struct *ps);