2 * Copyright (C) 2021-2024 Mt.ZERO Software, Harry Godden - All Rights Reserved
3 * All trademarks are property of their respective owners
7 #include "vg/vg_platform.h"
8 #include "vg/vg_steam_networking.h"
9 #include "vg/vg_mem_pool.h"
10 #include "vg/vg_msg.h"
12 #include "network_common.h"
13 #include "network_msg.h"
14 #include "addon_types.h"
16 #define NETWORK_MAX_REQUESTS 8
22 /* Call it at start; Connects us to the gameserver */
23 void network_init(void);
25 /* Run this from main loop */
26 void network_update(void);
28 /* Call it at shutdown */
29 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 void network_submit_highscore( u32 trackid
, u16 points
, u16 time
);
38 * Game endpoints are provided with the same names to allow running without a
44 u8 app_symmetric_key
[ 1024 ];
46 EServerMode auth_mode
;
48 HSteamNetConnection remote
;
49 ESteamNetworkingConnectionState state
;
52 f64 last_attempt
, last_frame
;
58 struct network_request
{
59 vg_pool_node poolnode
;
60 void (*callback
)( netmsg_request
*res
, vg_msg
*body
, u64 userdata
);
67 SteamNetworkingIPAddr ip
;
68 char host_port
[8], host_adress
[256];
72 k_server_intent_offline
,
73 k_server_intent_online
76 f64 last_intent_change
;
77 f32 fintent
; /* yeah this shit really shouldnt be here but oh well */
79 extern network_client
;
81 int packet_minsize( SteamNetworkingMessage_t
*msg
, u32 size
);
82 void network_send_item( enum netmsg_playeritem_type type
);
83 void network_request_scoreboard( const char *mod_uid
,
84 const char *route_uid
,
85 u32 week
, u64 userdata
);
86 void network_publish_laptime( const char *mod_uid
,
87 const char *route_uid
, f64 lap_time
);
88 void chat_send_message( const char *message
);
89 void render_server_status_gui(void);
90 void network_status_string( vg_str
*str
, u32
*colour
);
91 void network_send_region(void);
92 void network_set_host( const char *host_str
, const char *port_str
);
94 static inline int network_connected(void)
96 if( network_client
.remote_version
!= NETWORK_SKATERIFT_VERSION
) return 0;
97 return network_client
.state
== k_ESteamNetworkingConnectionState_Connected
;