2 * Copyright (C) 2021-2022 Mt.ZERO Software, Harry Godden - All Rights Reserved
3 * All trademarks are property of their respective owners
9 #include "vg/vg_stdint.h"
11 #include "network_common.h"
12 #include "network_msg.h"
13 #include "highscores.h"
14 #include "addon_types.h"
16 #define NETWORK_MAX_REQUESTS 8
22 /* Call it at start; Connects us to the gameserver */
23 static void network_init(void);
25 /* Run this from main loop */
26 static void network_update(void);
28 /* Call it at shutdown */
29 static void network_end(void);
32 * Can buffer up a bunch of these by calling many times, they will be
33 * sent at the next connection
35 static void network_submit_highscore( u32 trackid
, u16 points
, u16 time
);
38 * Game endpoints are provided with the same names to allow running without a
43 u8 app_symmetric_key
[ 1024 ];
45 EServerMode auth_mode
;
47 HSteamNetConnection remote
;
48 ESteamNetworkingConnectionState state
;
51 f64 last_attempt
, last_frame
;
56 struct network_request
{
57 vg_pool_node poolnode
;
58 void (*callback
)( netmsg_request
*res
, vg_msg
*body
, u64 userdata
);
65 char server_adress
[64];
67 static network_client
= {
68 .auth_mode
= eServerModeAuthentication
,
69 .state
= k_ESteamNetworkingConnectionState_None
,
70 .server_adress
= "46.101.34.155"
73 static int packet_minsize( SteamNetworkingMessage_t
*msg
, u32 size
);
74 static void network_send_item( enum netmsg_playeritem_type type
);
75 static void network_request_scoreboard( const char *mod_uid
,
76 const char *route_uid
,
77 u32 week
, u64 userdata
);
78 static void network_publish_laptime( const char *mod_uid
,
79 const char *route_uid
, f64 lap_time
);
80 static void chat_send_message( const char *message
);
82 static int network_connected(void){
83 if( network_client
.remote_version
!= NETWORK_SKATERIFT_VERSION
) return 0;
84 return network_client
.state
== k_ESteamNetworkingConnectionState_Connected
;
87 #endif /* NETWORK_H */