*Implement command .lookup map

--HG--
branch : trunk
This commit is contained in:
Anubisss
2009-06-19 01:48:34 +02:00
parent 46ad2e833f
commit ee6126dd50
6 changed files with 133 additions and 2 deletions
+1
View File
@@ -306,6 +306,7 @@ ChatCommand * ChatHandler::getCommandTable()
{ "spell", SEC_ADMINISTRATOR, true, &ChatHandler::HandleLookupSpellCommand, "", NULL },
{ "taxinode", SEC_ADMINISTRATOR, true, &ChatHandler::HandleLookupTaxiNodeCommand, "", NULL },
{ "tele", SEC_MODERATOR, true, &ChatHandler::HandleLookupTeleCommand, "", NULL },
{ "map", SEC_ADMINISTRATOR, true, &ChatHandler::HandleLookupMapCommand, "", NULL },
{ NULL, 0, false, NULL, "", NULL }
};
+1
View File
@@ -256,6 +256,7 @@ class ChatHandler
bool HandleLookupSpellCommand(const char* args);
bool HandleLookupTaxiNodeCommand(const char * args);
bool HandleLookupTeleCommand(const char * args);
bool HandleLookupMapCommand(const char* args);
bool HandleModifyKnownTitlesCommand(const char* args);
bool HandleModifyHPCommand(const char* args);
+11 -2
View File
@@ -854,7 +854,16 @@ enum TrinityStrings
LANG_COMMAND_PLAYED_TO_ALL = 5009,
LANG_NPCINFO_LINKGUID = 5010,
LANG_TELEPORTED_TO_BY_CONSOLE = 5011,
// Room for more Trinity strings 5012-9999
// for command lookup map
LANG_COMMAND_NOMAPFOUND = 5012,
LANG_CONTINENT = 5013,
LANG_INSTANCE = 5014,
LANG_BATTLEGROUND = 5015,
LANG_ARENA = 5016,
LANG_RAID = 5017,
LANG_HEROIC = 5018,
LANG_MOUNTABLE = 5019,
// Room for more Trinity strings 5020-9999
// Used for GM Announcements
LANG_GM_BROADCAST = 6613,
LANG_GM_NOTIFY = 6614,
@@ -929,7 +938,7 @@ enum TrinityStrings
LANG_OPVP_EP_FLIGHT_CGT = 10053,
LANG_OPVP_ZM_GOSSIP_ALLIANCE = 10054,
LANG_OPVP_ZM_GOSSIP_HORDE = 10055,
// Use for custom patches 11000-11999
// NOT RESERVED IDS 12000-1999999999
+97
View File
@@ -3799,6 +3799,103 @@ bool ChatHandler::HandleLookupTaxiNodeCommand(const char * args)
return true;
}
bool ChatHandler::HandleLookupMapCommand(const char* args)
{
if(!*args)
return false;
std::string namepart = args;
std::wstring wnamepart;
// converting string that we try to find to lower case
if(!Utf8toWStr(namepart, wnamepart))
return false;
wstrToLower(wnamepart);
uint32 counter = 0;
// search in Map.dbc
for(uint32 id = 0; id < sMapStore.GetNumRows(); id++)
{
MapEntry const* MapInfo = sMapStore.LookupEntry(id);
if(MapInfo)
{
uint8 loc = m_session ? m_session->GetSessionDbcLocale() : sWorld.GetDefaultDbcLocale();
std::string name = MapInfo->name[loc];
if(name.empty())
continue;
if(!Utf8FitTo(name, wnamepart))
{
loc = LOCALE_enUS;
for(; loc < MAX_LOCALE; loc++)
{
if(m_session && loc == m_session->GetSessionDbcLocale())
continue;
name = MapInfo->name[loc];
if(name.empty())
continue;
if(Utf8FitTo(name, wnamepart))
break;
}
}
if(loc < MAX_LOCALE)
{
// send map in "id - [name][Continent][Instance/Battleground/Arena][Raid reset time:][Heroic reset time:][Mountable]" format
std::ostringstream ss;
if(m_session)
ss << id << " - |cffffffff|Hmap:" << id << "|h[" << name << "]";
else // console
ss << id << " - [" << name << "]";
if(MapInfo->IsContinent())
ss << GetTrinityString(LANG_CONTINENT);
switch(MapInfo->map_type)
{
case MAP_INSTANCE: ss << GetTrinityString(LANG_INSTANCE); break;
case MAP_BATTLEGROUND: ss << GetTrinityString(LANG_BATTLEGROUND); break;
case MAP_ARENA: ss << GetTrinityString(LANG_ARENA); break;
}
if(MapInfo->IsRaid())
ss << GetTrinityString(LANG_RAID);
if(MapInfo->SupportsHeroicMode())
ss << GetTrinityString(LANG_HEROIC);
uint32 ResetTimeRaid = MapInfo->resetTimeRaid;
uint32 ResetTimeHeroic = MapInfo->resetTimeHeroic;
if(MapInfo->IsMountAllowed())
ss << GetTrinityString(LANG_MOUNTABLE);
if(ResetTimeRaid && !ResetTimeHeroic)
PSendSysMessage(ss.str().c_str(), ResetTimeRaid);
else if(!ResetTimeRaid && ResetTimeHeroic)
PSendSysMessage(ss.str().c_str(), ResetTimeHeroic);
else if(ResetTimeRaid && ResetTimeHeroic)
PSendSysMessage(ss.str().c_str(), ResetTimeRaid, ResetTimeHeroic);
else
SendSysMessage(ss.str().c_str());
counter++;
}
}
}
if(!counter)
SendSysMessage(LANG_COMMAND_NOMAPFOUND);
return true;
}
/** \brief GM command level 3 - Create a guild.
*
* This command allows a GM (level 3) to create a guild.