Populate MaxClients before OnPluginStart is called.
This commit is contained in:
parent
71cb002bc1
commit
8fc689c89a
@ -138,6 +138,8 @@ PlayerManager::PlayerManager()
|
|||||||
|
|
||||||
m_UserIdLookUp = new int[USHRT_MAX+1];
|
m_UserIdLookUp = new int[USHRT_MAX+1];
|
||||||
memset(m_UserIdLookUp, 0, sizeof(int) * (USHRT_MAX+1));
|
memset(m_UserIdLookUp, 0, sizeof(int) * (USHRT_MAX+1));
|
||||||
|
|
||||||
|
InitializePlayers();
|
||||||
}
|
}
|
||||||
|
|
||||||
PlayerManager::~PlayerManager()
|
PlayerManager::~PlayerManager()
|
||||||
@ -148,6 +150,20 @@ PlayerManager::~PlayerManager()
|
|||||||
delete [] m_UserIdLookUp;
|
delete [] m_UserIdLookUp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PlayerManager::InitializePlayers()
|
||||||
|
{
|
||||||
|
/* Initialize all players */
|
||||||
|
|
||||||
|
m_PlayerCount = 0;
|
||||||
|
m_Players = new CPlayer[SM_MAXPLAYERS + 1];
|
||||||
|
m_AuthQueue = new unsigned int[SM_MAXPLAYERS + 1];
|
||||||
|
m_FirstPass = true;
|
||||||
|
|
||||||
|
memset(m_AuthQueue, 0, sizeof(unsigned int) * (SM_MAXPLAYERS + 1));
|
||||||
|
|
||||||
|
g_NumPlayersToAuth = &m_AuthQueue[0];
|
||||||
|
}
|
||||||
|
|
||||||
void PlayerManager::OnSourceModAllInitialized()
|
void PlayerManager::OnSourceModAllInitialized()
|
||||||
{
|
{
|
||||||
SH_ADD_HOOK(IServerGameClients, ClientConnect, serverClients, SH_MEMBER(this, &PlayerManager::OnClientConnect), false);
|
SH_ADD_HOOK(IServerGameClients, ClientConnect, serverClients, SH_MEMBER(this, &PlayerManager::OnClientConnect), false);
|
||||||
@ -285,9 +301,6 @@ void PlayerManager::OnServerActivate(edict_t *pEdictList, int edictCount, int cl
|
|||||||
static ConVar *replay_enable = icvar->FindVar("replay_enable");
|
static ConVar *replay_enable = icvar->FindVar("replay_enable");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// clientMax will not necessarily be correct here (such as on late SourceTV enable)
|
|
||||||
m_maxClients = gpGlobals->maxClients;
|
|
||||||
|
|
||||||
ICommandLine *commandLine = g_HL2.GetValveCommandLine();
|
ICommandLine *commandLine = g_HL2.GetValveCommandLine();
|
||||||
m_bIsSourceTVActive = (tv_enable && tv_enable->GetBool() && (!commandLine || commandLine->FindParm("-nohltv") == 0));
|
m_bIsSourceTVActive = (tv_enable && tv_enable->GetBool() && (!commandLine || commandLine->FindParm("-nohltv") == 0));
|
||||||
m_bIsReplayActive = false;
|
m_bIsReplayActive = false;
|
||||||
@ -298,20 +311,9 @@ void PlayerManager::OnServerActivate(edict_t *pEdictList, int edictCount, int cl
|
|||||||
|
|
||||||
if (!m_FirstPass)
|
if (!m_FirstPass)
|
||||||
{
|
{
|
||||||
/* Initialize all players */
|
InitializePlayers();
|
||||||
|
|
||||||
m_PlayerCount = 0;
|
|
||||||
m_Players = new CPlayer[SM_MAXPLAYERS + 1];
|
|
||||||
m_AuthQueue = new unsigned int[SM_MAXPLAYERS + 1];
|
|
||||||
m_FirstPass = true;
|
|
||||||
|
|
||||||
memset(m_AuthQueue, 0, sizeof(unsigned int) * (SM_MAXPLAYERS + 1));
|
|
||||||
|
|
||||||
g_NumPlayersToAuth = &m_AuthQueue[0];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
scripts->SyncMaxClients(m_maxClients);
|
|
||||||
|
|
||||||
g_OnMapStarted = true;
|
g_OnMapStarted = true;
|
||||||
|
|
||||||
#if SOURCE_ENGINE == SE_DOTA
|
#if SOURCE_ENGINE == SE_DOTA
|
||||||
|
@ -233,6 +233,8 @@ private:
|
|||||||
void OnServerActivate(edict_t *pEdictList, int edictCount, int clientMax);
|
void OnServerActivate(edict_t *pEdictList, int edictCount, int clientMax);
|
||||||
#endif
|
#endif
|
||||||
void InvalidatePlayer(CPlayer *pPlayer);
|
void InvalidatePlayer(CPlayer *pPlayer);
|
||||||
|
private:
|
||||||
|
void InitializePlayers();
|
||||||
private:
|
private:
|
||||||
List<IClientListener *> m_hooks;
|
List<IClientListener *> m_hooks;
|
||||||
IForward *m_clconnect;
|
IForward *m_clconnect;
|
||||||
|
@ -320,6 +320,8 @@ void SourceModBase::StartSourceMod(bool late)
|
|||||||
static bool g_LevelEndBarrier = false;
|
static bool g_LevelEndBarrier = false;
|
||||||
bool SourceModBase::LevelInit(char const *pMapName, char const *pMapEntities, char const *pOldLevel, char const *pLandmarkName, bool loadGame, bool background)
|
bool SourceModBase::LevelInit(char const *pMapName, char const *pMapEntities, char const *pOldLevel, char const *pLandmarkName, bool loadGame, bool background)
|
||||||
{
|
{
|
||||||
|
g_Players.MaxPlayersChanged();
|
||||||
|
|
||||||
/* If we're not loaded... */
|
/* If we're not loaded... */
|
||||||
if (!g_Loaded)
|
if (!g_Loaded)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user