fix annoying script error
[carveJwlIkooP6JGAAIwe30JlM.git] / network.c
index 67fae51e0309ed37d4c6d92324816b6ea7f7506b..3bb59b3e6c08e708b34958372587e41756e6332c 100644 (file)
--- a/network.c
+++ b/network.c
@@ -7,6 +7,8 @@
 #include "world_sfd.h"
 #include "world_routes.h"
 #include "vg/vg_imgui.h"
+#include "gui.h"
+#include "ent_region.h"
 
 static void scores_update(void);
 
@@ -77,6 +79,25 @@ static void network_send_username(void){
          k_nSteamNetworkingSend_Reliable, NULL );
 }
 
+static void network_send_region(void){
+   if( !network_connected() )
+      return;
+   
+   netmsg_region *region = alloca( sizeof(netmsg_region) + NETWORK_REGION_MAX );
+
+   region->inetmsg_id = k_inetmsg_region;
+   region->client = 0;
+   region->flags = global_ent_region.flags;
+
+   u32 l = vg_strncpy( global_ent_region.location, region->loc, 
+                       NETWORK_REGION_MAX, k_strncpy_always_add_null );
+
+   SteamAPI_ISteamNetworkingSockets_SendMessageToConnection(
+         hSteamNetworkingSockets, network_client.remote, 
+         region, sizeof(netmsg_region)+l+1,
+         k_nSteamNetworkingSend_Reliable, NULL );
+}
+
 static void network_send_request( netmsg_request *req, vg_msg *body,
                                   void (*callback)( 
                                      netmsg_request *res, vg_msg *body, 
@@ -279,6 +300,11 @@ static void network_disconnect(void){
 }
 
 static void network_status_string( vg_str *str, u32 *colour ){
+   if( skaterift.demo_mode ){
+      vg_strcat( str, "Offline" );
+      return;
+   }
+
    if( steam_ready ){
       if( network_client.user_intent == k_server_intent_offline ){
          vg_strcat( str, "Offline" );
@@ -458,6 +484,7 @@ static void network_sign_on_complete(void){
    for( u32 i=0; i<k_netmsg_playeritem_max; i ++ ){
       network_send_item(i);
    }
+   network_send_region();
 }
 
 static void poll_remote_connection(void){
@@ -530,7 +557,7 @@ static void network_update(void){
       if( frame_delta > NETWORK_FRAMERATE ){
          network_client.last_frame = vg.time_real;
          remote_player_send_playerframe();
-         player__clear_sfx_buffer();
+         localplayer.sfx_buffer_count = 0;
       }
 
       remote_player_debug_update();