Attempting fix for SendConVarValue crash (bug 4315, r=fyren, a13=me).
This commit is contained in:
parent
b5a2ec7a5e
commit
bf345eea8c
@ -61,6 +61,7 @@ int lifestate_offset = -1;
|
|||||||
List<ICommandTargetProcessor *> target_processors;
|
List<ICommandTargetProcessor *> target_processors;
|
||||||
|
|
||||||
SH_DECL_HOOK5(IServerGameClients, ClientConnect, SH_NOATTRIB, 0, bool, edict_t *, const char *, const char *, char *, int);
|
SH_DECL_HOOK5(IServerGameClients, ClientConnect, SH_NOATTRIB, 0, bool, edict_t *, const char *, const char *, char *, int);
|
||||||
|
SH_DECL_HOOK2_void(IServerGameClients, ClientActive, SH_NOATTRIB, 0, edict_t *, bool);
|
||||||
SH_DECL_HOOK2_void(IServerGameClients, ClientPutInServer, SH_NOATTRIB, 0, edict_t *, const char *);
|
SH_DECL_HOOK2_void(IServerGameClients, ClientPutInServer, SH_NOATTRIB, 0, edict_t *, const char *);
|
||||||
SH_DECL_HOOK1_void(IServerGameClients, ClientDisconnect, SH_NOATTRIB, 0, edict_t *);
|
SH_DECL_HOOK1_void(IServerGameClients, ClientDisconnect, SH_NOATTRIB, 0, edict_t *);
|
||||||
#if SOURCE_ENGINE >= SE_ORANGEBOX
|
#if SOURCE_ENGINE >= SE_ORANGEBOX
|
||||||
@ -135,6 +136,7 @@ void PlayerManager::OnSourceModAllInitialized()
|
|||||||
SH_ADD_HOOK_MEMFUNC(IServerGameClients, ClientCommand, serverClients, this, &PlayerManager::OnClientCommand, false);
|
SH_ADD_HOOK_MEMFUNC(IServerGameClients, ClientCommand, serverClients, this, &PlayerManager::OnClientCommand, false);
|
||||||
SH_ADD_HOOK_MEMFUNC(IServerGameClients, ClientSettingsChanged, serverClients, this, &PlayerManager::OnClientSettingsChanged, true);
|
SH_ADD_HOOK_MEMFUNC(IServerGameClients, ClientSettingsChanged, serverClients, this, &PlayerManager::OnClientSettingsChanged, true);
|
||||||
SH_ADD_HOOK_MEMFUNC(IServerGameDLL, ServerActivate, gamedll, this, &PlayerManager::OnServerActivate, true);
|
SH_ADD_HOOK_MEMFUNC(IServerGameDLL, ServerActivate, gamedll, this, &PlayerManager::OnServerActivate, true);
|
||||||
|
SH_ADD_HOOK_MEMFUNC(IServerGameClients, ClientActive, serverClients, this, &PlayerManager::OnClientActive, true);
|
||||||
|
|
||||||
g_ShareSys.AddInterface(NULL, this);
|
g_ShareSys.AddInterface(NULL, this);
|
||||||
|
|
||||||
@ -171,6 +173,7 @@ void PlayerManager::OnSourceModAllInitialized()
|
|||||||
|
|
||||||
void PlayerManager::OnSourceModShutdown()
|
void PlayerManager::OnSourceModShutdown()
|
||||||
{
|
{
|
||||||
|
SH_REMOVE_HOOK_MEMFUNC(IServerGameClients, ClientActive, serverClients, this, &PlayerManager::OnClientActive, true);
|
||||||
SH_REMOVE_HOOK_MEMFUNC(IServerGameClients, ClientConnect, serverClients, this, &PlayerManager::OnClientConnect, false);
|
SH_REMOVE_HOOK_MEMFUNC(IServerGameClients, ClientConnect, serverClients, this, &PlayerManager::OnClientConnect, false);
|
||||||
SH_REMOVE_HOOK_MEMFUNC(IServerGameClients, ClientPutInServer, serverClients, this, &PlayerManager::OnClientPutInServer, true);
|
SH_REMOVE_HOOK_MEMFUNC(IServerGameClients, ClientPutInServer, serverClients, this, &PlayerManager::OnClientPutInServer, true);
|
||||||
SH_REMOVE_HOOK_MEMFUNC(IServerGameClients, ClientDisconnect, serverClients, this, &PlayerManager::OnClientDisconnect, false);
|
SH_REMOVE_HOOK_MEMFUNC(IServerGameClients, ClientDisconnect, serverClients, this, &PlayerManager::OnClientDisconnect, false);
|
||||||
@ -489,6 +492,14 @@ bool PlayerManager::OnClientConnect_Post(edict_t *pEntity, const char *pszName,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PlayerManager::OnClientActive(edict_t *pEntity, bool bLoadGame)
|
||||||
|
{
|
||||||
|
int client = IndexOfEdict(pEntity);
|
||||||
|
CPlayer *pPlayer = &m_Players[client];
|
||||||
|
|
||||||
|
pPlayer->Activate();
|
||||||
|
}
|
||||||
|
|
||||||
void PlayerManager::OnClientPutInServer(edict_t *pEntity, const char *playername)
|
void PlayerManager::OnClientPutInServer(edict_t *pEntity, const char *playername)
|
||||||
{
|
{
|
||||||
cell_t res;
|
cell_t res;
|
||||||
@ -1445,6 +1456,7 @@ CPlayer::CPlayer()
|
|||||||
m_LastPassword.clear();
|
m_LastPassword.clear();
|
||||||
m_LangId = SOURCEMOD_LANGUAGE_ENGLISH;
|
m_LangId = SOURCEMOD_LANGUAGE_ENGLISH;
|
||||||
m_bFakeClient = false;
|
m_bFakeClient = false;
|
||||||
|
m_IsActive = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPlayer::Initialize(const char *name, const char *ip, edict_t *pEntity)
|
void CPlayer::Initialize(const char *name, const char *ip, edict_t *pEntity)
|
||||||
@ -1516,6 +1528,7 @@ void CPlayer::Disconnect()
|
|||||||
m_UserId = -1;
|
m_UserId = -1;
|
||||||
m_bIsInKickQueue = false;
|
m_bIsInKickQueue = false;
|
||||||
m_bFakeClient = false;
|
m_bFakeClient = false;
|
||||||
|
m_IsActive = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPlayer::SetName(const char *name)
|
void CPlayer::SetName(const char *name)
|
||||||
@ -1827,3 +1840,14 @@ unsigned int CPlayer::GetSerial()
|
|||||||
{
|
{
|
||||||
return m_Serial.value;
|
return m_Serial.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CPlayer::IsActive()
|
||||||
|
{
|
||||||
|
return m_IsActive;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CPlayer::Activate()
|
||||||
|
{
|
||||||
|
m_IsActive = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -72,6 +72,7 @@ public:
|
|||||||
const char *GetAuthString();
|
const char *GetAuthString();
|
||||||
edict_t *GetEdict();
|
edict_t *GetEdict();
|
||||||
bool IsInGame();
|
bool IsInGame();
|
||||||
|
bool IsActive();
|
||||||
bool WasCountedAsInGame();
|
bool WasCountedAsInGame();
|
||||||
bool IsConnected();
|
bool IsConnected();
|
||||||
bool IsAuthorized();
|
bool IsAuthorized();
|
||||||
@ -90,6 +91,7 @@ public:
|
|||||||
void DoBasicAdminChecks();
|
void DoBasicAdminChecks();
|
||||||
void MarkAsBeingKicked();
|
void MarkAsBeingKicked();
|
||||||
int GetLifeState();
|
int GetLifeState();
|
||||||
|
void Activate();
|
||||||
private:
|
private:
|
||||||
void Initialize(const char *name, const char *ip, edict_t *pEntity);
|
void Initialize(const char *name, const char *ip, edict_t *pEntity);
|
||||||
void Connect();
|
void Connect();
|
||||||
@ -119,6 +121,7 @@ private:
|
|||||||
int m_UserId;
|
int m_UserId;
|
||||||
bool m_bFakeClient;
|
bool m_bFakeClient;
|
||||||
serial_t m_Serial;
|
serial_t m_Serial;
|
||||||
|
bool m_IsActive;
|
||||||
};
|
};
|
||||||
|
|
||||||
class PlayerManager :
|
class PlayerManager :
|
||||||
@ -147,6 +150,7 @@ public:
|
|||||||
void OnClientPutInServer(edict_t *pEntity, char const *playername);
|
void OnClientPutInServer(edict_t *pEntity, char const *playername);
|
||||||
void OnClientDisconnect(edict_t *pEntity);
|
void OnClientDisconnect(edict_t *pEntity);
|
||||||
void OnClientDisconnect_Post(edict_t *pEntity);
|
void OnClientDisconnect_Post(edict_t *pEntity);
|
||||||
|
void OnClientActive(edict_t *pEntity, bool bLoadGame);
|
||||||
#if SOURCE_ENGINE >= SE_ORANGEBOX
|
#if SOURCE_ENGINE >= SE_ORANGEBOX
|
||||||
void OnClientCommand(edict_t *pEntity, const CCommand &args);
|
void OnClientCommand(edict_t *pEntity, const CCommand &args);
|
||||||
#else
|
#else
|
||||||
|
@ -45,6 +45,7 @@
|
|||||||
#include <sm_trie_tpl.h>
|
#include <sm_trie_tpl.h>
|
||||||
#include "Logger.h"
|
#include "Logger.h"
|
||||||
#include "ConsoleDetours.h"
|
#include "ConsoleDetours.h"
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
#if (SOURCE_ENGINE == SE_LEFT4DEAD) || (SOURCE_ENGINE == SE_LEFT4DEAD2)
|
#if (SOURCE_ENGINE == SE_LEFT4DEAD) || (SOURCE_ENGINE == SE_LEFT4DEAD2)
|
||||||
#define NET_SETCONVAR 6
|
#define NET_SETCONVAR 6
|
||||||
@ -200,6 +201,7 @@ static void ReplicateConVar(ConVar *pConVar)
|
|||||||
|
|
||||||
if (pPlayer && pPlayer->IsInGame() && !pPlayer->IsFakeClient())
|
if (pPlayer && pPlayer->IsInGame() && !pPlayer->IsFakeClient())
|
||||||
{
|
{
|
||||||
|
assert(pPlayer->IsActive());
|
||||||
INetChannel *netchan = static_cast<INetChannel *>(engine->GetPlayerNetInfo(i));
|
INetChannel *netchan = static_cast<INetChannel *>(engine->GetPlayerNetInfo(i));
|
||||||
netchan->SendData(buffer);
|
netchan->SendData(buffer);
|
||||||
}
|
}
|
||||||
@ -1321,6 +1323,11 @@ static cell_t SendConVarValue(IPluginContext *pContext, const cell_t *params)
|
|||||||
return pContext->ThrowNativeError("Client %d is fake and cannot be targeted", params[1]);
|
return pContext->ThrowNativeError("Client %d is fake and cannot be targeted", params[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!pPlayer->IsActive())
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
INetChannel *netchan = static_cast<INetChannel *>(engine->GetPlayerNetInfo(params[1]));
|
INetChannel *netchan = static_cast<INetChannel *>(engine->GetPlayerNetInfo(params[1]));
|
||||||
netchan->SendData(buffer);
|
netchan->SendData(buffer);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user