2 * $Logfile: /Freespace2/code/Network/multi_ping.h $
8 * Revision 1.2 2002/05/27 00:40:47 theoddone33
9 * Fix net_addr vs net_addr_t
11 * Revision 1.1.1.1 2002/05/03 03:28:12 root
15 * 2 10/07/98 10:53a Dave
18 * 1 10/07/98 10:50a Dave
20 * 3 6/30/98 2:17p Dave
21 * Revised object update system. Removed updates for all weapons. Put
22 * button info back into control info packet.
24 * 2 6/12/98 2:49p Dave
27 * 1 3/03/98 5:09p Dave
32 #ifndef _MULTIPLAYER_PING_HEADER_FILE
33 #define _MULTIPLAYER_PING_HEADER_FILE
35 // ------------------------------------------------------------------------------------
36 // MULTIPLAYER PING DEFINES/VARS
42 // the max ping we'll store to calculate the average
45 typedef struct ping_struct {
46 float ping_start; // time the current ping was sent out, or -1 if none
47 float ping_times[MAX_PINGS]; // ping times for calculating the average
48 int num_pings; // # of pings in the ping_times array
49 int ping_add; // where to add the next ping
51 int ping_avg; // in ms, this is the only thing we should be concerned with
55 // ------------------------------------------------------------------------------------
56 // MULTIPLAYER PING FUNCTIONS
59 // initialize all player ping times
60 void multi_ping_reset_players();
62 // initialize the given ping struct
63 void multi_ping_reset(ping_struct *ps);
65 // start a ping - call this when sending a ping packet
66 void multi_ping_start(ping_struct *ps);
68 // evaluate a pong return on the given struct
69 void multi_ping_eval_pong(ping_struct *ps);
71 // send a ping to a specific player
72 void multi_ping_send(net_player *p);
74 // send a ping to the specified address
75 void multi_ping_send(net_addr_t *addr,ping_struct *ps);
77 // send a ping to all players
78 void multi_ping_send_all();
80 // get the lowest existing ping in the ping struct, returning -1 if no pings
81 int multi_ping_get_lowest(ping_struct *ps);
83 // (average ping + lowest ping)/2
84 int multi_ping_lowest_avg(ping_struct *ps);