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