dont try to load nothign
[carveJwlIkooP6JGAAIwe30JlM.git] / gameserver.c
index e641256c2ddc7f292afd0ef9f0c970b0ee07c48b..11721e7a4dc8abef2f45db49765d58ea1246dc1b 100644 (file)
@@ -92,6 +92,9 @@ static void gameserver_player_join( int index ){
       alloca( sizeof(netmsg_playeritem) + ADDON_UID_MAX );
    item->inetmsg_id = k_inetmsg_playeritem;
 
+   netmsg_region *region = alloca( sizeof(netmsg_region) + NETWORK_REGION_MAX );
+   region->inetmsg_id = k_inetmsg_region;
+
    for( int i=0; i<vg_list_size(gameserver.clients); i++ ){
       struct gameserver_client *client = &gameserver.clients[i];
 
@@ -124,6 +127,17 @@ static void gameserver_player_join( int index ){
          gameserver_send_to_client( index, item, size,
                                     k_nSteamNetworkingSend_Reliable );
       }
+
+      /* region */
+      
+      region->client = i;
+      region->flags = client->region_flags;
+      u32 l = vg_strncpy( client->region, region->loc, NETWORK_REGION_MAX, 
+                          k_strncpy_always_add_null );
+      size = sizeof(netmsg_region) + l + 1;
+
+      gameserver_send_to_client( index, region, size,
+                                 k_nSteamNetworkingSend_Reliable );
    }
 }
 
@@ -626,6 +640,26 @@ static void gameserver_rx_200_300( SteamNetworkingMessage_t *msg ){
       gameserver_send_to_all( client_id, prop, sizeof(netmsg_chat)+l+1, 
                               k_nSteamNetworkingSend_Reliable );
    }
+   else if( tmp->inetmsg_id == k_inetmsg_region ){
+      netmsg_region *region = msg->m_pData,
+                    *prop = alloca( sizeof(netmsg_region) + NETWORK_REGION_MAX );
+
+      prop->inetmsg_id = k_inetmsg_region;
+      prop->client = client_id;
+      prop->flags = region->flags;
+
+      u32 l = network_msgstring( 
+            region->loc, msg->m_cbSize, sizeof(netmsg_region),
+            client->region, NETWORK_REGION_MAX );
+      client->region_flags = region->flags;
+
+      l = vg_strncpy( client->region, prop->loc, NETWORK_REGION_MAX, 
+                      k_strncpy_always_add_null );
+
+      gameserver_send_to_all( client_id, prop, sizeof(netmsg_region)+l+1, 
+                              k_nSteamNetworkingSend_Reliable );
+      vg_info( "client %d moved to region: %s\n", client_id, client->region );
+   }
    else {
       vg_warn( "Unknown inetmsg_id recieved from client. (%u)\n",
                tmp->inetmsg_id );