diff options
| author | Shocker <none@none> | 2010-09-08 09:28:21 +0300 |
|---|---|---|
| committer | Shocker <none@none> | 2010-09-08 09:28:21 +0300 |
| commit | f9ecc36fb02b1a92b48550337d641acf25b81e28 (patch) | |
| tree | d6e54b27d2846837cdfb6ade52befeabfb7cf690 /src/server/game/Chat | |
| parent | 3bb2dc3588f9dbaacd3f5deb7cd9782f47383b84 (diff) | |
Core/Commands: Implement config for setting the maximum number of results a .lookup command can return, closes issue 3875
--HG--
branch : trunk
Diffstat (limited to 'src/server/game/Chat')
| -rw-r--r-- | src/server/game/Chat/Commands/Level1.cpp | 20 | ||||
| -rw-r--r-- | src/server/game/Chat/Commands/Level2.cpp | 23 | ||||
| -rw-r--r-- | src/server/game/Chat/Commands/Level3.cpp | 96 |
3 files changed, 139 insertions, 0 deletions
diff --git a/src/server/game/Chat/Commands/Level1.cpp b/src/server/game/Chat/Commands/Level1.cpp index 3f50ec762cb..e8d85bc6d2d 100644 --- a/src/server/game/Chat/Commands/Level1.cpp +++ b/src/server/game/Chat/Commands/Level1.cpp @@ -1851,6 +1851,8 @@ bool ChatHandler::HandleLookupAreaCommand(const char* args) return false; bool found = false; + uint32 count = 0; + uint32 maxResults = sWorld.getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS); // converting string that we try to find to lower case wstrToLower (wnamepart); @@ -1885,6 +1887,12 @@ bool ChatHandler::HandleLookupAreaCommand(const char* args) if (loc < MAX_LOCALE) { + if (maxResults && count++ == maxResults) + { + PSendSysMessage(LANG_COMMAND_LOOKUP_MAX_RESULTS, maxResults); + return true; + } + // send area in "id - [name]" format std::ostringstream ss; if (m_session) @@ -1930,6 +1938,9 @@ bool ChatHandler::HandleLookupTeleCommand(const char * args) wstrToLower(wnamepart); std::ostringstream reply; + uint32 count = 0; + uint32 maxResults = sWorld.getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS); + bool limitReached = false; GameTeleMap const & teleMap = sObjectMgr.GetGameTeleMap(); for (GameTeleMap::const_iterator itr = teleMap.begin(); itr != teleMap.end(); ++itr) @@ -1939,6 +1950,12 @@ bool ChatHandler::HandleLookupTeleCommand(const char * args) if (tele->wnameLow.find(wnamepart) == std::wstring::npos) continue; + if (maxResults && count++ == maxResults) + { + limitReached = true; + break; + } + if (m_session) reply << " |cffffffff|Htele:" << itr->first << "|h[" << tele->name << "]|h|r\n"; else @@ -1950,6 +1967,9 @@ bool ChatHandler::HandleLookupTeleCommand(const char * args) else PSendSysMessage(LANG_COMMAND_TELE_LOCATION,reply.str().c_str()); + if (limitReached) + PSendSysMessage(LANG_COMMAND_LOOKUP_MAX_RESULTS, maxResults); + return true; } diff --git a/src/server/game/Chat/Commands/Level2.cpp b/src/server/game/Chat/Commands/Level2.cpp index 838d3e861d9..a51840d92a4 100644 --- a/src/server/game/Chat/Commands/Level2.cpp +++ b/src/server/game/Chat/Commands/Level2.cpp @@ -3435,6 +3435,8 @@ bool ChatHandler::HandleLookupEventCommand(const char* args) wstrToLower(wnamepart); bool found = false; + uint32 count = 0; + uint32 maxResults = sWorld.getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS); GameEventMgr::GameEventDataMap const& events = sGameEventMgr.GetEventMap(); GameEventMgr::ActiveEvents const& activeEvents = sGameEventMgr.GetActiveEventList(); @@ -3449,6 +3451,12 @@ bool ChatHandler::HandleLookupEventCommand(const char* args) if (Utf8FitTo(descr, wnamepart)) { + if (maxResults && count++ == maxResults) + { + PSendSysMessage(LANG_COMMAND_LOOKUP_MAX_RESULTS, maxResults); + return true; + } + char const* active = activeEvents.find(id) != activeEvents.end() ? GetTrinityString(LANG_ACTIVE) : ""; if (m_session) @@ -3836,8 +3844,16 @@ bool ChatHandler::LookupPlayerSearchCommand(QueryResult_AutoPtr result, int32 li } int i = 0; + uint32 count = 0; + uint32 maxResults = sWorld.getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS); do { + if (maxResults && count++ == maxResults) + { + PSendSysMessage(LANG_COMMAND_LOOKUP_MAX_RESULTS, maxResults); + return true; + } + Field* fields = result->Fetch(); uint32 acc_id = fields[0].GetUInt32(); std::string acc_name = fields[1].GetCppString(); @@ -4287,6 +4303,7 @@ bool ChatHandler::HandleLookupTitleCommand(const char* args) wstrToLower(wnamepart); uint32 counter = 0; // Counter for figure out that we found smth. + uint32 maxResults = sWorld.getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS); // Search in CharTitles.dbc for (uint32 id = 0; id < sCharTitlesStore.GetNumRows(); id++) @@ -4318,6 +4335,12 @@ bool ChatHandler::HandleLookupTitleCommand(const char* args) if (loc < MAX_LOCALE) { + if (maxResults && counter == maxResults) + { + PSendSysMessage(LANG_COMMAND_LOOKUP_MAX_RESULTS, maxResults); + return true; + } + char const* knownStr = target && target->HasTitle(titleInfo) ? GetTrinityString(LANG_KNOWN) : ""; char const* activeStr = target && target->GetUInt32Value(PLAYER_CHOSEN_TITLE) == titleInfo->bit_index diff --git a/src/server/game/Chat/Commands/Level3.cpp b/src/server/game/Chat/Commands/Level3.cpp index 54206226890..d55e57c3569 100644 --- a/src/server/game/Chat/Commands/Level3.cpp +++ b/src/server/game/Chat/Commands/Level3.cpp @@ -2985,6 +2985,8 @@ bool ChatHandler::HandleLookupItemCommand(const char *args) wstrToLower(wnamepart); bool found = false; + uint32 count = 0; + uint32 maxResults = sWorld.getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS); // Search in `item_template` for (uint32 id = 0; id < sItemStorage.MaxEntry; id++) @@ -3005,6 +3007,12 @@ bool ChatHandler::HandleLookupItemCommand(const char *args) if (Utf8FitTo(name, wnamepart)) { + if (maxResults && count++ == maxResults) + { + PSendSysMessage(LANG_COMMAND_LOOKUP_MAX_RESULTS, maxResults); + return true; + } + if (m_session) PSendSysMessage(LANG_ITEM_LIST_CHAT, id, id, name.c_str()); else @@ -3025,6 +3033,12 @@ bool ChatHandler::HandleLookupItemCommand(const char *args) if (Utf8FitTo(name, wnamepart)) { + if (maxResults && count++ == maxResults) + { + PSendSysMessage(LANG_COMMAND_LOOKUP_MAX_RESULTS, maxResults); + return true; + } + if (m_session) PSendSysMessage(LANG_ITEM_LIST_CHAT, id, id, name.c_str()); else @@ -3056,6 +3070,8 @@ bool ChatHandler::HandleLookupItemSetCommand(const char *args) wstrToLower(wnamepart); bool found = false; + uint32 count = 0; + uint32 maxResults = sWorld.getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS); // Search in ItemSet.dbc for (uint32 id = 0; id < sItemSetStore.GetNumRows(); id++) @@ -3087,6 +3103,12 @@ bool ChatHandler::HandleLookupItemSetCommand(const char *args) if (loc < MAX_LOCALE) { + if (maxResults && count++ == maxResults) + { + PSendSysMessage(LANG_COMMAND_LOOKUP_MAX_RESULTS, maxResults); + return true; + } + // send item set in "id - [namedlink locale]" format if (m_session) PSendSysMessage(LANG_ITEMSET_LIST_CHAT,id,id,name.c_str(),localeNames[loc]); @@ -3121,6 +3143,8 @@ bool ChatHandler::HandleLookupSkillCommand(const char *args) wstrToLower(wnamepart); bool found = false; + uint32 count = 0; + uint32 maxResults = sWorld.getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS); // Search in SkillLine.dbc for (uint32 id = 0; id < sSkillLineStore.GetNumRows(); id++) @@ -3152,6 +3176,12 @@ bool ChatHandler::HandleLookupSkillCommand(const char *args) if (loc < MAX_LOCALE) { + if (maxResults && count++ == maxResults) + { + PSendSysMessage(LANG_COMMAND_LOOKUP_MAX_RESULTS, maxResults); + return true; + } + char valStr[50] = ""; char const* knownStr = ""; if (target && target->HasSkill(id)) @@ -3200,6 +3230,8 @@ bool ChatHandler::HandleLookupSpellCommand(const char *args) wstrToLower(wnamepart); bool found = false; + uint32 count = 0; + uint32 maxResults = sWorld.getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS); // Search in Spell.dbc for (uint32 id = 0; id < sSpellStore.GetNumRows(); id++) @@ -3231,6 +3263,12 @@ bool ChatHandler::HandleLookupSpellCommand(const char *args) if (loc < MAX_LOCALE) { + if (maxResults && count++ == maxResults) + { + PSendSysMessage(LANG_COMMAND_LOOKUP_MAX_RESULTS, maxResults); + return true; + } + bool known = target && target->HasSpell(id); bool learn = (spellInfo->Effect[0] == SPELL_EFFECT_LEARN_SPELL); @@ -3301,6 +3339,8 @@ bool ChatHandler::HandleLookupQuestCommand(const char *args) wstrToLower(wnamepart); bool found = false; + uint32 count = 0; + uint32 maxResults = sWorld.getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS); ObjectMgr::QuestMap const& qTemplates = sObjectMgr.GetQuestTemplates(); for (ObjectMgr::QuestMap::const_iterator iter = qTemplates.begin(); iter != qTemplates.end(); ++iter) @@ -3319,6 +3359,12 @@ bool ChatHandler::HandleLookupQuestCommand(const char *args) if (Utf8FitTo(title, wnamepart)) { + if (maxResults && count++ == maxResults) + { + PSendSysMessage(LANG_COMMAND_LOOKUP_MAX_RESULTS, maxResults); + return true; + } + char const* statusStr = ""; if (target) @@ -3356,6 +3402,12 @@ bool ChatHandler::HandleLookupQuestCommand(const char *args) if (Utf8FitTo(title, wnamepart)) { + if (maxResults && count++ == maxResults) + { + PSendSysMessage(LANG_COMMAND_LOOKUP_MAX_RESULTS, maxResults); + return true; + } + char const* statusStr = ""; if (target) @@ -3404,6 +3456,8 @@ bool ChatHandler::HandleLookupCreatureCommand(const char *args) wstrToLower (wnamepart); bool found = false; + uint32 count = 0; + uint32 maxResults = sWorld.getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS); for (uint32 id = 0; id< sCreatureStorage.MaxEntry; ++id) { @@ -3423,6 +3477,12 @@ bool ChatHandler::HandleLookupCreatureCommand(const char *args) if (Utf8FitTo (name, wnamepart)) { + if (maxResults && count++ == maxResults) + { + PSendSysMessage(LANG_COMMAND_LOOKUP_MAX_RESULTS, maxResults); + return true; + } + if (m_session) PSendSysMessage (LANG_CREATURE_ENTRY_LIST_CHAT, id, id, name.c_str ()); else @@ -3443,6 +3503,12 @@ bool ChatHandler::HandleLookupCreatureCommand(const char *args) if (Utf8FitTo(name, wnamepart)) { + if (maxResults && count++ == maxResults) + { + PSendSysMessage(LANG_COMMAND_LOOKUP_MAX_RESULTS, maxResults); + return true; + } + if (m_session) PSendSysMessage (LANG_CREATURE_ENTRY_LIST_CHAT, id, id, name.c_str ()); else @@ -3474,6 +3540,8 @@ bool ChatHandler::HandleLookupObjectCommand(const char *args) wstrToLower(wnamepart); bool found = false; + uint32 count = 0; + uint32 maxResults = sWorld.getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS); for (uint32 id = 0; id< sGOStorage.MaxEntry; id++) { @@ -3493,6 +3561,12 @@ bool ChatHandler::HandleLookupObjectCommand(const char *args) if (Utf8FitTo(name, wnamepart)) { + if (maxResults && count++ == maxResults) + { + PSendSysMessage(LANG_COMMAND_LOOKUP_MAX_RESULTS, maxResults); + return true; + } + if (m_session) PSendSysMessage(LANG_GO_ENTRY_LIST_CHAT, id, id, name.c_str()); else @@ -3513,6 +3587,12 @@ bool ChatHandler::HandleLookupObjectCommand(const char *args) if (Utf8FitTo(name, wnamepart)) { + if (maxResults && count++ == maxResults) + { + PSendSysMessage(LANG_COMMAND_LOOKUP_MAX_RESULTS, maxResults); + return true; + } + if (m_session) PSendSysMessage(LANG_GO_ENTRY_LIST_CHAT, id, id, name.c_str()); else @@ -3547,6 +3627,8 @@ bool ChatHandler::HandleLookupFactionCommand(const char *args) wstrToLower (wnamepart); bool found = false; + uint32 count = 0; + uint32 maxResults = sWorld.getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS); for (uint32 id = 0; id < sFactionStore.GetNumRows(); ++id) { @@ -3579,6 +3661,12 @@ bool ChatHandler::HandleLookupFactionCommand(const char *args) if (loc < MAX_LOCALE) { + if (maxResults && count++ == maxResults) + { + PSendSysMessage(LANG_COMMAND_LOOKUP_MAX_RESULTS, maxResults); + return true; + } + // send faction in "id - [faction] rank reputation [visible] [at war] [own team] [unknown] [invisible] [inactive]" format // or "id - [faction] [no reputation]" format std::ostringstream ss; @@ -3638,6 +3726,8 @@ bool ChatHandler::HandleLookupTaxiNodeCommand(const char * args) wstrToLower(wnamepart); bool found = false; + uint32 count = 0; + uint32 maxResults = sWorld.getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS); // Search in TaxiNodes.dbc for (uint32 id = 0; id < sTaxiNodesStore.GetNumRows(); id++) @@ -3669,6 +3759,12 @@ bool ChatHandler::HandleLookupTaxiNodeCommand(const char * args) if (loc < MAX_LOCALE) { + if (maxResults && count++ == maxResults) + { + PSendSysMessage(LANG_COMMAND_LOOKUP_MAX_RESULTS, maxResults); + return true; + } + // send taxinode in "id - [name] (Map:m X:x Y:y Z:z)" format if (m_session) PSendSysMessage (LANG_TAXINODE_ENTRY_LIST_CHAT, id, id, name.c_str(),localeNames[loc], |
