Show not available command with available subcommands in 'help' and 'commands' output.

Signed-off-by: VladimirMangos <vladimir@getmangos.com>
This commit is contained in:
VladimirMangos 2008-10-22 15:30:16 +04:00
parent 95840fd2c3
commit 15b085dc6d

View file

@ -580,7 +580,7 @@ const char *ChatHandler::GetMangosString(int32 entry) const
bool ChatHandler::isAvailable(ChatCommand const& cmd) const bool ChatHandler::isAvailable(ChatCommand const& cmd) const
{ {
// check security level only for simple command (without child commands) // check security level only for simple command (without child commands)
return cmd.Handler && m_session->GetSecurity() >= cmd.SecurityLevel; return m_session->GetSecurity() >= cmd.SecurityLevel;
} }
bool ChatHandler::hasStringAbbr(const char* name, const char* part) bool ChatHandler::hasStringAbbr(const char* name, const char* part)
@ -703,7 +703,8 @@ bool ChatHandler::ExecuteCommandInTable(ChatCommand *table, const char* text, st
return true; return true;
} }
if(!isAvailable(table[i])) // must be available and have handler
if(!table[i].Handler || !isAvailable(table[i]))
continue; continue;
SetSentErrorMessage(false); SetSentErrorMessage(false);
@ -778,6 +779,7 @@ bool ChatHandler::ShowHelpForSubCommands(ChatCommand *table, char const* cmd, ch
std::string list; std::string list;
for(uint32 i = 0; table[i].Name != NULL; ++i) for(uint32 i = 0; table[i].Name != NULL; ++i)
{ {
// must be available (ignore handler existence for show command with possibe avalable subcomands
if(!isAvailable(table[i])) if(!isAvailable(table[i]))
continue; continue;
@ -808,6 +810,7 @@ bool ChatHandler::ShowHelpForCommand(ChatCommand *table, const char* cmd)
{ {
for(uint32 i = 0; table[i].Name != NULL; ++i) for(uint32 i = 0; table[i].Name != NULL; ++i)
{ {
// must be available (ignore handler existence for show command with possibe avalable subcomands
if(!isAvailable(table[i])) if(!isAvailable(table[i]))
continue; continue;
@ -837,6 +840,7 @@ bool ChatHandler::ShowHelpForCommand(ChatCommand *table, const char* cmd)
{ {
for(uint32 i = 0; table[i].Name != NULL; ++i) for(uint32 i = 0; table[i].Name != NULL; ++i)
{ {
// must be available (ignore handler existence for show command with possibe avalable subcomands
if(!isAvailable(table[i])) if(!isAvailable(table[i]))
continue; continue;
@ -1190,7 +1194,7 @@ const char *CliHandler::GetMangosString(int32 entry) const
bool CliHandler::isAvailable(ChatCommand const& cmd) const bool CliHandler::isAvailable(ChatCommand const& cmd) const
{ {
// skip non-console commands in console case // skip non-console commands in console case
return cmd.Handler && cmd.AllowConsole; return cmd.AllowConsole;
} }
void CliHandler::SendSysMessage(const char *str) void CliHandler::SendSysMessage(const char *str)