2 * Copyright (C) Volition, Inc. 1999. All rights reserved.
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
10 * $Logfile: /Freespace2/code/Network/multi_ping.h $
16 * Revision 1.3 2002/06/09 04:41:14 relnev
17 * added copyright header
19 * Revision 1.2 2002/05/27 00:40:47 theoddone33
20 * Fix net_addr vs net_addr_t
22 * Revision 1.1.1.1 2002/05/03 03:28:12 root
26 * 2 10/07/98 10:53a Dave
29 * 1 10/07/98 10:50a Dave
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.
35 * 2 6/12/98 2:49p Dave
38 * 1 3/03/98 5:09p Dave
43 #ifndef _MULTIPLAYER_PING_HEADER_FILE
44 #define _MULTIPLAYER_PING_HEADER_FILE
46 // ------------------------------------------------------------------------------------
47 // MULTIPLAYER PING DEFINES/VARS
53 // the max ping we'll store to calculate the average
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
62 int ping_avg; // in ms, this is the only thing we should be concerned with
66 // ------------------------------------------------------------------------------------
67 // MULTIPLAYER PING FUNCTIONS
70 // initialize all player ping times
71 void multi_ping_reset_players();
73 // initialize the given ping struct
74 void multi_ping_reset(ping_struct *ps);
76 // start a ping - call this when sending a ping packet
77 void multi_ping_start(ping_struct *ps);
79 // evaluate a pong return on the given struct
80 void multi_ping_eval_pong(ping_struct *ps);
82 // send a ping to a specific player
83 void multi_ping_send(net_player *p);
85 // send a ping to the specified address
86 void multi_ping_send(net_addr_t *addr,ping_struct *ps);
88 // send a ping to all players
89 void multi_ping_send_all();
91 // get the lowest existing ping in the ping struct, returning -1 if no pings
92 int multi_ping_get_lowest(ping_struct *ps);
94 // (average ping + lowest ping)/2
95 int multi_ping_lowest_avg(ping_struct *ps);