foliage windy shader
[carveJwlIkooP6JGAAIwe30JlM.git] / player_remote.c
index 9e46321fc35e5ea6da930c0ab4977b6278050ab0..2234c6dc994aa3f50b8fdc0cf217603762dd551a 100644 (file)
@@ -6,6 +6,7 @@
 #include "font.h"
 #include "gui.h"
 #include "ent_miniworld.h"
+#include "ent_region.h"
 
 static i32 k_show_own_name = 0;
 
@@ -285,6 +286,20 @@ static void player_remote_rx_200_300( SteamNetworkingMessage_t *msg ){
       player->chat_time = vg.time_real;
       vg_info( "[%d]: %s\n", chat->client, player->chat );
    }
+   else if( tmp->inetmsg_id == k_inetmsg_region ){
+      netmsg_region *region = msg->m_pData;
+      struct network_player *player = &netplayers.list[ region->client ];
+
+      u32 l = network_msgstring( 
+               region->loc, msg->m_cbSize, sizeof(netmsg_region),
+               player->region, NETWORK_REGION_MAX );
+      player->region_flags = region->flags;
+
+      if( l )
+         player->region_flags |= k_ent_region_flag_hasname;
+
+      player->effect_data.spark.colour = region_spark_colour(region->flags);
+   }
 }
 
 /*
@@ -601,6 +616,8 @@ static void render_remote_players( world_instance *world, camera *cam ){
       struct network_player *player = &netplayers.list[i];
       if( !player->active || player->isblocked ) continue;
       if( player->active_world != world ) continue;
+      if( !player->isfriend && 
+            (world-world_static.instances == k_world_purpose_hub)) continue;
       
       m4x3f *final_mtx = &netplayers.final_mtx[ sk->bone_count*i ];
 
@@ -840,15 +857,20 @@ static void remote_player_gui_info( ui_rect box,
 }
 
 static void remote_players_imgui_lobby(void){
-    /*
-    * TODO: send location string over the network */
+   if( network_client.user_intent == k_server_intent_online ){
+      if( !(steam_ready &&
+         (network_client.state == k_ESteamNetworkingConnectionState_Connected)))
+      {
+         return;
+      }
+   }
 
    ui_px y = 50, width = 200, height = 42, gap = 2,
          x = vg.window_x - width;
 
    vg_ui.font = &vg_ui_font_big;
    ui_text( (ui_rect){ x, 0, width, height }, 
-            "Online Players", 1, k_ui_align_middle_center, 0 );
+            "In World", 1, k_ui_align_middle_center, 0 );
    vg_ui.font = &vg_ui_font_small;
 
 
@@ -862,14 +884,17 @@ static void remote_players_imgui_lobby(void){
       struct network_player *player = &netplayers.list[i];
       if( !player->active || player->isblocked ) continue;
 
-      int in_same_world = player->active_world != world_current_instance();
-
+      int in_same_world = player->active_world == world_current_instance();
       if( !player->isfriend && !in_same_world )
          continue;
+
+      const char *location = in_same_world? "": "another world";
+      if( player->region_flags & k_ent_region_flag_hasname ){
+         location = player->region;
+      }
       
       ui_rect box = { x, y, width, height };
-      remote_player_gui_info( box, player->username, 
-                              in_same_world? "": "another world", 
+      remote_player_gui_info( box, player->username, location,
                               player->isfriend, in_same_world );
       y += height + gap;
    }
@@ -887,6 +912,8 @@ static void remote_players_imgui_world( world_instance *world, m4x4f pv,
 
          if( !player->active_world )
             continue;
+         if( !player->isfriend && 
+               (world-world_static.instances == k_world_purpose_hub)) continue;
 
          /* their in our active subworld */
          if( player->active_world != world ){