Code:
Index: game/Chat.cpp
===================================================================
--- game/Chat.cpp (revision 2714)
+++ game/Chat.cpp (working copy)
@@ -540,6 +540,7 @@
{ "lookupitem", 'l', &ChatHandler::HandleLookupItemCommand, "Looks up item string x.", NULL, 0, 0, 0 },
{ "lookupquest", 'l', &ChatHandler::HandleQuestLookupCommand, "Looks up quest string x.", NULL, 0, 0, 0 },
{ "lookupcreature", 'l', &ChatHandler::HandleLookupCreatureCommand, "Looks up item string x.", NULL, 0, 0, 0 },
+ { "lookupdisplayid", 'l', &ChatHandler::HandleLookupDisplayIDCommand, "Looks up displayid x.", NULL, 0, 0, 0 },
// { "reloadscripts", 'w', &ChatHandler::HandleReloadScriptsCommand, "Reloads GM Scripts", NULL, 0, 0, 0 },
{ "silentplayer", 't', &ChatHandler::HandleSilentPlayerCommand, "Player cannot chat for x minutes <duration> (default 5 minutes)", NULL, 0, 0, 0 },
{ "changepassword", 'z', &ChatHandler::HandleChangePasswordCommand, "Changes your accounts password.", NULL, 0, 0, 0 },
Index: game/Chat.h
===================================================================
--- game/Chat.h (revision 2714)
+++ game/Chat.h (working copy)
@@ -425,6 +425,7 @@
bool HandleSetStandingCommand(const char * args, WorldSession * m_session);
bool HandleGetBaseStandingCommand(const char * args, WorldSession * m_session);
+ bool HandleLookupDisplayIDCommand(const char * args, WorldSession * m_session);
bool HandleLookupItemCommand(const char * args, WorldSession * m_session);
bool HandleLookupCreatureCommand(const char * args, WorldSession * m_session);
bool HandleLookupObjectCommand(const char * args, WorldSession * m_session);
Index: game/Level3.cpp
===================================================================
--- game/Level3.cpp (revision 2714)
+++ game/Level3.cpp (working copy)
@@ -1988,14 +1988,19 @@
return true;
}
-void SendHighlightedName(WorldSession * m_session, char* full_name, string& lowercase_name, string& highlight, uint32 id, bool item)
+void SendHighlightedName(WorldSession * m_session, char* full_name, string& lowercase_name, string& highlight, uint32 id, int type)
{
char message[1024];
char start[50];
start[0] = message[0] = 0;
+ string currenttype;
+ switch(type){
+ case 0: currenttype = "Creature"; break;
+ case 1: currenttype = "Item"; break;
+ case 2: currenttype = "Display ID"; break;
+ }
+ snprintf(start, 50, "%s %u: %s", currenttype.c_str(), (unsigned int)id, MSG_COLOR_WHITE);
- snprintf(start, 50, "%s %u: %s", item ? "Item" : "Creature", (unsigned int)id, MSG_COLOR_WHITE);
-
string::size_type hlen = highlight.length();
string fullname = string(full_name);
string::size_type offset = lowercase_name.find(highlight);
@@ -2055,6 +2060,51 @@
return true;
}
+bool ChatHandler::HandleLookupDisplayIDCommand(const char * args, WorldSession * m_session)
+{
+ if(!*args) return false;
+
+ string x = string(args);
+ ASCENT_TOLOWER(x);
+ if(x.length() < 2)
+ {
+ RedSystemMessage(m_session, "Your search string must be at least 3 characters long.");
+ return true;
+ }
+
+ StorageContainerIterator<CreatureInfo> * itr = CreatureNameStorage.MakeIterator();
+
+ GreenSystemMessage(m_session, "Starting search of displayid `%s`...", x.c_str());
+ uint32 t = getMSTime();
+ CreatureInfo * i;
+ uint32 count = 0;
+ while(!itr->AtEnd())
+ {
+ i = itr->Get();
+ if(FindXinYString(x, i->lowercase_name))
+ {
+ // Print out the name in a cool highlighted fashion
+ if (i->Male_DisplayID != 0)
+ SendHighlightedName(m_session, strcat(i->Name," (male)"), i->lowercase_name + " (male)", x, i->Male_DisplayID, 2);
+ if (i->Female_DisplayID != 0)
+ SendHighlightedName(m_session, strcat(i->Name," (female)"), i->lowercase_name + " (female)", x, i->Female_DisplayID, 2);
+ ++count;
+ if(count == 25)
+ {
+ RedSystemMessage(m_session, "More than 25 results returned. aborting.");
+ break;
+ }
+ }
+ if(!itr->Inc())
+ break;
+ }
+ itr->Destruct();
+
+ GreenSystemMessage(m_session, "Search completed in %u ms.", getMSTime() - t);
+ return true;
+
+}
+
bool ChatHandler::HandleLookupCreatureCommand(const char * args, WorldSession * m_session)
{
if(!*args) return false;
I pretty much copied the lookupcreature code, hacked it to lookup display IDs instead, and added some aethetics. Thank god c++ typecasts bool to int
Enjoy.