added amb1165 - exposed some plugin admin functionality to extensions

--HG--
extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%401694
This commit is contained in:
David Anderson
2007-11-17 02:54:44 +00:00
parent ecbd1f5e36
commit dfa007081b
3 changed files with 122 additions and 3 deletions
+45 -1
View File
@@ -1295,12 +1295,32 @@ void CPlayer::Authorize_Post()
void CPlayer::DoPostConnectAuthorization()
{
bool delay = false;
List<IClientListener *>::iterator iter;
for (iter = g_Players.m_hooks.begin();
iter != g_Players.m_hooks.end();
iter++)
{
IClientListener *pListener = (*iter);
#if defined MIN_API_FOR_ADMINCALLS
if (pListener->GetClientListenerVersion() < MIN_API_FOR_ADMINCALLS)
{
continue;
}
#endif
if (!pListener->OnClientPreAdminCheck(m_iIndex))
{
delay = true;
}
}
cell_t result = 0;
PreAdminCheck->PushCell(m_iIndex);
PreAdminCheck->Execute(&result);
/* Defer, for better or worse */
if ((ResultType)result >= Pl_Handled)
if (delay || (ResultType)result >= Pl_Handled)
{
return;
}
@@ -1318,6 +1338,15 @@ void CPlayer::DoPostConnectAuthorization()
NotifyPostAdminChecks();
}
bool CPlayer::RunAdminCacheChecks()
{
AdminId old_id = GetAdminId();
DoBasicAdminChecks();
return (GetAdminId() != old_id);
}
void CPlayer::NotifyPostAdminChecks()
{
if (m_bAdminCheckSignalled)
@@ -1328,6 +1357,21 @@ void CPlayer::NotifyPostAdminChecks()
/* Block beforehand so they can't double-call */
m_bAdminCheckSignalled = true;
List<IClientListener *>::iterator iter;
for (iter = g_Players.m_hooks.begin();
iter != g_Players.m_hooks.end();
iter++)
{
IClientListener *pListener = (*iter);
#if defined MIN_API_FOR_ADMINCALLS
if (pListener->GetClientListenerVersion() < MIN_API_FOR_ADMINCALLS)
{
continue;
}
#endif
pListener->OnClientPostAdminCheck(m_iIndex);
}
PostAdminCheck->PushCell(m_iIndex);
PostAdminCheck->Execute(NULL);
}
+5 -1
View File
@@ -48,6 +48,8 @@ using namespace SourceHook;
#define PLAYER_LIFE_ALIVE 1
#define PLAYER_LIFE_DEAD 2
#define MIN_API_FOR_ADMINCALLS 7
class CPlayer : public IGamePlayer
{
friend class PlayerManager;
@@ -69,8 +71,9 @@ public:
IPlayerInfo *GetPlayerInfo();
unsigned int GetLanguageId();
int GetUserId();
public:
bool RunAdminCacheChecks();
void NotifyPostAdminChecks();
public:
void DoBasicAdminChecks();
bool IsInKickQueue();
void MarkAsBeingKicked();
@@ -108,6 +111,7 @@ class PlayerManager :
public SMGlobalClass,
public IPlayerManager
{
friend class CPlayer;
public:
PlayerManager();
~PlayerManager();