Guest User

Untitled

a guest
Jan 21st, 2018
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 4.80 KB | None | 0 0
  1. # HG changeset patch
  2. # Parent 2d36dca5cdd5f7d8bf30e7e38fea051f78b90709
  3. diff --git a/core/PlayerManager.cpp b/core/PlayerManager.cpp
  4. --- a/core/PlayerManager.cpp
  5. +++ b/core/PlayerManager.cpp
  6. @@ -44,6 +44,7 @@
  7.  #include "HalfLife2.h"
  8.  #include <inetchannel.h>
  9.  #include <iclient.h>
  10. +#include <tier0/icommandline.h>
  11.  #include <IGameConfigs.h>
  12.  #include "ExtensionSys.h"
  13.  #include <sourcemod_version.h>
  14. @@ -240,6 +241,7 @@
  15.         /* Initialize all players */
  16.  
  17.         m_PlayerCount = 0;
  18. +       m_PlayersSinceActive = 0;
  19.         m_Players = new CPlayer[ABSOLUTE_PLAYER_LIMIT + 1];
  20.         m_AuthQueue = new unsigned int[ABSOLUTE_PLAYER_LIMIT + 1];
  21.         m_FirstPass = true;
  22. @@ -410,6 +412,7 @@
  23.  {
  24.     int client = IndexOfEdict(pEntity);
  25.     CPlayer *pPlayer = &m_Players[client];
  26. +   ++m_PlayersSinceActive;
  27.  
  28.     List<IClientListener *>::iterator iter;
  29.     IClientListener *pListener = NULL;
  30. @@ -495,6 +498,12 @@
  31.     int client = IndexOfEdict(pEntity);
  32.     CPlayer *pPlayer = &m_Players[client];
  33.  
  34. +   static ConVarRef tv_enable = ConVarRef("tv_enable");
  35. +   static bool bNoHLTV = (CommandLine()->FindParm("-nohltv") == 0);
  36. +#if SOURCE_ENGINE == SE_ORANGEBOXVALVE
  37. +   static ConVarRef replay_enable = ConVarRef("replay_enable");
  38. +#endif
  39. +
  40.     /* If they're not connected, they're a bot */
  41.     if (!pPlayer->IsConnected())
  42.     {
  43. @@ -503,6 +512,36 @@
  44.         const char *authid = engine->GetPlayerNetworkIDString(pEntity);
  45.         pPlayer->Authorize(authid);
  46.         pPlayer->m_bFakeClient = true;
  47. +
  48. +       /*
  49. +        * While we're already filtered to just bots, we'll do another check
  50. +        * to make sure the requisite services are enabled. If not, these are
  51. +        * just other bots that happened to have the same name
  52. +        *
  53. +        * Checking playerinfo's IsHLTV and IsReplay would be better and less
  54. +        * error-prone but will always show false until later in the frame,
  55. +        * after PutInServer and Activate, and we want it now!
  56. +        */
  57. +      
  58. +      
  59. +       bool bReplayEnabled = false;
  60. +#if SOURCE_ENGINE == SE_ORANGEBOXVALVE
  61. +       bReplayEnabled = (replay_enable.IsValid() && replay_enable.GetBool());
  62. +       if (bReplayEnabled && m_PlayersSinceActive+1 == 0
  63. +           && strcmp(playername, "Replay") == 0)
  64. +       {
  65. +           pPlayer->m_bIsReplay = true;
  66. +       }
  67. +#endif
  68. +       bool bTVEnabled = (tv_enable.IsValid() && tv_enable.GetBool());
  69. +       if (bTVEnabled && !bNoHLTV
  70. +           && ((!bReplayEnabled && (m_PlayersSinceActive+1) == 0)
  71. +               ||(bReplayEnabled && (m_PlayersSinceActive+2) == 0))
  72. +           && strcmp(playername, "SourceTV") == 0)
  73. +       {
  74. +           pPlayer->m_bIsSourceTV = true;
  75. +       }
  76. +
  77.         if (!OnClientConnect(pEntity, playername, "127.0.0.1", error, sizeof(error)))
  78.         {
  79.             /* :TODO: kick the bot if it's rejected */
  80. @@ -1450,6 +1489,8 @@
  81.     m_LastPassword.clear();
  82.     m_LangId = SOURCEMOD_LANGUAGE_ENGLISH;
  83.     m_bFakeClient = false;
  84. +   m_bIsSourceTV = false;
  85. +   m_bIsReplay = false;
  86.     m_Serial.value = -1;
  87.  }
  88.  
  89. @@ -1522,6 +1563,8 @@
  90.     m_UserId = -1;
  91.     m_bIsInKickQueue = false;
  92.     m_bFakeClient = false;
  93. +   m_bIsSourceTV = false;
  94. +   m_bIsReplay = false;
  95.     m_Serial.value = -1;
  96.  }
  97.  
  98. @@ -1590,6 +1633,16 @@
  99.     return m_bFakeClient;
  100.  }
  101.  
  102. +bool CPlayer::IsSourceTV() const
  103. +{
  104. +   return m_bIsSourceTV;
  105. +}
  106. +
  107. +bool CPlayer::IsReplay() const
  108. +{
  109. +   return m_bIsReplay;
  110. +}
  111. +
  112.  void CPlayer::SetAdminId(AdminId id, bool temporary)
  113.  {
  114.     if (!m_IsConnected)
  115. diff --git a/core/PlayerManager.h b/core/PlayerManager.h
  116. --- a/core/PlayerManager.h
  117. +++ b/core/PlayerManager.h
  118. @@ -76,6 +76,8 @@
  119.     bool IsConnected();
  120.     bool IsAuthorized();
  121.     bool IsFakeClient();
  122. +   bool IsSourceTV() const;
  123. +   bool IsReplay() const;
  124.     void SetAdminId(AdminId id, bool temporary);
  125.     AdminId GetAdminId();
  126.     void Kick(const char *str);
  127. @@ -119,6 +121,8 @@
  128.     unsigned int m_LangId;
  129.     int m_UserId;
  130.     bool m_bFakeClient;
  131. +   bool m_bIsSourceTV;
  132. +   bool m_bIsReplay;
  133.     serial_t m_Serial;
  134.  };
  135.  
  136. @@ -208,6 +212,7 @@
  137.     int *m_UserIdLookUp;
  138.     int m_maxClients;
  139.     int m_PlayerCount;
  140. +   int m_PlayersSinceActive;
  141.     bool m_FirstPass;
  142.     unsigned int *m_AuthQueue;
  143.     String m_PassInfoVar;
  144. diff --git a/public/IPlayerHelpers.h b/public/IPlayerHelpers.h
  145. --- a/public/IPlayerHelpers.h
  146. +++ b/public/IPlayerHelpers.h
  147. @@ -41,7 +41,7 @@
  148.  #include <IAdminSystem.h>
  149.  
  150.  #define SMINTERFACE_PLAYERMANAGER_NAME     "IPlayerManager"
  151. -#define SMINTERFACE_PLAYERMANAGER_VERSION  14
  152. +#define SMINTERFACE_PLAYERMANAGER_VERSION  15
  153.  
  154.  struct edict_t;
  155.  class IPlayerInfo;
  156. @@ -222,6 +222,20 @@
  157.         virtual void MarkAsBeingKicked() =0;
  158.  
  159.         virtual void SetLanguageId(unsigned int id) =0;
  160. +
  161. +       /**
  162. +        * @brief Returns whether the player is the SourceTV bot.
  163. +        *
  164. +        * @return      True if the SourceTV bot, false otherwise.
  165. +        */
  166. +       virtual bool IsSourceTV() const =0;
  167. +      
  168. +       /**
  169. +        * @brief Returns whether the player is the Replay bot.
  170. +        *
  171. +        * @return      True if the Replay bot, false otherwise.
  172. +        */
  173. +       virtual bool IsReplay() const =0;
  174.     };
  175.  
  176.     /**
Add Comment
Please, Sign In to add comment