move audio comp to its own thing
[carveJwlIkooP6JGAAIwe30JlM.git] / network_common.h
1 #ifndef NETWORK_COMMON_H
2 #define NETWORK_COMMON_H
3
4 #include "vg/vg_stdint.h"
5 #include "vg/vg_platform.h"
6
7 #define NETWORK_USERNAME_MAX 32
8 #define NETWORK_MAX_PLAYERS 20
9 #define NETWORK_FRAMERATE 0.1
10 #define NETWORK_BUFFERFRAMES 6
11 #define NETWORK_MAX_CHAT 128
12 #define NETWORK_REGION_MAX 32
13 #define NETWORK_SKATERIFT_VERSION 9
14 #define NETWORK_REQUEST_MAX 2048
15
16 #define NETWORK_LEADERBOARD_ALLTIME 0
17 #define NETWORK_LEADERBOARD_CURRENT_WEEK 1
18 #define NETWORK_LEADERBOARD_ALLTIME_AND_CURRENT_WEEK 2
19 #define NETWORK_PORT 27403
20 #define NETWORK_PORT_STR(STR, X) STR #X
21
22 #include "addon_types.h"
23
24 static u32 network_msgstring( const char *src,
25 u32 m_cbSize, u32 base_size,
26 char *buf, u32 buf_size ){
27
28 u32 string_len = VG_MIN( m_cbSize - base_size, buf_size );
29 return vg_strncpy( src, buf, string_len, k_strncpy_always_add_null );
30 }
31
32 static u32 network_pair_index( u32 _a, u32 _b ){
33 const u32 N = NETWORK_MAX_PLAYERS;
34 assert( (_a != _b) && (_a<N) && (_b<N) );
35
36 u32 a = VG_MIN( _a, _b ),
37 b = VG_MAX( _a, _b );
38
39 return ((N-a)*((N-a)-1))/2 - b + a;
40 }
41
42 #endif /* NETWORK_COMMON_H */