1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2024-11-08 00:37:15 +01:00

Fix bug in command system when identifiying where the command name ends.

Also add a quick helper function to retrieve the number of existing commands.
This commit is contained in:
Sandu Liviu Catalin 2016-03-15 14:12:14 +02:00
parent acaf826498
commit 98b2ddfda6
2 changed files with 16 additions and 1 deletions

View File

@ -268,7 +268,7 @@ Int32 CmdManager::Run(Int32 invoker, CCStr command)
// Where the name ends and argument begins
CCStr split = command;
// Find where the command name ends
while (isspace(*split)) ++split;
while (!isspace(*split)) ++split;
// Are there any arguments specified?
if (split != nullptr)
{
@ -1570,6 +1570,12 @@ static void Cmd_Sort()
_Cmd->Sort();
}
// ------------------------------------------------------------------------------------------------
static Uint32 Cmd_Count()
{
return _Cmd->Count();
}
// ------------------------------------------------------------------------------------------------
static const Object & Cmd_FindByName(CSStr name)
{
@ -1697,6 +1703,7 @@ void Register_Command(HSQUIRRELVM vm)
);
cmdns.Func(_SC("Sort"), &Cmd_Sort);
cmdns.Func(_SC("Count"), &Cmd_Count);
cmdns.Func(_SC("FindByName"), &Cmd_FindByName);
cmdns.Func(_SC("GetOnError"), &Cmd_GetOnError);
cmdns.Func(_SC("SetOnError"), &Cmd_SetOnError);

View File

@ -160,6 +160,14 @@ public:
*/
void Sort();
/* --------------------------------------------------------------------------------------------
* Retrieve the number of commands.
*/
Uint32 Count() const
{
return static_cast< Uint32 >(m_Commands.size());
}
/* --------------------------------------------------------------------------------------------
* Sort the command list in an ascending order.
*/