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_platform.h"
11 #include "network_common.h"
12 #include "network_msg.h"
13 #include "addon_types.h"
15 #define NETWORK_MAX_REQUESTS 8
21 /* Call it at start; Connects us to the gameserver */
22 static void network_init(void);
24 /* Run this from main loop */
25 static void network_update(void);
27 /* Call it at shutdown */
28 static void network_end(void);
31 * Can buffer up a bunch of these by calling many times, they will be
32 * sent at the next connection
34 static void network_submit_highscore( u32 trackid
, u16 points
, u16 time
);
37 * Game endpoints are provided with the same names to allow running without a
42 u8 app_symmetric_key
[ 1024 ];
44 EServerMode auth_mode
;
46 HSteamNetConnection remote
;
47 ESteamNetworkingConnectionState state
;
50 f64 last_attempt
, last_frame
;
55 struct network_request
{
56 vg_pool_node poolnode
;
57 void (*callback
)( netmsg_request
*res
, vg_msg
*body
, u64 userdata
);
64 char server_adress
[64];
67 k_server_intent_offline
,
68 k_server_intent_online
71 f64 last_intent_change
;
72 f32 fintent
; /* yeah this shit really shouldnt be here but oh well */
74 static network_client
= {
75 .auth_mode
= eServerModeAuthentication
,
76 .state
= k_ESteamNetworkingConnectionState_None
,
77 .server_adress
= "46.101.34.155",
78 .last_intent_change
= -99999.9
81 static int packet_minsize( SteamNetworkingMessage_t
*msg
, u32 size
);
82 static void network_send_item( enum netmsg_playeritem_type type
);
83 static void network_request_scoreboard( const char *mod_uid
,
84 const char *route_uid
,
85 u32 week
, u64 userdata
);
86 static void network_publish_laptime( const char *mod_uid
,
87 const char *route_uid
, f64 lap_time
);
88 static void chat_send_message( const char *message
);
89 static void render_server_status_gui(void);
90 static void network_status_string( vg_str
*str
, u32
*colour
);
91 static void network_send_region(void);
93 static int network_connected(void){
94 if( network_client
.remote_version
!= NETWORK_SKATERIFT_VERSION
) return 0;
95 return network_client
.state
== k_ESteamNetworkingConnectionState_Connected
;
98 #endif /* NETWORK_H */