Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions src/game/server/tf/entity_roundwin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,34 @@
// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"

#ifdef MAPBASE
// Matches up with WINREASON_ enum, but with WINREASON_ removed for comparison reasons
static const char *g_pszWinReasons[] = {
"NONE",
"ALL_POINTS_CAPTURED",
"OPPONENTS_DEAD",
"FLAG_CAPTURE_LIMIT",
"DEFEND_UNTIL_TIME_LIMIT",
"STALEMATE",
"TIMELIMIT",
"WINLIMIT",
"WINDIFFLIMIT",
#ifdef TF_DLL
"RD_REACTOR_CAPTURED",
"RD_CORES_COLLECTED",
"RD_REACTOR_RETURNED",
"PD_POINTS",
"SCORED",
"STOPWATCH_WATCHING_ROUNDS",
"STOPWATCH_WATCHING_FINAL_ROUND",
"STOPWATCH_PLAYING_ROUNDS",
#endif
};

// Add any new win reasons to the array above
COMPILE_TIME_ASSERT( ARRAYSIZE( g_pszWinReasons ) == WINREASON_COUNT );
#endif

//=============================================================================
//
// CTeamplayRoundWin tables.
Expand Down Expand Up @@ -42,6 +70,39 @@ CTeamplayRoundWin::CTeamplayRoundWin()
m_iWinReason = WINREASON_DEFEND_UNTIL_TIME_LIMIT;
}

//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
bool CTeamplayRoundWin::KeyValue( const char *szKeyName, const char *szValue )
{
#ifdef MAPBASE
if ( FStrEq( szKeyName, "win_reason" ) )
{
// Allow string input
if ( szValue[0] == 'W' )
{
// Strip the WINREASON_ so that we only compare the part that matters
const char *pszCompareValue = szValue + 10;
for ( int i = 0; i < ARRAYSIZE( g_pszWinReasons ); i++ )
{
if ( FStrEq( pszCompareValue, g_pszWinReasons[i] ) )
{
m_iWinReason = i;
return true;
}
}

// Win reason string does not match any known value
Warning( "%s: Invalid win reason \"%s\"", GetDebugName(), szValue );
}

// Fall through to base class for integer handling
}
#endif

return BaseClass::KeyValue( szKeyName, szValue );
}

//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
Expand Down
2 changes: 2 additions & 0 deletions src/game/server/tf/entity_roundwin.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ class CTeamplayRoundWin : public CPointEntity

CTeamplayRoundWin();

bool KeyValue( const char *szKeyName, const char *szValue );

// Input
void InputRoundWin( inputdata_t &inputdata );

Expand Down
2 changes: 2 additions & 0 deletions src/game/shared/teamplayroundbased_gamerules.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ enum {
WINREASON_STOPWATCH_WATCHING_FINAL_ROUND,
WINREASON_STOPWATCH_PLAYING_ROUNDS,
#endif

WINREASON_COUNT,
};

enum stalemate_reasons_t
Expand Down
Loading