bool ChatHandler::HandleHelpCommand(char* args) { if(!*args) { ShowHelpForCommand(getCommandTable(), "help"); ShowHelpForCommand(getCommandTable(), ""); } else { if (!ShowHelpForCommand(getCommandTable(), args)) SendSysMessage(LANG_NO_CMD); } return true; }
bool ChatHandler::HandleHelpCommand(const char* args) { char* cmd = strtok((char*)args, " "); if (!cmd) { ShowHelpForCommand(getCommandTable(), "help"); ShowHelpForCommand(getCommandTable(), ""); } else { if (!ShowHelpForCommand(getCommandTable(), cmd)) SendSysMessage(LANG_NO_HELP_CMD); } return true; }
int ChatHandler::ParseCommands(const char* text, WorldSession *session) { m_session = session; ASSERT(text); ASSERT(*text); //if(m_session->GetSecurity() == 0) // return 0; if(text[0] != '!' && text[0] != '.') return 0; // ignore single . and ! in line if(strlen(text) < 2) return 0; // ignore messages staring from many dots. if(text[0] == '.' && text[1] == '.' || text[0] == '!' && text[1] == '!') return 0; text++; if(!ExecuteCommandInTable(getCommandTable(), text)) { WorldPacket data; FillSystemMessageData(&data, m_session, "There is no such command."); m_session->SendPacket(&data); } return 1; }
bool ChatHandler::HandleHelpCommand(const char* args) { ChatCommand *table = getCommandTable(); if(!*args) return false; char* cmd = strtok((char*)args, " "); if(!cmd) return false; if(!ShowHelpForCommand(getCommandTable(), cmd)) m_session->SystemMessage(LANG_CMD_UNK, cmd); return true; }
bool ChatHandler::Command_Commands (const char* args) { ChatCommand *table = getCommandTable(); m_session->SystemMessage (LANG_CMD_AVAIL); std::string msg; for(uint32 i = 0; table[i].Name != NULL; ++i) { if(*args && !hasStringAbbr(table[i].Name, (char*)args)) continue; if(m_session->GetSecurity() < table[i].SecurityLevel) continue; // Format command help msg += "|cffcccccc"; msg += table[i].Name; ChatCommand * child = table[i].ChildCommands; if (child != NULL) { msg += " (|cffccccff"; for (uint32 q = 0; child[q].Name != NULL; q++) { msg += child[q].Name; if (child[q+1].Name != NULL) msg += ", "; // Flush too long lines if (msg.size() > 200) { m_session->SystemMessage ((char *)msg.c_str()); msg = "|cffccccff"; } } msg += "|cffcccccc)"; } if (table[i+1].Name != NULL) msg += ", "; // Flush too long lines if (msg.size() > 254) { m_session->SystemMessage ((char *)msg.c_str()); msg = "|cffcccccc"; } } // Flush the rest if (msg.size()) { msg += "."; m_session->SystemMessage ((char *)msg.c_str()); } m_session->SystemMessage (LANG_CMD_MHELP); return true; }
bool ChatHandler::SetDataForCommandInTable(std::vector<ChatCommand>& table, char const* text, uint32 permission, std::string const& help, std::string const& fullcommand) { std::string cmd = ""; while (*text != ' ' && *text != '\0') { cmd += *text; ++text; } while (*text == ' ') ++text; for (uint32 i = 0; i < table.size(); i++) { // for data fill use full explicit command names if (table[i].Name != cmd) continue; // select subcommand from child commands list (including "") if (!table[i].ChildCommands.empty()) { if (SetDataForCommandInTable(table[i].ChildCommands, text, permission, help, fullcommand)) return true; else if (*text) return false; // fail with "" subcommands, then use normal level up command instead } // expected subcommand by full name DB content else if (*text) { TC_LOG_ERROR("sql.sql", "Table `command` have unexpected subcommand '%s' in command '%s', skip.", text, fullcommand.c_str()); return false; } if (table[i].Permission != permission) TC_LOG_INFO("misc", "Table `command` overwrite for command '%s' default permission (%u) by %u", fullcommand.c_str(), table[i].Permission, permission); table[i].Permission = permission; table[i].Help = help; return true; } // in case "" command let process by caller if (!cmd.empty()) { if (&table == &getCommandTable()) TC_LOG_ERROR("sql.sql", "Table `command` have not existed command '%s', skip.", cmd.c_str()); else TC_LOG_ERROR("sql.sql", "Table `command` have not existed subcommand '%s' in command '%s', skip.", cmd.c_str(), fullcommand.c_str()); } return false; }
bool ChatHandler::SetDataForCommandInTable(ChatCommand* table, char const* text, uint32 security, std::string const& help, std::string const& fullcommand) { std::string cmd = ""; while (*text != ' ' && *text != '\0') { cmd += *text; ++text; } while (*text == ' ') ++text; for (uint32 i = 0; table[i].Name != NULL; i++) { // for data fill use full explicit command names if (table[i].Name != cmd) continue; // select subcommand from child commands list (including "") if (table[i].ChildCommands != NULL) { if (SetDataForCommandInTable(table[i].ChildCommands, text, security, help, fullcommand)) return true; else if (*text) return false; // fail with "" subcommands, then use normal level up command instead } // expected subcommand by full name DB content else if (*text) { sLog->outError(LOG_FILTER_SQL, "Table `command` have unexpected subcommand '%s' in command '%s', skip.", text, fullcommand.c_str()); return false; } if (table[i].SecurityLevel != security) sLog->outInfo(LOG_FILTER_GENERAL, "Table `command` overwrite for command '%s' default security (%u) by %u", fullcommand.c_str(), table[i].SecurityLevel, security); table[i].SecurityLevel = security; table[i].Help = help; return true; } // in case "" command let process by caller if (!cmd.empty()) { if (table == getCommandTable()) sLog->outError(LOG_FILTER_SQL, "Table `command` have not existed command '%s', skip.", cmd.c_str()); else sLog->outError(LOG_FILTER_SQL, "Table `command` have not existed subcommand '%s' in command '%s', skip.", cmd.c_str(), fullcommand.c_str()); } return false; }
bool ChatHandler::HandleHelpCommand(const char* args) { ChatCommand *table = getCommandTable(); WorldPacket data; if(!*args) return false; char* cmd = strtok((char*)args, " "); if(!cmd) return false; if(!ShowHelpForCommand(getCommandTable(), cmd)) { FillSystemMessageData(&data, m_session, "There is no such command"); m_session->SendPacket( &data ); } return true; }
bool ChatHandler::_ParseCommands(char const* text) { if (ExecuteCommandInTable(getCommandTable(), text, text)) return true; // Pretend commands don't exist for regular players if (m_session && !m_session->HasPermission(rbac::RBAC_PERM_COMMANDS_NOTIFY_COMMAND_NOT_FOUND_ERROR)) return false; // Send error message for GMs SendSysMessage(LANG_NO_CMD); SetSentErrorMessage(true); return true; }
bool ChatHandler::HandleHelpCommand(const char* args) { if(!*args) return false; char* cmd = strtok((char*)args, " "); if(!cmd) return false; if(!ShowHelpForCommand(getCommandTable(), cmd)) { SendSysMessage(LANG_NO_CMD); } return true; }
bool ChatHandler::HandleCommandsCommand(const char* args) { ChatCommand *table = getCommandTable(); SendSysMessage(LANG_AVIABLE_CMD); for(uint32 i = 0; table[i].Name != NULL; i++) { if(*args && !hasStringAbbr(table[i].Name, (char*)args)) continue; if(m_session->GetSecurity() < table[i].SecurityLevel) continue; SendSysMessage(table[i].Name); } return true; }
bool ChatHandler::ParseCommands(const char* text) { ASSERT(text); ASSERT(*text); std::string fullcmd = text; if (m_session && AccountMgr::IsPlayerAccount(m_session->GetSecurity()) && !sWorld->getBoolConfig(CONFIG_ALLOW_PLAYER_COMMANDS)) return false; /// chat case (.command or !command format) if (m_session) { if (text[0] != '!' && text[0] != '.') return false; } /// ignore single . and ! in line if (strlen(text) < 2) return false; // original `text` can't be used. It content destroyed in command code processing. /// ignore messages staring from many dots. if ((text[0] == '.' && text[1] == '.') || (text[0] == '!' && text[1] == '!')) return false; /// skip first . or ! (in console allowed use command with . and ! and without its) if (text[0] == '!' || text[0] == '.') ++text; if (m_session && AccountMgr::IsPlayerAccount(m_session->GetSecurity()) && m_session->HasCommandsCooldown()) return false; if (!ExecuteCommandInTable(getCommandTable(), text, fullcmd)) { if (m_session && AccountMgr::IsPlayerAccount(m_session->GetSecurity())) return false; SendSysMessage(LANG_NO_CMD); } return true; }
bool ChatHandler::ParseCommands(char const* text) { ASSERT(text); ASSERT(*text); std::string fullcmd = text; /// chat case (.command or !command format) if (m_session) { if (text[0] != '!' && text[0] != '.') return false; } /// ignore single . and ! in line if (strlen(text) < 2) return false; // original `text` can't be used. It content destroyed in command code processing. /// ignore messages staring from many dots. if ((text[0] == '.' && text[1] == '.') || (text[0] == '!' && text[1] == '!')) return false; /// skip first . or ! (in console allowed use command with . and ! and without its) if (text[0] == '!' || text[0] == '.') ++text; if (!ExecuteCommandInTable(getCommandTable(), text, fullcmd)) { #ifdef ELUNA if (!sEluna->OnCommand(GetSession() ? GetSession()->GetPlayer() : NULL, text)) return true; #endif if (m_session && !m_session->HasPermission(rbac::RBAC_PERM_COMMANDS_NOTIFY_COMMAND_NOT_FOUND_ERROR)) return false; SendSysMessage(LANG_NO_CMD); } return true; }
bool ChatHandler::HandleCommandsCommand(const char* args) { ChatCommand *table = getCommandTable(); WorldPacket data; FillSystemMessageData(&data, m_session, "Commands aviable to you:"); m_session->SendPacket(&data); for(uint32 i = 0; table[i].Name != NULL; i++) { if(*args && !hasStringAbbr(table[i].Name, (char*)args)) continue; if(m_session->GetSecurity() < table[i].SecurityLevel) continue; FillSystemMessageData(&data, m_session, table[i].Name); m_session->SendPacket(&data); } return true; }
bool ChatHandler::ShowHelpForSubCommands(std::vector<ChatCommand> const& table, char const* cmd, char const* subcmd) { std::string list; for (uint32 i = 0; i < table.size(); ++i) { // must be available (ignore handler existence for show command with possible available subcommands) if (!isAvailable(table[i])) continue; // for empty subcmd show all available if (*subcmd && !hasStringAbbr(table[i].Name, subcmd)) continue; if (m_session) list += "\n "; else list += "\n\r "; list += table[i].Name; if (!table[i].ChildCommands.empty()) list += " ..."; } if (list.empty()) return false; if (&table == &getCommandTable()) { SendSysMessage(LANG_AVIABLE_CMD); PSendSysMessage("%s", list.c_str()); } else PSendSysMessage(LANG_SUBCMDS_LIST, cmd, list.c_str()); return true; }
bool ChatHandler::HandleCommandsCommand(const char* /*args*/) { ShowHelpForCommand(getCommandTable(), ""); return true; }