mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-19 08:55:32 +01:00
Core/Commands: Convert lookup commands in commandscript
This commit is contained in:
@@ -112,34 +112,6 @@ ChatCommand* ChatHandler::getCommandTable()
|
||||
{ NULL, 0, false, NULL, "", NULL }
|
||||
};
|
||||
|
||||
static ChatCommand lookupPlayerCommandTable[] =
|
||||
{
|
||||
{ "ip", SEC_GAMEMASTER, true, OldHandler<&ChatHandler::HandleLookupPlayerIpCommand>, "", NULL },
|
||||
{ "account", SEC_GAMEMASTER, true, OldHandler<&ChatHandler::HandleLookupPlayerAccountCommand>, "", NULL },
|
||||
{ "email", SEC_GAMEMASTER, true, OldHandler<&ChatHandler::HandleLookupPlayerEmailCommand>, "", NULL },
|
||||
{ NULL, 0, false, NULL, "", NULL }
|
||||
};
|
||||
|
||||
static ChatCommand lookupCommandTable[] =
|
||||
{
|
||||
{ "area", SEC_MODERATOR, true, OldHandler<&ChatHandler::HandleLookupAreaCommand>, "", NULL },
|
||||
{ "creature", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleLookupCreatureCommand>, "", NULL },
|
||||
{ "event", SEC_GAMEMASTER, true, OldHandler<&ChatHandler::HandleLookupEventCommand>, "", NULL },
|
||||
{ "faction", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleLookupFactionCommand>, "", NULL },
|
||||
{ "item", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleLookupItemCommand>, "", NULL },
|
||||
{ "itemset", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleLookupItemSetCommand>, "", NULL },
|
||||
{ "object", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleLookupObjectCommand>, "", NULL },
|
||||
{ "quest", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleLookupQuestCommand>, "", NULL },
|
||||
{ "player", SEC_GAMEMASTER, true, NULL, "", lookupPlayerCommandTable },
|
||||
{ "skill", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleLookupSkillCommand>, "", NULL },
|
||||
{ "spell", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleLookupSpellCommand>, "", NULL },
|
||||
{ "taxinode", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleLookupTaxiNodeCommand>, "", NULL },
|
||||
{ "tele", SEC_MODERATOR, true, OldHandler<&ChatHandler::HandleLookupTeleCommand>, "", NULL },
|
||||
{ "title", SEC_GAMEMASTER, true, OldHandler<&ChatHandler::HandleLookupTitleCommand>, "", NULL },
|
||||
{ "map", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleLookupMapCommand>, "", NULL },
|
||||
{ NULL, 0, false, NULL, "", NULL }
|
||||
};
|
||||
|
||||
static ChatCommand petCommandTable[] =
|
||||
{
|
||||
{ "create", SEC_GAMEMASTER, false, OldHandler<&ChatHandler::HandleCreatePetCommand>, "", NULL },
|
||||
@@ -203,7 +175,6 @@ ChatCommand* ChatHandler::getCommandTable()
|
||||
|
||||
static ChatCommand commandTable[] =
|
||||
{
|
||||
{ "lookup", SEC_ADMINISTRATOR, true, NULL, "", lookupCommandTable },
|
||||
{ "pdump", SEC_ADMINISTRATOR, true, NULL, "", pdumpCommandTable },
|
||||
{ "group", SEC_ADMINISTRATOR, false, NULL, "", groupCommandTable },
|
||||
|
||||
|
||||
@@ -157,24 +157,6 @@ class ChatHandler
|
||||
bool HandleBindSightCommand(const char* args);
|
||||
bool HandleUnbindSightCommand(const char* args);
|
||||
|
||||
bool HandleLookupAreaCommand(const char* args);
|
||||
bool HandleLookupCreatureCommand(const char* args);
|
||||
bool HandleLookupEventCommand(const char* args);
|
||||
bool HandleLookupFactionCommand(const char * args);
|
||||
bool HandleLookupItemCommand(const char * args);
|
||||
bool HandleLookupItemSetCommand(const char * args);
|
||||
bool HandleLookupObjectCommand(const char* args);
|
||||
bool HandleLookupPlayerIpCommand(const char* args);
|
||||
bool HandleLookupPlayerAccountCommand(const char* args);
|
||||
bool HandleLookupPlayerEmailCommand(const char* args);
|
||||
bool HandleLookupQuestCommand(const char* args);
|
||||
bool HandleLookupSkillCommand(const char* args);
|
||||
bool HandleLookupSpellCommand(const char* args);
|
||||
bool HandleLookupTaxiNodeCommand(const char * args);
|
||||
bool HandleLookupTeleCommand(const char * args);
|
||||
bool HandleLookupMapCommand(const char* args);
|
||||
bool HandleLookupTitleCommand(const char * args);
|
||||
|
||||
bool HandlePDumpLoadCommand(const char *args);
|
||||
bool HandlePDumpWriteCommand(const char *args);
|
||||
|
||||
|
||||
@@ -450,140 +450,6 @@ bool ChatHandler::HandleTaxiCheatCommand(const char* args)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ChatHandler::HandleLookupAreaCommand(const char* args)
|
||||
{
|
||||
if (!*args)
|
||||
return false;
|
||||
|
||||
std::string namepart = args;
|
||||
std::wstring wnamepart;
|
||||
|
||||
if (!Utf8toWStr (namepart, wnamepart))
|
||||
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);
|
||||
|
||||
// Search in AreaTable.dbc
|
||||
for (uint32 areaflag = 0; areaflag < sAreaStore.GetNumRows(); ++areaflag)
|
||||
{
|
||||
AreaTableEntry const* areaEntry = sAreaStore.LookupEntry(areaflag);
|
||||
if (areaEntry)
|
||||
{
|
||||
int loc = GetSessionDbcLocale();
|
||||
std::string name = areaEntry->area_name[loc];
|
||||
if (name.empty())
|
||||
continue;
|
||||
|
||||
if (!Utf8FitTo (name, wnamepart))
|
||||
{
|
||||
loc = 0;
|
||||
for (; loc < TOTAL_LOCALES; ++loc)
|
||||
{
|
||||
if (loc == GetSessionDbcLocale())
|
||||
continue;
|
||||
|
||||
name = areaEntry->area_name[loc];
|
||||
if (name.empty())
|
||||
continue;
|
||||
|
||||
if (Utf8FitTo (name, wnamepart))
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (loc < TOTAL_LOCALES)
|
||||
{
|
||||
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)
|
||||
ss << areaEntry->ID << " - |cffffffff|Harea:" << areaEntry->ID << "|h[" << name << ' ' << localeNames[loc]<< "]|h|r";
|
||||
else
|
||||
ss << areaEntry->ID << " - " << name << ' ' << localeNames[loc];
|
||||
|
||||
SendSysMessage(ss.str().c_str());
|
||||
|
||||
if (!found)
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!found)
|
||||
SendSysMessage(LANG_COMMAND_NOAREAFOUND);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//Find tele in game_tele order by name
|
||||
bool ChatHandler::HandleLookupTeleCommand(const char * args)
|
||||
{
|
||||
if (!*args)
|
||||
{
|
||||
SendSysMessage(LANG_COMMAND_TELE_PARAMETER);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
char const* str = strtok((char*)args, " ");
|
||||
if (!str)
|
||||
return false;
|
||||
|
||||
std::string namepart = str;
|
||||
std::wstring wnamepart;
|
||||
|
||||
if (!Utf8toWStr(namepart, wnamepart))
|
||||
return false;
|
||||
|
||||
// converting string that we try to find to lower case
|
||||
wstrToLower(wnamepart);
|
||||
|
||||
std::ostringstream reply;
|
||||
uint32 count = 0;
|
||||
uint32 maxResults = sWorld->getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS);
|
||||
bool limitReached = false;
|
||||
|
||||
GameTeleContainer const & teleMap = sObjectMgr->GetGameTeleMap();
|
||||
for (GameTeleContainer::const_iterator itr = teleMap.begin(); itr != teleMap.end(); ++itr)
|
||||
{
|
||||
GameTele const* tele = &itr->second;
|
||||
|
||||
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
|
||||
reply << " " << itr->first << ' ' << tele->name << "\n";
|
||||
}
|
||||
|
||||
if (reply.str().empty())
|
||||
SendSysMessage(LANG_COMMAND_TELE_NOLOCATION);
|
||||
else
|
||||
PSendSysMessage(LANG_COMMAND_TELE_LOCATION, reply.str().c_str());
|
||||
|
||||
if (limitReached)
|
||||
PSendSysMessage(LANG_COMMAND_LOOKUP_MAX_RESULTS, maxResults);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//Enable\Dissable accept whispers (for GM)
|
||||
bool ChatHandler::HandleWhispersCommand(const char* args)
|
||||
{
|
||||
|
||||
@@ -456,61 +456,6 @@ bool ChatHandler::HandlePInfoCommand(const char* args)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ChatHandler::HandleLookupEventCommand(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);
|
||||
|
||||
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();
|
||||
|
||||
for (uint32 id = 0; id < events.size(); ++id)
|
||||
{
|
||||
GameEventData const& eventData = events[id];
|
||||
|
||||
std::string descr = eventData.description;
|
||||
if (descr.empty())
|
||||
continue;
|
||||
|
||||
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)
|
||||
PSendSysMessage(LANG_EVENT_ENTRY_LIST_CHAT, id, id, eventData.description.c_str(), active);
|
||||
else
|
||||
PSendSysMessage(LANG_EVENT_ENTRY_LIST_CONSOLE, id, eventData.description.c_str(), active);
|
||||
|
||||
if (!found)
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found)
|
||||
SendSysMessage(LANG_NOEVENTFOUND);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ChatHandler::HandleCombatStopCommand(const char* args)
|
||||
{
|
||||
Player* target = NULL;
|
||||
@@ -539,128 +484,6 @@ bool ChatHandler::HandleCombatStopCommand(const char* args)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ChatHandler::HandleLookupPlayerIpCommand(const char* args)
|
||||
{
|
||||
std::string ip;
|
||||
int32 limit;
|
||||
char* limit_str;
|
||||
|
||||
Player *chr = getSelectedPlayer();
|
||||
if (!*args)
|
||||
{
|
||||
// NULL only if used from console
|
||||
if (!chr || chr == GetSession()->GetPlayer())
|
||||
return false;
|
||||
|
||||
ip = chr->GetSession()->GetRemoteAddress();
|
||||
limit = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
ip = strtok ((char*)args, " ");
|
||||
limit_str = strtok (NULL, " ");
|
||||
limit = limit_str ? atoi (limit_str) : -1;
|
||||
}
|
||||
|
||||
PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_ACCOUNT_BY_IP);
|
||||
stmt->setString(0, ip);
|
||||
PreparedQueryResult result = LoginDatabase.Query(stmt);
|
||||
|
||||
return LookupPlayerSearchCommand(result, limit);
|
||||
}
|
||||
|
||||
bool ChatHandler::HandleLookupPlayerAccountCommand(const char* args)
|
||||
{
|
||||
if (!*args)
|
||||
return false;
|
||||
|
||||
std::string account = strtok ((char*)args, " ");
|
||||
char* limit_str = strtok (NULL, " ");
|
||||
int32 limit = limit_str ? atoi (limit_str) : -1;
|
||||
|
||||
if (!AccountMgr::normalizeString (account))
|
||||
return false;
|
||||
|
||||
PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_ACCOUNT_LIST_BY_NAME);
|
||||
stmt->setString(0, account);
|
||||
PreparedQueryResult result = LoginDatabase.Query(stmt);
|
||||
|
||||
return LookupPlayerSearchCommand (result, limit);
|
||||
}
|
||||
|
||||
bool ChatHandler::HandleLookupPlayerEmailCommand(const char* args)
|
||||
{
|
||||
if (!*args)
|
||||
return false;
|
||||
|
||||
std::string email = strtok ((char*)args, " ");
|
||||
char* limit_str = strtok (NULL, " ");
|
||||
int32 limit = limit_str ? atoi (limit_str) : -1;
|
||||
|
||||
PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_ACCOUNT_LIST_BY_EMAIL);
|
||||
stmt->setString(0, email);
|
||||
PreparedQueryResult result = LoginDatabase.Query(stmt);
|
||||
|
||||
return LookupPlayerSearchCommand(result, limit);
|
||||
}
|
||||
|
||||
bool ChatHandler::LookupPlayerSearchCommand(PreparedQueryResult result, int32 limit)
|
||||
{
|
||||
if (!result)
|
||||
{
|
||||
PSendSysMessage(LANG_NO_PLAYERS_FOUND);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
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].GetString();
|
||||
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_GUID_NAME_BY_ACC);
|
||||
stmt->setUInt32(0, acc_id);
|
||||
PreparedQueryResult result2 = CharacterDatabase.Query(stmt);
|
||||
|
||||
if (result2)
|
||||
{
|
||||
PSendSysMessage(LANG_LOOKUP_PLAYER_ACCOUNT, acc_name.c_str(), acc_id);
|
||||
|
||||
uint64 guid = 0;
|
||||
std::string name;
|
||||
|
||||
do
|
||||
{
|
||||
Field* charfields = result2->Fetch();
|
||||
guid = charfields[0].GetUInt64();
|
||||
name = charfields[1].GetString();
|
||||
|
||||
PSendSysMessage(LANG_LOOKUP_PLAYER_CHARACTER, name.c_str(), guid);
|
||||
++i;
|
||||
|
||||
} while (result2->NextRow() && (limit == -1 || i < limit));
|
||||
}
|
||||
} while (result->NextRow());
|
||||
|
||||
if (i == 0) // empty accounts only
|
||||
{
|
||||
PSendSysMessage(LANG_NO_PLAYERS_FOUND);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ChatHandler::HandleRepairitemsCommand(const char* args)
|
||||
{
|
||||
@@ -854,86 +677,3 @@ bool ChatHandler::HandlePetUnlearnCommand(const char *args)
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ChatHandler::HandleLookupTitleCommand(const char* args)
|
||||
{
|
||||
if (!*args)
|
||||
return false;
|
||||
|
||||
// can be NULL in console call
|
||||
Player* target = getSelectedPlayer();
|
||||
|
||||
// title name have single string arg for player name
|
||||
char const* targetName = target ? target->GetName() : "NAME";
|
||||
|
||||
std::string namepart = args;
|
||||
std::wstring wnamepart;
|
||||
|
||||
if (!Utf8toWStr(namepart, wnamepart))
|
||||
return false;
|
||||
|
||||
// converting string that we try to find to lower case
|
||||
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++)
|
||||
{
|
||||
CharTitlesEntry const* titleInfo = sCharTitlesStore.LookupEntry(id);
|
||||
if (titleInfo)
|
||||
{
|
||||
int loc = GetSessionDbcLocale();
|
||||
std::string name = titleInfo->name[loc];
|
||||
if (name.empty())
|
||||
continue;
|
||||
|
||||
if (!Utf8FitTo(name, wnamepart))
|
||||
{
|
||||
loc = 0;
|
||||
for (; loc < TOTAL_LOCALES; ++loc)
|
||||
{
|
||||
if (loc == GetSessionDbcLocale())
|
||||
continue;
|
||||
|
||||
name = titleInfo->name[loc];
|
||||
if (name.empty())
|
||||
continue;
|
||||
|
||||
if (Utf8FitTo(name, wnamepart))
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (loc < TOTAL_LOCALES)
|
||||
{
|
||||
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
|
||||
? GetTrinityString(LANG_ACTIVE)
|
||||
: "";
|
||||
|
||||
char titleNameStr[80];
|
||||
snprintf(titleNameStr, 80, name.c_str(), targetName);
|
||||
|
||||
// send title in "id (idx:idx) - [namedlink locale]" format
|
||||
if (m_session)
|
||||
PSendSysMessage(LANG_TITLE_LIST_CHAT, id, titleInfo->bit_index, id, titleNameStr, localeNames[loc], knownStr, activeStr);
|
||||
else
|
||||
PSendSysMessage(LANG_TITLE_LIST_CONSOLE, id, titleInfo->bit_index, titleNameStr, localeNames[loc], knownStr, activeStr);
|
||||
|
||||
++counter;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (counter == 0) // if counter == 0 then we found nth
|
||||
SendSysMessage(LANG_COMMAND_NOTITLEFOUND);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -385,921 +385,6 @@ bool ChatHandler::HandleAddItemSetCommand(const char *args)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ChatHandler::HandleLookupItemCommand(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);
|
||||
|
||||
bool found = false;
|
||||
uint32 count = 0;
|
||||
uint32 maxResults = sWorld->getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS);
|
||||
|
||||
// Search in `item_template`
|
||||
ItemTemplateContainer const* its = sObjectMgr->GetItemTemplateStore();
|
||||
for (ItemTemplateContainer::const_iterator itr = its->begin(); itr != its->end(); ++itr)
|
||||
{
|
||||
int loc_idx = GetSessionDbLocaleIndex();
|
||||
if (loc_idx >= 0)
|
||||
{
|
||||
uint8 uloc_idx = uint8(loc_idx);
|
||||
if (ItemLocale const* il = sObjectMgr->GetItemLocale(itr->second.ItemId))
|
||||
{
|
||||
if (il->Name.size() > uloc_idx && !il->Name[uloc_idx].empty())
|
||||
{
|
||||
std::string name = il->Name[uloc_idx];
|
||||
|
||||
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, itr->second.ItemId, itr->second.ItemId, name.c_str());
|
||||
else
|
||||
PSendSysMessage(LANG_ITEM_LIST_CONSOLE, itr->second.ItemId, name.c_str());
|
||||
|
||||
if (!found)
|
||||
found = true;
|
||||
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::string name = itr->second.Name1;
|
||||
if (name.empty())
|
||||
continue;
|
||||
|
||||
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, itr->second.ItemId, itr->second.ItemId, name.c_str());
|
||||
else
|
||||
PSendSysMessage(LANG_ITEM_LIST_CONSOLE, itr->second.ItemId, name.c_str());
|
||||
|
||||
if (!found)
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found)
|
||||
SendSysMessage(LANG_COMMAND_NOITEMFOUND);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ChatHandler::HandleLookupItemSetCommand(const char *args)
|
||||
{
|
||||
if (!*args)
|
||||
return false;
|
||||
|
||||
std::string namepart = args;
|
||||
std::wstring wnamepart;
|
||||
|
||||
if (!Utf8toWStr(namepart, wnamepart))
|
||||
return false;
|
||||
|
||||
// converting string that we try to find to lower case
|
||||
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++)
|
||||
{
|
||||
ItemSetEntry const* set = sItemSetStore.LookupEntry(id);
|
||||
if (set)
|
||||
{
|
||||
int loc = GetSessionDbcLocale();
|
||||
std::string name = set->name[loc];
|
||||
if (name.empty())
|
||||
continue;
|
||||
|
||||
if (!Utf8FitTo(name, wnamepart))
|
||||
{
|
||||
loc = 0;
|
||||
for (; loc < TOTAL_LOCALES; ++loc)
|
||||
{
|
||||
if (loc == GetSessionDbcLocale())
|
||||
continue;
|
||||
|
||||
name = set->name[loc];
|
||||
if (name.empty())
|
||||
continue;
|
||||
|
||||
if (Utf8FitTo(name, wnamepart))
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (loc < TOTAL_LOCALES)
|
||||
{
|
||||
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]);
|
||||
else
|
||||
PSendSysMessage(LANG_ITEMSET_LIST_CONSOLE, id, name.c_str(), localeNames[loc]);
|
||||
|
||||
if (!found)
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!found)
|
||||
SendSysMessage(LANG_COMMAND_NOITEMSETFOUND);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ChatHandler::HandleLookupSkillCommand(const char *args)
|
||||
{
|
||||
if (!*args)
|
||||
return false;
|
||||
|
||||
// can be NULL in console call
|
||||
Player* target = getSelectedPlayer();
|
||||
|
||||
std::string namepart = args;
|
||||
std::wstring wnamepart;
|
||||
|
||||
if (!Utf8toWStr(namepart, wnamepart))
|
||||
return false;
|
||||
|
||||
// converting string that we try to find to lower case
|
||||
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++)
|
||||
{
|
||||
SkillLineEntry const* skillInfo = sSkillLineStore.LookupEntry(id);
|
||||
if (skillInfo)
|
||||
{
|
||||
int loc = GetSessionDbcLocale();
|
||||
std::string name = skillInfo->name[loc];
|
||||
if (name.empty())
|
||||
continue;
|
||||
|
||||
if (!Utf8FitTo(name, wnamepart))
|
||||
{
|
||||
loc = 0;
|
||||
for (; loc < TOTAL_LOCALES; ++loc)
|
||||
{
|
||||
if (loc == GetSessionDbcLocale())
|
||||
continue;
|
||||
|
||||
name = skillInfo->name[loc];
|
||||
if (name.empty())
|
||||
continue;
|
||||
|
||||
if (Utf8FitTo(name, wnamepart))
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (loc < TOTAL_LOCALES)
|
||||
{
|
||||
if (maxResults && count++ == maxResults)
|
||||
{
|
||||
PSendSysMessage(LANG_COMMAND_LOOKUP_MAX_RESULTS, maxResults);
|
||||
return true;
|
||||
}
|
||||
|
||||
char valStr[50] = "";
|
||||
char const* knownStr = "";
|
||||
if (target && target->HasSkill(id))
|
||||
{
|
||||
knownStr = GetTrinityString(LANG_KNOWN);
|
||||
uint32 curValue = target->GetPureSkillValue(id);
|
||||
uint32 maxValue = target->GetPureMaxSkillValue(id);
|
||||
uint32 permValue = target->GetSkillPermBonusValue(id);
|
||||
uint32 tempValue = target->GetSkillTempBonusValue(id);
|
||||
|
||||
char const* valFormat = GetTrinityString(LANG_SKILL_VALUES);
|
||||
snprintf(valStr, 50, valFormat, curValue, maxValue, permValue, tempValue);
|
||||
}
|
||||
|
||||
// send skill in "id - [namedlink locale]" format
|
||||
if (m_session)
|
||||
PSendSysMessage(LANG_SKILL_LIST_CHAT, id, id, name.c_str(), localeNames[loc], knownStr, valStr);
|
||||
else
|
||||
PSendSysMessage(LANG_SKILL_LIST_CONSOLE, id, name.c_str(), localeNames[loc], knownStr, valStr);
|
||||
|
||||
if (!found)
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!found)
|
||||
SendSysMessage(LANG_COMMAND_NOSKILLFOUND);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ChatHandler::HandleLookupSpellCommand(const char *args)
|
||||
{
|
||||
if (!*args)
|
||||
return false;
|
||||
|
||||
// can be NULL at console call
|
||||
Player* target = getSelectedPlayer();
|
||||
|
||||
std::string namepart = args;
|
||||
std::wstring wnamepart;
|
||||
|
||||
if (!Utf8toWStr(namepart, wnamepart))
|
||||
return false;
|
||||
|
||||
// converting string that we try to find to lower case
|
||||
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 < sSpellMgr->GetSpellInfoStoreSize(); id++)
|
||||
{
|
||||
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(id);
|
||||
if (spellInfo)
|
||||
{
|
||||
int loc = GetSessionDbcLocale();
|
||||
std::string name = spellInfo->SpellName[loc];
|
||||
if (name.empty())
|
||||
continue;
|
||||
|
||||
if (!Utf8FitTo(name, wnamepart))
|
||||
{
|
||||
loc = 0;
|
||||
for (; loc < TOTAL_LOCALES; ++loc)
|
||||
{
|
||||
if (loc == GetSessionDbcLocale())
|
||||
continue;
|
||||
|
||||
name = spellInfo->SpellName[loc];
|
||||
if (name.empty())
|
||||
continue;
|
||||
|
||||
if (Utf8FitTo(name, wnamepart))
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (loc < TOTAL_LOCALES)
|
||||
{
|
||||
if (maxResults && count++ == maxResults)
|
||||
{
|
||||
PSendSysMessage(LANG_COMMAND_LOOKUP_MAX_RESULTS, maxResults);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool known = target && target->HasSpell(id);
|
||||
bool learn = (spellInfo->Effects[0].Effect == SPELL_EFFECT_LEARN_SPELL);
|
||||
|
||||
SpellInfo const* learnSpellInfo = sSpellMgr->GetSpellInfo(spellInfo->Effects[0].TriggerSpell);
|
||||
|
||||
uint32 talentCost = GetTalentSpellCost(id);
|
||||
|
||||
bool talent = (talentCost > 0);
|
||||
bool passive = spellInfo->IsPassive();
|
||||
bool active = target && target->HasAura(id);
|
||||
|
||||
// unit32 used to prevent interpreting uint8 as char at output
|
||||
// find rank of learned spell for learning spell, or talent rank
|
||||
uint32 rank = talentCost ? talentCost : learn && learnSpellInfo ? learnSpellInfo->GetRank() : spellInfo->GetRank();
|
||||
|
||||
// send spell in "id - [name, rank N] [talent] [passive] [learn] [known]" format
|
||||
std::ostringstream ss;
|
||||
if (m_session)
|
||||
ss << id << " - |cffffffff|Hspell:" << id << "|h[" << name;
|
||||
else
|
||||
ss << id << " - " << name;
|
||||
|
||||
// include rank in link name
|
||||
if (rank)
|
||||
ss << GetTrinityString(LANG_SPELL_RANK) << rank;
|
||||
|
||||
if (m_session)
|
||||
ss << ' ' << localeNames[loc] << "]|h|r";
|
||||
else
|
||||
ss << ' ' << localeNames[loc];
|
||||
|
||||
if (talent)
|
||||
ss << GetTrinityString(LANG_TALENT);
|
||||
if (passive)
|
||||
ss << GetTrinityString(LANG_PASSIVE);
|
||||
if (learn)
|
||||
ss << GetTrinityString(LANG_LEARN);
|
||||
if (known)
|
||||
ss << GetTrinityString(LANG_KNOWN);
|
||||
if (active)
|
||||
ss << GetTrinityString(LANG_ACTIVE);
|
||||
|
||||
SendSysMessage(ss.str().c_str());
|
||||
|
||||
if (!found)
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!found)
|
||||
SendSysMessage(LANG_COMMAND_NOSPELLFOUND);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ChatHandler::HandleLookupQuestCommand(const char *args)
|
||||
{
|
||||
if (!*args)
|
||||
return false;
|
||||
|
||||
// can be NULL at console call
|
||||
Player* target = getSelectedPlayer();
|
||||
|
||||
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);
|
||||
|
||||
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)
|
||||
{
|
||||
Quest * qinfo = iter->second;
|
||||
|
||||
int loc_idx = GetSessionDbLocaleIndex();
|
||||
if (loc_idx >= 0)
|
||||
{
|
||||
uint8 uloc_idx = uint8(loc_idx);
|
||||
if (QuestLocale const* il = sObjectMgr->GetQuestLocale(qinfo->GetQuestId()))
|
||||
{
|
||||
if (il->Title.size() > uloc_idx && !il->Title[uloc_idx].empty())
|
||||
{
|
||||
std::string title = il->Title[uloc_idx];
|
||||
|
||||
if (Utf8FitTo(title, wnamepart))
|
||||
{
|
||||
if (maxResults && count++ == maxResults)
|
||||
{
|
||||
PSendSysMessage(LANG_COMMAND_LOOKUP_MAX_RESULTS, maxResults);
|
||||
return true;
|
||||
}
|
||||
|
||||
char const* statusStr = "";
|
||||
|
||||
if (target)
|
||||
{
|
||||
QuestStatus status = target->GetQuestStatus(qinfo->GetQuestId());
|
||||
|
||||
switch (status)
|
||||
{
|
||||
case QUEST_STATUS_COMPLETE:
|
||||
statusStr = GetTrinityString(LANG_COMMAND_QUEST_COMPLETE);
|
||||
break;
|
||||
case QUEST_STATUS_INCOMPLETE:
|
||||
statusStr = GetTrinityString(LANG_COMMAND_QUEST_ACTIVE);
|
||||
break;
|
||||
case QUEST_STATUS_REWARDED:
|
||||
statusStr = GetTrinityString(LANG_COMMAND_QUEST_REWARDED);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (m_session)
|
||||
PSendSysMessage(LANG_QUEST_LIST_CHAT, qinfo->GetQuestId(), qinfo->GetQuestId(), qinfo->GetQuestLevel(), title.c_str(), statusStr);
|
||||
else
|
||||
PSendSysMessage(LANG_QUEST_LIST_CONSOLE, qinfo->GetQuestId(), title.c_str(), statusStr);
|
||||
|
||||
if (!found)
|
||||
found = true;
|
||||
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::string title = qinfo->GetTitle();
|
||||
if (title.empty())
|
||||
continue;
|
||||
|
||||
if (Utf8FitTo(title, wnamepart))
|
||||
{
|
||||
if (maxResults && count++ == maxResults)
|
||||
{
|
||||
PSendSysMessage(LANG_COMMAND_LOOKUP_MAX_RESULTS, maxResults);
|
||||
return true;
|
||||
}
|
||||
|
||||
char const* statusStr = "";
|
||||
|
||||
if (target)
|
||||
{
|
||||
QuestStatus status = target->GetQuestStatus(qinfo->GetQuestId());
|
||||
|
||||
switch (status)
|
||||
{
|
||||
case QUEST_STATUS_COMPLETE:
|
||||
statusStr = GetTrinityString(LANG_COMMAND_QUEST_COMPLETE);
|
||||
break;
|
||||
case QUEST_STATUS_INCOMPLETE:
|
||||
statusStr = GetTrinityString(LANG_COMMAND_QUEST_ACTIVE);
|
||||
break;
|
||||
case QUEST_STATUS_REWARDED:
|
||||
statusStr = GetTrinityString(LANG_COMMAND_QUEST_REWARDED);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (m_session)
|
||||
PSendSysMessage(LANG_QUEST_LIST_CHAT, qinfo->GetQuestId(), qinfo->GetQuestId(), qinfo->GetQuestLevel(), title.c_str(), statusStr);
|
||||
else
|
||||
PSendSysMessage(LANG_QUEST_LIST_CONSOLE, qinfo->GetQuestId(), title.c_str(), statusStr);
|
||||
|
||||
if (!found)
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found)
|
||||
SendSysMessage(LANG_COMMAND_NOQUESTFOUND);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ChatHandler::HandleLookupCreatureCommand(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);
|
||||
|
||||
bool found = false;
|
||||
uint32 count = 0;
|
||||
uint32 maxResults = sWorld->getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS);
|
||||
|
||||
CreatureTemplateContainer const* ctc = sObjectMgr->GetCreatureTemplates();
|
||||
for (CreatureTemplateContainer::const_iterator itr = ctc->begin(); itr != ctc->end(); ++itr)
|
||||
{
|
||||
uint32 id = itr->second.Entry;
|
||||
uint8 localeIndex = GetSessionDbLocaleIndex();
|
||||
if (CreatureLocale const* cl = sObjectMgr->GetCreatureLocale(id))
|
||||
{
|
||||
if (cl->Name.size() > localeIndex && !cl->Name[localeIndex].empty())
|
||||
{
|
||||
std::string name = cl->Name[localeIndex];
|
||||
|
||||
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
|
||||
PSendSysMessage(LANG_CREATURE_ENTRY_LIST_CONSOLE, id, name.c_str());
|
||||
|
||||
if (!found)
|
||||
found = true;
|
||||
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::string name = itr->second.Name;
|
||||
if (name.empty())
|
||||
continue;
|
||||
|
||||
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
|
||||
PSendSysMessage(LANG_CREATURE_ENTRY_LIST_CONSOLE, id, name.c_str());
|
||||
|
||||
if (!found)
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found)
|
||||
SendSysMessage(LANG_COMMAND_NOCREATUREFOUND);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ChatHandler::HandleLookupObjectCommand(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);
|
||||
|
||||
bool found = false;
|
||||
uint32 count = 0;
|
||||
uint32 maxResults = sWorld->getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS);
|
||||
|
||||
GameObjectTemplateContainer const* gotc = sObjectMgr->GetGameObjectTemplates();
|
||||
for (GameObjectTemplateContainer::const_iterator itr = gotc->begin(); itr != gotc->end(); ++itr)
|
||||
{
|
||||
uint8 localeIndex = GetSessionDbLocaleIndex();
|
||||
if (GameObjectLocale const* gl = sObjectMgr->GetGameObjectLocale(itr->second.entry))
|
||||
{
|
||||
if (gl->Name.size() > localeIndex && !gl->Name[localeIndex].empty())
|
||||
{
|
||||
std::string name = gl->Name[localeIndex];
|
||||
|
||||
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, itr->second.entry, itr->second.entry, name.c_str());
|
||||
else
|
||||
PSendSysMessage(LANG_GO_ENTRY_LIST_CONSOLE, itr->second.entry, name.c_str());
|
||||
|
||||
if (!found)
|
||||
found = true;
|
||||
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::string name = itr->second.name;
|
||||
if (name.empty())
|
||||
continue;
|
||||
|
||||
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, itr->second.entry, itr->second.entry, name.c_str());
|
||||
else
|
||||
PSendSysMessage(LANG_GO_ENTRY_LIST_CONSOLE, itr->second.entry, name.c_str());
|
||||
|
||||
if (!found)
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found)
|
||||
SendSysMessage(LANG_COMMAND_NOGAMEOBJECTFOUND);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ChatHandler::HandleLookupFactionCommand(const char *args)
|
||||
{
|
||||
if (!*args)
|
||||
return false;
|
||||
|
||||
// Can be NULL at console call
|
||||
Player* target = getSelectedPlayer();
|
||||
|
||||
std::string namepart = args;
|
||||
std::wstring wnamepart;
|
||||
|
||||
if (!Utf8toWStr (namepart, wnamepart))
|
||||
return false;
|
||||
|
||||
// converting string that we try to find to lower case
|
||||
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)
|
||||
{
|
||||
FactionEntry const* factionEntry = sFactionStore.LookupEntry (id);
|
||||
if (factionEntry)
|
||||
{
|
||||
FactionState const* repState = target ? target->GetReputationMgr().GetState(factionEntry) : NULL;
|
||||
|
||||
int loc = GetSessionDbcLocale();
|
||||
std::string name = factionEntry->name[loc];
|
||||
if (name.empty())
|
||||
continue;
|
||||
|
||||
if (!Utf8FitTo(name, wnamepart))
|
||||
{
|
||||
loc = 0;
|
||||
for (; loc < TOTAL_LOCALES; ++loc)
|
||||
{
|
||||
if (loc == GetSessionDbcLocale())
|
||||
continue;
|
||||
|
||||
name = factionEntry->name[loc];
|
||||
if (name.empty())
|
||||
continue;
|
||||
|
||||
if (Utf8FitTo(name, wnamepart))
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (loc < TOTAL_LOCALES)
|
||||
{
|
||||
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;
|
||||
if (m_session)
|
||||
ss << id << " - |cffffffff|Hfaction:" << id << "|h[" << name << ' ' << localeNames[loc] << "]|h|r";
|
||||
else
|
||||
ss << id << " - " << name << ' ' << localeNames[loc];
|
||||
|
||||
if (repState) // and then target != NULL also
|
||||
{
|
||||
uint32 index = target->GetReputationMgr().GetReputationRankStrIndex(factionEntry);
|
||||
std::string rankName = GetTrinityString(index);
|
||||
|
||||
ss << ' ' << rankName << "|h|r (" << target->GetReputationMgr().GetReputation(factionEntry) << ')';
|
||||
|
||||
if (repState->Flags & FACTION_FLAG_VISIBLE)
|
||||
ss << GetTrinityString(LANG_FACTION_VISIBLE);
|
||||
if (repState->Flags & FACTION_FLAG_AT_WAR)
|
||||
ss << GetTrinityString(LANG_FACTION_ATWAR);
|
||||
if (repState->Flags & FACTION_FLAG_PEACE_FORCED)
|
||||
ss << GetTrinityString(LANG_FACTION_PEACE_FORCED);
|
||||
if (repState->Flags & FACTION_FLAG_HIDDEN)
|
||||
ss << GetTrinityString(LANG_FACTION_HIDDEN);
|
||||
if (repState->Flags & FACTION_FLAG_INVISIBLE_FORCED)
|
||||
ss << GetTrinityString(LANG_FACTION_INVISIBLE_FORCED);
|
||||
if (repState->Flags & FACTION_FLAG_INACTIVE)
|
||||
ss << GetTrinityString(LANG_FACTION_INACTIVE);
|
||||
}
|
||||
else
|
||||
ss << GetTrinityString(LANG_FACTION_NOREPUTATION);
|
||||
|
||||
SendSysMessage(ss.str().c_str());
|
||||
|
||||
if (!found)
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!found)
|
||||
SendSysMessage(LANG_COMMAND_FACTION_NOTFOUND);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ChatHandler::HandleLookupTaxiNodeCommand(const char * args)
|
||||
{
|
||||
if (!*args)
|
||||
return false;
|
||||
|
||||
std::string namepart = args;
|
||||
std::wstring wnamepart;
|
||||
|
||||
if (!Utf8toWStr(namepart, wnamepart))
|
||||
return false;
|
||||
|
||||
// converting string that we try to find to lower case
|
||||
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++)
|
||||
{
|
||||
TaxiNodesEntry const* nodeEntry = sTaxiNodesStore.LookupEntry(id);
|
||||
if (nodeEntry)
|
||||
{
|
||||
int loc = GetSessionDbcLocale();
|
||||
std::string name = nodeEntry->name[loc];
|
||||
if (name.empty())
|
||||
continue;
|
||||
|
||||
if (!Utf8FitTo(name, wnamepart))
|
||||
{
|
||||
loc = 0;
|
||||
for (; loc < TOTAL_LOCALES; ++loc)
|
||||
{
|
||||
if (loc == GetSessionDbcLocale())
|
||||
continue;
|
||||
|
||||
name = nodeEntry->name[loc];
|
||||
if (name.empty())
|
||||
continue;
|
||||
|
||||
if (Utf8FitTo(name, wnamepart))
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (loc < TOTAL_LOCALES)
|
||||
{
|
||||
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],
|
||||
nodeEntry->map_id, nodeEntry->x, nodeEntry->y, nodeEntry->z);
|
||||
else
|
||||
PSendSysMessage(LANG_TAXINODE_ENTRY_LIST_CONSOLE, id, name.c_str(), localeNames[loc],
|
||||
nodeEntry->map_id, nodeEntry->x, nodeEntry->y, nodeEntry->z);
|
||||
|
||||
if (!found)
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!found)
|
||||
SendSysMessage(LANG_COMMAND_NOTAXINODEFOUND);
|
||||
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);
|
||||
|
||||
bool found = false;
|
||||
|
||||
// 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 < TOTAL_LOCALES; loc++)
|
||||
{
|
||||
if (m_session && loc == m_session->GetSessionDbcLocale())
|
||||
continue;
|
||||
|
||||
name = MapInfo->name[loc];
|
||||
if (name.empty())
|
||||
continue;
|
||||
|
||||
if (Utf8FitTo(name, wnamepart))
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (loc < TOTAL_LOCALES)
|
||||
{
|
||||
// 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;
|
||||
|
||||
std::string ResetTimeRaidStr;
|
||||
if (ResetTimeRaid)
|
||||
ResetTimeRaidStr = secsToTimeString(ResetTimeRaid, true, false);
|
||||
|
||||
uint32 ResetTimeHeroic = MapInfo->resetTimeHeroic;
|
||||
std::string ResetTimeHeroicStr;
|
||||
if (ResetTimeHeroic)
|
||||
ResetTimeHeroicStr = secsToTimeString(ResetTimeHeroic, true, false);
|
||||
|
||||
if (MapInfo->IsMountAllowed())
|
||||
ss << GetTrinityString(LANG_MOUNTABLE);
|
||||
|
||||
if (ResetTimeRaid && !ResetTimeHeroic)
|
||||
PSendSysMessage(ss.str().c_str(), ResetTimeRaidStr.c_str());
|
||||
else if (!ResetTimeRaid && ResetTimeHeroic)
|
||||
PSendSysMessage(ss.str().c_str(), ResetTimeHeroicStr.c_str());
|
||||
else if (ResetTimeRaid && ResetTimeHeroic)
|
||||
PSendSysMessage(ss.str().c_str(), ResetTimeRaidStr.c_str(), ResetTimeHeroicStr.c_str());
|
||||
else
|
||||
SendSysMessage(ss.str().c_str());
|
||||
|
||||
if (!found)
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!found)
|
||||
SendSysMessage(LANG_COMMAND_NOMAPFOUND);
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ChatHandler::HandleGetDistanceCommand(const char *args)
|
||||
{
|
||||
WorldObject* obj = NULL;
|
||||
|
||||
@@ -57,6 +57,7 @@ void AddSC_honor_commandscript();
|
||||
void AddSC_instance_commandscript();
|
||||
void AddSC_learn_commandscript();
|
||||
void AddSC_list_commandscript();
|
||||
void AddSC_lookup_commandscript();
|
||||
void AddSC_misc_commandscript();
|
||||
void AddSC_modify_commandscript();
|
||||
void AddSC_npc_commandscript();
|
||||
@@ -665,6 +666,7 @@ void AddCommandScripts()
|
||||
AddSC_honor_commandscript();
|
||||
AddSC_instance_commandscript();
|
||||
AddSC_learn_commandscript();
|
||||
AddSC_lookup_commandscript();
|
||||
AddSC_list_commandscript();
|
||||
AddSC_misc_commandscript();
|
||||
AddSC_modify_commandscript();
|
||||
|
||||
@@ -24,6 +24,7 @@ set(scripts_STAT_SRCS
|
||||
Commands/cs_instance.cpp
|
||||
Commands/cs_learn.cpp
|
||||
Commands/cs_list.cpp
|
||||
Commands/cs_lookup.cpp
|
||||
Commands/cs_misc.cpp
|
||||
Commands/cs_modify.cpp
|
||||
Commands/cs_npc.cpp
|
||||
@@ -34,7 +35,6 @@ set(scripts_STAT_SRCS
|
||||
Commands/cs_server.cpp
|
||||
Commands/cs_titles.cpp
|
||||
Commands/cs_wp.cpp
|
||||
# Commands/cs_lookup.cpp
|
||||
# Commands/cs_pdump.cpp
|
||||
# Commands/cs_channel.cpp
|
||||
# Commands/cs_pet.cpp
|
||||
|
||||
1391
src/server/scripts/Commands/cs_lookup.cpp
Normal file
1391
src/server/scripts/Commands/cs_lookup.cpp
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user