Core/Commands: Implement config for setting the maximum number of results a .lookup command can return, closes issue 3875
--HG-- branch : trunk
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user