X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=network.h;h=2916ad94a824f6f9a5d543daa2e1e319d8ac14ec;hb=f6bc1299d5b30e1aba87e6ce084bcd7eed22975f;hp=6121f0fb8b22a460df51483aa1caf4ca4bb141af;hpb=a5cdfe2fc872f03c7988d63498abb7e7827325c1;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/network.h b/network.h index 6121f0f..2916ad9 100644 --- a/network.h +++ b/network.h @@ -10,8 +10,11 @@ #include "steam.h" #include "network_msg.h" #include "highscores.h" +#include "addon_types.h" -VG_STATIC int network_scores_updated = 0; +#define NETWORK_MAX_REQUESTS 8 + +static int network_scores_updated = 0; /* * Interface @@ -19,50 +22,57 @@ VG_STATIC int network_scores_updated = 0; //#define SR_USE_LOCALHOST /* Call it at start; Connects us to the gameserver */ -VG_STATIC void network_init(void); +static void network_init(void); /* Run this from main loop */ -VG_STATIC void network_update(void); +static void network_update(void); /* Call it at shutdown */ -VG_STATIC void network_end(void); +static void network_end(void); /* * Can buffer up a bunch of these by calling many times, they will be * sent at the next connection */ -VG_STATIC void network_submit_highscore( u32 trackid, u16 points, u16 time ); +static void network_submit_highscore( u32 trackid, u16 points, u16 time ); /* * Game endpoints are provided with the same names to allow running without a * network connection. */ -#ifdef SR_NETWORKED struct { u8 app_symmetric_key[ 1024 ]; u32 app_key_length; EServerMode auth_mode; - - int name_update; HSteamNetConnection remote; ESteamNetworkingConnectionState state; f64 last_attempt, last_frame; u32 retries; + + i32 network_info; + + struct network_request { + vg_pool_node poolnode; + void (*callback)( netmsg_request *res, vg_msg *body ); + f64 sendtime; + } + *request_buffer; + vg_pool request_pool; } static network_client = { - .state = k_ESteamNetworkingConnectionState_None, .auth_mode = eServerModeAuthentication, - .name_update = 1 + .state = k_ESteamNetworkingConnectionState_None, }; -#else /* SR_NETWORKED */ - -VG_STATIC void network_init(void){} -VG_STATIC void network_update(void){} -VG_STATIC void network_end(void){} +static int packet_minsize( SteamNetworkingMessage_t *msg, u32 size ); +static void network_send_item( enum netmsg_playeritem_type type ); +static void network_request_scoreboard( const char *mod_uid, + const char *route_uid, + u32 week ); +static void network_publish_laptime( const char *mod_uid, + const char *route_uid, f64 lap_time ); -#endif /* SR_NETWORKED */ #endif /* NETWORK_H */