Added FindFlagChar native. (bug 3776, r=dvander)

This commit is contained in:
_KaszpiR_ 2010-06-27 19:17:25 -04:00
parent f439cad46c
commit 5d5400a9ac
4 changed files with 37 additions and 2 deletions

View File

@ -42,7 +42,7 @@ using namespace SourceMod;
* Add 1 to the RHS of this expression to bump the intercom file * Add 1 to the RHS of this expression to bump the intercom file
* This is to prevent mismatching core/logic binaries * This is to prevent mismatching core/logic binaries
*/ */
#define SM_LOGIC_MAGIC (0x0F47C0DE - 14) #define SM_LOGIC_MAGIC (0x0F47C0DE - 15)
#if defined SM_LOGIC #if defined SM_LOGIC
class IVEngineServer class IVEngineServer

View File

@ -507,6 +507,22 @@ static cell_t FindFlagByChar(IPluginContext *pContext, const cell_t *params)
return 1; return 1;
} }
static cell_t FindFlagChar(IPluginContext *pContext, const cell_t *params)
{
cell_t *addr;
pContext->LocalToPhysAddr(params[2], &addr);
char flagchar;
if (!adminsys->FindFlagChar((AdminFlag)params[1], &flagchar))
{
return 0;
}
*addr = (cell_t)flagchar;
return 1;
}
static cell_t ReadFlagString(IPluginContext *pContext, const cell_t *params) static cell_t ReadFlagString(IPluginContext *pContext, const cell_t *params)
{ {
char *flag; char *flag;
@ -563,6 +579,7 @@ REGISTER_NATIVES(adminNatives)
{"CreateAuthMethod", CreateAuthMethod}, {"CreateAuthMethod", CreateAuthMethod},
{"FindFlagByName", FindFlagByName}, {"FindFlagByName", FindFlagByName},
{"FindFlagByChar", FindFlagByChar}, {"FindFlagByChar", FindFlagByChar},
{"FindFlagChar", FindFlagChar},
{"ReadFlagString", ReadFlagString}, {"ReadFlagString", ReadFlagString},
{"GetAdmGroupImmunityLevel",GetAdmGroupImmunityLevel}, {"GetAdmGroupImmunityLevel",GetAdmGroupImmunityLevel},
{"SetAdmGroupImmunityLevel",SetAdmGroupImmunityLevel}, {"SetAdmGroupImmunityLevel",SetAdmGroupImmunityLevel},

View File

@ -516,6 +516,15 @@ native bool:FindFlagByName(const String:name[], &AdminFlag:flag);
*/ */
native bool:FindFlagByChar(c, &AdminFlag:flag); native bool:FindFlagByChar(c, &AdminFlag:flag);
/**
* Finds a flag char by a gived admin flag.
*
* @param flag Flag to look up.
* @param c Variable to store flag char.
* @return True on success, false if not found.
*/
native bool:FindFlagChar(AdminFlag:flag, &c);
/** /**
* Converts a string of flag characters to a bit string. * Converts a string of flag characters to a bit string.
* *

View File

@ -35,7 +35,7 @@
#include <IShareSys.h> #include <IShareSys.h>
#define SMINTERFACE_ADMINSYS_NAME "IAdminSys" #define SMINTERFACE_ADMINSYS_NAME "IAdminSys"
#define SMINTERFACE_ADMINSYS_VERSION 5 #define SMINTERFACE_ADMINSYS_VERSION 6
/** /**
* @file IAdminSystem.h * @file IAdminSystem.h
@ -717,6 +717,15 @@ namespace SourceMod
const char *cmd, const char *cmd,
FlagBits flags, FlagBits flags,
bool override_only) =0; bool override_only) =0;
/**
* @brief Reads a flag as the corresponding character.
*
* @param flag Flag to look up.
* @param c Variable to store flag char.
* @return True on success, false if not found.
*/
virtual bool FindFlagChar(AdminFlag flag, char *c);
}; };
} }