|
11 | 11 | // memdbgon must be the last include file in a .cpp file!!! |
12 | 12 | #include "tier0/memdbgon.h" |
13 | 13 |
|
| 14 | +#ifdef MAPBASE |
| 15 | +// Matches up with WINREASON_ enum, but with WINREASON_ removed for comparison reasons |
| 16 | +static const char *g_pszWinReasons[] = { |
| 17 | + "NONE", |
| 18 | + "ALL_POINTS_CAPTURED", |
| 19 | + "OPPONENTS_DEAD", |
| 20 | + "FLAG_CAPTURE_LIMIT", |
| 21 | + "DEFEND_UNTIL_TIME_LIMIT", |
| 22 | + "STALEMATE", |
| 23 | + "TIMELIMIT", |
| 24 | + "WINLIMIT", |
| 25 | + "WINDIFFLIMIT", |
| 26 | +#ifdef TF_DLL |
| 27 | + "RD_REACTOR_CAPTURED", |
| 28 | + "RD_CORES_COLLECTED", |
| 29 | + "RD_REACTOR_RETURNED", |
| 30 | + "PD_POINTS", |
| 31 | + "SCORED", |
| 32 | + "STOPWATCH_WATCHING_ROUNDS", |
| 33 | + "STOPWATCH_WATCHING_FINAL_ROUND", |
| 34 | + "STOPWATCH_PLAYING_ROUNDS", |
| 35 | +#endif |
| 36 | +}; |
| 37 | + |
| 38 | +// Add any new win reasons to the array above |
| 39 | +COMPILE_TIME_ASSERT( ARRAYSIZE( g_pszWinReasons ) == WINREASON_COUNT ); |
| 40 | +#endif |
| 41 | + |
14 | 42 | //============================================================================= |
15 | 43 | // |
16 | 44 | // CTeamplayRoundWin tables. |
@@ -42,6 +70,39 @@ CTeamplayRoundWin::CTeamplayRoundWin() |
42 | 70 | m_iWinReason = WINREASON_DEFEND_UNTIL_TIME_LIMIT; |
43 | 71 | } |
44 | 72 |
|
| 73 | +//----------------------------------------------------------------------------- |
| 74 | +// Purpose: |
| 75 | +//----------------------------------------------------------------------------- |
| 76 | +bool CTeamplayRoundWin::KeyValue( const char *szKeyName, const char *szValue ) |
| 77 | +{ |
| 78 | +#ifdef MAPBASE |
| 79 | + if ( FStrEq( szKeyName, "win_reason" ) ) |
| 80 | + { |
| 81 | + // Allow string input |
| 82 | + if ( szValue[0] == 'W' ) |
| 83 | + { |
| 84 | + // Strip the WINREASON_ so that we only compare the part that matters |
| 85 | + const char *pszCompareValue = szValue + 10; |
| 86 | + for ( int i = 0; i < ARRAYSIZE( g_pszWinReasons ); i++ ) |
| 87 | + { |
| 88 | + if ( FStrEq( pszCompareValue, g_pszWinReasons[i] ) ) |
| 89 | + { |
| 90 | + m_iWinReason = i; |
| 91 | + return true; |
| 92 | + } |
| 93 | + } |
| 94 | + |
| 95 | + // Win reason string does not match any known value |
| 96 | + Warning( "%s: Invalid win reason \"%s\"", GetDebugName(), szValue ); |
| 97 | + } |
| 98 | + |
| 99 | + // Fall through to base class for integer handling |
| 100 | + } |
| 101 | +#endif |
| 102 | + |
| 103 | + return BaseClass::KeyValue( szKeyName, szValue ); |
| 104 | +} |
| 105 | + |
45 | 106 | //----------------------------------------------------------------------------- |
46 | 107 | // Purpose: |
47 | 108 | //----------------------------------------------------------------------------- |
|
0 commit comments