File: multi_ping.h

package info (click to toggle)
freespace2 3.7.0%2Brepack-2
  • links: PTS, VCS
  • area: non-free
  • in suites: jessie, jessie-kfreebsd
  • size: 22,848 kB
  • ctags: 41,897
  • sloc: cpp: 369,931; makefile: 1,060; xml: 129; sh: 112
file content (61 lines) | stat: -rw-r--r-- 1,682 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/*
 * Copyright (C) Volition, Inc. 1999.  All rights reserved.
 *
 * All source code herein is the property of Volition, Inc. You may not sell 
 * or otherwise commercially exploit the source or things you created based on the 
 * source.
 *
*/



#ifndef _MULTIPLAYER_PING_HEADER_FILE
#define _MULTIPLAYER_PING_HEADER_FILE

// ------------------------------------------------------------------------------------
// MULTIPLAYER PING DEFINES/VARS
//

struct header;
struct net_addr;
struct net_player;

// the max ping we'll store to calculate the average
#define MAX_PINGS					10

typedef struct ping_struct {
	float ping_start;										// time the current ping was sent out, or -1 if none
	float ping_times[MAX_PINGS];						// ping times for calculating the average
	int num_pings;											// # of pings in the ping_times array
	int ping_add;											// where to add the next ping

	int ping_avg;											// in ms, this is the only thing we should be concerned with
} ping_struct;


// ------------------------------------------------------------------------------------
// MULTIPLAYER PING FUNCTIONS
//

// initialize all player ping times
void multi_ping_reset_players();

// initialize the given ping struct
void multi_ping_reset(ping_struct *ps);

// start a ping - call this when sending a ping packet
void multi_ping_start(ping_struct *ps);

// evaluate a pong return on the given struct
void multi_ping_eval_pong(ping_struct *ps);

// send a ping to a specific player
void multi_ping_send(net_player *p);

// send a ping to the specified address
void multi_ping_send(net_addr *addr,ping_struct *ps);

// send a ping to all players
void multi_ping_send_all();

#endif