+ /* create response packet */
+ netmsg_request *res = alloca( sizeof(netmsg_request) + NETWORK_REQUEST_MAX );
+ res->inetmsg_id = k_inetmsg_response;
+ res->id = req->id;
+ vg_msg body;
+ vg_msg_init( &body, res->q, NETWORK_REQUEST_MAX );
+
+ const char *endpoint = vg_msg_getkvstr( &data, "endpoint" );
+
+ if( !endpoint ){
+ gameserver_request_respond( k_request_status_invalid_endpoint,
+ res, NULL, msg );
+ return;
+ }
+
+ if( !strcmp( endpoint, "scoreboard" ) ){
+ const char *mod = vg_msg_getkvstr( &data, "mod" );
+ const char *route = vg_msg_getkvstr( &data, "route" );
+ u32 week;
+ vg_msg_getkvintg( &data, "week", k_vg_msg_u32, &week );
+
+ if( week == NETWORK_LEADERBOARD_CURRENT_WEEK ){
+ gameserver_cat_table( &body, mod, route,
+ gameserver_get_current_week(), "rows_weekly" );
+ }
+ else if( week == NETWORK_LEADERBOARD_ALLTIME_AND_CURRENT_WEEK ){
+ gameserver_cat_table( &body, mod, route, 0, "rows" );
+ gameserver_cat_table( &body, mod, route,
+ gameserver_get_current_week(), "rows_weekly" );
+ }
+ else
+ gameserver_cat_table( &body, mod, route, week, "rows" );
+
+ if( body.error != k_vg_msg_error_OK ){
+ gameserver_request_respond( k_request_status_out_of_memory,
+ res, NULL, msg );
+ return;
+ }
+
+ gameserver_request_respond( k_request_status_ok, res, &body, msg );
+ }
+ else if( !strcmp( endpoint, "setlap" ) ){
+ if( client->steamid == k_steamid_max ){
+ gameserver_request_respond( k_request_status_unauthorized,
+ res, NULL, msg );
+ return;
+ }
+
+ const char *mod = vg_msg_getkvstr( &data, "mod" );
+ const char *route = vg_msg_getkvstr( &data, "route" );
+
+ char weekly_table[ DB_TABLE_UID_MAX ],
+ alltime_table[ DB_TABLE_UID_MAX ];
+
+ u32 week = gameserver_get_current_week();
+
+ if( !db_get_highscore_table_name( mod, route, 0, alltime_table ) ||
+ !db_get_highscore_table_name( mod, route, week, weekly_table ) ){
+ gameserver_request_respond( k_request_status_out_of_memory,
+ res, NULL, msg );
+ return;
+ }
+
+ i32 centiseconds;
+ vg_msg_getkvintg( &data, "time", k_vg_msg_i32, ¢iseconds );
+ if( centiseconds < 5*100 ){
+ gameserver_request_respond( k_request_status_client_error,
+ res, NULL, msg );
+ return;
+ }
+
+ db_writeusertime( alltime_table, client->steamid, centiseconds, 1 );
+ db_writeusertime( weekly_table, client->steamid, centiseconds, 1 );
+ gameserver_request_respond( k_request_status_ok, res, NULL, msg );
+ }
+ else{
+ gameserver_request_respond( k_request_status_invalid_endpoint,
+ res, NULL, msg );
+ }
+}
+
+static void gameserver_rx_300_400( SteamNetworkingMessage_t *msg ){
+ netmsg_blank *tmp = msg->m_pData;
+
+ int client_id = gameserver_conid( msg->m_conn );
+ if( client_id == -1 ){
+ SteamAPI_SteamNetworkingMessage_t_Release( msg );