Merge pull request #322 from Ni3znajomy/feature/client-connecting
New client_connectex forward & extend client_authorized
This commit is contained in:
commit
20959d1444
|
@ -339,6 +339,7 @@ extern int FF_PluginEnd;
|
||||||
extern int FF_InconsistentFile;
|
extern int FF_InconsistentFile;
|
||||||
extern int FF_ClientAuthorized;
|
extern int FF_ClientAuthorized;
|
||||||
extern int FF_ChangeLevel;
|
extern int FF_ChangeLevel;
|
||||||
|
extern int FF_ClientConnectEx;
|
||||||
|
|
||||||
extern bool g_coloredmenus;
|
extern bool g_coloredmenus;
|
||||||
|
|
||||||
|
|
|
@ -145,6 +145,7 @@ int FF_PluginEnd = -1;
|
||||||
int FF_InconsistentFile = -1;
|
int FF_InconsistentFile = -1;
|
||||||
int FF_ClientAuthorized = -1;
|
int FF_ClientAuthorized = -1;
|
||||||
int FF_ChangeLevel = -1;
|
int FF_ChangeLevel = -1;
|
||||||
|
int FF_ClientConnectEx = -1;
|
||||||
|
|
||||||
IFileSystem* g_FileSystem;
|
IFileSystem* g_FileSystem;
|
||||||
HLTypeConversion TypeConversion;
|
HLTypeConversion TypeConversion;
|
||||||
|
@ -503,8 +504,9 @@ int C_Spawn(edict_t *pent)
|
||||||
FF_PluginLog = registerForward("plugin_log", ET_STOP, FP_DONE);
|
FF_PluginLog = registerForward("plugin_log", ET_STOP, FP_DONE);
|
||||||
FF_PluginEnd = registerForward("plugin_end", ET_IGNORE, FP_DONE);
|
FF_PluginEnd = registerForward("plugin_end", ET_IGNORE, FP_DONE);
|
||||||
FF_InconsistentFile = registerForward("inconsistent_file", ET_STOP, FP_CELL, FP_STRING, FP_STRINGEX, FP_DONE);
|
FF_InconsistentFile = registerForward("inconsistent_file", ET_STOP, FP_CELL, FP_STRING, FP_STRINGEX, FP_DONE);
|
||||||
FF_ClientAuthorized = registerForward("client_authorized", ET_IGNORE, FP_CELL, FP_DONE);
|
FF_ClientAuthorized = registerForward("client_authorized", ET_IGNORE, FP_CELL, FP_STRING, FP_DONE);
|
||||||
FF_ChangeLevel = registerForward("server_changelevel", ET_STOP, FP_STRING, FP_DONE);
|
FF_ChangeLevel = registerForward("server_changelevel", ET_STOP, FP_STRING, FP_DONE);
|
||||||
|
FF_ClientConnectEx = registerForward("client_connectex", ET_STOP, FP_CELL, FP_STRING, FP_STRING, FP_ARRAY, FP_DONE);
|
||||||
|
|
||||||
CoreCfg.OnAmxxInitialized();
|
CoreCfg.OnAmxxInitialized();
|
||||||
|
|
||||||
|
@ -820,24 +822,34 @@ BOOL C_ClientConnect_Post(edict_t *pEntity, const char *pszName, const char *psz
|
||||||
g_auth.put(aa);
|
g_auth.put(aa);
|
||||||
} else {
|
} else {
|
||||||
pPlayer->Authorize();
|
pPlayer->Authorize();
|
||||||
|
const char* authid = GETPLAYERAUTHID(pEntity);
|
||||||
if (g_auth_funcs.size())
|
if (g_auth_funcs.size())
|
||||||
{
|
{
|
||||||
List<AUTHORIZEFUNC>::iterator iter, end=g_auth_funcs.end();
|
List<AUTHORIZEFUNC>::iterator iter, end=g_auth_funcs.end();
|
||||||
AUTHORIZEFUNC fn;
|
AUTHORIZEFUNC fn;
|
||||||
const char* authid = GETPLAYERAUTHID(pEntity);
|
|
||||||
for (iter=g_auth_funcs.begin(); iter!=end; iter++)
|
for (iter=g_auth_funcs.begin(); iter!=end; iter++)
|
||||||
{
|
{
|
||||||
fn = (*iter);
|
fn = (*iter);
|
||||||
fn(pPlayer->index, authid);
|
fn(pPlayer->index, authid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
executeForwards(FF_ClientAuthorized, static_cast<cell>(pPlayer->index));
|
executeForwards(FF_ClientAuthorized, static_cast<cell>(pPlayer->index), authid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RETURN_META_VALUE(MRES_IGNORED, TRUE);
|
RETURN_META_VALUE(MRES_IGNORED, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOL C_ClientConnect(edict_t *pEntity, const char *pszName, const char *pszAddress, char szRejectReason[128])
|
||||||
|
{
|
||||||
|
CPlayer* pPlayer = GET_PLAYER_POINTER(pEntity);
|
||||||
|
|
||||||
|
if(executeForwards(FF_ClientConnectEx, static_cast<cell>(pPlayer->index), pszName, pszAddress, prepareCharArray(szRejectReason, 128, true)))
|
||||||
|
RETURN_META_VALUE(MRES_SUPERCEDE, FALSE);
|
||||||
|
|
||||||
|
RETURN_META_VALUE(MRES_IGNORED, TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
void C_ClientDisconnect(edict_t *pEntity)
|
void C_ClientDisconnect(edict_t *pEntity)
|
||||||
{
|
{
|
||||||
CPlayer *pPlayer = GET_PLAYER_POINTER(pEntity);
|
CPlayer *pPlayer = GET_PLAYER_POINTER(pEntity);
|
||||||
|
@ -923,18 +935,18 @@ void C_ClientUserInfoChanged_Post(edict_t *pEntity, char *infobuffer)
|
||||||
executeForwards(FF_ClientConnect, static_cast<cell>(pPlayer->index));
|
executeForwards(FF_ClientConnect, static_cast<cell>(pPlayer->index));
|
||||||
|
|
||||||
pPlayer->Authorize();
|
pPlayer->Authorize();
|
||||||
|
const char* authid = GETPLAYERAUTHID(pEntity);
|
||||||
if (g_auth_funcs.size())
|
if (g_auth_funcs.size())
|
||||||
{
|
{
|
||||||
List<AUTHORIZEFUNC>::iterator iter, end=g_auth_funcs.end();
|
List<AUTHORIZEFUNC>::iterator iter, end=g_auth_funcs.end();
|
||||||
AUTHORIZEFUNC fn;
|
AUTHORIZEFUNC fn;
|
||||||
const char* authid = GETPLAYERAUTHID(pEntity);
|
|
||||||
for (iter=g_auth_funcs.begin(); iter!=end; iter++)
|
for (iter=g_auth_funcs.begin(); iter!=end; iter++)
|
||||||
{
|
{
|
||||||
fn = (*iter);
|
fn = (*iter);
|
||||||
fn(pPlayer->index, authid);
|
fn(pPlayer->index, authid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
executeForwards(FF_ClientAuthorized, static_cast<cell>(pPlayer->index));
|
executeForwards(FF_ClientAuthorized, static_cast<cell>(pPlayer->index), authid);
|
||||||
|
|
||||||
pPlayer->PutInServer();
|
pPlayer->PutInServer();
|
||||||
++g_players_num;
|
++g_players_num;
|
||||||
|
@ -1131,7 +1143,7 @@ void C_StartFrame_Post(void)
|
||||||
fn((*a)->index, auth);
|
fn((*a)->index, auth);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
executeForwards(FF_ClientAuthorized, static_cast<cell>((*a)->index));
|
executeForwards(FF_ClientAuthorized, static_cast<cell>((*a)->index), auth);
|
||||||
a.remove();
|
a.remove();
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
|
@ -1717,6 +1729,7 @@ C_DLLEXPORT int GetEntityAPI2(DLL_FUNCTIONS *pFunctionTable, int *interfaceVersi
|
||||||
gFunctionTable.pfnClientDisconnect = C_ClientDisconnect;
|
gFunctionTable.pfnClientDisconnect = C_ClientDisconnect;
|
||||||
gFunctionTable.pfnInconsistentFile = C_InconsistentFile;
|
gFunctionTable.pfnInconsistentFile = C_InconsistentFile;
|
||||||
gFunctionTable.pfnServerActivate = C_ServerActivate;
|
gFunctionTable.pfnServerActivate = C_ServerActivate;
|
||||||
|
gFunctionTable.pfnClientConnect = C_ClientConnect;
|
||||||
|
|
||||||
memcpy(pFunctionTable, &gFunctionTable, sizeof(DLL_FUNCTIONS));
|
memcpy(pFunctionTable, &gFunctionTable, sizeof(DLL_FUNCTIONS));
|
||||||
|
|
||||||
|
|
|
@ -143,6 +143,22 @@ forward client_infochanged(id);
|
||||||
*/
|
*/
|
||||||
forward client_connect(id);
|
forward client_connect(id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a client is connecting.
|
||||||
|
*
|
||||||
|
* @note This forward is called too early to do anything that directly affects
|
||||||
|
* the client.
|
||||||
|
*
|
||||||
|
* @param id Client index
|
||||||
|
* @param name Client name
|
||||||
|
* @param ip Client ip address with port
|
||||||
|
* @param reason A reason that will be displayed when player gets rejected (can be overwritten)
|
||||||
|
*
|
||||||
|
* @return PLUGIN_CONTINUE to let a client join to the server
|
||||||
|
* PLUGIN_HANDLED or higher to prevent a client to join
|
||||||
|
*/
|
||||||
|
forward client_connectex(id, const name[], const ip[], reason[128]);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the client gets a valid SteamID.
|
* Called when the client gets a valid SteamID.
|
||||||
*
|
*
|
||||||
|
@ -150,10 +166,11 @@ forward client_connect(id);
|
||||||
* @note This is called for bots, and the SteamID will be "BOT".
|
* @note This is called for bots, and the SteamID will be "BOT".
|
||||||
*
|
*
|
||||||
* @param id Client index
|
* @param id Client index
|
||||||
|
* @param authid Client auth
|
||||||
*
|
*
|
||||||
* @noreturn
|
* @noreturn
|
||||||
*/
|
*/
|
||||||
forward client_authorized(id);
|
forward client_authorized(id, const authid[]);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated This function does not catch all cases.
|
* @deprecated This function does not catch all cases.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user