Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # HG changeset patch
- # Parent 2d36dca5cdd5f7d8bf30e7e38fea051f78b90709
- diff --git a/core/PlayerManager.cpp b/core/PlayerManager.cpp
- --- a/core/PlayerManager.cpp
- +++ b/core/PlayerManager.cpp
- @@ -44,6 +44,7 @@
- #include "HalfLife2.h"
- #include <inetchannel.h>
- #include <iclient.h>
- +#include <tier0/icommandline.h>
- #include <IGameConfigs.h>
- #include "ExtensionSys.h"
- #include <sourcemod_version.h>
- @@ -240,6 +241,7 @@
- /* Initialize all players */
- m_PlayerCount = 0;
- + m_PlayersSinceActive = 0;
- m_Players = new CPlayer[ABSOLUTE_PLAYER_LIMIT + 1];
- m_AuthQueue = new unsigned int[ABSOLUTE_PLAYER_LIMIT + 1];
- m_FirstPass = true;
- @@ -410,6 +412,7 @@
- {
- int client = IndexOfEdict(pEntity);
- CPlayer *pPlayer = &m_Players[client];
- + ++m_PlayersSinceActive;
- List<IClientListener *>::iterator iter;
- IClientListener *pListener = NULL;
- @@ -495,6 +498,12 @@
- int client = IndexOfEdict(pEntity);
- CPlayer *pPlayer = &m_Players[client];
- + static ConVarRef tv_enable = ConVarRef("tv_enable");
- + static bool bNoHLTV = (CommandLine()->FindParm("-nohltv") == 0);
- +#if SOURCE_ENGINE == SE_ORANGEBOXVALVE
- + static ConVarRef replay_enable = ConVarRef("replay_enable");
- +#endif
- +
- /* If they're not connected, they're a bot */
- if (!pPlayer->IsConnected())
- {
- @@ -503,6 +512,36 @@
- const char *authid = engine->GetPlayerNetworkIDString(pEntity);
- pPlayer->Authorize(authid);
- pPlayer->m_bFakeClient = true;
- +
- + /*
- + * While we're already filtered to just bots, we'll do another check
- + * to make sure the requisite services are enabled. If not, these are
- + * just other bots that happened to have the same name
- + *
- + * Checking playerinfo's IsHLTV and IsReplay would be better and less
- + * error-prone but will always show false until later in the frame,
- + * after PutInServer and Activate, and we want it now!
- + */
- +
- +
- + bool bReplayEnabled = false;
- +#if SOURCE_ENGINE == SE_ORANGEBOXVALVE
- + bReplayEnabled = (replay_enable.IsValid() && replay_enable.GetBool());
- + if (bReplayEnabled && m_PlayersSinceActive+1 == 0
- + && strcmp(playername, "Replay") == 0)
- + {
- + pPlayer->m_bIsReplay = true;
- + }
- +#endif
- + bool bTVEnabled = (tv_enable.IsValid() && tv_enable.GetBool());
- + if (bTVEnabled && !bNoHLTV
- + && ((!bReplayEnabled && (m_PlayersSinceActive+1) == 0)
- + ||(bReplayEnabled && (m_PlayersSinceActive+2) == 0))
- + && strcmp(playername, "SourceTV") == 0)
- + {
- + pPlayer->m_bIsSourceTV = true;
- + }
- +
- if (!OnClientConnect(pEntity, playername, "127.0.0.1", error, sizeof(error)))
- {
- /* :TODO: kick the bot if it's rejected */
- @@ -1450,6 +1489,8 @@
- m_LastPassword.clear();
- m_LangId = SOURCEMOD_LANGUAGE_ENGLISH;
- m_bFakeClient = false;
- + m_bIsSourceTV = false;
- + m_bIsReplay = false;
- m_Serial.value = -1;
- }
- @@ -1522,6 +1563,8 @@
- m_UserId = -1;
- m_bIsInKickQueue = false;
- m_bFakeClient = false;
- + m_bIsSourceTV = false;
- + m_bIsReplay = false;
- m_Serial.value = -1;
- }
- @@ -1590,6 +1633,16 @@
- return m_bFakeClient;
- }
- +bool CPlayer::IsSourceTV() const
- +{
- + return m_bIsSourceTV;
- +}
- +
- +bool CPlayer::IsReplay() const
- +{
- + return m_bIsReplay;
- +}
- +
- void CPlayer::SetAdminId(AdminId id, bool temporary)
- {
- if (!m_IsConnected)
- diff --git a/core/PlayerManager.h b/core/PlayerManager.h
- --- a/core/PlayerManager.h
- +++ b/core/PlayerManager.h
- @@ -76,6 +76,8 @@
- bool IsConnected();
- bool IsAuthorized();
- bool IsFakeClient();
- + bool IsSourceTV() const;
- + bool IsReplay() const;
- void SetAdminId(AdminId id, bool temporary);
- AdminId GetAdminId();
- void Kick(const char *str);
- @@ -119,6 +121,8 @@
- unsigned int m_LangId;
- int m_UserId;
- bool m_bFakeClient;
- + bool m_bIsSourceTV;
- + bool m_bIsReplay;
- serial_t m_Serial;
- };
- @@ -208,6 +212,7 @@
- int *m_UserIdLookUp;
- int m_maxClients;
- int m_PlayerCount;
- + int m_PlayersSinceActive;
- bool m_FirstPass;
- unsigned int *m_AuthQueue;
- String m_PassInfoVar;
- diff --git a/public/IPlayerHelpers.h b/public/IPlayerHelpers.h
- --- a/public/IPlayerHelpers.h
- +++ b/public/IPlayerHelpers.h
- @@ -41,7 +41,7 @@
- #include <IAdminSystem.h>
- #define SMINTERFACE_PLAYERMANAGER_NAME "IPlayerManager"
- -#define SMINTERFACE_PLAYERMANAGER_VERSION 14
- +#define SMINTERFACE_PLAYERMANAGER_VERSION 15
- struct edict_t;
- class IPlayerInfo;
- @@ -222,6 +222,20 @@
- virtual void MarkAsBeingKicked() =0;
- virtual void SetLanguageId(unsigned int id) =0;
- +
- + /**
- + * @brief Returns whether the player is the SourceTV bot.
- + *
- + * @return True if the SourceTV bot, false otherwise.
- + */
- + virtual bool IsSourceTV() const =0;
- +
- + /**
- + * @brief Returns whether the player is the Replay bot.
- + *
- + * @return True if the Replay bot, false otherwise.
- + */
- + virtual bool IsReplay() const =0;
- };
- /**
Add Comment
Please, Sign In to add comment