Merge pull request #337 from alliedmodders/earlier-maxclients
Populate MaxClients before OnPluginStart is called.
This commit is contained in:
commit
9f8a40f482
@ -128,7 +128,7 @@ public:
|
||||
PlayerManager::PlayerManager()
|
||||
{
|
||||
m_AuthQueue = NULL;
|
||||
m_FirstPass = false;
|
||||
m_bServerActivated = false;
|
||||
m_maxClients = 0;
|
||||
|
||||
m_SourceTVUserId = -1;
|
||||
@ -148,6 +148,19 @@ PlayerManager::~PlayerManager()
|
||||
delete [] m_UserIdLookUp;
|
||||
}
|
||||
|
||||
void PlayerManager::OnSourceModStartup(bool late)
|
||||
{
|
||||
/* Initialize all players */
|
||||
|
||||
m_PlayerCount = 0;
|
||||
m_Players = new CPlayer[SM_MAXPLAYERS + 1];
|
||||
m_AuthQueue = new unsigned int[SM_MAXPLAYERS + 1];
|
||||
|
||||
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 +298,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;
|
||||
@ -296,23 +306,8 @@ void PlayerManager::OnServerActivate(edict_t *pEdictList, int edictCount, int cl
|
||||
#endif
|
||||
m_PlayersSinceActive = 0;
|
||||
|
||||
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];
|
||||
}
|
||||
|
||||
scripts->SyncMaxClients(m_maxClients);
|
||||
|
||||
g_OnMapStarted = true;
|
||||
m_bServerActivated = true;
|
||||
|
||||
#if SOURCE_ENGINE == SE_DOTA
|
||||
extsys->CallOnCoreMapStart(gpGlobals->pEdicts, gpGlobals->maxEntities, gpGlobals->maxClients);
|
||||
@ -344,7 +339,7 @@ void PlayerManager::OnServerActivate(edict_t *pEdictList, int edictCount, int cl
|
||||
|
||||
bool PlayerManager::IsServerActivated()
|
||||
{
|
||||
return m_FirstPass;
|
||||
return m_bServerActivated;
|
||||
}
|
||||
|
||||
bool PlayerManager::CheckSetAdmin(int index, CPlayer *pPlayer, AdminId id)
|
||||
@ -1826,11 +1821,6 @@ void PlayerManager::OnSourceModMaxPlayersChanged( int newvalue )
|
||||
|
||||
void PlayerManager::MaxPlayersChanged( int newvalue /*= -1*/ )
|
||||
{
|
||||
if (!m_FirstPass)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (newvalue == -1)
|
||||
{
|
||||
newvalue = gpGlobals->maxClients;
|
||||
|
@ -154,6 +154,7 @@ public:
|
||||
PlayerManager();
|
||||
~PlayerManager();
|
||||
public: //SMGlobalClass
|
||||
void OnSourceModStartup(bool late) override;
|
||||
void OnSourceModAllInitialized();
|
||||
void OnSourceModShutdown();
|
||||
void OnSourceModLevelEnd();
|
||||
@ -250,7 +251,7 @@ private:
|
||||
int m_maxClients;
|
||||
int m_PlayerCount;
|
||||
int m_PlayersSinceActive;
|
||||
bool m_FirstPass;
|
||||
bool m_bServerActivated;
|
||||
unsigned int *m_AuthQueue;
|
||||
String m_PassInfoVar;
|
||||
bool m_QueryLang;
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -67,9 +67,6 @@ enum AuthIdType
|
||||
/**
|
||||
* MAXPLAYERS is not the same as MaxClients.
|
||||
* MAXPLAYERS is a hardcoded value as an upper limit. MaxClients changes based on the server.
|
||||
*
|
||||
* Both GetMaxClients() and MaxClients are only available once the map is loaded, and should
|
||||
* not be used in OnPluginStart().
|
||||
*/
|
||||
|
||||
#define MAXPLAYERS 65 /**< Maximum number of players SourceMod supports */
|
||||
|
Loading…
Reference in New Issue
Block a user