mirror of
				https://github.com/VCMP-SqMod/SqMod.git
				synced 2025-11-04 08:17:19 +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:
		@@ -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);
 | 
			
		||||
 
 | 
			
		||||
@@ -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.
 | 
			
		||||
    */
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user