mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2024-11-08 00:37:15 +01:00
Documentation spelling corrections and added several functions to retrieve useful information about the currently executed command and a more expanded constructor as well.
This commit is contained in:
parent
e41581a0e3
commit
ad65cf91d8
@ -497,6 +497,13 @@ CmdListener::CmdListener(const SQChar * name)
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
CmdListener::CmdListener(const SQChar * name, const SQChar * spec)
|
||||
: CmdListener(name, spec, 0, MAX_CMD_ARGS)
|
||||
{
|
||||
/* ... */
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
CmdListener::CmdListener(const SQChar * name, const SQChar * spec, SQUint32 min, SQUint32 max)
|
||||
: m_Args({{0}})
|
||||
, m_MinArgc(0)
|
||||
, m_MaxArgc(MAX_CMD_ARGS)
|
||||
@ -504,15 +511,18 @@ CmdListener::CmdListener(const SQChar * name, const SQChar * spec)
|
||||
, m_Spec()
|
||||
, m_Help()
|
||||
, m_Info()
|
||||
, m_OnAuth(_Cmd->GetOnAuth())
|
||||
, m_OnExec()
|
||||
, m_OnAuth(_Cmd->GetOnAuth())
|
||||
, m_Tag()
|
||||
, m_Data()
|
||||
, m_Level(SQMOD_UNKNOWN)
|
||||
, m_Suspended(false)
|
||||
, m_Authority(false)
|
||||
, m_Suspended(false)
|
||||
, m_Lock(false)
|
||||
{
|
||||
// Set the minimum and maximum allowed arguments
|
||||
SetMinArgC(min);
|
||||
SetMaxArgC(max);
|
||||
// Bind to the specified command name
|
||||
SetName(name);
|
||||
// Apply the specified argument rules
|
||||
@ -654,6 +664,24 @@ void CmdListener::SetInfo(const SQChar * info)
|
||||
m_Info.assign(info);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
Function & CmdListener::GetOnExec()
|
||||
{
|
||||
return m_OnExec;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void CmdListener::SetOnExec(Function & func)
|
||||
{
|
||||
m_OnExec = func;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void CmdListener::SetOnExec_Env(SqObj & env, Function & func)
|
||||
{
|
||||
m_OnExec = Function(env.GetVM(), env, func.GetFunc());
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
Function & CmdListener::GetOnAuth()
|
||||
{
|
||||
@ -667,15 +695,9 @@ void CmdListener::SetOnAuth(Function & func)
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
Function & CmdListener::GetOnExec()
|
||||
void CmdListener::SetOnAuth_Env(SqObj & env, Function & func)
|
||||
{
|
||||
return m_OnExec;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void CmdListener::SetOnExec(Function & func)
|
||||
{
|
||||
m_OnExec = func;
|
||||
m_OnAuth = Function(env.GetVM(), env, func.GetFunc());
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
@ -690,18 +712,6 @@ void CmdListener::SetLevel(SQInt32 level)
|
||||
m_Level = level;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
bool CmdListener::GetSuspended() const
|
||||
{
|
||||
return m_Suspended;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void CmdListener::SetSuspended(bool toggle)
|
||||
{
|
||||
m_Suspended = toggle;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
bool CmdListener::GetAuthority() const
|
||||
{
|
||||
@ -714,6 +724,18 @@ void CmdListener::SetAuthority(bool toggle)
|
||||
m_Authority = toggle;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
bool CmdListener::GetSuspended() const
|
||||
{
|
||||
return m_Suspended;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void CmdListener::SetSuspended(bool toggle)
|
||||
{
|
||||
m_Suspended = toggle;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
SQUint32 CmdListener::GetMinArgC() const
|
||||
{
|
||||
@ -926,37 +948,49 @@ const SQChar * CmdArgSpecToStr(Uint8 spec)
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
Function & Cmd_GetOnError()
|
||||
static Function & Cmd_GetOnError()
|
||||
{
|
||||
return _Cmd->GetOnError();
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void Cmd_SetOnError(Function & func)
|
||||
static void Cmd_SetOnError(Function & func)
|
||||
{
|
||||
_Cmd->SetOnError(func);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
Function & Cmd_GetOnAuth()
|
||||
static Function & Cmd_GetOnAuth()
|
||||
{
|
||||
return _Cmd->GetOnAuth();
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void Cmd_SetOnAuth(Function & func)
|
||||
static void Cmd_SetOnAuth(Function & func)
|
||||
{
|
||||
_Cmd->SetOnAuth(func);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
const SQChar * Cmd_GetName()
|
||||
static SQInt32 Cmd_GetInvokerID()
|
||||
{
|
||||
return _Cmd->GetInvokerID();
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
static Reference< CPlayer > Cmd_GetInvoker()
|
||||
{
|
||||
return Reference< CPlayer >(_Cmd->GetInvokerID());
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
static const SQChar * Cmd_GetName()
|
||||
{
|
||||
return _Cmd->GetName();
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
const SQChar * Cmd_GetText()
|
||||
static const SQChar * Cmd_GetText()
|
||||
{
|
||||
return _Cmd->GetText();
|
||||
}
|
||||
@ -975,6 +1009,7 @@ bool Register_Cmd(HSQUIRRELVM vm)
|
||||
.Ctor()
|
||||
.Ctor< const SQChar * >()
|
||||
.Ctor< const SQChar *, const SQChar * >()
|
||||
.Ctor< const SQChar *, const SQChar *, SQUint32, SQUint32 >()
|
||||
/* Metamethods */
|
||||
.Func(_SC("_cmp"), &CmdListener::Cmp)
|
||||
.Func(_SC("_tostring"), &CmdListener::ToString)
|
||||
@ -985,15 +1020,17 @@ bool Register_Cmd(HSQUIRRELVM vm)
|
||||
.Prop(_SC("spec"), &CmdListener::GetSpec, &CmdListener::SetSpec)
|
||||
.Prop(_SC("help"), &CmdListener::GetHelp, &CmdListener::SetHelp)
|
||||
.Prop(_SC("info"), &CmdListener::GetInfo, &CmdListener::SetInfo)
|
||||
.Prop(_SC("on_auth"), &CmdListener::GetOnAuth, &CmdListener::SetOnAuth)
|
||||
.Prop(_SC("on_exec"), &CmdListener::GetOnExec, &CmdListener::SetOnExec)
|
||||
.Prop(_SC("on_auth"), &CmdListener::GetOnAuth, &CmdListener::SetOnAuth)
|
||||
.Prop(_SC("level"), &CmdListener::GetLevel, &CmdListener::SetLevel)
|
||||
.Prop(_SC("suspended"), &CmdListener::GetSuspended, &CmdListener::SetSuspended)
|
||||
.Prop(_SC("auth"), &CmdListener::GetAuthority, &CmdListener::SetAuthority)
|
||||
.Prop(_SC("authority"), &CmdListener::GetAuthority, &CmdListener::SetAuthority)
|
||||
.Prop(_SC("suspended"), &CmdListener::GetSuspended, &CmdListener::SetSuspended)
|
||||
.Prop(_SC("min_args"), &CmdListener::GetMinArgC, &CmdListener::SetMinArgC)
|
||||
.Prop(_SC("max_args"), &CmdListener::GetMaxArgC, &CmdListener::SetMaxArgC)
|
||||
/* Functions */
|
||||
.Func(_SC("set_on_exec"), &CmdListener::SetOnExec_Env)
|
||||
.Func(_SC("set_on_auth"), &CmdListener::SetOnAuth_Env)
|
||||
);
|
||||
|
||||
// Output debugging information
|
||||
@ -1002,12 +1039,14 @@ bool Register_Cmd(HSQUIRRELVM vm)
|
||||
// Output debugging information
|
||||
LogDbg("Beginning registration of <Cmd functions> type");
|
||||
// Attempt to register the free functions
|
||||
cmdns.Func(_SC("get_on_error"), &Cmd_GetOnError);
|
||||
cmdns.Func(_SC("set_on_error"), &Cmd_SetOnError);
|
||||
cmdns.Func(_SC("get_on_auth"), &Cmd_GetOnAuth);
|
||||
cmdns.Func(_SC("set_on_auth"), &Cmd_SetOnAuth);
|
||||
cmdns.Func(_SC("get_name"), &Cmd_GetName);
|
||||
cmdns.Func(_SC("get_text"), &Cmd_GetText);
|
||||
cmdns.Func(_SC("GetOnError"), &Cmd_GetOnError);
|
||||
cmdns.Func(_SC("SetOnError"), &Cmd_SetOnError);
|
||||
cmdns.Func(_SC("GetOnAuth"), &Cmd_GetOnAuth);
|
||||
cmdns.Func(_SC("SetOnAuth"), &Cmd_SetOnAuth);
|
||||
cmdns.Func(_SC("GetInvoker"), &Cmd_GetInvoker);
|
||||
cmdns.Func(_SC("GetInvokerID"), &Cmd_GetInvokerID);
|
||||
cmdns.Func(_SC("GetName"), &Cmd_GetName);
|
||||
cmdns.Func(_SC("getText"), &Cmd_GetText);
|
||||
// Output debugging information
|
||||
LogDbg("Registration of <Cmd functions> type was successful");
|
||||
|
||||
|
@ -291,6 +291,11 @@ public:
|
||||
*/
|
||||
CmdListener(const SQChar * name, const SQChar * spec);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Construct and instance and attach it to the specified name.
|
||||
*/
|
||||
CmdListener(const SQChar * name, const SQChar * spec, SQUint32 min, SQUint32 max);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Copy constructor (disabled).
|
||||
*/
|
||||
@ -391,6 +396,21 @@ public:
|
||||
*/
|
||||
void SetInfo(const SQChar * info);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the function responsible for processing the command.
|
||||
*/
|
||||
Function & GetOnExec();
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Change the function responsible for processing the command.
|
||||
*/
|
||||
void SetOnExec(Function & func);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Change the function responsible for processing the command.
|
||||
*/
|
||||
void SetOnExec_Env(SqObj & env, Function & func);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the function responsible for testing the invoker authority.
|
||||
*/
|
||||
@ -402,14 +422,9 @@ public:
|
||||
void SetOnAuth(Function & func);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the function responsible for processing the command.
|
||||
* Change the function responsible for testing the invoker authority.
|
||||
*/
|
||||
Function & GetOnExec();
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Change the function responsible for processing the command.
|
||||
*/
|
||||
void SetOnExec(Function & func);
|
||||
void SetOnAuth_Env(SqObj & env, Function & func);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the internal level required to execute this command.
|
||||
@ -421,16 +436,6 @@ public:
|
||||
*/
|
||||
void SetLevel(SQInt32 level);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* See whether this command listener is allowed to execute or not.
|
||||
*/
|
||||
bool GetSuspended() const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Set whether this command listener is allowed to execute or not.
|
||||
*/
|
||||
void SetSuspended(bool toggle);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* See whether this command needs explicit authority clearance to execute.
|
||||
*/
|
||||
@ -441,6 +446,16 @@ public:
|
||||
*/
|
||||
void SetAuthority(bool toggle);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* See whether this command listener is allowed to execute or not.
|
||||
*/
|
||||
bool GetSuspended() const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Set whether this command listener is allowed to execute or not.
|
||||
*/
|
||||
void SetSuspended(bool toggle);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the minimum arguments allowed required to execute this command.
|
||||
*/
|
||||
@ -523,16 +538,16 @@ private:
|
||||
*/
|
||||
String m_Info;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Function responsible for deciding whether the invoker is allowed to execute.
|
||||
*/
|
||||
Function m_OnAuth;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Function responsible for processing the received command arguments.
|
||||
*/
|
||||
Function m_OnExec;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Function responsible for deciding whether the invoker is allowed to execute.
|
||||
*/
|
||||
Function m_OnAuth;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Arbitrary tag associated with this instance.
|
||||
*/
|
||||
@ -548,16 +563,16 @@ private:
|
||||
*/
|
||||
SQInt32 m_Level;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Whether the command is allowed to execute or not.
|
||||
*/
|
||||
bool m_Suspended;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Whether this command needs an explicit authority verification in order to execute.
|
||||
*/
|
||||
bool m_Authority;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Whether the command is allowed to execute or not.
|
||||
*/
|
||||
bool m_Suspended;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Whether the command is allowed to change name.
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user