]> icculus.org git repositories - taylor/freespace2.git/blob - include/multi_ping.h
Fix net_addr vs net_addr_t
[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.2  2002/05/27 00:40:47  theoddone33
9  * Fix net_addr vs net_addr_t
10  *
11  * Revision 1.1.1.1  2002/05/03 03:28:12  root
12  * Initial import.
13  *  
14  * 
15  * 2     10/07/98 10:53a Dave
16  * Initial checkin.
17  * 
18  * 1     10/07/98 10:50a Dave
19  * 
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.
23  * 
24  * 2     6/12/98 2:49p Dave
25  * Patch 1.02 changes.
26  * 
27  * 1     3/03/98 5:09p Dave
28  *  
29  * $NoKeywords: $
30  */
31
32 #ifndef _MULTIPLAYER_PING_HEADER_FILE
33 #define _MULTIPLAYER_PING_HEADER_FILE
34
35 // ------------------------------------------------------------------------------------
36 // MULTIPLAYER PING DEFINES/VARS
37 //
38
39 struct header;
40 struct net_player;
41
42 // the max ping we'll store to calculate the average
43 #define MAX_PINGS                                       10
44
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
50
51         int ping_avg;                                                                                   // in ms, this is the only thing we should be concerned with
52 } ping_struct;
53
54
55 // ------------------------------------------------------------------------------------
56 // MULTIPLAYER PING FUNCTIONS
57 //
58
59 // initialize all player ping times
60 void multi_ping_reset_players();
61
62 // initialize the given ping struct
63 void multi_ping_reset(ping_struct *ps);
64
65 // start a ping - call this when sending a ping packet
66 void multi_ping_start(ping_struct *ps);
67
68 // evaluate a pong return on the given struct
69 void multi_ping_eval_pong(ping_struct *ps);
70
71 // send a ping to a specific player
72 void multi_ping_send(net_player *p);
73
74 // send a ping to the specified address
75 void multi_ping_send(net_addr_t *addr,ping_struct *ps);
76
77 // send a ping to all players
78 void multi_ping_send_all();
79
80 // get the lowest existing ping in the ping struct, returning -1 if no pings
81 int multi_ping_get_lowest(ping_struct *ps);
82
83 // (average ping + lowest ping)/2
84 int multi_ping_lowest_avg(ping_struct *ps);
85
86 #endif
87