Fixed Replay dectection on TF2 and SourceTV detection on ND (bug 5529, r=asherkin).
authorNicholas Hastings <skamonkey@gmail.com>
Sat Nov 24 09:56:46 2012 -0500 (2012-11-24)
changeset 36929d4a1d8d9a39
parent 3691 09c4ca9c9712
child 3693 16b6bd52a029
Fixed Replay dectection on TF2 and SourceTV detection on ND (bug 5529, r=asherkin).
core/PlayerManager.cpp
     1.1 --- a/core/PlayerManager.cpp	Sat Nov 24 09:53:44 2012 -0500
     1.2 +++ b/core/PlayerManager.cpp	Sat Nov 24 09:56:46 2012 -0500
     1.3 @@ -569,18 +569,37 @@
     1.4  		 * Checking playerinfo's IsHLTV and IsReplay would be better and less
     1.5  		 * error-prone but will always show false until later in the frame,
     1.6  		 * after PutInServer and Activate, and we want it now!
     1.7 +		 *
     1.8 +		 * These checks are hairy as hell due to differences between engines and games.
     1.9 +		 * 
    1.10 +		 * Most engines use "Replay" and "SourceTV" as bot names for these when they're
    1.11 +		 * created. EP2V, CSS and Nuclear Dawn (but not L4D2) differ from this by now using
    1.12 +		 * replay_/tv_name directly when creating the bot(s). To complicate it slightly
    1.13 +		 * further, the cvar can be empty and the engine's fallback to "unnamed" will be used.
    1.14 +		 * We can maybe just rip out the name checks at some point and rely solely on whether
    1.15 +		 * they're enabled and the join order.
    1.16  		 */
    1.17  		
    1.18  		// This doesn't actually get incremented until OnClientConnect. Fake it to check.
    1.19  		int newCount = m_PlayersSinceActive + 1;
    1.20 +
    1.21  		int userId = engine->GetPlayerUserId(pEntity);
    1.22 -#if (SOURCE_ENGINE == SE_ORANGEBOXVALVE || SOURCE_ENGINE == SE_CSS)
    1.23 +#if (SOURCE_ENGINE == SE_ORANGEBOXVALVE || SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_LEFT4DEAD2)
    1.24  		static ConVar *tv_name = icvar->FindVar("tv_name");
    1.25  #endif
    1.26 +#if SOURCE_ENGINE == SE_ORANGEBOXVALVE
    1.27 +		static ConVar *replay_name = icvar->FindVar("replay_name");
    1.28 +#endif
    1.29 +#if SOURCE_ENGINE == SE_LEFT4DEAD2
    1.30 +		static bool bIsNuclearDawn = (strcmp(g_SourceMod.GetGameFolderName(), "nucleardawn") == 0);
    1.31 +#endif
    1.32  
    1.33  #if SOURCE_ENGINE == SE_ORANGEBOXVALVE
    1.34  		if (m_bIsReplayActive && newCount == 1
    1.35 -			&& (m_ReplayUserId == userId || strcmp(playername, "Replay") == 0))
    1.36 +			&& (m_ReplayUserId == userId
    1.37 +				|| (replay_name && strcmp(playername, replay_name->GetString()) == 0) || (replay_name && replay_name->GetString()[0] == 0 && strcmp(playername, "unnamed") == 0)
    1.38 +				)
    1.39 +			)
    1.40  		{
    1.41  			pPlayer->m_bIsReplay = true;
    1.42  			m_ReplayUserId = userId;
    1.43 @@ -590,13 +609,22 @@
    1.44  		if (m_bIsSourceTVActive
    1.45  			&& ((!m_bIsReplayActive && newCount == 1)
    1.46  				|| (m_bIsReplayActive && newCount == 2))
    1.47 +			&& (m_SourceTVUserId == userId
    1.48  #if SOURCE_ENGINE == SE_CSGO
    1.49 -			&& (m_SourceTVUserId == userId || strcmp(playername, "GOTV") == 0)
    1.50 -#elif (SOURCE_ENGINE == SE_ORANGEBOXVALVE || SOURCE_ENGINE == SE_CSS)
    1.51 -				&& (m_SourceTVUserId == userId || (tv_name && strcmp(playername, tv_name->GetString()) == 0) || (tv_name && tv_name->GetString()[0] == 0 && strcmp(playername, "unnamed") == 0))
    1.52 +				|| strcmp(playername, "GOTV") == 0
    1.53 +#elif (SOURCE_ENGINE == SE_ORANGEBOXVALVE || SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_LEFT4DEAD2)
    1.54 +#if SOURCE_ENGINE == SE_LEFT4DEAD2
    1.55 +				|| (bIsNuclearDawn && ( true
    1.56 +#endif // SE_LEFT4DEAD2
    1.57 +				|| (tv_name && strcmp(playername, tv_name->GetString()) == 0) || (tv_name && tv_name->GetString()[0] == 0 && strcmp(playername, "unnamed") == 0)
    1.58 +#if SOURCE_ENGINE == SE_LEFT4DEAD2
    1.59 +					))
    1.60 +				|| (!bIsNuclearDawn && strcmp(playername, "SourceTV") == 0)
    1.61 +#endif // SE_LEFT4DEAD2
    1.62  #else
    1.63 -			&& (m_SourceTVUserId == userId || strcmp(playername, "SourceTV") == 0)
    1.64 +				|| strcmp(playername, "SourceTV") == 0
    1.65  #endif
    1.66 +				)
    1.67  			)
    1.68  		{
    1.69  			pPlayer->m_bIsSourceTV = true;