From a6579c7bcb78ca5191aa36b130fb3e531e57de4e Mon Sep 17 00:00:00 2001 From: David Anderson Date: Sat, 18 Oct 2008 22:14:13 -0500 Subject: [PATCH] Added new OnClientConnected callback with correct pairing intent (bug 3311, r=pred). --- core/PlayerManager.cpp | 7 +++++++ plugins/include/clients.inc | 12 +++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/core/PlayerManager.cpp b/core/PlayerManager.cpp index 67a51b5a..b17a6f9c 100644 --- a/core/PlayerManager.cpp +++ b/core/PlayerManager.cpp @@ -53,6 +53,7 @@ bool g_OnMapStarted = false; IForward *PreAdminCheck = NULL; IForward *PostAdminCheck = NULL; IForward *PostAdminFilter = NULL; +IForward *OnClientConnected = NULL; const unsigned int *g_NumPlayersToAuth = NULL; int lifestate_offset = -1; List target_processors; @@ -139,6 +140,7 @@ void PlayerManager::OnSourceModAllInitialized() m_clauth = g_Forwards.CreateForward("OnClientAuthorized", ET_Ignore, 2, NULL, Param_Cell, Param_String); m_onActivate = g_Forwards.CreateForward("OnServerLoad", ET_Ignore, 0, NULL); m_onActivate2 = g_Forwards.CreateForward("OnMapStart", ET_Ignore, 0, NULL); + OnClientConnected = g_Forwards.CreateForward("OnClientConnected", ET_Ignore, 1, p2); PreAdminCheck = g_Forwards.CreateForward("OnClientPreAdminCheck", ET_Event, 1, p1); PostAdminCheck = g_Forwards.CreateForward("OnClientPostAdminCheck", ET_Ignore, 1, p1); @@ -194,6 +196,7 @@ void PlayerManager::OnSourceModShutdown() g_Forwards.ReleaseForward(m_clauth); g_Forwards.ReleaseForward(m_onActivate); g_Forwards.ReleaseForward(m_onActivate2); + g_Forwards.ReleaseForward(OnClientConnected); g_Forwards.ReleaseForward(PreAdminCheck); g_Forwards.ReleaseForward(PostAdminCheck); @@ -473,6 +476,10 @@ bool PlayerManager::OnClientConnect_Post(edict_t *pEntity, const char *pszName, { m_ListenClient = client; } + + cell_t res; + OnClientConnected->PushCell(client); + OnClientConnected->Execute(&res, NULL); } else { diff --git a/plugins/include/clients.inc b/plugins/include/clients.inc index 880eb0b0..e319af18 100644 --- a/plugins/include/clients.inc +++ b/plugins/include/clients.inc @@ -59,7 +59,9 @@ enum NetFlow public const MaxClients; /**< Maximum number of players the server supports (dynamic) */ /** - * Called on client connection. + * Called on client connection. If you return true, the client will be allowed in the server. + * If you return false (or return nothing), the client will be rejected. If the client is + * rejected by this forward or any other, OnClientDisconnect will not be called. * * @param client Client index. * @param rejectmsg Buffer to store the rejection message when the connection is refused. @@ -68,6 +70,14 @@ public const MaxClients; /**< Maximum number of players the server supports (dyn */ forward bool:OnClientConnect(client, String:rejectmsg[], maxlen); +/** + * Called once a client successfully connects. This callback is paired with OnClientDisconnect. + * + * @param client Client index. + * @noreturn + */ +forward OnClientConnected(client); + /** * Called when a client is entering the game. *