[9886] Implement new commands for account search

* .lookup account email, .lookup account ip, .lookup account name
* For new commands and for .lookup player versions use first arg as part of email/ip/name search
* Use similar output format for player/account lists.
This commit is contained in:
VladimirMangos 2010-05-13 11:10:00 +04:00
parent a3e61dc560
commit 080727cbfa
12 changed files with 249 additions and 113 deletions

View file

@ -6136,24 +6136,23 @@ bool ChatHandler::HandleServerSetMotdCommand(const char* args)
return true;
}
/// Output list of character for account
bool ChatHandler::HandleAccountCharactersCommand(const char* args)
bool ChatHandler::ShowPlayerListHelper(QueryResult* result, uint32* limit, bool title, bool error)
{
///- Get the command line arguments
std::string account_name;
Player* target = NULL; // only for triggering use targeted player account
uint32 account_id = extractAccountId((char*)args, &account_name, &target);
if (!account_id )
return false;
///- Get the characters for account id
QueryResult *result = CharacterDatabase.PQuery( "SELECT guid, name, race, class, level FROM characters WHERE account = %u", account_id);
if (!m_session)
if (!result)
{
SendSysMessage(LANG_ACCOUNT_CHARACTERS_LIST_BAR);
SendSysMessage(LANG_ACCOUNT_CHARACTERS_LIST_HEADER);
SendSysMessage(LANG_ACCOUNT_CHARACTERS_LIST_BAR);
if (error)
{
PSendSysMessage(LANG_NO_PLAYERS_FOUND);
SetSentErrorMessage(true);
}
return false;
}
if (!m_session && title)
{
SendSysMessage(LANG_CHARACTERS_LIST_BAR);
SendSysMessage(LANG_CHARACTERS_LIST_HEADER);
SendSysMessage(LANG_CHARACTERS_LIST_BAR);
}
if (result)
@ -6161,6 +6160,14 @@ bool ChatHandler::HandleAccountCharactersCommand(const char* args)
///- Circle through them. Display username and GM level
do
{
// check limit
if (limit)
{
if(*limit == 0)
break;
--*limit;
}
Field *fields = result->Fetch();
uint32 guid = fields[0].GetUInt32();
std::string name = fields[1].GetCppString();
@ -6175,9 +6182,9 @@ bool ChatHandler::HandleAccountCharactersCommand(const char* args)
char const* class_name = classEntry ? classEntry->name[GetSessionDbcLocale()] : "<?>";
if (!m_session)
PSendSysMessage(LANG_ACCOUNT_CHARACTERS_LIST_LINE_CONSOLE, guid, name.c_str(), race_name, class_name, level);
PSendSysMessage(LANG_CHARACTERS_LIST_LINE_CONSOLE, guid, name.c_str(), race_name, class_name, level);
else
PSendSysMessage(LANG_ACCOUNT_CHARACTERS_LIST_LINE_CHAT, guid, name.c_str(), name.c_str(), race_name, class_name, level);
PSendSysMessage(LANG_CHARACTERS_LIST_LINE_CHAT, guid, name.c_str(), name.c_str(), race_name, class_name, level);
}while( result->NextRow() );
@ -6185,11 +6192,28 @@ bool ChatHandler::HandleAccountCharactersCommand(const char* args)
}
if (!m_session)
SendSysMessage(LANG_ACCOUNT_CHARACTERS_LIST_BAR);
SendSysMessage(LANG_CHARACTERS_LIST_BAR);
return true;
}
/// Output list of character for account
bool ChatHandler::HandleAccountCharactersCommand(const char* args)
{
///- Get the command line arguments
std::string account_name;
Player* target = NULL; // only for triggering use targeted player account
uint32 account_id = extractAccountId((char*)args, &account_name, &target);
if (!account_id )
return false;
///- Get the characters for account id
QueryResult *result = CharacterDatabase.PQuery( "SELECT guid, name, race, class, level FROM characters WHERE account = %u", account_id);
return ShowPlayerListHelper(result);
}
/// Set/Unset the expansion level for an account
bool ChatHandler::HandleAccountSetAddonCommand(const char* args)
{