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:
Shocker
2010-09-08 09:28:21 +03:00
parent 3bb2dc3588
commit f9ecc36fb0
8 changed files with 152 additions and 1 deletions
+20
View File
@@ -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;
}