fixed amb1591 - mods like IOS:S which, in listen server mode add bots before the player, caused crashes in SM

--HG--
extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%402050
This commit is contained in:
David Anderson 2008-04-12 02:18:03 +00:00
parent 800838d76a
commit 2fbd32cd1a
3 changed files with 31 additions and 6 deletions

View File

@ -379,14 +379,14 @@ void ConCmdManager::InternalDispatch(const CCommand &command)
/* On a listen server, sometimes the server host's client index can be set as 0. /* On a listen server, sometimes the server host's client index can be set as 0.
* So index 1 is passed to the command callback to correct this potential problem. * So index 1 is passed to the command callback to correct this potential problem.
*/ */
if (client == 0 && !engine->IsDedicatedServer()) if (!engine->IsDedicatedServer())
{ {
pHook->pf->PushCell(1); client = g_Players.ListenClient();
} else {
pHook->pf->PushCell(client);
} }
pHook->pf->PushCell(client);
pHook->pf->PushCell(args); pHook->pf->PushCell(args);
if (pHook->pf->Execute(&tempres) == SP_ERROR_NONE) if (pHook->pf->Execute(&tempres) == SP_ERROR_NONE)
{ {
if (tempres > result) if (tempres > result)

View File

@ -134,6 +134,9 @@ void PlayerManager::OnSourceModAllInitialized()
PreAdminCheck = g_Forwards.CreateForward("OnClientPreAdminCheck", ET_Event, 1, p1); PreAdminCheck = g_Forwards.CreateForward("OnClientPreAdminCheck", ET_Event, 1, p1);
PostAdminCheck = g_Forwards.CreateForward("OnClientPostAdminCheck", ET_Ignore, 1, p1); PostAdminCheck = g_Forwards.CreateForward("OnClientPostAdminCheck", ET_Ignore, 1, p1);
PostAdminFilter = g_Forwards.CreateForward("OnClientPostAdminFilter", ET_Ignore, 1, p1); PostAdminFilter = g_Forwards.CreateForward("OnClientPostAdminFilter", ET_Ignore, 1, p1);
m_bIsListenServer = !engine->IsDedicatedServer();
m_ListenClient = 0;
} }
void PlayerManager::OnSourceModShutdown() void PlayerManager::OnSourceModShutdown()
@ -385,7 +388,9 @@ bool PlayerManager::OnClientConnect(edict_t *pEntity, const char *pszName, const
{ {
m_AuthQueue[++m_AuthQueue[0]] = client; m_AuthQueue[++m_AuthQueue[0]] = client;
} }
} else { }
else
{
RETURN_META_VALUE(MRES_SUPERCEDE, false); RETURN_META_VALUE(MRES_SUPERCEDE, false);
} }
@ -415,6 +420,13 @@ bool PlayerManager::OnClientConnect_Post(edict_t *pEntity, const char *pszName,
} }
} }
if (!pPlayer->IsFakeClient()
&& m_bIsListenServer
&& strncmp(pszAddress, "127.0.0.1", 9) == 0)
{
m_ListenClient = client;
}
return true; return true;
} }
@ -524,7 +536,9 @@ void PlayerManager::OnClientDisconnect(edict_t *pEntity)
{ {
m_cldisconnect->PushCell(client); m_cldisconnect->PushCell(client);
m_cldisconnect->Execute(&res, NULL); m_cldisconnect->Execute(&res, NULL);
} else { }
else
{
/* We don't care, prevent a double call */ /* We don't care, prevent a double call */
return; return;
} }
@ -565,6 +579,11 @@ void PlayerManager::OnClientDisconnect(edict_t *pEntity)
m_Players[client].Disconnect(); m_Players[client].Disconnect();
m_UserIdLookUp[engine->GetPlayerUserId(pEntity)] = 0; m_UserIdLookUp[engine->GetPlayerUserId(pEntity)] = 0;
if (m_ListenClient == client)
{
m_ListenClient = 0;
}
} }
void PlayerManager::OnClientDisconnect_Post(edict_t *pEntity) void PlayerManager::OnClientDisconnect_Post(edict_t *pEntity)

View File

@ -161,6 +161,10 @@ public:
{ {
return m_PlayerCount; return m_PlayerCount;
} }
inline int ListenClient()
{
return m_ListenClient;
}
bool CheckSetAdmin(int index, CPlayer *pPlayer, AdminId id); bool CheckSetAdmin(int index, CPlayer *pPlayer, AdminId id);
bool CheckSetAdminName(int index, CPlayer *pPlayer, AdminId id); bool CheckSetAdminName(int index, CPlayer *pPlayer, AdminId id);
const char *GetPassInfoVar(); const char *GetPassInfoVar();
@ -188,6 +192,8 @@ private:
unsigned int *m_AuthQueue; unsigned int *m_AuthQueue;
String m_PassInfoVar; String m_PassInfoVar;
bool m_QueryLang; bool m_QueryLang;
bool m_bIsListenServer;
int m_ListenClient;
}; };
extern PlayerManager g_Players; extern PlayerManager g_Players;