mirror of
https://github.com/nillerusr/source-engine.git
synced 2026-08-30 14:09:19 +00:00
upload "kind" alien swarm
This commit is contained in:
+77
-41
@@ -1,4 +1,4 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
@@ -9,6 +9,8 @@
|
||||
#include "EventLog.h"
|
||||
#include "team.h"
|
||||
#include "KeyValues.h"
|
||||
#include "nav.h"
|
||||
#include "nav_area.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
@@ -22,8 +24,66 @@ CEventLog::~CEventLog()
|
||||
}
|
||||
|
||||
|
||||
void CEventLog::FormatPlayer( CBaseEntity *ent, char *str, int len ) const
|
||||
{
|
||||
if ( !str || len <= 0 )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
CBasePlayer *player = ToBasePlayer( ent );
|
||||
|
||||
const char *playerName = "Unknown";
|
||||
int userID = 0;
|
||||
const char *networkIDString = "";
|
||||
const char *teamName = "";
|
||||
int areaID = 0;
|
||||
if ( player )
|
||||
{
|
||||
playerName = player->GetPlayerName();
|
||||
userID = player->GetUserID();
|
||||
networkIDString = player->GetNetworkIDString();
|
||||
CTeam *team = player->GetTeam();
|
||||
if ( team )
|
||||
{
|
||||
teamName = team->GetName();
|
||||
}
|
||||
}
|
||||
|
||||
if ( ent && ent->MyCombatCharacterPointer() )
|
||||
{
|
||||
CNavArea *area = ent->MyCombatCharacterPointer()->GetLastKnownArea();
|
||||
if ( area )
|
||||
{
|
||||
areaID = area->GetID();
|
||||
}
|
||||
}
|
||||
|
||||
V_snprintf( str, len, "\"%s<%i><%s><%s><Area %d>\"", playerName, userID, networkIDString, teamName, areaID );
|
||||
}
|
||||
|
||||
const char *CEventLog::FormatPlayer( CBaseEntity *ent ) const
|
||||
{
|
||||
const int MaxEntries = 4;
|
||||
const int BufferLength = PLAYER_LOGINFO_SIZE;
|
||||
static char s_buffer[ MaxEntries ][ BufferLength ];
|
||||
static int s_index = 0;
|
||||
|
||||
char *ret = s_buffer[ s_index++ ];
|
||||
if ( s_index >= MaxEntries )
|
||||
{
|
||||
s_index = 0;
|
||||
}
|
||||
|
||||
FormatPlayer( ent, ret, BufferLength );
|
||||
return ret;
|
||||
}
|
||||
|
||||
void CEventLog::FireGameEvent( IGameEvent *event )
|
||||
{
|
||||
if ( !g_bIsLogging )
|
||||
return;
|
||||
|
||||
PrintEvent ( event );
|
||||
}
|
||||
|
||||
@@ -107,13 +167,22 @@ bool CEventLog::PrintPlayerEvent( IGameEvent *event )
|
||||
const int oldTeam = event->GetInt( "oldteam" );
|
||||
CTeam *team = GetGlobalTeam( newTeam );
|
||||
CTeam *oldteam = GetGlobalTeam( oldTeam );
|
||||
|
||||
UTIL_LogPrintf( "\"%s<%i><%s><%s>\" joined team \"%s\"\n",
|
||||
pPlayer->GetPlayerName(),
|
||||
pPlayer->GetUserID(),
|
||||
pPlayer->GetNetworkIDString(),
|
||||
oldteam->GetName(),
|
||||
team->GetName() );
|
||||
|
||||
const char *playerName = pPlayer->GetPlayerName();
|
||||
int userID = pPlayer->GetUserID();
|
||||
if ( userID > 0 )
|
||||
{
|
||||
const char *networkID = pPlayer->GetNetworkIDString();
|
||||
const char *oldTeamName = (oldteam) ? oldteam->GetName() : "Unassigned";
|
||||
const char *teamName = (team) ? team->GetName() : "Unassigned";
|
||||
|
||||
UTIL_LogPrintf( "\"%s<%i><%s><%s>\" joined team \"%s\"\n",
|
||||
playerName,
|
||||
userID,
|
||||
networkID,
|
||||
oldTeamName,
|
||||
teamName );
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -122,10 +191,6 @@ bool CEventLog::PrintPlayerEvent( IGameEvent *event )
|
||||
{
|
||||
const int attackerid = event->GetInt("attacker" );
|
||||
|
||||
#ifdef HL2MP
|
||||
const char *weapon = event->GetString( "weapon" );
|
||||
#endif
|
||||
|
||||
CBasePlayer *pAttacker = UTIL_PlayerByUserId( attackerid );
|
||||
CTeam *team = pPlayer->GetTeam();
|
||||
CTeam *attackerTeam = NULL;
|
||||
@@ -137,15 +202,6 @@ bool CEventLog::PrintPlayerEvent( IGameEvent *event )
|
||||
if ( pPlayer == pAttacker && pPlayer )
|
||||
{
|
||||
|
||||
#ifdef HL2MP
|
||||
UTIL_LogPrintf( "\"%s<%i><%s><%s>\" committed suicide with \"%s\"\n",
|
||||
pPlayer->GetPlayerName(),
|
||||
userid,
|
||||
pPlayer->GetNetworkIDString(),
|
||||
team ? team->GetName() : "",
|
||||
weapon
|
||||
);
|
||||
#else
|
||||
UTIL_LogPrintf( "\"%s<%i><%s><%s>\" committed suicide with \"%s\"\n",
|
||||
pPlayer->GetPlayerName(),
|
||||
userid,
|
||||
@@ -153,25 +209,11 @@ bool CEventLog::PrintPlayerEvent( IGameEvent *event )
|
||||
team ? team->GetName() : "",
|
||||
pAttacker->GetClassname()
|
||||
);
|
||||
#endif
|
||||
}
|
||||
else if ( pAttacker )
|
||||
{
|
||||
CTeam *attackerTeam = pAttacker->GetTeam();
|
||||
|
||||
#ifdef HL2MP
|
||||
UTIL_LogPrintf( "\"%s<%i><%s><%s>\" killed \"%s<%i><%s><%s>\" with \"%s\"\n",
|
||||
pAttacker->GetPlayerName(),
|
||||
attackerid,
|
||||
pAttacker->GetNetworkIDString(),
|
||||
attackerTeam ? attackerTeam->GetName() : "",
|
||||
pPlayer->GetPlayerName(),
|
||||
userid,
|
||||
pPlayer->GetNetworkIDString(),
|
||||
team ? team->GetName() : "",
|
||||
weapon
|
||||
);
|
||||
#else
|
||||
UTIL_LogPrintf( "\"%s<%i><%s><%s>\" killed \"%s<%i><%s><%s>\"\n",
|
||||
pAttacker->GetPlayerName(),
|
||||
attackerid,
|
||||
@@ -182,7 +224,6 @@ bool CEventLog::PrintPlayerEvent( IGameEvent *event )
|
||||
pPlayer->GetNetworkIDString(),
|
||||
team ? team->GetName() : ""
|
||||
);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -250,8 +291,3 @@ bool CEventLog::Init()
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CEventLog::Shutdown()
|
||||
{
|
||||
StopListeningForAllEvents();
|
||||
}
|
||||
Reference in New Issue
Block a user