small compression
[carveJwlIkooP6JGAAIwe30JlM.git] / network.h
index 066b9f82f3e1bc245ce3a3fbe63fa6a3331ec03c..ef6876a79b843c2e2de39ef634331cb075816895 100644 (file)
--- a/network.h
+++ b/network.h
@@ -10,8 +10,9 @@
 #include "steam.h"
 #include "network_msg.h"
 #include "highscores.h"
+#include "addon_types.h"
 
-static int network_scores_updated = 0;
+#define NETWORK_MAX_REQUESTS 8
 
 /* 
  * Interface
@@ -42,8 +43,6 @@ struct {
    u8 app_symmetric_key[ 1024 ];
    u32 app_key_length;
    EServerMode auth_mode;
-   
-   int name_update;
 
    HSteamNetConnection remote;
    ESteamNetworkingConnectionState state;
@@ -52,11 +51,34 @@ struct {
    u32 retries;
 
    i32 network_info;
+
+   struct network_request {
+      vg_pool_node poolnode;
+      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 = {
-   .state = k_ESteamNetworkingConnectionState_None,
    .auth_mode = eServerModeAuthentication,
-   .name_update = 1
+   .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, u64 userdata );
+static void network_publish_laptime( const char *mod_uid, 
+                                     const char *route_uid, f64 lap_time );
+
+static int network_connected(void){
+   return network_client.state == k_ESteamNetworkingConnectionState_Connected;
+}
+
 #endif /* NETWORK_H */