Remove unfinished ConVar queries on client disconnect (bug 6003, r=psychonic).

This commit is contained in:
Kyle Sanderson
2014-02-27 19:55:13 -07:00
parent c679b97e5f
commit 84d58ff421
2 changed files with 28 additions and 2 deletions
+21 -1
View File
@@ -123,6 +123,8 @@ void ConVarManager::OnSourceModAllInitialized()
}
#endif
g_Players.AddClientListener(this);
#if SOURCE_ENGINE >= SE_ORANGEBOX
SH_ADD_HOOK(ICvar, CallGlobalChangeCallbacks, icvar, SH_STATIC(OnConVarChanged), false);
#else
@@ -194,6 +196,8 @@ void ConVarManager::OnSourceModShutdown()
}
#endif
g_Players.RemoveClientListener(this);
#if SOURCE_ENGINE >= SE_ORANGEBOX
SH_REMOVE_HOOK(ICvar, CallGlobalChangeCallbacks, icvar, SH_STATIC(OnConVarChanged), false);
#else
@@ -310,6 +314,22 @@ void ConVarManager::OnPluginUnloaded(IPlugin *plugin)
}
}
void ConVarManager::OnClientDisconnected(int client)
{
/* Remove convar queries for this client that haven't returned results yet */
for (List<ConVarQuery>::iterator iter = m_ConVarQueries.begin(); iter != m_ConVarQueries.end();)
{
ConVarQuery &query = (*iter);
if (query.client == client)
{
iter = m_ConVarQueries.erase(iter);
continue;
}
++iter;
}
}
void ConVarManager::OnHandleDestroy(HandleType_t type, void *object)
{
}
@@ -628,7 +648,7 @@ QueryCvarCookie_t ConVarManager::QueryClientConVar(edict_t *pPlayer, const char
return InvalidQueryCvarCookie;
}
ConVarQuery query = {cookie, pCallback, (cell_t)hndl};
ConVarQuery query = {cookie, pCallback, (cell_t)hndl, IndexOfEdict(pPlayer)};
m_ConVarQueries.push_back(query);
#endif