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