Move adminsys and more natives from core to logic.

This commit is contained in:
Nicholas Hastings 2014-05-29 13:31:12 -04:00
parent dc4c3f2f1a
commit 35784c018d
22 changed files with 2880 additions and 2769 deletions

View File

@ -52,7 +52,6 @@ for sdk_name in SM.sdks:
compiler.linkflags.insert(0, binary.Dep(lib_path))
binary.sources += [
'AdminCache.cpp',
'MenuStyle_Valve.cpp',
'logic_bridge.cpp',
'smn_entities.cpp',
@ -60,7 +59,6 @@ for sdk_name in SM.sdks:
'MenuVoting.cpp',
'smn_events.cpp',
'smn_menus.cpp',
'sm_trie.cpp',
'CDataPack.cpp',
'frame_hooks.cpp',
'smn_nextmap.cpp',

View File

@ -31,7 +31,6 @@
#include "ConCmdManager.h"
#include "sm_srvcmds.h"
#include "AdminCache.h"
#include "sm_stringutil.h"
#include "PlayerManager.h"
#include "HalfLife2.h"
@ -330,85 +329,9 @@ void ConCmdManager::InternalDispatch(const CCommand &command)
}
}
bool ConCmdManager::CheckClientCommandAccess(int client, const char *cmd, FlagBits cmdflags)
{
if (cmdflags == 0 || client == 0)
{
return true;
}
/* If running listen server, then client 1 is the server host and should have 'root' access */
if (client == 1 && !engine->IsDedicatedServer())
{
return true;
}
CPlayer *player = g_Players.GetPlayerByIndex(client);
if (!player
|| player->GetEdict() == NULL
|| player->IsFakeClient())
{
return false;
}
return CheckAdminCommandAccess(player->GetAdminId(), cmd, cmdflags);
}
bool ConCmdManager::CheckAdminCommandAccess(AdminId adm, const char *cmd, FlagBits cmdflags)
{
if (adm != INVALID_ADMIN_ID)
{
FlagBits bits = g_Admins.GetAdminFlags(adm, Access_Effective);
/* root knows all, WHOA */
if ((bits & ADMFLAG_ROOT) == ADMFLAG_ROOT)
{
return true;
}
/* Check for overrides
* :TODO: is it worth optimizing this?
*/
unsigned int groups = g_Admins.GetAdminGroupCount(adm);
GroupId gid;
OverrideRule rule;
bool override = false;
for (unsigned int i=0; i<groups; i++)
{
gid = g_Admins.GetAdminGroup(adm, i, NULL);
/* First get group-level override */
override = g_Admins.GetGroupCommandOverride(gid, cmd, Override_CommandGroup, &rule);
/* Now get the specific command override */
if (g_Admins.GetGroupCommandOverride(gid, cmd, Override_Command, &rule))
{
override = true;
}
if (override)
{
if (rule == Command_Allow)
{
return true;
}
else if (rule == Command_Deny)
{
return false;
}
}
}
/* See if our other flags match */
if ((bits & cmdflags) == cmdflags)
{
return true;
}
}
return false;
}
bool ConCmdManager::CheckAccess(int client, const char *cmd, AdminCmdInfo *pAdmin)
{
if (CheckClientCommandAccess(client, cmd, pAdmin->eflags))
if (adminsys->CheckClientCommandAccess(client, cmd, pAdmin->eflags))
{
return true;
}
@ -468,12 +391,12 @@ bool ConCmdManager::AddAdminCommand(IPluginFunction *pFunction,
pHook->admin = new AdminCmdInfo(cmdgroup, adminflags);
/* First get the command group override, if any */
bool override = g_Admins.GetCommandOverride(group,
bool override = adminsys->GetCommandOverride(group,
Override_CommandGroup,
&(pHook->admin->eflags));
/* Next get the command override, if any */
if (g_Admins.GetCommandOverride(name,
if (adminsys->GetCommandOverride(name,
Override_Command,
&(pHook->admin->eflags)))
{

View File

@ -146,8 +146,6 @@ public:
void UpdateAdminCmdFlags(const char *cmd, OverrideType type, FlagBits bits, bool remove);
bool LookForSourceModCommand(const char *cmd);
bool LookForCommandAdminFlags(const char *cmd, FlagBits *pFlags);
bool CheckClientCommandAccess(int client, const char *cmd, FlagBits flags);
bool CheckAdminCommandAccess(AdminId adm, const char *cmd, FlagBits flags);
private:
void InternalDispatch(const CCommand &command);
ResultType RunAdminCommand(ConCmdInfo *pInfo, int client, int args);

View File

@ -30,7 +30,7 @@
*/
#include "PlayerManager.h"
#include "AdminCache.h"
#include "IAdminSystem.h"
#include "ConCmdManager.h"
#include "MenuStyle_Valve.h"
#include "MenuStyle_Radio.h"
@ -333,7 +333,7 @@ bool PlayerManager::IsServerActivated()
bool PlayerManager::CheckSetAdmin(int index, CPlayer *pPlayer, AdminId id)
{
const char *password = g_Admins.GetAdminPassword(id);
const char *password = adminsys->GetAdminPassword(id);
if (password != NULL)
{
if (m_PassInfoVar.size() < 1)
@ -356,7 +356,7 @@ bool PlayerManager::CheckSetAdmin(int index, CPlayer *pPlayer, AdminId id)
bool PlayerManager::CheckSetAdminName(int index, CPlayer *pPlayer, AdminId id)
{
const char *password = g_Admins.GetAdminPassword(id);
const char *password = adminsys->GetAdminPassword(id);
if (password == NULL)
{
return false;
@ -1183,7 +1183,7 @@ void PlayerManager::OnClientSettingsChanged(edict_t *pEntity)
if (strcmp(old_name, new_name) != 0)
{
AdminId id = g_Admins.FindAdminByIdentity("name", new_name);
AdminId id = adminsys->FindAdminByIdentity("name", new_name);
if (id != INVALID_ADMIN_ID && pPlayer->GetAdminId() != id)
{
if (!CheckSetAdminName(client, pPlayer, id))
@ -1193,7 +1193,7 @@ void PlayerManager::OnClientSettingsChanged(edict_t *pEntity)
pPlayer->Kick(kickMsg);
RETURN_META(MRES_IGNORED);
}
} else if ((id = g_Admins.FindAdminByIdentity("name", old_name)) != INVALID_ADMIN_ID) {
} else if ((id = adminsys->FindAdminByIdentity("name", old_name)) != INVALID_ADMIN_ID) {
if (id == pPlayer->GetAdminId())
{
/* This player is changing their name; force them to drop admin privileges! */
@ -1327,14 +1327,6 @@ void PlayerManager::ClearAdminId(AdminId id)
}
}
void PlayerManager::ClearAllAdmins()
{
for (int i=1; i<=m_maxClients; i++)
{
m_Players[i].DumpAdmin(true);
}
}
const char *PlayerManager::GetPassInfoVar()
{
return m_PassInfoVar.c_str();
@ -1425,7 +1417,7 @@ int PlayerManager::InternalFilterCommandTarget(CPlayer *pAdmin, CPlayer *pTarget
if (pAdmin != NULL)
{
if ((flags & COMMAND_FILTER_NO_IMMUNITY) != COMMAND_FILTER_NO_IMMUNITY
&& !g_Admins.CanAdminTarget(pAdmin->GetAdminId(), pTarget->GetAdminId()))
&& !adminsys->CanAdminTarget(pAdmin->GetAdminId(), pTarget->GetAdminId()))
{
return COMMAND_TARGET_IMMUNE;
}
@ -2076,13 +2068,18 @@ AdminId CPlayer::GetAdminId()
return m_Admin;
}
void CPlayer::ClearAdmin()
{
DumpAdmin(true);
}
void CPlayer::DumpAdmin(bool deleting)
{
if (m_Admin != INVALID_ADMIN_ID)
{
if (m_TempAdmin && !deleting)
{
g_Admins.InvalidateAdmin(m_Admin);
adminsys->InvalidateAdmin(m_Admin);
}
m_Admin = INVALID_ADMIN_ID;
m_TempAdmin = false;
@ -2225,7 +2222,7 @@ void CPlayer::DoBasicAdminChecks()
AdminId id;
int client = IndexOfEdict(m_pEdict);
if ((id = g_Admins.FindAdminByIdentity("name", GetName())) != INVALID_ADMIN_ID)
if ((id = adminsys->FindAdminByIdentity("name", GetName())) != INVALID_ADMIN_ID)
{
if (!g_Players.CheckSetAdminName(client, this, id))
{
@ -2236,7 +2233,7 @@ void CPlayer::DoBasicAdminChecks()
}
/* Check IP */
if ((id = g_Admins.FindAdminByIdentity("ip", m_IpNoPort.c_str())) != INVALID_ADMIN_ID)
if ((id = adminsys->FindAdminByIdentity("ip", m_IpNoPort.c_str())) != INVALID_ADMIN_ID)
{
if (g_Players.CheckSetAdmin(client, this, id))
{
@ -2245,7 +2242,7 @@ void CPlayer::DoBasicAdminChecks()
}
/* Check steam id */
if ((id = g_Admins.FindAdminByIdentity("steam", m_AuthID.c_str())) != INVALID_ADMIN_ID)
if ((id = adminsys->FindAdminByIdentity("steam", m_AuthID.c_str())) != INVALID_ADMIN_ID)
{
if (g_Players.CheckSetAdmin(client, this, id))
{

View File

@ -92,6 +92,7 @@ public:
unsigned int GetSerial();
int GetIndex() const;
void PrintToConsole(const char *pMsg);
void ClearAdmin();
public:
void DoBasicAdminChecks();
void MarkAsBeingKicked();
@ -149,8 +150,6 @@ public: //SMGlobalClass
public:
CPlayer *GetPlayerByIndex(int client) const;
void RunAuthChecks();
void ClearAdminId(AdminId id);
void ClearAllAdmins();
public:
#if SOURCE_ENGINE == SE_DOTA
bool OnClientConnect(CEntityIndex index, const char *pszName, const char *pszAddress, char *reject, int maxrejectlen);
@ -190,6 +189,8 @@ public: //IPlayerManager
void UnregisterCommandTargetProcessor(ICommandTargetProcessor *pHandler);
void ProcessCommandTarget(cmd_target_info_t *info);
int GetClientFromSerial(unsigned int serial);
void ClearAdminId(AdminId id);
void RecheckAnyAdmins();
public:
inline int MaxClients()
{
@ -206,7 +207,6 @@ public:
bool CheckSetAdmin(int index, CPlayer *pPlayer, AdminId id);
bool CheckSetAdminName(int index, CPlayer *pPlayer, AdminId id);
const char *GetPassInfoVar();
void RecheckAnyAdmins();
unsigned int GetReplyTo();
unsigned int SetReplyTo(unsigned int reply);
void MaxPlayersChanged(int newvalue = -1);

View File

@ -63,6 +63,9 @@ binary.sources += [
'Database.cpp',
'smn_database.cpp',
'ForwardSys.cpp',
'AdminCache.cpp',
'sm_trie.cpp',
'smn_console.cpp',
]
if builder.target_platform == 'windows':
binary.sources += ['thread/WinThreads.cpp']

View File

@ -32,15 +32,12 @@
#include <string.h>
#include <assert.h>
#include <ITextParsers.h>
#include <ISourceMod.h>
#include <IGameHelpers.h>
#include <IPlayerHelpers.h>
#include "AdminCache.h"
#include "PlayerManager.h"
#include "ConCmdManager.h"
#include "Logger.h"
#include "sourcemod.h"
#include "sm_stringutil.h"
#include "sourcemm_api.h"
#include "sm_srvcmds.h"
#include "logic_bridge.h"
#include "Translator.h"
#include "common_logic.h"
#define LEVEL_STATE_NONE 0
#define LEVEL_STATE_LEVELS 1
@ -51,8 +48,6 @@ char g_ReverseFlags[26];
AdminFlag g_FlagLetters[26];
bool g_FlagSet[26];
ConVar sm_immunity_mode("sm_immunity_mode", "1", FCVAR_SPONLY, "Mode for deciding immunity protection");
/* Default flags */
AdminFlag g_DefaultFlags[26] =
{
@ -87,7 +82,7 @@ private:
SMCError error;
m_bFileNameLogged = false;
g_SourceMod.BuildPath(Path_SM, m_File, sizeof(m_File), "configs/admin_levels.cfg");
g_pSM->BuildPath(Path_SM, m_File, sizeof(m_File), "configs/admin_levels.cfg");
if ((error = textparsers->ParseFile_SMC(m_File, this, &states))
!= SMCError_Okay)
@ -197,16 +192,16 @@ private:
char buffer[256];
va_start(ap, message);
UTIL_FormatArgs(buffer, sizeof(buffer), message, ap);
g_pSM->FormatArgs(buffer, sizeof(buffer), message, ap);
va_end(ap);
if (!m_bFileNameLogged)
{
g_Logger.LogError("[SM] Parse error(s) detected in file \"%s\":", m_File);
smcore.LogError("[SM] Parse error(s) detected in file \"%s\":", m_File);
m_bFileNameLogged = true;
}
g_Logger.LogError("[SM] (Line %d): %s", states ? states->line : 0, buffer);
smcore.LogError("[SM] (Line %d): %s", states ? states->line : 0, buffer);
}
private:
bool m_bFileNameLogged;
@ -331,7 +326,7 @@ void AdminCache::AddCommandOverride(const char *cmd, OverrideType type, FlagBits
return;
map->insert(cmd, flags);
g_ConCmds.UpdateAdminCmdFlags(cmd, type, flags, false);
smcore.UpdateAdminCmdFlags(cmd, type, flags, false);
}
bool AdminCache::GetCommandOverride(const char *cmd, OverrideType type, FlagBits *pFlags)
@ -360,13 +355,13 @@ void AdminCache::UnsetCommandOverride(const char *cmd, OverrideType type)
void AdminCache::_UnsetCommandGroupOverride(const char *group)
{
m_CmdGrpOverrides.remove(group);
g_ConCmds.UpdateAdminCmdFlags(group, Override_CommandGroup, 0, true);
smcore.UpdateAdminCmdFlags(group, Override_CommandGroup, 0, true);
}
void AdminCache::_UnsetCommandOverride(const char *cmd)
{
m_CmdOverrides.remove(cmd);
g_ConCmds.UpdateAdminCmdFlags(cmd, Override_Command, 0, true);
smcore.UpdateAdminCmdFlags(cmd, Override_Command, 0, true);
}
void AdminCache::DumpCommandOverrideCache(OverrideType type)
@ -769,7 +764,7 @@ bool AdminCache::InvalidateAdmin(AdminId id)
if (!m_InvalidatingAdmins && !m_destroying)
{
g_Players.ClearAdminId(id);
playerhelpers->ClearAdminId(id);
}
/* Unlink from the dbl link list */
@ -952,7 +947,11 @@ void AdminCache::InvalidateAdminCache(bool unlink_admins)
m_InvalidatingAdmins = true;
if (!m_destroying)
{
g_Players.ClearAllAdmins();
int maxClients = playerhelpers->GetMaxClients();
for (int i = 1; i <= maxClients; ++i)
{
playerhelpers->GetGamePlayer(i)->ClearAdmin();
}
}
/* Wipe the identity cache first */
List<AuthMethod *>::iterator iter;
@ -1022,7 +1021,7 @@ void AdminCache::DumpAdminCache(AdminCachePart part, bool rebuild)
}
m_pCacheFwd->PushCell(AdminCache_Admins);
m_pCacheFwd->Execute(&result);
g_Players.RecheckAnyAdmins();
playerhelpers->RecheckAnyAdmins();
}
}
}
@ -1449,7 +1448,7 @@ bool AdminCache::CanAdminTarget(AdminId id, AdminId target)
}
/** Fourth, if the targeted admin is immune from targeting admin. */
int mode = sm_immunity_mode.GetInt();
int mode = smcore.GetImmunityMode();
switch (mode)
{
case 1:
@ -1590,7 +1589,7 @@ bool AdminCache::CanAdminUseCommand(int client, const char *cmd)
cmd++;
}
if (!g_ConCmds.LookForCommandAdminFlags(cmd, &bits))
if (!smcore.LookForCommandAdminFlags(cmd, &bits))
{
if (!GetCommandOverride(cmd, otype, &bits))
{
@ -1598,7 +1597,7 @@ bool AdminCache::CanAdminUseCommand(int client, const char *cmd)
}
}
return g_ConCmds.CheckClientCommandAccess(client, cmd, bits);
return CheckClientCommandAccess(client, cmd, bits);
}
unsigned int AdminCache::SetGroupImmunityLevel(GroupId gid, unsigned int level)
@ -1665,7 +1664,7 @@ bool AdminCache::CheckAccess(int client, const char *cmd, FlagBits flags, bool o
bool found_command = false;
if (!override_only)
{
found_command = g_ConCmds.LookForCommandAdminFlags(cmd, &bits);
found_command = smcore.LookForCommandAdminFlags(cmd, &bits);
}
if (!found_command)
@ -1673,7 +1672,7 @@ bool AdminCache::CheckAccess(int client, const char *cmd, FlagBits flags, bool o
GetCommandOverride(cmd, Override_Command, &bits);
}
return g_ConCmds.CheckClientCommandAccess(client, cmd, bits) ? 1 : 0;
return CheckClientCommandAccess(client, cmd, bits) ? 1 : 0;
}
void iterator_glob_basic_override(FILE *fp, const char *key, FlagBits flags)
@ -1911,22 +1910,78 @@ size_t AdminCache::FillFlagString(FlagBits bits, char *buffer, size_t maxlen)
return pos;
}
CON_COMMAND(sm_dump_admcache, "Dumps the admin cache for debugging")
bool AdminCache::CheckClientCommandAccess(int client, const char *cmd, FlagBits cmdflags)
{
FILE *fp;
char buffer[PLATFORM_MAX_PATH];
g_SourceMod.BuildPath(Path_SM, buffer, sizeof(buffer), "data/admin_cache_dump.txt");
if ((fp = fopen(buffer, "wt")) == NULL)
if (cmdflags == 0 || client == 0)
{
g_RootMenu.ConsolePrint("Could not open file for writing: %s", buffer);
return;
return true;
}
g_Admins.DumpCache(fp);
/* If running listen server, then client 1 is the server host and should have 'root' access */
if (client == 1 && !engine->IsDedicatedServer())
{
return true;
}
g_RootMenu.ConsolePrint("Admin cache dumped to: %s", buffer);
IGamePlayer *player = playerhelpers->GetGamePlayer(client);
if (!player
|| player->GetEdict() == NULL
|| player->IsFakeClient())
{
return false;
}
fclose(fp);
return CheckAdminCommandAccess(player->GetAdminId(), cmd, cmdflags);
}
bool AdminCache::CheckAdminCommandAccess(AdminId adm, const char *cmd, FlagBits cmdflags)
{
if (adm != INVALID_ADMIN_ID)
{
FlagBits bits = GetAdminFlags(adm, Access_Effective);
/* root knows all, WHOA */
if ((bits & ADMFLAG_ROOT) == ADMFLAG_ROOT)
{
return true;
}
/* Check for overrides
* :TODO: is it worth optimizing this?
*/
unsigned int groups = GetAdminGroupCount(adm);
GroupId gid;
OverrideRule rule;
bool override = false;
for (unsigned int i = 0; i<groups; i++)
{
gid = GetAdminGroup(adm, i, NULL);
/* First get group-level override */
override = GetGroupCommandOverride(gid, cmd, Override_CommandGroup, &rule);
/* Now get the specific command override */
if (GetGroupCommandOverride(gid, cmd, Override_Command, &rule))
{
override = true;
}
if (override)
{
if (rule == Command_Allow)
{
return true;
}
else if (rule == Command_Deny)
{
return false;
}
}
}
/* See if our other flags match */
if ((bits & cmdflags) == cmdflags)
{
return true;
}
}
return false;
}

View File

@ -32,12 +32,12 @@
#ifndef _INCLUDE_SOURCEMOD_ADMINCACHE_H_
#define _INCLUDE_SOURCEMOD_ADMINCACHE_H_
#include "common_logic.h"
#include <IAdminSystem.h>
#include "sm_memtable.h"
#include <sm_trie.h>
#include <sh_list.h>
#include <sh_string.h>
#include <IAdminSystem.h>
#include "sm_globals.h"
#include <IForwardSys.h>
#include <sm_stringhashmap.h>
#include <sm_namehashset.h>
@ -181,11 +181,13 @@ public: //IAdminSystem
bool override_only);
bool FindFlagChar(AdminFlag flag, char *c);
bool IsValidAdmin(AdminId id);
bool CheckClientCommandAccess(int client, const char *cmd, FlagBits cmdflags);
public:
void DumpCache(FILE *fp);
AdminGroup *GetGroup(GroupId gid);
AdminUser *GetUser(AdminId id);
const char *GetString(int idx);
bool CheckAdminCommandAccess(AdminId adm, const char *cmd, FlagBits flags);
private:
void _UnsetCommandOverride(const char *cmd);
void _UnsetCommandGroupOverride(const char *group);

View File

@ -49,6 +49,7 @@
#include "HandleSys.h"
#include "ExtensionSys.h"
#include "ForwardSys.h"
#include "AdminCache.h"
sm_core_t smcore;
IHandleSys *handlesys = &g_HandleSys;
@ -65,7 +66,7 @@ IForwardManager *forwardsys = &g_Forwards;
ITimerSystem *timersys;
ServerGlobals serverGlobals;
IPlayerManager *playerhelpers;
IAdminSystem *adminsys;
IAdminSystem *adminsys = &g_Admins;
IGameHelpers *gamehelpers;
ISourcePawnEngine *g_pSourcePawn;
ISourcePawnEngine2 *g_pSourcePawn2;
@ -103,6 +104,11 @@ static void DumpHandles(void (*dumpfn)(const char *fmt, ...))
g_HandleSys.Dump(dumpfn);
}
static void DumpAdminCache(FILE *f)
{
g_Admins.DumpCache(f);
}
static sm_logic_t logic =
{
NULL,
@ -121,11 +127,13 @@ static sm_logic_t logic =
GenerateError,
AddNatives,
DumpHandles,
DumpAdminCache,
&g_PluginSys,
&g_ShareSys,
&g_Extensions,
&g_HandleSys,
&g_Forwards,
&g_Admins,
NULL,
-1.0f
};
@ -144,7 +152,6 @@ static void logic_init(const sm_core_t* core, sm_logic_t* _logic)
rootmenu = core->rootmenu;
timersys = core->timersys;
playerhelpers = core->playerhelpers;
adminsys = core->adminsys;
gamehelpers = core->gamehelpers;
g_pSourcePawn = *core->spe1;
g_pSourcePawn2 = *core->spe2;

View File

@ -42,6 +42,7 @@
#include <sh_vector.h>
#include <IExtensionSys.h>
#include <IForwardSys.h>
#include <IAdminSystem.h>
using namespace SourceMod;
using namespace SourcePawn;
@ -51,7 +52,7 @@ using namespace SourceHook;
* Add 1 to the RHS of this expression to bump the intercom file
* This is to prevent mismatching core/logic binaries
*/
#define SM_LOGIC_MAGIC (0x0F47C0DE - 27)
#define SM_LOGIC_MAGIC (0x0F47C0DE - 28)
#if defined SM_LOGIC
class IVEngineServer
@ -61,8 +62,13 @@ class IVEngineServer_Logic
{
public:
virtual bool IsMapValid(const char *map) = 0;
virtual bool IsDedicatedServer() = 0;
virtual void InsertServerCommand(const char *cmd) = 0;
virtual void ServerCommand(const char *cmd) = 0;
virtual void ServerExecute() = 0;
virtual const char *GetClientConVarValue(int clientIndex, const char *name) = 0;
virtual void ClientCommand(edict_t *pEdict, const char *szCommand) = 0;
virtual void FakeClientCommand(edict_t *pEdict, const char *szCommand) = 0;
};
typedef void * FileHandle_t;
@ -260,7 +266,6 @@ struct sm_core_t
IRootConsole *rootmenu;
ITimerSystem *timersys;
IPlayerManager *playerhelpers;
IAdminSystem *adminsys;
IGameHelpers *gamehelpers;
ISourcePawnEngine **spe1;
ISourcePawnEngine2 **spe2;
@ -296,6 +301,9 @@ struct sm_core_t
void (*ExecuteConfigs)(IPluginContext *ctx);
DatabaseInfo (*GetDBInfoFromKeyValues)(KeyValues *);
int (*GetActivityFlags)();
int (*GetImmunityMode)();
void (*UpdateAdminCmdFlags)(const char *cmd, OverrideType type, FlagBits bits, bool remove);
bool (*LookForCommandAdminFlags)(const char *cmd, FlagBits *pFlags);
const char *gamesuffix;
/* Data */
ServerGlobals *serverGlobals;
@ -323,11 +331,13 @@ struct sm_logic_t
void (*GenerateError)(IPluginContext *, cell_t, int, const char *, ...);
void (*AddNatives)(sp_nativeinfo_t *natives);
void (*DumpHandles)(void (*dumpfn)(const char *fmt, ...));
void (*DumpAdminCache)(FILE *);
IScriptManager *scripts;
IShareSys *sharesys;
IExtensionSys *extsys;
IHandleSys *handlesys;
IForwardManager *forwardsys;
IAdminSystem *adminsys;
IdentityToken_t *core_ident;
float sentinel;
};

347
core/logic/smn_console.cpp Normal file
View File

@ -0,0 +1,347 @@
/**
* vim: set ts=4 sw=4 tw=99 noet :
* =============================================================================
* SourceMod
* Copyright (C) 2004-2010 AlliedModders LLC. All rights reserved.
* =============================================================================
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, version 3.0, as published by the
* Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*
* As a special exception, AlliedModders LLC gives you permission to link the
* code of this program (as well as its derivative works) to "Half-Life 2," the
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
* by the Valve Corporation. You must obey the GNU General Public License in
* all respects for all other code used. Additionally, AlliedModders LLC grants
* this exception to all derivative works. AlliedModders LLC defines further
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
* or <http://www.sourcemod.net/license.php>.
*
* Version: $Id$
*/
#include "common_logic.h"
#include "AdminCache.h"
#include <IGameHelpers.h>
#include <IPlayerHelpers.h>
#include <ISourceMod.h>
#include <ITranslator.h>
static cell_t CheckCommandAccess(IPluginContext *pContext, const cell_t *params)
{
if (params[1] == 0)
{
return 1;
}
char *cmd;
pContext->LocalToString(params[2], &cmd);
/* Match up with an admin command if possible */
FlagBits bits = params[3];
bool found_command = false;
if (params[0] < 4 || !params[4])
{
found_command = smcore.LookForCommandAdminFlags(cmd, &bits);
}
if (!found_command)
{
adminsys->GetCommandOverride(cmd, Override_Command, &bits);
}
return adminsys->CheckClientCommandAccess(params[1], cmd, bits) ? 1 : 0;
}
static cell_t CheckAccess(IPluginContext *pContext, const cell_t *params)
{
char *cmd;
pContext->LocalToString(params[2], &cmd);
/* Match up with an admin command if possible */
FlagBits bits = params[3];
bool found_command = false;
if (params[0] < 4 || !params[4])
{
found_command = smcore.LookForCommandAdminFlags(cmd, &bits);
}
if (!found_command)
{
adminsys->GetCommandOverride(cmd, Override_Command, &bits);
}
return g_Admins.CheckAdminCommandAccess(params[1], cmd, bits) ? 1 : 0;
}
static cell_t sm_PrintToServer(IPluginContext *pCtx, const cell_t *params)
{
char buffer[1024];
char *fmt;
int arg = 2;
pCtx->LocalToString(params[1], &fmt);
size_t res = smcore.atcprintf(buffer, sizeof(buffer) - 2, fmt, pCtx, params, &arg);
buffer[res++] = '\n';
buffer[res] = '\0';
smcore.ConPrint(buffer);
return 1;
}
static cell_t sm_PrintToConsole(IPluginContext *pCtx, const cell_t *params)
{
int index = params[1];
if ((index < 0) || (index > playerhelpers->GetMaxClients()))
{
return pCtx->ThrowNativeError("Client index %d is invalid", index);
}
IGamePlayer *pPlayer = NULL;
if (index != 0)
{
pPlayer = playerhelpers->GetGamePlayer(index);
if (!pPlayer->IsInGame())
{
return pCtx->ThrowNativeError("Client %d is not in game", index);
}
/* Silent fail on bots, engine will crash */
if (pPlayer->IsFakeClient())
{
return 0;
}
}
char buffer[1024];
char *fmt;
int arg = 3;
pCtx->LocalToString(params[2], &fmt);
size_t res = smcore.atcprintf(buffer, sizeof(buffer) - 2, fmt, pCtx, params, &arg);
buffer[res++] = '\n';
buffer[res] = '\0';
if (index != 0)
{
pPlayer->PrintToConsole(buffer);
}
else {
smcore.ConPrint(buffer);
}
return 1;
}
static cell_t sm_ServerCommand(IPluginContext *pContext, const cell_t *params)
{
g_pSM->SetGlobalTarget(SOURCEMOD_SERVER_LANGUAGE);
char buffer[1024];
size_t len = g_pSM->FormatString(buffer, sizeof(buffer) - 2, pContext, params, 1);
if (pContext->GetLastNativeError() != SP_ERROR_NONE)
{
return 0;
}
/* One byte for null terminator, one for newline */
buffer[len++] = '\n';
buffer[len] = '\0';
engine->ServerCommand(buffer);
return 1;
}
static cell_t sm_InsertServerCommand(IPluginContext *pContext, const cell_t *params)
{
g_pSM->SetGlobalTarget(SOURCEMOD_SERVER_LANGUAGE);
char buffer[1024];
size_t len = g_pSM->FormatString(buffer, sizeof(buffer) - 2, pContext, params, 1);
if (pContext->GetLastNativeError() != SP_ERROR_NONE)
{
return 0;
}
/* One byte for null terminator, one for newline */
buffer[len++] = '\n';
buffer[len] = '\0';
engine->InsertServerCommand(buffer);
return 1;
}
static cell_t sm_ServerExecute(IPluginContext *pContext, const cell_t *params)
{
engine->ServerExecute();
return 1;
}
static cell_t sm_ClientCommand(IPluginContext *pContext, const cell_t *params)
{
IGamePlayer *pPlayer = playerhelpers->GetGamePlayer(params[1]);
if (!pPlayer)
{
return pContext->ThrowNativeError("Client index %d is invalid", params[1]);
}
if (!pPlayer->IsConnected())
{
return pContext->ThrowNativeError("Client %d is not connected", params[1]);
}
g_pSM->SetGlobalTarget(params[1]);
char buffer[256];
g_pSM->FormatString(buffer, sizeof(buffer), pContext, params, 2);
if (pContext->GetLastNativeError() != SP_ERROR_NONE)
{
return 0;
}
engine->ClientCommand(pPlayer->GetEdict(), buffer);
return 1;
}
static cell_t FakeClientCommand(IPluginContext *pContext, const cell_t *params)
{
IGamePlayer *pPlayer = playerhelpers->GetGamePlayer(params[1]);
if (!pPlayer)
{
return pContext->ThrowNativeError("Client index %d is invalid", params[1]);
}
if (!pPlayer->IsConnected())
{
return pContext->ThrowNativeError("Client %d is not connected", params[1]);
}
g_pSM->SetGlobalTarget(params[1]);
char buffer[256];
g_pSM->FormatString(buffer, sizeof(buffer), pContext, params, 2);
if (pContext->GetLastNativeError() != SP_ERROR_NONE)
{
return 0;
}
engine->FakeClientCommand(pPlayer->GetEdict(), buffer);
return 1;
}
static cell_t ReplyToCommand(IPluginContext *pContext, const cell_t *params)
{
g_pSM->SetGlobalTarget(params[1]);
/* Build the format string */
char buffer[1024];
size_t len = g_pSM->FormatString(buffer, sizeof(buffer) - 2, pContext, params, 2);
if (pContext->GetLastNativeError() != SP_ERROR_NONE)
{
return 0;
}
/* If we're printing to the server, shortcut out */
if (params[1] == 0)
{
/* Print */
buffer[len++] = '\n';
buffer[len] = '\0';
smcore.ConPrint(buffer);
return 1;
}
IGamePlayer *pPlayer = playerhelpers->GetGamePlayer(params[1]);
if (!pPlayer)
{
return pContext->ThrowNativeError("Client index %d is invalid", params[1]);
}
if (!pPlayer->IsConnected())
{
return pContext->ThrowNativeError("Client %d is not connected", params[1]);
}
unsigned int replyto = playerhelpers->GetReplyTo();
if (replyto == SM_REPLY_CONSOLE)
{
buffer[len++] = '\n';
buffer[len] = '\0';
pPlayer->PrintToConsole(buffer);
}
else if (replyto == SM_REPLY_CHAT) {
if (len >= 191)
{
len = 191;
}
buffer[len] = '\0';
gamehelpers->TextMsg(params[1], TEXTMSG_DEST_CHAT, buffer);
}
return 1;
}
static cell_t GetCmdReplyTarget(IPluginContext *pContext, const cell_t *params)
{
return playerhelpers->GetReplyTo();
}
static cell_t SetCmdReplyTarget(IPluginContext *pContext, const cell_t *params)
{
return playerhelpers->SetReplyTo(params[1]);
}
static cell_t AddServerTag(IPluginContext *pContext, const cell_t *params)
{
return 0;
}
static cell_t RemoveServerTag(IPluginContext *pContext, const cell_t *params)
{
return 0;
}
REGISTER_NATIVES(consoleNatives)
{
{"CheckCommandAccess", CheckCommandAccess},
{"CheckAccess", CheckAccess},
{"PrintToServer", sm_PrintToServer},
{"PrintToConsole", sm_PrintToConsole},
{"ServerCommand", sm_ServerCommand},
{"InsertServerCommand", sm_InsertServerCommand},
{"ServerExecute", sm_ServerExecute},
{"ClientCommand", sm_ClientCommand},
{"FakeClientCommand", FakeClientCommand},
{"ReplyToCommand", ReplyToCommand},
{"GetCmdReplySource", GetCmdReplyTarget},
{"SetCmdReplySource", SetCmdReplyTarget},
{"AddServerTag", AddServerTag},
{"RemoveServerTag", RemoveServerTag},
{NULL, NULL}
};

View File

@ -42,9 +42,9 @@
#include "TimerSys.h"
#include "logic_bridge.h"
#include "PlayerManager.h"
#include "AdminCache.h"
#include "HalfLife2.h"
#include "CoreConfig.h"
#include "ConCmdManager.h"
#include "IDBDriver.h"
#if SOURCE_ENGINE == SE_DOTA
#include "convar_sm_dota.h"
@ -85,6 +85,7 @@ IShareSys *sharesys;
IExtensionSys *extsys;
IHandleSys *handlesys;
IForwardManager *forwardsys;
IAdminSystem *adminsys;
class VEngineServer_Logic : public IVEngineServer_Logic
{
@ -93,16 +94,42 @@ public:
{
return !!engine->IsMapValid(map);
}
virtual bool IsDedicatedServer()
{
return engine->IsDedicatedServer();
}
virtual void InsertServerCommand(const char *cmd)
{
engine->InsertServerCommand(cmd);
}
virtual void ServerCommand(const char *cmd)
{
engine->ServerCommand(cmd);
}
virtual void ServerExecute()
{
engine->ServerExecute();
}
virtual const char *GetClientConVarValue(int clientIndex, const char *name)
{
return engine->GetClientConVarValue(clientIndex, name);
}
virtual void ClientCommand(edict_t *pEdict, const char *szCommand)
{
#if SOURCE_ENGINE == SE_DOTA
engine->ClientCommand(IndexOfEdict(pEdict), "%s", szCommand);
#else
engine->ClientCommand(pEdict, "%s", szCommand);
#endif
}
virtual void FakeClientCommand(edict_t *pEdict, const char *szCommand)
{
#if SOURCE_ENGINE == SE_DOTA
engine->ClientCommand(IndexOfEdict(pEdict), "%s", szCommand);
#else
serverpluginhelpers->ClientCommand(pEdict, szCommand);
#endif
}
};
static VEngineServer_Logic logic_engine;
@ -223,6 +250,7 @@ public:
static VPlayerInfo_Logic logic_playerinfo;
static ConVar sm_show_activity("sm_show_activity", "13", FCVAR_SPONLY, "Activity display setting (see sourcemod.cfg)");
static ConVar sm_immunity_mode("sm_immunity_mode", "1", FCVAR_SPONLY, "Mode for deciding immunity protection");
static ConVar *find_convar(const char *name)
{
@ -401,6 +429,21 @@ static int get_activity_flags()
return sm_show_activity.GetInt();
}
static int get_immunity_mode()
{
return sm_immunity_mode.GetInt();
}
static void update_admin_cmd_flags(const char *cmd, OverrideType type, FlagBits bits, bool remove)
{
g_ConCmds.UpdateAdminCmdFlags(cmd, type, bits, remove);
}
static bool look_for_cmd_admin_flags(const char *cmd, FlagBits *pFlags)
{
return g_ConCmds.LookForCommandAdminFlags(cmd, pFlags);
}
int read_cmd_argc(const CCommand &args)
{
return args.ArgC();
@ -511,7 +554,6 @@ static sm_core_t core_bridge =
&g_RootMenu,
&g_Timers,
&g_Players,
&g_Admins,
&g_HL2,
&g_pSourcePawn,
&g_pSourcePawn2,
@ -546,6 +588,9 @@ static sm_core_t core_bridge =
SM_ExecuteForPlugin,
keyvalues_to_dbinfo,
get_activity_flags,
get_immunity_mode,
update_admin_cmd_flags,
look_for_cmd_admin_flags,
GAMEFIX,
&serverGlobals,
};
@ -591,6 +636,7 @@ void InitLogicBridge()
g_pCoreIdent = logicore.core_ident;
handlesys = logicore.handlesys;
forwardsys = logicore.forwardsys;
adminsys = logicore.adminsys;
}
bool StartLogicBridge(char *error, size_t maxlength)

View File

@ -47,5 +47,6 @@ extern IShareSys *sharesys;
extern IExtensionSys *extsys;
extern IHandleSys *handlesys;
extern IForwardManager *forwardsys;
extern IAdminSystem *adminsys;
#endif /* _INCLUDE_SOURCEMOD_LOGIC_BRIDGE_H_ */

View File

@ -422,3 +422,23 @@ CON_COMMAND(sm_reload_translations, "Reparses all loaded translation files")
translator->RebuildLanguageDatabase();
}
CON_COMMAND(sm_dump_admcache, "Dumps the admin cache for debugging")
{
FILE *fp;
char buffer[PLATFORM_MAX_PATH];
g_SourceMod.BuildPath(Path_SM, buffer, sizeof(buffer), "data/admin_cache_dump.txt");
if ((fp = fopen(buffer, "wt")) == NULL)
{
g_RootMenu.ConsolePrint("Could not open file for writing: %s", buffer);
return;
}
logicore.DumpAdminCache(fp);
g_RootMenu.ConsolePrint("Admin cache dumped to: %s", buffer);
fclose(fp);
}

View File

@ -38,7 +38,6 @@
#include "sm_stringutil.h"
#include "PlayerManager.h"
#include "ChatTriggers.h"
#include "AdminCache.h"
#include <inetchannel.h>
#include <bitbuf.h>
#include <tier0/dbg.h>
@ -831,88 +830,6 @@ static cell_t sm_GetCmdArgString(IPluginContext *pContext, const cell_t *params)
return (cell_t)length;
}
static cell_t sm_PrintToServer(IPluginContext *pCtx, const cell_t *params)
{
char buffer[1024];
char *fmt;
int arg = 2;
pCtx->LocalToString(params[1], &fmt);
size_t res = atcprintf(buffer, sizeof(buffer)-2, fmt, pCtx, params, &arg);
buffer[res++] = '\n';
buffer[res] = '\0';
META_CONPRINT(buffer);
return 1;
}
static cell_t sm_PrintToConsole(IPluginContext *pCtx, const cell_t *params)
{
int index = params[1];
if ((index < 0) || (index > g_Players.GetMaxClients()))
{
return pCtx->ThrowNativeError("Client index %d is invalid", index);
}
CPlayer *pPlayer = NULL;
if (index != 0)
{
pPlayer = g_Players.GetPlayerByIndex(index);
if (!pPlayer->IsInGame())
{
return pCtx->ThrowNativeError("Client %d is not in game", index);
}
/* Silent fail on bots, engine will crash */
if (pPlayer->IsFakeClient())
{
return 0;
}
}
char buffer[1024];
char *fmt;
int arg = 3;
pCtx->LocalToString(params[2], &fmt);
size_t res = atcprintf(buffer, sizeof(buffer)-2, fmt, pCtx, params, &arg);
buffer[res++] = '\n';
buffer[res] = '\0';
if (index != 0)
{
pPlayer->PrintToConsole(buffer);
} else {
META_CONPRINT(buffer);
}
return 1;
}
static cell_t sm_ServerCommand(IPluginContext *pContext, const cell_t *params)
{
g_SourceMod.SetGlobalTarget(SOURCEMOD_SERVER_LANGUAGE);
char buffer[1024];
size_t len = g_SourceMod.FormatString(buffer, sizeof(buffer)-2, pContext, params, 1);
if (pContext->GetLastNativeError() != SP_ERROR_NONE)
{
return 0;
}
/* One byte for null terminator, one for newline */
buffer[len++] = '\n';
buffer[len] = '\0';
engine->ServerCommand(buffer);
return 1;
}
char *g_ServerCommandBuffer = NULL;
cell_t g_ServerCommandBufferLength;
@ -1031,102 +948,6 @@ static cell_t sm_ServerCommandEx(IPluginContext *pContext, const cell_t *params)
return 1;
}
static cell_t sm_InsertServerCommand(IPluginContext *pContext, const cell_t *params)
{
g_SourceMod.SetGlobalTarget(SOURCEMOD_SERVER_LANGUAGE);
char buffer[1024];
size_t len = g_SourceMod.FormatString(buffer, sizeof(buffer)-2, pContext, params, 1);
if (pContext->GetLastNativeError() != SP_ERROR_NONE)
{
return 0;
}
/* One byte for null terminator, one for newline */
buffer[len++] = '\n';
buffer[len] = '\0';
InsertServerCommand(buffer);
return 1;
}
static cell_t sm_ServerExecute(IPluginContext *pContext, const cell_t *params)
{
engine->ServerExecute();
return 1;
}
static cell_t sm_ClientCommand(IPluginContext *pContext, const cell_t *params)
{
CPlayer *pPlayer = g_Players.GetPlayerByIndex(params[1]);
if (!pPlayer)
{
return pContext->ThrowNativeError("Client index %d is invalid", params[1]);
}
if (!pPlayer->IsConnected())
{
return pContext->ThrowNativeError("Client %d is not connected", params[1]);
}
g_SourceMod.SetGlobalTarget(params[1]);
char buffer[256];
g_SourceMod.FormatString(buffer, sizeof(buffer), pContext, params, 2);
if (pContext->GetLastNativeError() != SP_ERROR_NONE)
{
return 0;
}
engine->ClientCommand(
#if SOURCE_ENGINE == SE_DOTA
pPlayer->GetIndex(),
#else
pPlayer->GetEdict(),
#endif
"%s", buffer);
return 1;
}
static cell_t FakeClientCommand(IPluginContext *pContext, const cell_t *params)
{
CPlayer *pPlayer = g_Players.GetPlayerByIndex(params[1]);
if (!pPlayer)
{
return pContext->ThrowNativeError("Client index %d is invalid", params[1]);
}
if (!pPlayer->IsConnected())
{
return pContext->ThrowNativeError("Client %d is not connected", params[1]);
}
g_SourceMod.SetGlobalTarget(params[1]);
char buffer[256];
g_SourceMod.FormatString(buffer, sizeof(buffer), pContext, params, 2);
if (pContext->GetLastNativeError() != SP_ERROR_NONE)
{
return 0;
}
#if SOURCE_ENGINE == SE_DOTA
engine->ClientCommand(pPlayer->GetIndex(), "%s", buffer);
#else
serverpluginhelpers->ClientCommand(pPlayer->GetEdict(), buffer);
#endif
return 1;
}
static cell_t FakeClientCommandEx(IPluginContext *pContext, const cell_t *params)
{
CPlayer *pPlayer = g_Players.GetPlayerByIndex(params[1]);
@ -1156,69 +977,6 @@ static cell_t FakeClientCommandEx(IPluginContext *pContext, const cell_t *params
return 1;
}
static cell_t ReplyToCommand(IPluginContext *pContext, const cell_t *params)
{
g_SourceMod.SetGlobalTarget(params[1]);
/* Build the format string */
char buffer[1024];
size_t len = g_SourceMod.FormatString(buffer, sizeof(buffer)-2, pContext, params, 2);
if (pContext->GetLastNativeError() != SP_ERROR_NONE)
{
return 0;
}
/* If we're printing to the server, shortcut out */
if (params[1] == 0)
{
/* Print */
buffer[len++] = '\n';
buffer[len] = '\0';
META_CONPRINT(buffer);
return 1;
}
CPlayer *pPlayer = g_Players.GetPlayerByIndex(params[1]);
if (!pPlayer)
{
return pContext->ThrowNativeError("Client index %d is invalid", params[1]);
}
if (!pPlayer->IsConnected())
{
return pContext->ThrowNativeError("Client %d is not connected", params[1]);
}
unsigned int replyto = g_ChatTriggers.GetReplyTo();
if (replyto == SM_REPLY_CONSOLE)
{
buffer[len++] = '\n';
buffer[len] = '\0';
pPlayer->PrintToConsole(buffer);
} else if (replyto == SM_REPLY_CHAT) {
if (len >= 191)
{
len = 191;
}
buffer[len] = '\0';
g_HL2.TextMsg(params[1], HUD_PRINTTALK, buffer);
}
return 1;
}
static cell_t GetCmdReplyTarget(IPluginContext *pContext, const cell_t *params)
{
return g_ChatTriggers.GetReplyTo();
}
static cell_t SetCmdReplyTarget(IPluginContext *pContext, const cell_t *params)
{
return g_ChatTriggers.SetReplyTo(params[1]);
}
static cell_t GetCommandIterator(IPluginContext *pContext, const cell_t *params)
{
GlobCmdIter *iter = new GlobCmdIter;
@ -1278,53 +1036,6 @@ static cell_t ReadCommandIterator(IPluginContext *pContext, const cell_t *params
return 1;
}
static cell_t CheckCommandAccess(IPluginContext *pContext, const cell_t *params)
{
if (params[1] == 0)
{
return 1;
}
char *cmd;
pContext->LocalToString(params[2], &cmd);
/* Match up with an admin command if possible */
FlagBits bits = params[3];
bool found_command = false;
if (params[0] < 4 || !params[4])
{
found_command = g_ConCmds.LookForCommandAdminFlags(cmd, &bits);
}
if (!found_command)
{
g_Admins.GetCommandOverride(cmd, Override_Command, &bits);
}
return g_ConCmds.CheckClientCommandAccess(params[1], cmd, bits) ? 1 : 0;
}
static cell_t CheckAccess(IPluginContext *pContext, const cell_t *params)
{
char *cmd;
pContext->LocalToString(params[2], &cmd);
/* Match up with an admin command if possible */
FlagBits bits = params[3];
bool found_command = false;
if (params[0] < 4 || !params[4])
{
found_command = g_ConCmds.LookForCommandAdminFlags(cmd, &bits);
}
if (!found_command)
{
g_Admins.GetCommandOverride(cmd, Override_Command, &bits);
}
return g_ConCmds.CheckAdminCommandAccess(params[1], cmd, bits) ? 1 : 0;
}
static cell_t IsChatTrigger(IPluginContext *pContext, const cell_t *params)
{
return g_ChatTriggers.IsChatTrigger() ? 1 : 0;
@ -1496,16 +1207,6 @@ static cell_t SendConVarValue(IPluginContext *pContext, const cell_t *params)
return 1;
}
static cell_t AddServerTag(IPluginContext *pContext, const cell_t *params)
{
return 0;
}
static cell_t RemoveServerTag(IPluginContext *pContext, const cell_t *params)
{
return 0;
}
static cell_t AddCommandListener(IPluginContext *pContext, const cell_t *params)
{
char *name;
@ -1573,22 +1274,10 @@ REGISTER_NATIVES(consoleNatives)
{"GetCmdArgString", sm_GetCmdArgString},
{"GetCmdArgs", sm_GetCmdArgs},
{"GetCmdArg", sm_GetCmdArg},
{"PrintToServer", sm_PrintToServer},
{"PrintToConsole", sm_PrintToConsole},
{"RegAdminCmd", sm_RegAdminCmd},
{"ServerCommand", sm_ServerCommand},
{"ServerCommandEx", sm_ServerCommandEx},
{"InsertServerCommand", sm_InsertServerCommand},
{"ServerExecute", sm_ServerExecute},
{"ClientCommand", sm_ClientCommand},
{"FakeClientCommand", FakeClientCommand},
{"ReplyToCommand", ReplyToCommand},
{"GetCmdReplySource", GetCmdReplyTarget},
{"SetCmdReplySource", SetCmdReplyTarget},
{"GetCommandIterator", GetCommandIterator},
{"ReadCommandIterator", ReadCommandIterator},
{"CheckCommandAccess", CheckCommandAccess},
{"CheckAccess", CheckAccess},
{"FakeClientCommandEx", FakeClientCommandEx},
{"IsChatTrigger", IsChatTrigger},
{"SetCommandFlags", SetCommandFlags},
@ -1596,8 +1285,6 @@ REGISTER_NATIVES(consoleNatives)
{"FindFirstConCommand", FindFirstConCommand},
{"FindNextConCommand", FindNextConCommand},
{"SendConVarValue", SendConVarValue},
{"AddServerTag", AddServerTag},
{"RemoveServerTag", RemoveServerTag},
{"AddCommandListener", AddCommandListener},
{"RemoveCommandListener", RemoveCommandListener},
{NULL, NULL}

View File

@ -30,7 +30,6 @@
*/
#include "PlayerManager.h"
#include "AdminCache.h"
#include "sm_stringutil.h"
#include "HalfLife2.h"
#include "sourcemod.h"

View File

@ -36,7 +36,6 @@
#include <sh_string.h>
#include "CoreConfig.h"
#include "Logger.h"
#include "AdminCache.h"
#include "sm_stringutil.h"
#include "PlayerManager.h"
#include "TimerSys.h"

View File

@ -35,7 +35,7 @@
#include <IShareSys.h>
#define SMINTERFACE_ADMINSYS_NAME "IAdminSys"
#define SMINTERFACE_ADMINSYS_VERSION 7
#define SMINTERFACE_ADMINSYS_VERSION 8
/**
* @file IAdminSystem.h
@ -728,12 +728,22 @@ namespace SourceMod
virtual bool FindFlagChar(AdminFlag flag, char *c) =0;
/**
* brief Returns whether or not an admin id is valid.
* @brief Returns whether or not an admin id is valid.
*
* @param id Admin id to check.
* @return True if valid, otherwise false.
*/
virtual bool IsValidAdmin(AdminId id) =0;
/**
* @brief Returns whether or not a client has access to a given command.
*
* @param client Client index.
* @param cmd Command name.
* @param flags Command admin flags.
* @return True if allowed access, otherwise false;
*/
virtual bool CheckClientCommandAccess(int client, const char *cmd, FlagBits cmdflags) =0;
};
}

View File

@ -41,7 +41,7 @@
#include <IAdminSystem.h>
#define SMINTERFACE_PLAYERMANAGER_NAME "IPlayerManager"
#define SMINTERFACE_PLAYERMANAGER_VERSION 19
#define SMINTERFACE_PLAYERMANAGER_VERSION 20
struct edict_t;
class IPlayerInfo;
@ -262,6 +262,11 @@ namespace SourceMod
* @param pMsg String to print.
*/
virtual void PrintToConsole(const char *pMsg) =0;
/**
* @brief Removes admin access from the client.
*/
virtual void ClearAdmin() =0;
};
/**
@ -584,6 +589,18 @@ namespace SourceMod
* @param info Pointer to the cmd_target_info_t structure to process.
*/
virtual void ProcessCommandTarget(cmd_target_info_t *info) =0;
/**
* @brief Removes all access for the given admin id.
*
* @param id Admin id.
*/
virtual void ClearAdminId(AdminId id) =0;
/**
* @brief Reruns admin checks on all players.
*/
virtual void RecheckAnyAdmins() =0;
};
}

View File

@ -41,10 +41,6 @@
{
return cmd->IsFlagSet(flag);
}
inline void InsertServerCommand(const char *buf)
{
engine->InsertServerCommand(buf);
}
inline ConCommandBase *FindCommandBase(const char *name)
{
return icvar->FindCommandBase(name);
@ -77,10 +73,6 @@
{
return cmd->IsBitSet(flag);
}
inline void InsertServerCommand(const char *buf)
{
engine->InsertServerCommand(buf);
}
inline ConCommandBase *FindCommandBase(const char *name)
{
ConCommandBase *pBase = icvar->GetCommands();