leave.index = index;
vg_info( "Player leave (%d)\n", index );
- _gs_monitor_journal( 0, "[OK] Client leave (%u)\n", index );
- gameserver_send_to_all( index, &leave, sizeof(leave),
- k_nSteamNetworkingSend_Reliable );
+ _gs_monitor_journal( 0, "// Client leave (%u)\n", index );
+ gameserver_send_to_all( index, &leave, sizeof(leave), k_nSteamNetworkingSend_Reliable );
}
static void gameserver_update_all_knowledge( int client, int clear );
if( index == -1 )
{
- _gs_monitor_journal( 0, "[BAD] Hit Player limit!\n" );
+ _gs_monitor_journal( 0, "// BAD!! Hit Player limit!\n" );
vg_error( "Server full\n" );
SteamAPI_ISteamNetworkingSockets_CloseConnection( hSteamNetworkingSockets, conn, 4500, NULL, 1 );
return;
if( accept_status == k_EResultOK )
{
vg_success( "Accepted client (id: %u, index: %d)\n", conn, index );
- _gs_monitor_journal( 0, "[OK] New client (%u)\n", index );
+ _gs_monitor_journal( 0, "// New client (%u)\n", index );
_gameserver.global_uid ++;
client->session_uid = _gameserver.global_uid;
client->admin? "Admin": "User" );
gameserver_player_join( client_id );
_gs_monitor_playerjoin();
- _gs_monitor_journal( 0, "[OK] Authenticated client (%u)\n", client_id );
+ _gs_monitor_journal( 0, "// Authenticated client (%u)\n", client_id );
}
/*
return 0;
}
+struct task_writeusertime
+{
+ char uid[DB_TABLE_UID_MAX];
+ u64 steamid;
+ u32 centiseconds;
+ u64 last_second;
+ bool only_if_faster;
+};
+
+static void setlap_task( vg_async_task *task )
+{
+ THREAD_1;
+ struct task_writeusertime *info = (void *)task->data;
+ db_writeusertime( info->uid, info->steamid, info->centiseconds, info->last_second, info->only_if_faster );
+}
+
+static int _rcon_set_lap( int argc, const char *argv[] )
+{
+ if( argc != 4 )
+ {
+ vg_error( "Usage: set_lap <steamid> <table> <centiseconds> <last_second>\n" );
+ return 0;
+ }
+
+ if( strlen( argv[1] ) >= DB_TABLE_UID_MAX )
+ {
+ vg_error( "Table name too long. '%s'\n", argv[1] );
+ return 0;
+ }
+
+ vg_async_task *task = vg_allocate_async_task( &_gs_db.tasks, sizeof(struct task_writeusertime), 1 );
+ struct task_writeusertime *info = (void *)task->data;
+
+ info->steamid = strtoull( argv[0], NULL, 10 );
+ strcpy( info->uid, argv[1] );
+ info->centiseconds = strtoul( argv[2], NULL, 10 );
+ info->last_second = strtoull( argv[3], NULL, 10 );
+
+ vg_async_task_dispatch( task, setlap_task );
+
+ return 0;
+}
+
static int _rcon_edit_user( int argc, const char *argv[] )
{
if( argc >= 1 )
static int _rcon_dumpdb( int argc, const char *argv[] )
{
- if( argc == 1 )
+ if( argc >= 1 )
{
- db_action_dump( argv[0] );
+ db_action_dump( argv[0], argc>1? atoi(argv[1]): 0 );
return 1;
}
else
vg_console_reg_cmd( "spoofid", _rcon_spoofid, NULL );
vg_console_reg_cmd( "dumpdb", _rcon_dumpdb, NULL );
vg_console_reg_cmd( "edit_user", _rcon_edit_user, NULL );
+ vg_console_reg_cmd( "setlap", _rcon_set_lap, NULL );
+ signal( SIGTERM, inthandler );
signal( SIGINT, inthandler );
signal( SIGQUIT, inthandler );
signal( SIGPIPE, SIG_IGN );
listener = SteamAPI_ISteamNetworkingSockets_CreateListenSocketIP( hSteamNetworkingSockets, &localAddr, 0, NULL );
_gameserver.client_group = SteamAPI_ISteamNetworkingSockets_CreatePollGroup( hSteamNetworkingSockets );
_gameserver.ticks = seconds_to_server_ticks( 30.0 * 60.0 );
- _gs_monitor_journal( 0, "[OK] Gameserver Starting\n" );
+ _gs_monitor_journal( 0, "// Gameserver Starting\n" );
while(1)
{
EE:vg_info( "Server end\n" );
- _gs_monitor_journal( 0, "[OK] Gameserver Ending\n" );
+ _gs_monitor_journal( 0, "// Gameserver Ending\n" );
SteamAPI_ISteamNetworkingSockets_DestroyPollGroup( hSteamNetworkingSockets, _gameserver.client_group );
SteamAPI_ISteamNetworkingSockets_CloseListenSocket( hSteamNetworkingSockets, listener );
return k_request_status_ok;
}
+enum dump_mode
+{
+ k_dump_mode_commands,
+ k_dump_mode_kv
+};
+
struct task_db_dump
{
- u32 none;
+ u32 mode;
char output_path[];
};
u64 master_table_addr = db->userdata_address + offsetof(struct skaterift_database, leaderboards_table),
user_tree_addr = db->userdata_address + offsetof(struct skaterift_database, users_tree);
- fprintf( fp, "profiles\n"
- "{\n" );
+ if( info->mode == k_dump_mode_kv )
+ {
+ fprintf( fp, "profiles\n"
+ "{\n" );
+ }
+
vg_tree_iter iter;
vg_db_tree_iter_init( db, &iter, user_tree_addr );
struct skaterift_profile profile;
vg_db_read( db, profile_addr, &profile, sizeof(profile) );
- fprintf( fp, " 0x%lx\n"
- " {\n"
- " name %s\n"
- " cc %s\n"
- " flags 0x%x\n"
- " }\n", steamid, profile.name, profile.cc, profile.flags );
+
+ if( info->mode == k_dump_mode_kv )
+ {
+ fprintf( fp, " 0x%lx\n"
+ " {\n"
+ " name %s\n"
+ " cc %s\n"
+ " flags 0x%x\n"
+ " }\n", steamid, profile.name, profile.cc, profile.flags );
+ }
+ else
+ {
+ fprintf( fp, "edit_user %lu name \"%s\"\n", steamid, profile.name );
+
+ if( profile.cc[0] != '\0' )
+ fprintf( fp, "edit_user %lu cc %s\n", steamid, profile.cc );
+
+ if( profile.flags & 0x2 )
+ fprintf( fp, "edit_user %lu +LEGEND\n", steamid );
+
+ if( profile.flags & 0x1 )
+ fprintf( fp, "edit_user %lu +EARLY\n", steamid );
+
+ if( profile.flags & 0x8000 )
+ fprintf( fp, "edit_user %lu +ADMIN\n", steamid );
+ }
}
- fprintf( fp, "}\n" );
+ if( info->mode == k_dump_mode_kv )
+ {
+ fprintf( fp, "}\n" );
+
+ fprintf( fp, "leaderboards\n"
+ "{\n" );
+ }
- fprintf( fp, "leaderboards\n"
- "{\n" );
u16 table_count = vg_db_table_count( db, master_table_addr );
for( u16 i=0; i<table_count; i ++ )
{
char uid[ DB_TABLE_UID_MAX ];
vg_db_read( db, leaderboard_addr + offsetof(struct skaterift_leaderboard,uid), uid, sizeof(uid) );
- fprintf( fp, " %s\n"
- " {\n", uid );
+ if( info->mode == k_dump_mode_kv )
+ {
+ fprintf( fp, " %s\n"
+ " {\n", uid );
+ }
u64 entries_addr = leaderboard_addr + offsetof(struct skaterift_leaderboard, entries);
u16 entries_count = vg_db_table_count( db, entries_addr );
struct skaterift_entry entry;
u64 entry_addr = vg_db_table_get( db, entries_addr, j );
vg_db_read( db, entry_addr, &entry, sizeof(entry) );
- fprintf( fp, " 0x%lx\n"
- " {\n"
- " last_second %lu\n"
- " centiseconds %u\n"
- " }\n", entry.steamid, entry.last_second, entry.centiseconds );
+
+ if( info->mode == k_dump_mode_kv )
+ {
+ fprintf( fp, " 0x%lx\n"
+ " {\n"
+ " last_second %lu\n"
+ " centiseconds %u\n"
+ " }\n", entry.steamid, entry.last_second, entry.centiseconds );
+ }
+ else
+ {
+
+ fprintf( fp, "setlap %lu \"%s\" %u %lu\n", entry.steamid, uid, entry.centiseconds, entry.last_second );
+ }
}
- fprintf( fp, " }\n" );
+ if( info->mode == k_dump_mode_kv )
+ fprintf( fp, " }\n" );
}
- fprintf( fp, "}\n" );
+ if( info->mode == k_dump_mode_kv )
+ fprintf( fp, "}\n" );
fclose( fp );
}
-void db_action_dump( const char *path )
+void db_action_dump( const char *path, bool kv_mode )
{
THREAD_0;
vg_async_task *task = vg_allocate_async_task( &_gs_db.tasks, sizeof(struct task_db_dump) + strlen(path)+1, 1 );
struct task_db_dump *info = (void *)task->data;
- info->none = 0;
+ info->mode = kv_mode? k_dump_mode_kv: k_dump_mode_commands;
strcpy( info->output_path, path );
vg_async_task_dispatch( task, _gs_db_dump_task );
}
}
extern _gs_db;
-void db_action_dump( const char *path );
+void db_action_dump( const char *path, bool kv_mode );
bool db_get_highscore_table_name( const char *mod_uid, const char *run_uid, char table_name[DB_TABLE_UID_MAX] );
bool db_writeusertime( char uid[DB_TABLE_UID_MAX], u64 steamid, u32 score, u64 last_second, bool only_if_faster );
_gs_replay.current_minute = new_minute;
vg_info( "The new minute is: %u\n", new_minute );
+ _gs_monitor_journal( 0, "// new minute: %u\n", new_minute );
}
}
SteamAPI_ISteamNetworkingSockets_SendMessages( hSteamNetworkingSockets, 1, &msg, NULL );
req->state = k_request_state_finished;
log_request_status( req );
+ _gameserver.bytes_send1 += size;
}
else if( req->state == k_request_state_transfer_start )
{
SteamAPI_ISteamNetworkingSockets_SendMessages( hSteamNetworkingSockets, 1, &msg, NULL );
req->state = k_request_state_transfer;
log_request_status( req );
+ _gameserver.bytes_send1 += size;
}
else if( req->state == k_request_state_transfer )
{
SteamAPI_ISteamNetworkingSockets_SendMessages( hSteamNetworkingSockets, 1, &msg, NULL );
req->send_offset += size;
+ _gameserver.bytes_send1 += size;
}
else if( req->state == k_request_state_finished )
{
{
if( steamid == req->user_steamid )
{
+ _gs_monitor_journal( 1, "edit_user %lu cc %s\n", req->user_steamid, set_cc );
u64 user_address = vg_db_translate( &_gs_db.db, _gs_db.users_tree, steamid );
if( user_address )
{
i64 last_second = time(NULL);
const char *mod = vg_msg_getkvstr( &client_msg, "mod" );
const char *route = vg_msg_getkvstr( &client_msg, "route" );
+
+ i32 centiseconds;
+ vg_msg_getkvintg( &client_msg, "time", k_vg_msg_i32, ¢iseconds, NULL );
- //char weekly_table[ DB_TABLE_UID_MAX ],
char table[ DB_TABLE_UID_MAX ];
-
if( !db_get_highscore_table_name( mod, route, table ) )
{
req->status = k_request_status_out_of_memory;
goto E0;
}
- i32 centiseconds;
- vg_msg_getkvintg( &client_msg, "time", k_vg_msg_i32, ¢iseconds, NULL );
+ _gs_monitor_journal( 1, "setlap %lu \"%s\" %u %u\n", req->user_steamid, table, centiseconds, last_second );
+
if( centiseconds < 5*100 )
{
req->status = k_request_status_client_error;
goto E0;
}
- _gs_monitor_journal( 1, "[REQ] setlap %lu \"%s\" %u\n", req->user_steamid, table, centiseconds );
-
if( db_writeusertime( table, req->user_steamid, centiseconds, last_second, 1 ) )
_gs_replay_request_save( req->client_id, req->user_steamid, last_second, centiseconds, 1 );
}
struct _remote_replay _remote_replay;
struct _replay2 _replay2;
+static int cmd_replay2_manual_download( int argc, const char *argv[] )
+{
+ if( argc < 2 )
+ {
+ vg_error( "Usage: replay2_watch <steamid> <last_second> <minutes_span (optional)>\n" );
+ return 0;
+ }
+
+ if( _remote_replay.state != k_remote_replay_state_none )
+ {
+ vg_error( "Cant do that right now (remote replay state: %u\n", _remote_replay.state );
+ return 0;
+ }
+
+ u32 minutes_span = 1;
+ if( argc >= 3 )
+ minutes_span = strtoull( argv[2], NULL, 10 );
+
+ u64 steamid = strtoull( argv[0], NULL, 16 );
+ u64 last_second = strtoull( argv[1], NULL, 16 );
+ u32 last_minute = (u32)( last_second / 60 );
+
+ skaterift.activity = k_skaterift_default;
+ vg_queue_clear( &_remote_replay.buffer );
+ _remote_replay.min_frame_t = 0.0;
+ _remote_replay.total_chunks = minutes_span;
+ _remote_replay.chunks_downloaded = 0;
+ _remote_replay.steamid = steamid;
+ _remote_replay.state = k_remote_replay_state_init;
+ _remote_replay.last_second = last_second;
+
+ for( u32 i=0; i<minutes_span; i ++ )
+ {
+ struct remote_replay_chunk *chunk = &_remote_replay.chunks[i];
+ chunk->minute = last_minute - minutes_span + 1 + i;
+ chunk->state = k_chunk_state_none;
+ }
+
+ gui_helper_reset( k_gui_helper_mode_clear );
+ _replay2_open_player( k_replay_type_network, 0 );
+ return 1;
+}
+
void _replay2_init(void)
{
+ vg_console_reg_cmd( "replay2_watch", cmd_replay2_manual_download, NULL );
+
u32 MB = 1024*1024,
size = 4*MB;