Populate MaxClients before OnPluginStart is called.

This commit is contained in:
Nicholas Hastings 2015-05-11 19:31:22 -04:00
parent 71cb002bc1
commit 8fc689c89a
3 changed files with 21 additions and 15 deletions

View File

@ -138,6 +138,8 @@ PlayerManager::PlayerManager()
m_UserIdLookUp = new int[USHRT_MAX+1];
memset(m_UserIdLookUp, 0, sizeof(int) * (USHRT_MAX+1));
InitializePlayers();
}
PlayerManager::~PlayerManager()
@ -148,6 +150,20 @@ PlayerManager::~PlayerManager()
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()
{
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");
#endif
// clientMax will not necessarily be correct here (such as on late SourceTV enable)
m_maxClients = gpGlobals->maxClients;
ICommandLine *commandLine = g_HL2.GetValveCommandLine();
m_bIsSourceTVActive = (tv_enable && tv_enable->GetBool() && (!commandLine || commandLine->FindParm("-nohltv") == 0));
m_bIsReplayActive = false;
@ -298,20 +311,9 @@ void PlayerManager::OnServerActivate(edict_t *pEdictList, int edictCount, int cl
if (!m_FirstPass)
{
/* 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];
InitializePlayers();
}
scripts->SyncMaxClients(m_maxClients);
g_OnMapStarted = true;
#if SOURCE_ENGINE == SE_DOTA

View File

@ -233,6 +233,8 @@ private:
void OnServerActivate(edict_t *pEdictList, int edictCount, int clientMax);
#endif
void InvalidatePlayer(CPlayer *pPlayer);
private:
void InitializePlayers();
private:
List<IClientListener *> m_hooks;
IForward *m_clconnect;

View File

@ -320,6 +320,8 @@ void SourceModBase::StartSourceMod(bool late)
static bool g_LevelEndBarrier = false;
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 (!g_Loaded)
{