X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=gameserver.c;h=e36e60f704c345030c9189fab49d27ab42046353;hb=1fd91b77f23ce1593037e01b9abb62859545b400;hp=e641256c2ddc7f292afd0ef9f0c970b0ee07c48b;hpb=15c0b8cb57ed5d10814103eaa0b5c06e8ae117e4;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/gameserver.c b/gameserver.c index e641256..e36e60f 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 ); @@ -673,7 +707,7 @@ static enum request_status gameserver_cat_table( vg_strnull( &q, buf, 512 ); vg_strcat( &q, "SELECT * FROM \"" ); vg_strcat( &q, table_name ); - vg_strcat( &q, "\" ORDER BY time DESC LIMIT 10;" ); + vg_strcat( &q, "\" ORDER BY time ASC LIMIT 10;" ); if( !vg_strgood(&q) ) return k_request_status_out_of_memory; @@ -890,6 +924,7 @@ static u64 seconds_to_server_ticks( double s ){ } static void test_runner( db_request *req ){ +#if 0 vg_warn( "RUNNER\n" ); char table[DB_TABLE_UID_MAX]; if( db_get_highscore_table_name( "sr002-local-mp_mtzero", @@ -900,8 +935,16 @@ static void test_runner( db_request *req ){ vg_success( "Returned time: %u\n", v ); } } +#endif } +#define SIDELOAD +#ifdef SIDELOAD +#include "gameserver_sideload.h" +static int bsideload = 0; +const char *sideload_path = NULL; +#endif + int main( int argc, char *argv[] ){ signal( SIGINT, inthandler ); signal( SIGQUIT, inthandler ); @@ -912,7 +955,12 @@ int main( int argc, char *argv[] ){ if( vg_long_opt( "noauth" ) ) gameserver.auth_mode = eServerModeNoAuthentication; - /* TODO: Options to override, ammend, remove etc */ +#ifdef SIDELOAD + if( (arg = vg_long_opt_arg( "sideload" )) ){ + sideload_path = arg; + bsideload = 1; + } +#endif } vg_set_mem_quota( 80*1024*1024 ); @@ -925,6 +973,15 @@ int main( int argc, char *argv[] ){ db_send_request(req); } +#ifdef SIDELOAD + if( bsideload ){ + sideload( sideload_path ); + db_kill(); + db_free(); + return 0; + } +#endif + monitor_start_server(); /* UNIX socket monitor */ /* steamworks init