X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=gameserver.c;fp=gameserver.c;h=11721e7a4dc8abef2f45db49765d58ea1246dc1b;hb=3b1909cad505b859b9c6524498b1969cd018af8c;hp=e641256c2ddc7f292afd0ef9f0c970b0ee07c48b;hpb=71b7175073e0c764c3c5cb0c7ceee0f8cca09e58;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/gameserver.c b/gameserver.c index e641256..11721e7 100644 --- a/gameserver.c +++ b/gameserver.c @@ -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; iclient = 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 );