From a079a87f68b1030b3b7c3f0a9880fe88747f8fe8 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Sat, 22 Dec 2007 08:57:08 +0000 Subject: [PATCH] fixed amb1305 by making OnClientPostAdminCheck() always occur after OnClientPutInServer(). this is now GUARANTEED. it was undefined before, however the usual case was opposite. if plugins were relying on this, they were written poorly and shouldn't have worked in the first place, especially with the threaded SQL plugin. --HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%401819 --- core/PlayerManager.cpp | 12 +++++++----- plugins/include/clients.inc | 29 ++++++++++++++++++++++------- 2 files changed, 29 insertions(+), 12 deletions(-) diff --git a/core/PlayerManager.cpp b/core/PlayerManager.cpp index 0e54712f..dcee273e 100644 --- a/core/PlayerManager.cpp +++ b/core/PlayerManager.cpp @@ -489,6 +489,11 @@ void PlayerManager::OnClientPutInServer(edict_t *pEntity, const char *playername m_clputinserver->PushCell(client); m_clputinserver->Execute(&res, NULL); + + if (m_Players[client].IsAuthorized()) + { + m_Players[client].DoPostConnectAuthorization(); + } } void PlayerManager::OnSourceModLevelEnd() @@ -1144,13 +1149,10 @@ void CPlayer::Connect() { const char *pass = engine->GetClientConVarValue(client, var); m_LastPassword.assign(pass ? pass : ""); - } else { - m_LastPassword.assign(""); } - - if (m_IsAuthorized) + else { - DoPostConnectAuthorization(); + m_LastPassword.assign(""); } } diff --git a/plugins/include/clients.inc b/plugins/include/clients.inc index 219a25dd..69d90587 100644 --- a/plugins/include/clients.inc +++ b/plugins/include/clients.inc @@ -56,10 +56,15 @@ enum NetFlow forward bool:OnClientConnect(client, String:rejectmsg[], maxlen); /** - * Called when a client is entering to the game. + * Called when a client is entering the game. * - * @note Whether a client has a steamid is undefined until OnClientAuthorized + * Whether a client has a steamid is undefined until OnClientAuthorized * is called, which may occur either before or after OnClientPutInServer. + * Similarly, use OnClientPostAdminCheck() if you need to verify whether + * connecting players are admins. + * + * GetClientCount() will include clients as they are passed through this + * function, as clients are already in game at this point. * * @param client Client index. * @noreturn @@ -100,9 +105,11 @@ forward Action:OnClientCommand(client, args); forward OnClientSettingsChanged(client); /** - * Called when a client receives a Steam ID. - - * Admin properties are not assigned here, but on OnClientPostAdminCheck(). + * Called when a client receives a Steam ID. The state of a client's + * authorization via Steam or as an admin is not guaranteed here. + * Use OnClientAuthorized() or OnClientPostAdminCheck() for those, + * respectively. + * * This is called by bots, but the ID will be "BOT". * * @param client Client index. @@ -114,11 +121,16 @@ forward OnClientAuthorized(client, const String:auth[]); /** * Called once a client is authorized and fully in-game, but * before admin checks are done. This can be used to override - * the default admin checks for a client. + * the default admin checks for a client. You should only use + * this for overriding; use OnClientPostAdminCheck() instead + * if you want notification. * * Note: If handled/blocked, PostAdminCheck must be signalled * manually via NotifyPostAdminCheck(). * + * This callback is gauranteed to occur on all clients, and always + * after each OnClientPutInServer() call. + * * @param client Client index. * @return Plugin_Handled to block admin checks. */ @@ -126,7 +138,10 @@ forward Action:OnClientPreAdminCheck(client); /** * Called once a client is authorized and fully in-game, and - * after all post-connection authorizations have been performed. + * after all post-connection authorizations have been performed. + * + * This callback is gauranteed to occur on all clients, and always + * after each OnClientPutInServer() call. * * @param client Client index. * @noreturn