Added new OnClientConnected callback with correct pairing intent (bug 3311, r=pred).

This commit is contained in:
David Anderson 2008-10-18 22:14:13 -05:00
parent 5a2f8afd33
commit a6579c7bcb
2 changed files with 18 additions and 1 deletions
core
plugins/include

View File

@ -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<ICommandTargetProcessor *> 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
{

View File

@ -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.
*