X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=network.h;h=b643a1b7da9f96641972d352417c3569d3ba2577;hb=8090b8da9ce1397ba47d7e2d91b4f1716f708f25;hp=2916ad94a824f6f9a5d543daa2e1e319d8ac14ec;hpb=f6bc1299d5b30e1aba87e6ce084bcd7eed22975f;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/network.h b/network.h index 2916ad9..b643a1b 100644 --- a/network.h +++ b/network.h @@ -8,18 +8,16 @@ #include "vg/vg_stdint.h" #include "steam.h" +#include "network_common.h" #include "network_msg.h" #include "highscores.h" #include "addon_types.h" #define NETWORK_MAX_REQUESTS 8 -static int network_scores_updated = 0; - /* * Interface */ -//#define SR_USE_LOCALHOST /* Call it at start; Connects us to the gameserver */ static void network_init(void); @@ -48,6 +46,7 @@ struct { HSteamNetConnection remote; ESteamNetworkingConnectionState state; + u32 remote_version; f64 last_attempt, last_frame; u32 retries; @@ -56,23 +55,33 @@ struct { struct network_request { vg_pool_node poolnode; - void (*callback)( netmsg_request *res, vg_msg *body ); + void (*callback)( netmsg_request *res, vg_msg *body, u64 userdata ); f64 sendtime; + u64 userdata; } *request_buffer; vg_pool request_pool; + + char server_adress[64]; } static network_client = { .auth_mode = eServerModeAuthentication, .state = k_ESteamNetworkingConnectionState_None, + .server_adress = "46.101.34.155" }; 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 ); + u32 week, u64 userdata ); static void network_publish_laptime( const char *mod_uid, const char *route_uid, f64 lap_time ); +static void chat_send_message( const char *message ); + +static int network_connected(void){ + if( network_client.remote_version != NETWORK_SKATERIFT_VERSION ) return 0; + return network_client.state == k_ESteamNetworkingConnectionState_Connected; +} #endif /* NETWORK_H */