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 );
}
if( index == -1 )
{
+ _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 );
_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 );
}
/*
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" );
while(1)
{
}
EE:vg_info( "Server end\n" );
-
+
+ _gs_monitor_journal( 0, "[OK] Gameserver Ending\n" );
SteamAPI_ISteamNetworkingSockets_DestroyPollGroup( hSteamNetworkingSockets, _gameserver.client_group );
SteamAPI_ISteamNetworkingSockets_CloseListenSocket( hSteamNetworkingSockets, listener );
+#include <stdarg.h>
+
struct
{
const char *html_path;
bool _gs_monitor_start_journal( const char *path )
{
_gs_monitor.journal_fp = fopen( path, "a+" );
+ fseek( _gs_monitor.journal_fp, 0, SEEK_END );
if( !_gs_monitor.journal_fp )
{
_gs_monitor.timer = 0;
}
-void _gs_monitor_log_event( const char *event )
+struct task_journal
+{
+ char buf[ 1024 ];
+};
+
+void _monitor_journal_task( vg_async_task *task )
+{
+ THREAD_1;
+ struct task_journal *info = (void *)task->data;
+ fputs( info->buf, _gs_monitor.journal_fp );
+}
+
+static void _gs_journal_va( bool thread1, const char *fmt, va_list args )
{
- /* TODO */
+ if( thread1 )
+ {
+ char buf[ 1024 ];
+ vsnprintf( buf, sizeof(buf), fmt, args );
+ fputs( buf, _gs_monitor.journal_fp );
+ }
+ else
+ {
+ vg_async_task *task = vg_allocate_async_task( &_gs_db.tasks, sizeof(struct task_journal), 1 );
+ struct task_journal *info = (void *)task->data;
+ vsnprintf( info->buf, sizeof(info->buf), fmt, args );
+ info->buf[sizeof(info->buf)-2] = '|';
+ info->buf[sizeof(info->buf)-1] = '\0';
+ vg_async_task_dispatch( task, _monitor_journal_task );
+ }
+}
+
+void _gs_monitor_journal( bool thread1, const char *message, ... )
+{
+ if( _gs_monitor.journal_fp == NULL )
+ return;
+
+ if( thread1 )
+ {
+ THREAD_1;
+ }
+ else
+ {
+ THREAD_0;
+ }
+
+ va_list args;
+ va_start( args, message );
+ _gs_journal_va( thread1, message, args );
+ va_end( args );
}
void _gs_monitor_playerjoin(void)
bool _gs_monitor_start_journal( const char *path );
void _gs_monitor_start_html( const char *path );
void _gs_monitor_set_interval( f64 seconds );
-void _gs_monitor_log_event( const char *event );
void _gs_monitor_cleanup(void);
void _gs_monitor_playerjoin(void);
+void _gs_monitor_journal( bool thread1, const char *message, ... );
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 );
}