From 470f5cc7203a148289d6ad6f0f5c7b4d80a48d50 Mon Sep 17 00:00:00 2001 From: Tim Angus Date: Fri, 20 Jan 2006 23:37:31 +0000 Subject: * Master server now logs version and renderer strings * Master server now responsible for logging game statistics --- src/game/g_local.h | 2 +- src/game/g_main.c | 124 +++++++++++++++++++++++++++++++++--------------- src/game/g_public.h | 2 + src/game/g_syscalls.asm | 97 ++++++++++++++++++------------------- src/game/g_syscalls.c | 6 +++ 5 files changed, 144 insertions(+), 87 deletions(-) (limited to 'src/game') diff --git a/src/game/g_local.h b/src/game/g_local.h index 1648f116..82f294b0 100644 --- a/src/game/g_local.h +++ b/src/game/g_local.h @@ -1136,4 +1136,4 @@ int trap_DebugPolygonCreate(int color, int numPoints, vec3_t *points); void trap_DebugPolygonDelete(int id); void trap_SnapVector( float *v ); - +void trap_SendGameStat( const char *data ); diff --git a/src/game/g_main.c b/src/game/g_main.c index d3e5b13e..a72d0459 100644 --- a/src/game/g_main.c +++ b/src/game/g_main.c @@ -452,6 +452,8 @@ void G_InitGame( int levelTime, int randomSeed, int restart ) memset( &level, 0, sizeof( level ) ); level.time = levelTime; level.startTime = levelTime; + level.alienStage2Time = level.alienStage3Time = + level.humanStage2Time = level.humanStage3Time = level.startTime; level.snd_fry = G_SoundIndex( "sound/misc/fry.wav" ); // FIXME standing in lava / slime @@ -1451,6 +1453,87 @@ void QDECL G_LogPrintf( const char *fmt, ... ) trap_FS_Write( string, strlen( string ), level.logFile ); } +/* +================= +G_SendGameStat +================= +*/ +void G_SendGameStat( pTeam_t team ) +{ + char map[ MAX_STRING_CHARS ]; + char teamChar; + char data[ BIG_INFO_STRING ]; + char entry[ MAX_STRING_CHARS ]; + int i, dataLength, entryLength; + gclient_t *cl; + + trap_Cvar_VariableStringBuffer( "mapname", map, sizeof( map ) ); + + switch( team ) + { + case PTE_ALIENS: teamChar = 'A'; break; + case PTE_HUMANS: teamChar = 'H'; break; + case PTE_NONE: teamChar = 'L'; break; + default: return; + } + + Com_sprintf( data, BIG_INFO_STRING, + "%s T:%c A:%f H:%f M:%s D:%d AS:%d AS2T:%d AS3T:%d HS:%d HS2T:%d HS3T:%d CL:%d", + Q3_VERSION, + teamChar, + level.averageNumAlienClients, + level.averageNumHumanClients, + map, + level.time - level.startTime, + g_alienStage.integer, + level.alienStage2Time - level.startTime, + level.alienStage3Time - level.startTime, + g_humanStage.integer, + level.humanStage2Time - level.startTime, + level.humanStage3Time - level.startTime, + level.numConnectedClients ); + + dataLength = strlen( data ); + + for( i = 0; i < level.numConnectedClients; i++ ) + { + int ping; + + cl = &level.clients[ level.sortedClients[ i ] ]; + + if( cl->pers.connected == CON_CONNECTING ) + ping = -1; + else + ping = cl->ps.ping < 999 ? cl->ps.ping : 999; + + switch( cl->ps.stats[ STAT_PTEAM ] ) + { + case PTE_ALIENS: teamChar = 'A'; break; + case PTE_HUMANS: teamChar = 'H'; break; + case PTE_NONE: teamChar = 'S'; break; + default: return; + } + + Com_sprintf( entry, MAX_STRING_CHARS, + " %s %c %d %d %d", + cl->pers.netname, + teamChar, + cl->ps.persistant[ PERS_SCORE ], + ping, + ( level.time - cl->pers.enterTime ) / 60000 ); + + entryLength = strlen( entry ); + + if( dataLength + entryLength > MAX_STRING_CHARS ) + break; + + Q_strncpyz( data + dataLength, entry, BIG_INFO_STRING ); + dataLength += entryLength; + } + + trap_SendGameStat( data ); +} + /* ================ LogExit @@ -1508,6 +1591,8 @@ void LogExit( const char *string ) ent->use( ent, ent, ent ); } } + + G_SendGameStat( level.lastWin ); } @@ -1628,10 +1713,6 @@ can see the last frag. */ void CheckExitRules( void ) { - char s[ MAX_STRING_CHARS ]; - - trap_Cvar_VariableStringBuffer( "mapname", s, sizeof( s ) ); - // if at the intermission, wait for all non-bots to // signal ready, then go to next level if( level.intermissiontime ) @@ -1655,23 +1736,13 @@ void CheckExitRules( void ) { if( level.time - level.startTime >= g_timelimit.integer * 60000 ) { - G_SendCommandFromServer( -1, "print \"Timelimit hit\n\"" ); - - G_LogPrintf( "STATS T:L A:%f H:%f M:%s D:%d AS:%d AS2T:%d AS3T:%d HS:%d HS2T:%d HS3T:%d\n", - level.averageNumAlienClients, level.averageNumHumanClients, - s, level.time - level.startTime, - g_alienStage.integer, - level.alienStage2Time - level.startTime, level.alienStage3Time - level.startTime, - g_humanStage.integer, - level.humanStage2Time - level.startTime, level.humanStage3Time - level.startTime ); - level.lastWin = PTE_NONE; + G_SendCommandFromServer( -1, "print \"Timelimit hit\n\"" ); LogExit( "Timelimit hit." ); return; } } - //TA: end the game on these conditions if( level.uncondHumanWin || ( ( level.time > level.startTime + 1000 ) && ( level.numAlienSpawns == 0 ) && @@ -1680,17 +1751,7 @@ void CheckExitRules( void ) //humans win level.lastWin = PTE_HUMANS; G_SendCommandFromServer( -1, "print \"Humans win\n\""); - - G_LogPrintf( "STATS T:H A:%f H:%f M:%s D:%d AS:%d AS2T:%d AS3T:%d HS:%d HS2T:%d HS3T:%d\n", - level.averageNumAlienClients, level.averageNumHumanClients, - s, level.time - level.startTime, - g_alienStage.integer, - level.alienStage2Time - level.startTime, level.alienStage3Time - level.startTime, - g_humanStage.integer, - level.humanStage2Time - level.startTime, level.humanStage3Time - level.startTime ); - LogExit( "Humans win." ); - return; } else if( level.uncondAlienWin || ( ( level.time > level.startTime + 1000 ) && @@ -1700,21 +1761,8 @@ void CheckExitRules( void ) //aliens win level.lastWin = PTE_ALIENS; G_SendCommandFromServer( -1, "print \"Aliens win\n\""); - - G_LogPrintf( "STATS T:A A:%f H:%f M:%s D:%d AS:%d AS2T:%d AS3T:%d HS:%d HS2T:%d HS3T:%d\n", - level.averageNumAlienClients, level.averageNumHumanClients, - s, level.time - level.startTime, - g_alienStage.integer, - level.alienStage2Time - level.startTime, level.alienStage3Time - level.startTime, - g_humanStage.integer, - level.humanStage2Time - level.startTime, level.humanStage3Time - level.startTime ); - LogExit( "Aliens win." ); - return; } - - if( level.numPlayingClients < 2 ) - return; } diff --git a/src/game/g_public.h b/src/game/g_public.h index de955e30..ba7a6e69 100644 --- a/src/game/g_public.h +++ b/src/game/g_public.h @@ -224,6 +224,8 @@ typedef enum { // 1.32 G_FS_SEEK, + G_SEND_GAMESTAT, + BOTLIB_SETUP = 200, // ( void ); BOTLIB_SHUTDOWN, // ( void ); BOTLIB_LIBVAR_SET, diff --git a/src/game/g_syscalls.asm b/src/game/g_syscalls.asm index 8035c349..fda100a0 100644 --- a/src/game/g_syscalls.asm +++ b/src/game/g_syscalls.asm @@ -1,44 +1,44 @@ code -equ trap_Printf -1 -equ trap_Error -2 -equ trap_Milliseconds -3 -equ trap_Cvar_Register -4 -equ trap_Cvar_Update -5 -equ trap_Cvar_Set -6 -equ trap_Cvar_VariableIntegerValue -7 -equ trap_Cvar_VariableStringBuffer -8 -equ trap_Argc -9 -equ trap_Argv -10 -equ trap_FS_FOpenFile -11 -equ trap_FS_Read -12 -equ trap_FS_Write -13 -equ trap_FS_FCloseFile -14 -equ trap_SendConsoleCommand -15 -equ trap_LocateGameData -16 -equ trap_DropClient -17 -equ trap_SendServerCommand -18 -equ trap_SetConfigstring -19 -equ trap_GetConfigstring -20 -equ trap_GetUserinfo -21 -equ trap_SetUserinfo -22 -equ trap_GetServerinfo -23 -equ trap_SetBrushModel -24 -equ trap_Trace -25 -equ trap_PointContents -26 +equ trap_Printf -1 +equ trap_Error -2 +equ trap_Milliseconds -3 +equ trap_Cvar_Register -4 +equ trap_Cvar_Update -5 +equ trap_Cvar_Set -6 +equ trap_Cvar_VariableIntegerValue -7 +equ trap_Cvar_VariableStringBuffer -8 +equ trap_Argc -9 +equ trap_Argv -10 +equ trap_FS_FOpenFile -11 +equ trap_FS_Read -12 +equ trap_FS_Write -13 +equ trap_FS_FCloseFile -14 +equ trap_SendConsoleCommand -15 +equ trap_LocateGameData -16 +equ trap_DropClient -17 +equ trap_SendServerCommand -18 +equ trap_SetConfigstring -19 +equ trap_GetConfigstring -20 +equ trap_GetUserinfo -21 +equ trap_SetUserinfo -22 +equ trap_GetServerinfo -23 +equ trap_SetBrushModel -24 +equ trap_Trace -25 +equ trap_PointContents -26 equ trap_InPVS -27 -equ trap_InPVSIgnorePortals -28 -equ trap_AdjustAreaPortalState -29 -equ trap_AreasConnected -30 -equ trap_LinkEntity -31 -equ trap_UnlinkEntity -32 -equ trap_EntitiesInBox -33 -equ trap_EntityContact -34 -equ trap_BotAllocateClient -35 -equ trap_BotFreeClient -36 -equ trap_GetUsercmd -37 -equ trap_GetEntityToken -38 -equ trap_FS_GetFileList -39 +equ trap_InPVSIgnorePortals -28 +equ trap_AdjustAreaPortalState -29 +equ trap_AreasConnected -30 +equ trap_LinkEntity -31 +equ trap_UnlinkEntity -32 +equ trap_EntitiesInBox -33 +equ trap_EntityContact -34 +equ trap_BotAllocateClient -35 +equ trap_BotFreeClient -36 +equ trap_GetUsercmd -37 +equ trap_GetEntityToken -38 +equ trap_FS_GetFileList -39 equ trap_DebugPolygonCreate -40 equ trap_DebugPolygonDelete -41 equ trap_RealTime -42 @@ -46,16 +46,17 @@ equ trap_SnapVector -43 equ trap_TraceCapsule -44 equ trap_EntityContactCapsule -45 equ trap_FS_Seek -46 +equ trap_SendGameStat -47 -equ memset -101 -equ memcpy -102 -equ strncpy -103 -equ sin -104 -equ cos -105 -equ atan2 -106 -equ sqrt -107 +equ memset -101 +equ memcpy -102 +equ strncpy -103 +equ sin -104 +equ cos -105 +equ atan2 -106 +equ sqrt -107 equ floor -111 -equ ceil -112 -equ testPrintInt -113 -equ testPrintFloat -114 +equ ceil -112 +equ testPrintInt -113 +equ testPrintFloat -114 diff --git a/src/game/g_syscalls.c b/src/game/g_syscalls.c index b1e55e59..4fe05c91 100644 --- a/src/game/g_syscalls.c +++ b/src/game/g_syscalls.c @@ -269,3 +269,9 @@ void trap_SnapVector( float *v ) syscall( G_SNAPVECTOR, v ); return; } + +void trap_SendGameStat( const char *data ) +{ + syscall( G_SEND_GAMESTAT, data ); + return; +} -- cgit