From 7ee25008d35cf7265d39cddb25f99b1f9a0a981f Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Mon, 26 Apr 2010 06:55:16 +0400 Subject: [PATCH] [9794] Implement ".account characters" command Console/chat command output characters list for specific account. --- sql/mangos.sql | 13 +- sql/updates/9794_01_mangos_mangos_string.sql | 8 + sql/updates/9794_02_mangos_command.sql | 8 + sql/updates/Makefile.am | 4 + src/game/Chat.cpp | 78 +++++++ src/game/Chat.h | 3 + src/game/DBCStructure.h | 6 +- src/game/DBCfmt.h | 2 +- src/game/Language.h | 6 +- src/game/Level3.cpp | 231 +++++++------------ src/mangosd/CliRunnable.cpp | 20 +- src/shared/revision_nr.h | 2 +- src/shared/revision_sql.h | 2 +- 13 files changed, 210 insertions(+), 173 deletions(-) create mode 100644 sql/updates/9794_01_mangos_mangos_string.sql create mode 100644 sql/updates/9794_02_mangos_command.sql diff --git a/sql/mangos.sql b/sql/mangos.sql index 5a2f8f838..4328a0c69 100644 --- a/sql/mangos.sql +++ b/sql/mangos.sql @@ -24,7 +24,7 @@ CREATE TABLE `db_version` ( `version` varchar(120) default NULL, `creature_ai_version` varchar(120) default NULL, `cache_id` int(10) default '0', - `required_9768_01_mangos_command` bit(1) default NULL + `required_9794_02_mangos_command` bit(1) default NULL ) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Used DB version notes'; -- @@ -508,14 +508,15 @@ LOCK TABLES `command` WRITE; /*!40000 ALTER TABLE `command` DISABLE KEYS */; INSERT INTO `command` VALUES ('account',0,'Syntax: .account\r\n\r\nDisplay the access level of your account.'), +('account characters',3,'Syntax: .account characters [#accountId|$accountName]\r\n\r\nShow list all characters for account seelcted by provided #accountId or $accountName, or for selected player in game.'), ('account create',4,'Syntax: .account create $account $password\r\n\r\nCreate account and set password to it.'), ('account delete',4,'Syntax: .account delete $account\r\n\r\nDelete account with all characters.'), ('account lock',0,'Syntax: .account lock [on|off]\r\n\r\nAllow login from account only from current used IP or remove this requirement.'), ('account onlinelist',4,'Syntax: .account onlinelist\r\n\r\nShow list of online accounts.'), ('account password',0,'Syntax: .account password $old_password $new_password $new_password\r\n\r\nChange your account password.'), -('account set addon',3,'Syntax: .account set addon [$account] #addon\r\n\r\nSet user (possible targeted) expansion addon level allowed. Addon values: 0 - normal, 1 - tbc, 2 - wotlk.'), -('account set gmlevel',4,'Syntax: .account set gmlevel [$account] #level\r\n\r\nSet the security level for targeted player (can''t be used at self) or for account $name to a level of #level.\r\n\r\n#level may range from 0 to 3.'), -('account set password',4,'Syntax: .account set password $account $password $password\r\n\r\nSet password for account.'), +('account set addon',3,'Syntax: .account set addon [#accountId|$accountName] #addon\r\n\r\nSet user (possible targeted) expansion addon level allowed. Addon values: 0 - normal, 1 - tbc, 2 - wotlk.'), +('account set gmlevel',4,'Syntax: .account set gmlevel [#accountId|$accountName] #level\r\n\r\nSet the security level for targeted player (can''t be used at self) or for #accountId or $accountName to a level of #level.\r\n\r\n#level may range from 0 to 3.'), +('account set password',4,'Syntax: .account set password (#accountId|$accountName) $password $password\r\n\r\nSet password for account.'), ('additem',3,'Syntax: .additem #itemid/[#itemname]/#shift-click-item-link #itemcount\r\n\r\nAdds the specified number of items of id #itemid (or exact (!) name $itemname in brackets, or link created by shift-click at item in inventory or recipe) to your or selected character inventory. If #itemcount is omitted, only one item will be added.\r\n.'), ('additemset',3,'Syntax: .additemset #itemsetid\r\n\r\nAdd items from itemset of id #itemsetid to your or selected character inventory. Will add by one example each item from itemset.'), ('announce',1,'Syntax: .announce $MessageToBroadcast\r\n\r\nSend a global message to all players online in chat log.'), @@ -3630,6 +3631,10 @@ INSERT INTO `mangos_string` VALUES (1135,'List known talents:',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), (1136,' (Found talents: %u used talent points: %u)',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), (1137,'%d - |cffffffff|Hgameobject:%d|h[%s X:%f Y:%f Z:%f MapId:%d]|h|r ',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(1138, '=================================================================================',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(1139, '| GUID | Name | Race | Class | Level |',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(1140, '| %10u | %20s | %15s | %15s | %5u |',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(1141, '%u - |cffffffff|Hplayer:%s|h[%s]|h|r %s %s %u',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), (1200,'You try to view cinemitic %u but it doesn\'t exist.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), (1201,'You try to view movie %u but it doesn\'t exist.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL); /*!40000 ALTER TABLE `mangos_string` ENABLE KEYS */; diff --git a/sql/updates/9794_01_mangos_mangos_string.sql b/sql/updates/9794_01_mangos_mangos_string.sql new file mode 100644 index 000000000..a91fb8782 --- /dev/null +++ b/sql/updates/9794_01_mangos_mangos_string.sql @@ -0,0 +1,8 @@ +ALTER TABLE db_version CHANGE COLUMN required_9768_01_mangos_command required_9794_01_mangos_mangos_string bit; + +DELETE FROM mangos_string WHERE entry IN (1138, 1139, 1140, 1141); +INSERT INTO mangos_string VALUES +(1138, '=================================================================================',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(1139, '| GUID | Name | Race | Class | Level |',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(1140, '| %10u | %20s | %15s | %15s | %5u |',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(1141, '%u - |cffffffff|Hplayer:%s|h[%s]|h|r %s %s %u',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL); diff --git a/sql/updates/9794_02_mangos_command.sql b/sql/updates/9794_02_mangos_command.sql new file mode 100644 index 000000000..0bacf6549 --- /dev/null +++ b/sql/updates/9794_02_mangos_command.sql @@ -0,0 +1,8 @@ +ALTER TABLE db_version CHANGE COLUMN required_9794_01_mangos_mangos_string required_9794_02_mangos_command bit; + +DELETE FROM command WHERE name IN('account characters','account set gmlevel','account set password'); +INSERT INTO command (name, security, help) VALUES +('account characters',3,'Syntax: .account characters [#accountId|$accountName]\r\n\r\nShow list all characters for account seelcted by provided #accountId or $accountName, or for selected player in game.'), +('account set addon',3,'Syntax: .account set addon [#accountId|$accountName] #addon\r\n\r\nSet user (possible targeted) expansion addon level allowed. Addon values: 0 - normal, 1 - tbc, 2 - wotlk.'), +('account set gmlevel',4,'Syntax: .account set gmlevel [#accountId|$accountName] #level\r\n\r\nSet the security level for targeted player (can''t be used at self) or for #accountId or $accountName to a level of #level.\r\n\r\n#level may range from 0 to 3.'), +('account set password',4,'Syntax: .account set password (#accountId|$accountName) $password $password\r\n\r\nSet password for account.'); diff --git a/sql/updates/Makefile.am b/sql/updates/Makefile.am index ed39da324..ca07d9c0a 100644 --- a/sql/updates/Makefile.am +++ b/sql/updates/Makefile.am @@ -132,6 +132,8 @@ pkgdata_DATA = \ 9767_02_mangos_command.sql \ 9767_03_characters_characters.sql \ 9768_01_mangos_command.sql \ + 9794_01_mangos_mangos_string.sql \ + 9794_02_mangos_command.sql \ README ## Additional files to include when running 'make dist' @@ -244,4 +246,6 @@ EXTRA_DIST = \ 9767_02_mangos_command.sql \ 9767_03_characters_characters.sql \ 9768_01_mangos_command.sql \ + 9794_01_mangos_mangos_string.sql \ + 9794_02_mangos_command.sql \ README diff --git a/src/game/Chat.cpp b/src/game/Chat.cpp index 389026343..422426fc1 100644 --- a/src/game/Chat.cpp +++ b/src/game/Chat.cpp @@ -72,6 +72,7 @@ ChatCommand * ChatHandler::getCommandTable() static ChatCommand accountCommandTable[] = { + { "characters", SEC_CONSOLE, true, &ChatHandler::HandleAccountCharactersCommand, "", NULL }, { "create", SEC_CONSOLE, true, &ChatHandler::HandleAccountCreateCommand, "", NULL }, { "delete", SEC_CONSOLE, true, &ChatHandler::HandleAccountDeleteCommand, "", NULL }, { "onlinelist", SEC_CONSOLE, true, &ChatHandler::HandleAccountOnlineListCommand, "", NULL }, @@ -2248,6 +2249,83 @@ char* ChatHandler::extractQuotedArg( char* args ) } } +uint32 ChatHandler::extractAccountId(char* args, std::string* accountName /*= NULL*/, Player** targetIfNullArg /*= NULL*/) +{ + uint32 account_id = 0; + + ///- Get the account name from the command line + char* account_str = args ? strtok (args," ") : NULL; + + if (!account_str) + { + if (!targetIfNullArg) + return 0; + + /// only target player different from self allowed (if targetPlayer!=NULL then not console) + Player* targetPlayer = getSelectedPlayer(); + if (!targetPlayer) + return 0; + + account_id = targetPlayer->GetSession()->GetAccountId(); + + if (accountName) + sAccountMgr.GetName(account_id, *accountName); + + if (targetIfNullArg) + *targetIfNullArg = targetPlayer; + + return account_id; + } + + std::string account_name; + + if (isNumeric(account_str)) + { + long id = atol(account_str); + if (id <= 0 || ((unsigned long)id) >= std::numeric_limits::max()) + { + PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_str); + SetSentErrorMessage(true); + return 0; + } + + account_id = uint32(id); + + if (!sAccountMgr.GetName(account_id, account_name)) + { + PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_str); + SetSentErrorMessage(true); + return 0; + } + } + else + { + account_name = account_str; + if (!AccountMgr::normalizeString(account_name)) + { + PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str()); + SetSentErrorMessage(true); + return 0; + } + + account_id = sAccountMgr.GetId(account_name); + if (!account_id) + { + PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str()); + SetSentErrorMessage(true); + return 0; + } + } + + if (accountName) + *accountName = account_name; + + if (targetIfNullArg) + *targetIfNullArg = NULL; + + return account_id; +} + bool ChatHandler::needReportToTarget(Player* chr) const { Player* pl = m_session->GetPlayer(); diff --git a/src/game/Chat.h b/src/game/Chat.h index d2590d6f4..88c24e92f 100644 --- a/src/game/Chat.h +++ b/src/game/Chat.h @@ -99,6 +99,7 @@ class ChatHandler ChatCommand* getCommandTable(); bool HandleAccountCommand(const char* args); + bool HandleAccountCharactersCommand(const char* args); bool HandleAccountCreateCommand(const char* args); bool HandleAccountDeleteCommand(const char* args); bool HandleAccountLockCommand(const char* args); @@ -537,6 +538,8 @@ class ChatHandler std::string playerLink(std::string const& name) const { return m_session ? "|cffffffff|Hplayer:"+name+"|h["+name+"]|h|r" : name; } std::string GetNameLink(Player* chr) const { return playerLink(chr->GetName()); } + uint32 extractAccountId(char* args, std::string* accountName = NULL, Player** targetIfNullArg = NULL); + GameObject* GetObjectGlobalyWithGuidOrNearWithDbGuid(uint32 lowguid,uint32 entry); // Utility methods for commands diff --git a/src/game/DBCStructure.h b/src/game/DBCStructure.h index 2067c1c80..5d9fae3ea 100644 --- a/src/game/DBCStructure.h +++ b/src/game/DBCStructure.h @@ -635,9 +635,9 @@ struct ChrClassesEntry uint32 ClassID; // 0 //uint32 flags; // 1, unused uint32 powerType; // 2 - // 3-4, unused - //char* name[16]; // 5-20 unused - // 21 string flag, unused + // 3, unused + char const* name[16]; // 4-19 unused + // 20 string flag, unused //char* nameFemale[16]; // 21-36 unused, if different from base (male) case // 37 string flag, unused //char* nameNeutralGender[16]; // 38-53 unused, if different from base (male) case diff --git a/src/game/DBCfmt.h b/src/game/DBCfmt.h index 97e3a6285..8c2fc6757 100644 --- a/src/game/DBCfmt.h +++ b/src/game/DBCfmt.h @@ -32,7 +32,7 @@ const char CharStartOutfitEntryfmt[]="diiiiiiiiiiiiiiiiiiiiiiiiixxxxxxxxxxxxxxxx const char CharTitlesEntryfmt[]="nxssssssssssssssssxxxxxxxxxxxxxxxxxxi"; const char ChatChannelsEntryfmt[]="iixssssssssssssssssxxxxxxxxxxxxxxxxxx"; // ChatChannelsEntryfmt, index not used (more compact store) -const char ChrClassesEntryfmt[]="nxixxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxixii"; +const char ChrClassesEntryfmt[]="nxixssssssssssssssssxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxixii"; const char ChrRacesEntryfmt[]="nxixiixixxxxixssssssssssssssssxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxi"; const char CinematicSequencesEntryfmt[]="nxxxxxxxxx"; const char CreatureDisplayInfofmt[]="nxxxfxxxxxxxxxxx"; diff --git a/src/game/Language.h b/src/game/Language.h index 7fb71f998..d845f3700 100644 --- a/src/game/Language.h +++ b/src/game/Language.h @@ -833,7 +833,11 @@ enum MangosStrings LANG_LIST_TALENTS_TITLE = 1135, LANG_LIST_TALENTS_COUNT = 1136, LANG_GO_LIST_CHAT = 1137, - // Room for more level 3 1138-1199 not used + LANG_ACCOUNT_CHARACTERS_LIST_BAR = 1138, + LANG_ACCOUNT_CHARACTERS_LIST_HEADER = 1139, + LANG_ACCOUNT_CHARACTERS_LIST_LINE_CONSOLE = 1140, + LANG_ACCOUNT_CHARACTERS_LIST_LINE_CHAT = 1141, + // Room for more level 3 1142-1199 not used // Debug commands LANG_CINEMATIC_NOT_EXIST = 1200, diff --git a/src/game/Level3.cpp b/src/game/Level3.cpp index 927348e74..9fe413f4a 100644 --- a/src/game/Level3.cpp +++ b/src/game/Level3.cpp @@ -901,52 +901,20 @@ bool ChatHandler::HandleLoadScriptsCommand(const char* args) bool ChatHandler::HandleAccountSetGmLevelCommand(const char* args) { - char* arg1 = strtok((char*)args, " "); - if( !arg1 ) - return false; + char* arg1; + char* arg2; - /// must be NULL if targeted syntax and must be not nULL if not targeted - char* arg2 = strtok(NULL, " "); + extractOptFirstArg((char*)args, &arg1, &arg2); std::string targetAccountName; - uint32 targetAccountId = 0; + Player* targetPlayer = NULL; + uint32 targetAccountId = extractAccountId(arg1,&targetAccountName,&targetPlayer); + if (!targetAccountId) + return false; - /// only target player different from self allowed (if targetPlayer!=NULL then not console) - Player* targetPlayer = getSelectedPlayer(); - if(targetPlayer && m_session->GetPlayer()!=targetPlayer) - { - /// wrong command syntax or unexpected targeting - if(arg2) - return false; - - /// security level expected in arg2 after this if. - arg2 = arg1; - - targetAccountId = targetPlayer->GetSession()->GetAccountId(); - sAccountMgr.GetName(targetAccountId, targetAccountName); - } - else - { - /// wrong command syntax (second arg expected) - if(!arg2) - return false; - - targetAccountName = arg1; - if (!AccountMgr::normalizeString(targetAccountName)) - { - PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,targetAccountName.c_str()); - SetSentErrorMessage(true); - return false; - } - - targetAccountId = sAccountMgr.GetId(targetAccountName); - if(!targetAccountId) - { - PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,targetAccountName.c_str()); - SetSentErrorMessage(true); - return false; - } - } + /// only target player different from self allowed + if (GetAccountId() == targetAccountId) + return false; int32 gm = (int32)atoi(arg2); if ( gm < SEC_PLAYER || gm > SEC_ADMINISTRATOR ) @@ -970,8 +938,7 @@ bool ChatHandler::HandleAccountSetGmLevelCommand(const char* args) return false; } - // This will prevent self apply by self target or no target - if(targetPlayer && m_session->GetPlayer()!=targetPlayer) + if (targetPlayer) { ChatHandler(targetPlayer).PSendSysMessage(LANG_YOURS_SECURITY_CHANGED,GetNameLink().c_str(), gm); targetPlayer->GetSession()->SetSecurity(AccountTypes(gm)); @@ -990,29 +957,16 @@ bool ChatHandler::HandleAccountSetPasswordCommand(const char* args) return false; ///- Get the command line arguments - char *szAccount = strtok ((char*)args," "); + std::string account_name; + uint32 targetAccountId = extractAccountId((char*)args, &account_name); + if (!targetAccountId) + return false; + char *szPassword1 = strtok (NULL," "); char *szPassword2 = strtok (NULL," "); - - if (!szAccount||!szPassword1 || !szPassword2) + if (!szPassword1 || !szPassword2) return false; - std::string account_name = szAccount; - if (!AccountMgr::normalizeString(account_name)) - { - PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str()); - SetSentErrorMessage(true); - return false; - } - - uint32 targetAccountId = sAccountMgr.GetId(account_name); - if (!targetAccountId) - { - PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str()); - SetSentErrorMessage(true); - return false; - } - /// can set password only for target with less security /// This is also reject self apply in fact if(HasLowerSecurityAccount (NULL,targetAccountId,true)) @@ -5148,24 +5102,10 @@ bool ChatHandler::HandleBanInfoAccountCommand(const char* args) if (!*args) return false; - char* cname = strtok((char*)args, ""); - if (!cname) - return false; - - std::string account_name = cname; - if (!AccountMgr::normalizeString(account_name)) - { - PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str()); - SetSentErrorMessage(true); - return false; - } - - uint32 accountid = sAccountMgr.GetId(account_name); + std::string account_name; + uint32 accountid = extractAccountId((char*)args, &account_name); if (!accountid) - { - PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str()); - return true; - } + return false; return HandleBanInfoHelper(accountid,account_name.c_str()); } @@ -5508,43 +5448,22 @@ bool ChatHandler::HandlePDumpLoadCommand(const char *args) if (!*args) return false; - char * file = strtok((char*)args, " "); + char* file = strtok((char*)args, " "); if (!file) return false; - char * account = strtok(NULL, " "); + char* account = strtok(NULL, " "); if (!account) return false; - std::string account_name = account; - if (!AccountMgr::normalizeString(account_name)) - { - PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str()); - SetSentErrorMessage(true); - return false; - } + char* name_str = strtok(NULL, " "); - uint32 account_id = sAccountMgr.GetId(account_name); + std::string account_name; + uint32 account_id = extractAccountId(account, &account_name); if (!account_id) - { - account_id = atoi(account); // use original string - if (!account_id) - { - PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str()); - SetSentErrorMessage(true); - return false; - } - } - - if (!sAccountMgr.GetName(account_id,account_name)) - { - PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str()); - SetSentErrorMessage(true); return false; - } char* guid_str = NULL; - char* name_str = strtok(NULL, " "); std::string name; if (name_str) @@ -6217,49 +6136,73 @@ bool ChatHandler::HandleServerSetMotdCommand(const char* args) 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); + + if (!m_session) + { + SendSysMessage(LANG_ACCOUNT_CHARACTERS_LIST_BAR); + SendSysMessage(LANG_ACCOUNT_CHARACTERS_LIST_HEADER); + SendSysMessage(LANG_ACCOUNT_CHARACTERS_LIST_BAR); + } + + if (result) + { + ///- Circle through them. Display username and GM level + do + { + Field *fields = result->Fetch(); + uint32 guid = fields[0].GetUInt32(); + std::string name = fields[1].GetCppString(); + uint8 race = fields[2].GetUInt8(); + uint8 class_ = fields[3].GetUInt8(); + uint32 level = fields[4].GetUInt32(); + + ChrRacesEntry const* raceEntry = sChrRacesStore.LookupEntry(race); + ChrClassesEntry const* classEntry = sChrClassesStore.LookupEntry(class_); + + char const* race_name = raceEntry ? raceEntry->name[GetSessionDbcLocale()] : ""; + 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); + else + PSendSysMessage(LANG_ACCOUNT_CHARACTERS_LIST_LINE_CHAT, guid, name.c_str(), name.c_str(), race_name, class_name, level); + + }while( result->NextRow() ); + + delete result; + } + + if (!m_session) + SendSysMessage(LANG_ACCOUNT_CHARACTERS_LIST_BAR); + + return true; +} + /// Set/Unset the expansion level for an account bool ChatHandler::HandleAccountSetAddonCommand(const char* args) { ///- Get the command line arguments - char *szAcc = strtok((char*)args," "); - char *szExp = strtok(NULL," "); + char* arg1; + char* arg2; - if(!szAcc) - return false; + extractOptFirstArg((char*)args, &arg1, &arg2); std::string account_name; - uint32 account_id; - - if (!szExp) - { - Player* player = getSelectedPlayer(); - if (!player) - return false; - - account_id = player->GetSession()->GetAccountId(); - sAccountMgr.GetName(account_id,account_name); - szExp = szAcc; - } - else - { - ///- Convert Account name to Upper Format - account_name = szAcc; - if (!AccountMgr::normalizeString(account_name)) - { - PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str()); - SetSentErrorMessage(true); - return false; - } - - account_id = sAccountMgr.GetId(account_name); - if (!account_id) - { - PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str()); - SetSentErrorMessage(true); - return false; - } - - } + uint32 account_id = extractAccountId(arg1, &account_name); + if (!account_id ) + return false; // Let set addon state only for lesser (strong) security level // or to self account @@ -6267,8 +6210,8 @@ bool ChatHandler::HandleAccountSetAddonCommand(const char* args) HasLowerSecurityAccount (NULL,account_id,true)) return false; - int lev=atoi(szExp); //get int anyway (0 if error) - if(lev < 0) + int lev=atoi(arg2); //get int anyway (0 if error) + if (lev < 0) return false; // No SQL injection diff --git a/src/mangosd/CliRunnable.cpp b/src/mangosd/CliRunnable.cpp index 757a0c212..d93b3419d 100644 --- a/src/mangosd/CliRunnable.cpp +++ b/src/mangosd/CliRunnable.cpp @@ -64,26 +64,10 @@ bool ChatHandler::HandleAccountDeleteCommand(const char* args) if (!*args) return false; - ///- Get the account name from the command line - char *account_name_str=strtok ((char*)args," "); - if (!account_name_str) - return false; - - std::string account_name = account_name_str; - if (!AccountMgr::normalizeString(account_name)) - { - PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str()); - SetSentErrorMessage(true); - return false; - } - - uint32 account_id = sAccountMgr.GetId(account_name); + std::string account_name; + uint32 account_id = extractAccountId((char*)args,&account_name); if (!account_id) - { - PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str()); - SetSentErrorMessage(true); return false; - } /// Commands not recommended call from chat, but support anyway /// can delete only for account with less security diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 55ee35a02..cf3241dfe 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "9793" + #define REVISION_NR "9794" #endif // __REVISION_NR_H__ diff --git a/src/shared/revision_sql.h b/src/shared/revision_sql.h index 21f5ab1ca..682b95996 100644 --- a/src/shared/revision_sql.h +++ b/src/shared/revision_sql.h @@ -1,6 +1,6 @@ #ifndef __REVISION_SQL_H__ #define __REVISION_SQL_H__ #define REVISION_DB_CHARACTERS "required_9767_03_characters_characters" - #define REVISION_DB_MANGOS "required_9768_01_mangos_command" + #define REVISION_DB_MANGOS "required_9794_02_mangos_command" #define REVISION_DB_REALMD "required_9748_01_realmd_realmlist" #endif // __REVISION_SQL_H__