AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
character_commandscript Class Reference
Inheritance diagram for character_commandscript:
CommandScript ScriptObject

Classes

struct  DeletedInfo
 

Public Types

typedef std::list< DeletedInfoDeletedInfoList
 

Public Member Functions

 character_commandscript ()
 
ChatCommandTable GetCommands () const override
 
virtual std::vector< Acore::ChatCommands::ChatCommandBuilderGetCommands () const =0
 
- Public Member Functions inherited from ScriptObject
virtual bool IsDatabaseBound () const
 
virtual bool isAfterLoadScript () const
 
virtual void checkValidity ()
 
const std::string & GetName () const
 

Static Public Member Functions

static bool GetDeletedCharacterInfoList (DeletedInfoList &foundList, std::string searchString)
 
static void HandleCharacterDeletedListHelper (DeletedInfoList const &foundList, ChatHandler *handler)
 
static void HandleCharacterDeletedRestoreHelper (DeletedInfo const &delInfo, ChatHandler *handler)
 
static void HandleCharacterLevel (Player *player, ObjectGuid playerGuid, uint32 oldLevel, uint32 newLevel, ChatHandler *handler)
 
static bool HandleCharacterTitlesCommand (ChatHandler *handler, Optional< PlayerIdentifier > player)
 
static bool HandleCharacterRenameCommand (ChatHandler *handler, Optional< PlayerIdentifier > player, Optional< bool > reserveName, Optional< std::string_view > newNameV)
 
static bool HandleCharacterLevelCommand (ChatHandler *handler, Optional< PlayerIdentifier > player, int16 newlevel)
 
static bool HandleCharacterCustomizeCommand (ChatHandler *handler, Optional< PlayerIdentifier > player)
 
static bool HandleCharacterChangeFactionCommand (ChatHandler *handler, Optional< PlayerIdentifier > player)
 
static bool HandleCharacterChangeRaceCommand (ChatHandler *handler, Optional< PlayerIdentifier > player)
 
static bool HandleCharacterReputationCommand (ChatHandler *handler, Optional< PlayerIdentifier > player)
 
static bool HandleCharacterDeletedListCommand (ChatHandler *handler, Optional< std::string_view > needleStr)
 
static bool HandleCharacterDeletedRestoreCommand (ChatHandler *handler, std::string needle, Optional< std::string_view > newCharName, Optional< AccountIdentifier > newAccount)
 
static bool HandleCharacterDeletedDeleteCommand (ChatHandler *handler, std::string needle)
 
static bool HandleCharacterDeletedPurgeCommand (ChatHandler *, Optional< uint16 > days)
 
static bool HandleCharacterEraseCommand (ChatHandler *handler, PlayerIdentifier player)
 
static bool HandleLevelUpCommand (ChatHandler *handler, Optional< PlayerIdentifier > player, int16 level)
 
static bool ValidatePDumpTarget (ChatHandler *handler, std::string &name, Optional< std::string_view > characterName, Optional< ObjectGuid::LowType > characterGUID)
 
static bool HandlePDumpLoadCommand (ChatHandler *handler, std::string fileName, AccountIdentifier account, Optional< std::string_view > characterName, Optional< ObjectGuid::LowType > characterGUID)
 
static bool HandlePDumpCopyCommand (ChatHandler *handler, PlayerIdentifier player, AccountIdentifier account, Optional< std::string_view > characterName, Optional< ObjectGuid::LowType > characterGUID)
 
static bool HandlePDumpWriteCommand (ChatHandler *handler, std::string fileName, PlayerIdentifier player)
 
static bool HandleCharacterCheckBankCommand (ChatHandler *handler)
 
static bool HandleCharacterCheckBagCommand (ChatHandler *handler, uint8 BagSlot)
 
static bool HandleCharacterCheckProfessionCommand (ChatHandler *handler)
 
static bool HandleCharacterChangeAccountCommand (ChatHandler *handler, std::string accountName, Optional< PlayerIdentifier > player)
 

Additional Inherited Members

- Protected Member Functions inherited from CommandScript
 CommandScript (const char *name)
 
- Protected Member Functions inherited from ScriptObject
 ScriptObject (const char *name)
 
virtual ~ScriptObject ()=default
 

Detailed Description

Member Typedef Documentation

◆ DeletedInfoList

Constructor & Destructor Documentation

◆ character_commandscript()

character_commandscript::character_commandscript ( )
inline
45: CommandScript("character_commandscript") { }
Definition: ScriptMgr.h:850

Member Function Documentation

◆ GetCommands()

ChatCommandTable character_commandscript::GetCommands ( ) const
inlineoverridevirtual

Implements CommandScript.

48 {
49 static ChatCommandTable pdumpCommandTable =
50 {
51 { "load", HandlePDumpLoadCommand, SEC_ADMINISTRATOR, Console::Yes },
52 { "write", HandlePDumpWriteCommand, SEC_ADMINISTRATOR, Console::Yes }
53 };
54
55 static ChatCommandTable characterDeletedCommandTable =
56 {
57 { "delete", HandleCharacterDeletedDeleteCommand, SEC_CONSOLE, Console::Yes },
59 { "restore", HandleCharacterDeletedRestoreCommand, SEC_ADMINISTRATOR, Console::Yes },
60 { "purge", HandleCharacterDeletedPurgeCommand, SEC_CONSOLE, Console::Yes }
61 };
62
63 static ChatCommandTable characterCheckCommandTable =
64 {
65 { "bank", HandleCharacterCheckBankCommand, SEC_GAMEMASTER, Console::Yes },
66 { "bag", HandleCharacterCheckBagCommand, SEC_GAMEMASTER, Console::Yes },
67 { "profession", HandleCharacterCheckProfessionCommand, SEC_GAMEMASTER, Console::Yes }
68 };
69
70 static ChatCommandTable characterCommandTable =
71 {
72 { "customize", HandleCharacterCustomizeCommand, SEC_GAMEMASTER, Console::Yes },
73 { "changefaction", HandleCharacterChangeFactionCommand, SEC_GAMEMASTER, Console::Yes },
74 { "changerace", HandleCharacterChangeRaceCommand, SEC_GAMEMASTER, Console::Yes },
75 { "changeaccount", HandleCharacterChangeAccountCommand, SEC_ADMINISTRATOR, Console::Yes },
76 { "check", characterCheckCommandTable },
77 { "erase", HandleCharacterEraseCommand, SEC_CONSOLE, Console::Yes },
78 { "deleted", characterDeletedCommandTable },
79 { "level", HandleCharacterLevelCommand, SEC_GAMEMASTER, Console::Yes },
80 { "rename", HandleCharacterRenameCommand, SEC_GAMEMASTER, Console::Yes },
81 { "reputation", HandleCharacterReputationCommand, SEC_GAMEMASTER, Console::Yes },
82 { "titles", HandleCharacterTitlesCommand, SEC_GAMEMASTER, Console::Yes }
83 };
84
85 static ChatCommandTable commandTable =
86 {
87 { "character", characterCommandTable },
88 { "levelup", HandleLevelUpCommand, SEC_GAMEMASTER, Console::No },
89 { "pdump", pdumpCommandTable }
90 };
91
92 return commandTable;
93 }
@ SEC_ADMINISTRATOR
Definition: Common.h:69
@ SEC_GAMEMASTER
Definition: Common.h:68
@ SEC_CONSOLE
Definition: Common.h:70
std::vector< ChatCommandBuilder > ChatCommandTable
Definition: ChatCommand.h:50
static bool HandleCharacterChangeAccountCommand(ChatHandler *handler, std::string accountName, Optional< PlayerIdentifier > player)
Definition: cs_character.cpp:1073
static bool HandleCharacterDeletedListCommand(ChatHandler *handler, Optional< std::string_view > needleStr)
Definition: cs_character.cpp:596
static bool HandleCharacterCheckBankCommand(ChatHandler *handler)
Definition: cs_character.cpp:924
static bool HandlePDumpLoadCommand(ChatHandler *handler, std::string fileName, AccountIdentifier account, Optional< std::string_view > characterName, Optional< ObjectGuid::LowType > characterGUID)
Definition: cs_character.cpp:823
static bool HandleCharacterDeletedPurgeCommand(ChatHandler *, Optional< uint16 > days)
Definition: cs_character.cpp:721
static bool HandleLevelUpCommand(ChatHandler *handler, Optional< PlayerIdentifier > player, int16 level)
Definition: cs_character.cpp:764
static bool HandleCharacterRenameCommand(ChatHandler *handler, Optional< PlayerIdentifier > player, Optional< bool > reserveName, Optional< std::string_view > newNameV)
Definition: cs_character.cpp:328
static bool HandleCharacterLevelCommand(ChatHandler *handler, Optional< PlayerIdentifier > player, int16 newlevel)
Definition: cs_character.cpp:439
static bool HandleCharacterCustomizeCommand(ChatHandler *handler, Optional< PlayerIdentifier > player)
Definition: cs_character.cpp:464
static bool HandleCharacterCheckProfessionCommand(ChatHandler *handler)
Definition: cs_character.cpp:995
static bool HandleCharacterDeletedDeleteCommand(ChatHandler *handler, std::string needle)
Definition: cs_character.cpp:687
static bool HandleCharacterChangeRaceCommand(ChatHandler *handler, Optional< PlayerIdentifier > player)
Definition: cs_character.cpp:512
static bool HandleCharacterTitlesCommand(ChatHandler *handler, Optional< PlayerIdentifier > player)
Definition: cs_character.cpp:279
static bool HandlePDumpWriteCommand(ChatHandler *handler, std::string fileName, PlayerIdentifier player)
Definition: cs_character.cpp:900
static bool HandleCharacterReputationCommand(ChatHandler *handler, Optional< PlayerIdentifier > player)
Definition: cs_character.cpp:536
static bool HandleCharacterEraseCommand(ChatHandler *handler, PlayerIdentifier player)
Definition: cs_character.cpp:742
static bool HandleCharacterCheckBagCommand(ChatHandler *handler, uint8 BagSlot)
Definition: cs_character.cpp:930
static bool HandleCharacterChangeFactionCommand(ChatHandler *handler, Optional< PlayerIdentifier > player)
Definition: cs_character.cpp:488
static bool HandleCharacterDeletedRestoreCommand(ChatHandler *handler, std::string needle, Optional< std::string_view > newCharName, Optional< AccountIdentifier > newAccount)
Definition: cs_character.cpp:629

References HandleCharacterChangeAccountCommand(), HandleCharacterChangeFactionCommand(), HandleCharacterChangeRaceCommand(), HandleCharacterCheckBagCommand(), HandleCharacterCheckBankCommand(), HandleCharacterCheckProfessionCommand(), HandleCharacterCustomizeCommand(), HandleCharacterDeletedDeleteCommand(), HandleCharacterDeletedListCommand(), HandleCharacterDeletedPurgeCommand(), HandleCharacterDeletedRestoreCommand(), HandleCharacterEraseCommand(), HandleCharacterLevelCommand(), HandleCharacterRenameCommand(), HandleCharacterReputationCommand(), HandleCharacterTitlesCommand(), HandleLevelUpCommand(), HandlePDumpLoadCommand(), HandlePDumpWriteCommand(), SEC_ADMINISTRATOR, SEC_CONSOLE, and SEC_GAMEMASTER.

◆ GetDeletedCharacterInfoList()

static bool character_commandscript::GetDeletedCharacterInfoList ( DeletedInfoList foundList,
std::string  searchString 
)
inlinestatic

Collects all GUIDs (and related info) from deleted characters which are still in the database.

Parameters
foundLista reference to an std::list which will be filled with info data
searchStringthe search string which either contains a player GUID or a part fo the character-name
Returns
returns false if there was a problem while selecting the characters (e.g. player name not normalizeable)
115 {
116 PreparedQueryResult result;
118 if (!searchString.empty())
119 {
120 // search by GUID
121 if (isNumeric(searchString.c_str()))
122 {
123 stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_DEL_INFO_BY_GUID);
124 stmt->SetData(0, *Acore::StringTo<uint32>(searchString));
125 result = CharacterDatabase.Query(stmt);
126 }
127 // search by name
128 else
129 {
130 if (!normalizePlayerName(searchString))
131 return false;
132
133 stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_DEL_INFO_BY_NAME);
134 stmt->SetData(0, searchString);
135 result = CharacterDatabase.Query(stmt);
136 }
137 }
138 else
139 {
140 stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_DEL_INFO);
141 result = CharacterDatabase.Query(stmt);
142 }
143
144 if (result)
145 {
146 do
147 {
148 Field* fields = result->Fetch();
149
150 DeletedInfo info;
151
152 info.lowGuid = fields[0].Get<uint32>();
153 info.name = fields[1].Get<std::string>();
154 info.accountId = fields[2].Get<uint32>();
155
156 // account name will be empty for nonexisting account
157 AccountMgr::GetName(info.accountId, info.accountName);
158 info.deleteDate = time_t(fields[3].Get<uint32>());
159 foundList.push_back(info);
160 } while (result->NextRow());
161 }
162
163 return true;
164 }
std::uint32_t uint32
Definition: Define.h:108
bool isNumeric(wchar_t wchar)
Definition: Util.h:204
DatabaseWorkerPool< CharacterDatabaseConnection > CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
std::shared_ptr< PreparedResultSet > PreparedQueryResult
Definition: DatabaseEnvFwd.h:46
@ CHAR_SEL_CHAR_DEL_INFO_BY_NAME
Definition: CharacterDatabase.h:331
@ CHAR_SEL_CHAR_DEL_INFO
Definition: CharacterDatabase.h:332
@ CHAR_SEL_CHAR_DEL_INFO_BY_GUID
Definition: CharacterDatabase.h:330
bool normalizePlayerName(std::string &name)
Definition: ObjectMgr.cpp:264
bool GetName(uint32 accountId, std::string &name)
Definition: AccountMgr.cpp:228
Definition: PreparedStatement.h:158
Class used to access individual fields of database query result.
Definition: Field.h:99
std::enable_if_t< std::is_arithmetic_v< T >, T > Get() const
Definition: Field.h:113
Acore::Types::is_default< T > SetData(const uint8 index, T value)
Definition: PreparedStatement.h:78

References character_commandscript::DeletedInfo::accountId, character_commandscript::DeletedInfo::accountName, CHAR_SEL_CHAR_DEL_INFO, CHAR_SEL_CHAR_DEL_INFO_BY_GUID, CHAR_SEL_CHAR_DEL_INFO_BY_NAME, CharacterDatabase, character_commandscript::DeletedInfo::deleteDate, Field::Get(), AccountMgr::GetName(), isNumeric(), character_commandscript::DeletedInfo::lowGuid, character_commandscript::DeletedInfo::name, normalizePlayerName(), and PreparedStatementBase::SetData().

Referenced by HandleCharacterDeletedDeleteCommand(), HandleCharacterDeletedListCommand(), and HandleCharacterDeletedRestoreCommand().

◆ HandleCharacterChangeAccountCommand()

static bool character_commandscript::HandleCharacterChangeAccountCommand ( ChatHandler handler,
std::string  accountName,
Optional< PlayerIdentifier player 
)
inlinestatic
1074 {
1075 if (!player)
1076 {
1077 player = PlayerIdentifier::FromTargetOrSelf(handler);
1078 }
1079
1080 if (!player)
1081 {
1083 handler->SetSentErrorMessage(true);
1084 return false;
1085 }
1086
1087 if (uint32 accountId = AccountMgr::GetId(accountName))
1088 {
1089 if (AccountMgr::GetCharactersCount(accountId) >= 10)
1090 {
1091 handler->PSendSysMessage(LANG_ACCOUNT_CHARACTER_LIST_FULL, accountName, accountId);
1092 handler->SetSentErrorMessage(true);
1093 return true;
1094 }
1095
1096 if (CharacterCacheEntry const* cache = sCharacterCache->GetCharacterCacheByName(player->GetName()))
1097 {
1098 std::string accName;
1099 AccountMgr::GetName(cache->AccountId, accName);
1100 handler->PSendSysMessage(LANG_CMD_CHAR_CHANGE_ACC_SUCCESS, player->GetName(), player->GetGUID().GetCounter(), accName, cache->AccountId, accountName, accountId);
1101 }
1102
1103 if (player->IsConnected())
1104 {
1105 player->GetConnectedPlayer()->GetSession()->KickPlayer("CMD char changeaccount");
1106 }
1107
1108 CharacterDatabase.Query("UPDATE characters SET account = {} WHERE guid = {}", accountId, player->GetGUID().GetCounter());
1109 sCharacterCache->UpdateCharacterAccountId(player->GetGUID(), accountId);
1110
1111 }
1112 else
1113 {
1114 handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName);
1115 handler->SetSentErrorMessage(true);
1116 return true;
1117 }
1118
1119 return true;
1120 }
#define sCharacterCache
Definition: CharacterCache.h:83
@ LANG_ACCOUNT_CHARACTER_LIST_FULL
Definition: Language.h:875
@ LANG_PLAYER_NOT_FOUND
Definition: Language.h:522
@ LANG_ACCOUNT_NOT_EXIST
Definition: Language.h:425
@ LANG_CMD_CHAR_CHANGE_ACC_SUCCESS
Definition: Language.h:1149
uint32 GetCharactersCount(uint32 accountId)
Definition: AccountMgr.cpp:266
uint32 GetId(std::string const &username)
Definition: AccountMgr.cpp:200
Definition: CharacterCache.h:28
void SetSentErrorMessage(bool val)
Definition: Chat.h:118
void PSendSysMessage(char const *fmt, Args &&... args)
Definition: Chat.h:60
virtual void SendSysMessage(std::string_view str, bool escapeCharacters=false)
Definition: Chat.cpp:103
static Optional< PlayerIdentifier > FromTargetOrSelf(ChatHandler *handler)
Definition: ChatCommandTags.h:189

References CharacterDatabase, Acore::ChatCommands::PlayerIdentifier::FromTargetOrSelf(), AccountMgr::GetCharactersCount(), AccountMgr::GetId(), AccountMgr::GetName(), LANG_ACCOUNT_CHARACTER_LIST_FULL, LANG_ACCOUNT_NOT_EXIST, LANG_CMD_CHAR_CHANGE_ACC_SUCCESS, LANG_PLAYER_NOT_FOUND, ChatHandler::PSendSysMessage(), sCharacterCache, ChatHandler::SendSysMessage(), and ChatHandler::SetSentErrorMessage().

Referenced by GetCommands().

◆ HandleCharacterChangeFactionCommand()

static bool character_commandscript::HandleCharacterChangeFactionCommand ( ChatHandler handler,
Optional< PlayerIdentifier player 
)
inlinestatic
489 {
490 if (!player)
491 player = PlayerIdentifier::FromTarget(handler);
492 if (!player)
493 return false;
494
495 if (Player* target = player->GetConnectedPlayer())
496 {
497 handler->PSendSysMessage(LANG_CUSTOMIZE_PLAYER, handler->GetNameLink(target).c_str());
498 target->SetAtLoginFlag(AT_LOGIN_CHANGE_FACTION);
499 }
500 else
501 {
502 handler->PSendSysMessage(LANG_CUSTOMIZE_PLAYER_GUID, handler->playerLink(*player).c_str(), player->GetGUID().GetCounter());
505 stmt->SetData(1, player->GetGUID().GetCounter());
506 CharacterDatabase.Execute(stmt);
507 }
508
509 return true;
510 }
std::uint16_t uint16
Definition: Define.h:109
@ CHAR_UPD_ADD_AT_LOGIN_FLAG
Definition: CharacterDatabase.h:274
@ AT_LOGIN_CHANGE_FACTION
Definition: Player.h:607
@ LANG_CUSTOMIZE_PLAYER_GUID
Definition: Language.h:387
@ LANG_CUSTOMIZE_PLAYER
Definition: Language.h:386
virtual std::string GetNameLink() const
Definition: Chat.h:84
std::string playerLink(std::string const &name) const
Definition: Chat.h:111
static Optional< PlayerIdentifier > FromTarget(ChatHandler *handler)
Definition: ChatCommandTags.cpp:138
Definition: Player.h:1046

References AT_LOGIN_CHANGE_FACTION, CHAR_UPD_ADD_AT_LOGIN_FLAG, CharacterDatabase, Acore::ChatCommands::PlayerIdentifier::FromTarget(), ChatHandler::GetNameLink(), LANG_CUSTOMIZE_PLAYER, LANG_CUSTOMIZE_PLAYER_GUID, ChatHandler::playerLink(), ChatHandler::PSendSysMessage(), and PreparedStatementBase::SetData().

Referenced by GetCommands().

◆ HandleCharacterChangeRaceCommand()

static bool character_commandscript::HandleCharacterChangeRaceCommand ( ChatHandler handler,
Optional< PlayerIdentifier player 
)
inlinestatic
513 {
514 if (!player)
515 player = PlayerIdentifier::FromTarget(handler);
516 if (!player)
517 return false;
518
519 if (Player* target = player->GetConnectedPlayer())
520 {
521 handler->PSendSysMessage(LANG_CUSTOMIZE_PLAYER, handler->GetNameLink(target).c_str());
522 target->SetAtLoginFlag(AT_LOGIN_CHANGE_RACE);
523 }
524 else
525 {
526 handler->PSendSysMessage(LANG_CUSTOMIZE_PLAYER_GUID, handler->playerLink(*player).c_str(), player->GetGUID().GetCounter());
529 stmt->SetData(1, player->GetGUID().GetCounter());
530 CharacterDatabase.Execute(stmt);
531 }
532
533 return true;
534 }
@ AT_LOGIN_CHANGE_RACE
Definition: Player.h:608

References AT_LOGIN_CHANGE_RACE, CHAR_UPD_ADD_AT_LOGIN_FLAG, CharacterDatabase, Acore::ChatCommands::PlayerIdentifier::FromTarget(), ChatHandler::GetNameLink(), LANG_CUSTOMIZE_PLAYER, LANG_CUSTOMIZE_PLAYER_GUID, ChatHandler::playerLink(), ChatHandler::PSendSysMessage(), and PreparedStatementBase::SetData().

Referenced by GetCommands().

◆ HandleCharacterCheckBagCommand()

static bool character_commandscript::HandleCharacterCheckBagCommand ( ChatHandler handler,
uint8  BagSlot 
)
inlinestatic
931 {
932 Player* target = handler->getSelectedPlayerOrSelf();
933
934 if (!target)
935 return false;
936
937 uint8 Counter = 0;
938 switch (BagSlot)
939 {
940 case 2:
941 BagSlot = 19;
942 break;
943 case 3:
944 BagSlot = 20;
945 break;
946 case 4:
947 BagSlot = 21;
948 break;
949 case 5:
950 BagSlot = 22;
951 break;
952 default:
953 BagSlot = 1;
954 break;
955 }
956
957 handler->PSendSysMessage("--------------------------------------");
958
959 if (BagSlot == 1)
960 {
961 for (uint32 i = 23; i < 39; i++)
962 {
963 if (Item* item = target->GetItemByPos(INVENTORY_SLOT_BAG_0, i))
964 {
965 Counter++;
966 std::ostringstream ItemString;
967 ItemString << std::hex << ItemQualityColors[item->GetTemplate()->Quality];
968
969 handler->PSendSysMessage("%u - |c%s|Hitem:%u:0:0:0:0:0:0:0:0:0|h[%s]|h|r - %u", Counter, ItemString.str().c_str(), item->GetEntry(), item->GetTemplate()->Name1.c_str(), item->GetCount());
970 }
971 }
972 }
973 else
974 {
975 if (Bag* bag = target->GetBagByPos(BagSlot))
976 {
977 for (uint32 i = 0; i < bag->GetBagSize(); i++)
978 {
979 if (Item* item = target->GetItemByPos(BagSlot, i))
980 {
981 Counter++;
982 std::ostringstream ItemString;
983 ItemString << std::hex << ItemQualityColors[item->GetTemplate()->Quality];
984
985 handler->PSendSysMessage("%u - |c%s|Hitem:%u:0:0:0:0:0:0:0:0:0|h[%s]|h|r - %u", Counter, ItemString.str().c_str(), item->GetEntry(), item->GetTemplate()->Name1.c_str(), item->GetCount());
986 }
987 }
988 }
989 }
990
991 handler->PSendSysMessage("--------------------------------------");
992 return true;
993 }
std::uint8_t uint8
Definition: Define.h:110
#define INVENTORY_SLOT_BAG_0
Definition: Player.h:671
const uint32 ItemQualityColors[MAX_ITEM_QUALITY]
Definition: SharedDefines.h:325
Player * getSelectedPlayerOrSelf() const
Definition: Chat.cpp:345
Definition: Bag.h:28
Definition: Item.h:214
Bag * GetBagByPos(uint8 slot) const
Definition: PlayerStorage.cpp:488
Item * GetItemByPos(uint16 pos) const
Definition: PlayerStorage.cpp:472

References Player::GetBagByPos(), Player::GetItemByPos(), ChatHandler::getSelectedPlayerOrSelf(), INVENTORY_SLOT_BAG_0, ItemQualityColors, and ChatHandler::PSendSysMessage().

Referenced by GetCommands().

◆ HandleCharacterCheckBankCommand()

static bool character_commandscript::HandleCharacterCheckBankCommand ( ChatHandler handler)
inlinestatic
925 {
926 handler->GetSession()->SendShowBank(handler->GetSession()->GetPlayer()->GetGUID());
927 return true;
928 }
WorldSession * GetSession()
Definition: Chat.h:122
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:106
Player * GetPlayer() const
Definition: WorldSession.h:361
void SendShowBank(ObjectGuid guid)
Definition: BankHandler.cpp:191

References Object::GetGUID(), WorldSession::GetPlayer(), ChatHandler::GetSession(), and WorldSession::SendShowBank().

Referenced by GetCommands().

◆ HandleCharacterCheckProfessionCommand()

static bool character_commandscript::HandleCharacterCheckProfessionCommand ( ChatHandler handler)
inlinestatic
996 {
997 Player* player = handler->getSelectedPlayerOrSelf();
998
999 if (!player)
1000 return false;
1001
1002 uint8 Counter = 0;
1003
1004 handler->PSendSysMessage("--------------------------------------");
1005
1006 for (uint32 i = 1; i < sSkillLineStore.GetNumRows(); ++i)
1007 {
1008 SkillLineEntry const* SkillInfo = sSkillLineStore.LookupEntry(i);
1009
1010 if (!SkillInfo)
1011 continue;
1012
1013 if ((SkillInfo->categoryId != SKILL_CATEGORY_PROFESSION) && !SkillInfo->canLink)
1014 continue;
1015
1016 uint32 SkillID = SkillInfo->id;
1017
1018 if (player->HasSkill(SkillID))
1019 {
1020 Counter++;
1021
1022 switch (SkillID)
1023 {
1024 case SKILL_ALCHEMY:
1025 handler->PSendSysMessage("%u - Alchemy - %u", Counter, player->GetSkillValue(SkillID));
1026 break;
1028 handler->PSendSysMessage("%u - Blacksmithing - %u", Counter, player->GetSkillValue(SkillID));
1029 break;
1030 case SKILL_ENCHANTING:
1031 handler->PSendSysMessage("%u - Enchanting - %u", Counter, player->GetSkillValue(SkillID));
1032 break;
1033 case SKILL_ENGINEERING:
1034 handler->PSendSysMessage("%u - Engineering - %u", Counter, player->GetSkillValue(SkillID));
1035 break;
1036 case SKILL_INSCRIPTION:
1037 handler->PSendSysMessage("%u - Inscription - %u", Counter, player->GetSkillValue(SkillID));
1038 break;
1040 handler->PSendSysMessage("%u - Jewelcrafting - %u", Counter, player->GetSkillValue(SkillID));
1041 break;
1043 handler->PSendSysMessage("%u - Leatherworking - %u", Counter, player->GetSkillValue(SkillID));
1044 break;
1045 case SKILL_TAILORING:
1046 handler->PSendSysMessage("%u - Tailoring - %u", Counter, player->GetSkillValue(SkillID));
1047 break;
1048 case SKILL_SKINNING:
1049 handler->PSendSysMessage("%u - Skinning - %u", Counter, player->GetSkillValue(SkillID));
1050 break;
1051 case SKILL_HERBALISM:
1052 handler->PSendSysMessage("%u - Herbalism - %u", Counter, player->GetSkillValue(SkillID));
1053 break;
1054 case SKILL_MINING:
1055 handler->PSendSysMessage("%u - Mining - %u", Counter, player->GetSkillValue(SkillID));
1056 break;
1057 case SKILL_COOKING:
1058 handler->PSendSysMessage("%u - Cooking - %u", Counter, player->GetSkillValue(SkillID));
1059 break;
1060 case SKILL_FIRST_AID:
1061 handler->PSendSysMessage("%u - First Aid - %u", Counter, player->GetSkillValue(SkillID));
1062 break;
1063 default:
1064 break;
1065 }
1066 }
1067 }
1068
1069 handler->PSendSysMessage("--------------------------------------");
1070 return true;
1071 }
DBCStorage< SkillLineEntry > sSkillLineStore(SkillLinefmt)
@ SKILL_CATEGORY_PROFESSION
Definition: SharedDefines.h:3050
@ SKILL_INSCRIPTION
Definition: SharedDefines.h:2974
@ SKILL_COOKING
Definition: SharedDefines.h:2890
@ SKILL_BLACKSMITHING
Definition: SharedDefines.h:2881
@ SKILL_LEATHERWORKING
Definition: SharedDefines.h:2882
@ SKILL_TAILORING
Definition: SharedDefines.h:2894
@ SKILL_MINING
Definition: SharedDefines.h:2891
@ SKILL_ENGINEERING
Definition: SharedDefines.h:2895
@ SKILL_FIRST_AID
Definition: SharedDefines.h:2864
@ SKILL_SKINNING
Definition: SharedDefines.h:2933
@ SKILL_ALCHEMY
Definition: SharedDefines.h:2883
@ SKILL_ENCHANTING
Definition: SharedDefines.h:2926
@ SKILL_JEWELCRAFTING
Definition: SharedDefines.h:2957
@ SKILL_HERBALISM
Definition: SharedDefines.h:2887
uint16 GetSkillValue(uint32 skill) const
Definition: Player.cpp:5354
bool HasSkill(uint32 skill) const
Definition: Player.cpp:5333
Definition: DBCStructure.h:1556
uint32 id
Definition: DBCStructure.h:1557
int32 categoryId
Definition: DBCStructure.h:1558
uint32 canLink
Definition: DBCStructure.h:1567

References SkillLineEntry::canLink, SkillLineEntry::categoryId, ChatHandler::getSelectedPlayerOrSelf(), Player::GetSkillValue(), Player::HasSkill(), SkillLineEntry::id, ChatHandler::PSendSysMessage(), SKILL_ALCHEMY, SKILL_BLACKSMITHING, SKILL_CATEGORY_PROFESSION, SKILL_COOKING, SKILL_ENCHANTING, SKILL_ENGINEERING, SKILL_FIRST_AID, SKILL_HERBALISM, SKILL_INSCRIPTION, SKILL_JEWELCRAFTING, SKILL_LEATHERWORKING, SKILL_MINING, SKILL_SKINNING, SKILL_TAILORING, and sSkillLineStore.

Referenced by GetCommands().

◆ HandleCharacterCustomizeCommand()

static bool character_commandscript::HandleCharacterCustomizeCommand ( ChatHandler handler,
Optional< PlayerIdentifier player 
)
inlinestatic
465 {
466 if (!player)
467 player = PlayerIdentifier::FromTarget(handler);
468 if (!player)
469 return false;
470
471 if (Player* target = player->GetConnectedPlayer())
472 {
473 handler->PSendSysMessage(LANG_CUSTOMIZE_PLAYER, handler->GetNameLink(target).c_str());
474 target->SetAtLoginFlag(AT_LOGIN_CUSTOMIZE);
475 }
476 else
477 {
478 handler->PSendSysMessage(LANG_CUSTOMIZE_PLAYER_GUID, handler->playerLink(*player).c_str(), player->GetGUID().GetCounter());
480 stmt->SetData(0, static_cast<uint16>(AT_LOGIN_CUSTOMIZE));
481 stmt->SetData(1, player->GetGUID().GetCounter());
482 CharacterDatabase.Execute(stmt);
483 }
484
485 return true;
486 }
@ AT_LOGIN_CUSTOMIZE
Definition: Player.h:604

References AT_LOGIN_CUSTOMIZE, CHAR_UPD_ADD_AT_LOGIN_FLAG, CharacterDatabase, Acore::ChatCommands::PlayerIdentifier::FromTarget(), ChatHandler::GetNameLink(), LANG_CUSTOMIZE_PLAYER, LANG_CUSTOMIZE_PLAYER_GUID, ChatHandler::playerLink(), ChatHandler::PSendSysMessage(), and PreparedStatementBase::SetData().

Referenced by GetCommands().

◆ HandleCharacterDeletedDeleteCommand()

static bool character_commandscript::HandleCharacterDeletedDeleteCommand ( ChatHandler handler,
std::string  needle 
)
inlinestatic

Handles the '.character deleted delete' command, which completely deletes all deleted characters which matches the given search string

See also
Player::GetDeletedCharacterGUIDs
Player::DeleteFromDB
HandleCharacterDeletedListCommand
HandleCharacterDeletedRestoreCommand
Parameters
argsthe search string which either contains a player GUID or a part fo the character-name
688 {
689 DeletedInfoList foundList;
690 if (!GetDeletedCharacterInfoList(foundList, needle))
691 return false;
692
693 if (foundList.empty())
694 {
696 handler->SetSentErrorMessage(true);
697 return false;
698 }
699
701 HandleCharacterDeletedListHelper(foundList, handler);
702
703 // Call the appropriate function to delete them (current account for deleted characters is 0)
704 for (DeletedInfoList::const_iterator itr = foundList.begin(); itr != foundList.end(); ++itr)
705 Player::DeleteFromDB(itr->lowGuid, 0, false, true);
706
707 return true;
708 }
@ LANG_CHARACTER_DELETED_LIST_EMPTY
Definition: Language.h:847
@ LANG_CHARACTER_DELETED_DELETE
Definition: Language.h:849
static void DeleteFromDB(ObjectGuid::LowType lowGuid, uint32 accountId, bool updateRealmChars, bool deleteFinally)
Definition: Player.cpp:3914
static bool GetDeletedCharacterInfoList(DeletedInfoList &foundList, std::string searchString)
Definition: cs_character.cpp:114
static void HandleCharacterDeletedListHelper(DeletedInfoList const &foundList, ChatHandler *handler)
Definition: cs_character.cpp:176
std::list< DeletedInfo > DeletedInfoList
Definition: cs_character.cpp:105

References Player::DeleteFromDB(), GetDeletedCharacterInfoList(), HandleCharacterDeletedListHelper(), LANG_CHARACTER_DELETED_DELETE, LANG_CHARACTER_DELETED_LIST_EMPTY, ChatHandler::SendSysMessage(), and ChatHandler::SetSentErrorMessage().

Referenced by GetCommands().

◆ HandleCharacterDeletedListCommand()

static bool character_commandscript::HandleCharacterDeletedListCommand ( ChatHandler handler,
Optional< std::string_view >  needleStr 
)
inlinestatic

Handles the '.character deleted list' command, which shows all deleted characters which matches the given search string

See also
HandleCharacterDeletedListHelper
HandleCharacterDeletedRestoreCommand
HandleCharacterDeletedDeleteCommand
DeletedInfoList
Parameters
argsthe search string which either contains a player GUID or a part fo the character-name
597 {
598 std::string needle;
599 if (needleStr)
600 needle.assign(*needleStr);
601 DeletedInfoList foundList;
602 if (!GetDeletedCharacterInfoList(foundList, needle))
603 return false;
604
605 // if no characters have been found, output a warning
606 if (foundList.empty())
607 {
609 handler->SetSentErrorMessage(true);
610 return false;
611 }
612
613 HandleCharacterDeletedListHelper(foundList, handler);
614
615 return true;
616 }

References GetDeletedCharacterInfoList(), HandleCharacterDeletedListHelper(), LANG_CHARACTER_DELETED_LIST_EMPTY, ChatHandler::SendSysMessage(), and ChatHandler::SetSentErrorMessage().

Referenced by GetCommands().

◆ HandleCharacterDeletedListHelper()

static void character_commandscript::HandleCharacterDeletedListHelper ( DeletedInfoList const &  foundList,
ChatHandler handler 
)
inlinestatic

Shows all deleted characters which matches the given search string, expected non empty list

See also
HandleCharacterDeletedListCommand
HandleCharacterDeletedRestoreCommand
HandleCharacterDeletedDeleteCommand
DeletedInfoList
Parameters
foundListcontains a list with all found deleted characters
177 {
178 if (!handler->GetSession())
179 {
183 }
184
185 for (DeletedInfoList::const_iterator itr = foundList.begin(); itr != foundList.end(); ++itr)
186 {
187 std::string dateStr = Acore::Time::TimeToTimestampStr(Seconds(itr->deleteDate));
188
189 if (!handler->GetSession())
191 itr->lowGuid, itr->name.c_str(), itr->accountName.empty() ? "<Not existing>" : itr->accountName.c_str(),
192 itr->accountId, dateStr.c_str());
193 else
195 itr->lowGuid, itr->name.c_str(), itr->accountName.empty() ? "<Not existing>" : itr->accountName.c_str(),
196 itr->accountId, dateStr.c_str());
197 }
198
199 if (!handler->GetSession())
201 }
std::chrono::seconds Seconds
Seconds shorthand typedef.
Definition: Duration.h:30
@ LANG_CHARACTER_DELETED_LIST_LINE_CHAT
Definition: Language.h:854
@ LANG_CHARACTER_DELETED_LIST_HEADER
Definition: Language.h:844
@ LANG_CHARACTER_DELETED_LIST_LINE_CONSOLE
Definition: Language.h:845
@ LANG_CHARACTER_DELETED_LIST_BAR
Definition: Language.h:846
AC_COMMON_API std::string TimeToTimestampStr(Seconds time=0s, std::string_view fmt={})
Definition: Timer.cpp:272

References ChatHandler::GetSession(), LANG_CHARACTER_DELETED_LIST_BAR, LANG_CHARACTER_DELETED_LIST_HEADER, LANG_CHARACTER_DELETED_LIST_LINE_CHAT, LANG_CHARACTER_DELETED_LIST_LINE_CONSOLE, ChatHandler::PSendSysMessage(), ChatHandler::SendSysMessage(), and Acore::Time::TimeToTimestampStr().

Referenced by HandleCharacterDeletedDeleteCommand(), HandleCharacterDeletedListCommand(), and HandleCharacterDeletedRestoreCommand().

◆ HandleCharacterDeletedPurgeCommand()

static bool character_commandscript::HandleCharacterDeletedPurgeCommand ( ChatHandler ,
Optional< uint16 days 
)
inlinestatic

Handles the '.character deleted old' command, which completely deletes all deleted characters deleted with some days ago

See also
Player::DeleteOldCharacters
Player::DeleteFromDB
HandleCharacterDeletedDeleteCommand
HandleCharacterDeletedListCommand
HandleCharacterDeletedRestoreCommand
Parameters
argsthe search string which either contains a player GUID or a part of the character-name
722 {
723 int32 keepDays = static_cast<int32>(sWorld->getIntConfig(CONFIG_CHARDELETE_KEEP_DAYS));
724
725 if (days)
726 keepDays = static_cast<int32>(*days);
727 else if (keepDays <= 0) // config option value 0 -> disabled and can't be used
728 return false;
729
730 Player::DeleteOldCharacters(static_cast<uint32>(keepDays));
731
732 return true;
733 }
std::int32_t int32
Definition: Define.h:104
@ CONFIG_CHARDELETE_KEEP_DAYS
Definition: IWorld.h:348
#define sWorld
Definition: World.h:451
static void DeleteOldCharacters()
Definition: Player.cpp:4264

References CONFIG_CHARDELETE_KEEP_DAYS, Player::DeleteOldCharacters(), and sWorld.

Referenced by GetCommands().

◆ HandleCharacterDeletedRestoreCommand()

static bool character_commandscript::HandleCharacterDeletedRestoreCommand ( ChatHandler handler,
std::string  needle,
Optional< std::string_view >  newCharName,
Optional< AccountIdentifier newAccount 
)
inlinestatic

Handles the '.character deleted restore' command, which restores all deleted characters which matches the given search string

The command automatically calls '.character deleted list' command with the search string to show all restored characters.

See also
HandleCharacterDeletedRestoreHelper
HandleCharacterDeletedListCommand
HandleCharacterDeletedDeleteCommand
Parameters
argsthe search string which either contains a player GUID or a part of the character-name
630 {
631 DeletedInfoList foundList;
632 if (!GetDeletedCharacterInfoList(foundList, needle))
633 return false;
634
635 if (foundList.empty())
636 {
638 handler->SetSentErrorMessage(true);
639 return false;
640 }
641
643 HandleCharacterDeletedListHelper(foundList, handler);
644
645 if (!newCharName)
646 {
647 // Drop nonexisting account cases
648 for (DeletedInfoList::iterator itr = foundList.begin(); itr != foundList.end(); ++itr)
650 return true;
651 }
652
653 if (foundList.size() == 1)
654 {
655 std::string newName{ *newCharName };
656 DeletedInfo delInfo = foundList.front();
657
658 // update name
659 delInfo.name = newName;
660
661 // if new account provided update deleted info
662 if (newAccount)
663 {
664 delInfo.accountId = newAccount->GetID();
665 delInfo.accountName = newAccount->GetName();
666 }
667
668 HandleCharacterDeletedRestoreHelper(delInfo, handler);
669 return true;
670 }
671
673 handler->SetSentErrorMessage(true);
674 return false;
675 }
@ LANG_CHARACTER_DELETED_ERR_RENAME
Definition: Language.h:850
@ LANG_CHARACTER_DELETED_RESTORE
Definition: Language.h:848
static void HandleCharacterDeletedRestoreHelper(DeletedInfo const &delInfo, ChatHandler *handler)
Definition: cs_character.cpp:213

References character_commandscript::DeletedInfo::accountId, character_commandscript::DeletedInfo::accountName, GetDeletedCharacterInfoList(), HandleCharacterDeletedListHelper(), HandleCharacterDeletedRestoreHelper(), LANG_CHARACTER_DELETED_ERR_RENAME, LANG_CHARACTER_DELETED_LIST_EMPTY, LANG_CHARACTER_DELETED_RESTORE, character_commandscript::DeletedInfo::name, ChatHandler::SendSysMessage(), and ChatHandler::SetSentErrorMessage().

Referenced by GetCommands().

◆ HandleCharacterDeletedRestoreHelper()

static void character_commandscript::HandleCharacterDeletedRestoreHelper ( DeletedInfo const &  delInfo,
ChatHandler handler 
)
inlinestatic

Restore a previously deleted character

See also
HandleCharacterDeletedListHelper
HandleCharacterDeletedRestoreCommand
HandleCharacterDeletedDeleteCommand
DeletedInfoList
Parameters
delInfothe informations about the character which will be restored
214 {
215 if (delInfo.accountName.empty()) // account does not exist
216 {
217 handler->PSendSysMessage(LANG_CHARACTER_DELETED_SKIP_ACCOUNT, delInfo.name.c_str(), delInfo.lowGuid, delInfo.accountId);
218 return;
219 }
220
221 // check character count
222 uint32 charcount = AccountMgr::GetCharactersCount(delInfo.accountId);
223 if (charcount >= 10)
224 {
225 handler->PSendSysMessage(LANG_CHARACTER_DELETED_SKIP_FULL, delInfo.name.c_str(), delInfo.lowGuid, delInfo.accountId);
226 return;
227 }
228
229 if (sCharacterCache->GetCharacterGuidByName(delInfo.name))
230 {
231 handler->PSendSysMessage(LANG_CHARACTER_DELETED_SKIP_NAME, delInfo.name.c_str(), delInfo.lowGuid, delInfo.accountId);
232 return;
233 }
234
235 auto* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UDP_RESTORE_DELETE_INFO);
236 stmt->SetData(0, delInfo.name);
237 stmt->SetData(1, delInfo.accountId);
238 stmt->SetData(2, delInfo.lowGuid);
239 CharacterDatabase.Execute(stmt);
240
241 stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHARACTER_NAME_DATA);
242 stmt->SetData(0, delInfo.lowGuid);
243 if (PreparedQueryResult result = CharacterDatabase.Query(stmt))
244 {
245 sCharacterCache->AddCharacterCacheEntry(ObjectGuid(HighGuid::Player, delInfo.lowGuid), delInfo.accountId, delInfo.name, (*result)[2].Get<uint8>(), (*result)[0].Get<uint8>(), (*result)[1].Get<uint8>(), (*result)[3].Get<uint8>());
246 }
247 }
@ CHAR_UDP_RESTORE_DELETE_INFO
Definition: CharacterDatabase.h:293
@ CHAR_SEL_CHARACTER_NAME_DATA
Definition: CharacterDatabase.h:52
@ LANG_CHARACTER_DELETED_SKIP_NAME
Definition: Language.h:853
@ LANG_CHARACTER_DELETED_SKIP_FULL
Definition: Language.h:852
@ LANG_CHARACTER_DELETED_SKIP_ACCOUNT
Definition: Language.h:851
Definition: ObjectGuid.h:120

References character_commandscript::DeletedInfo::accountId, character_commandscript::DeletedInfo::accountName, CHAR_SEL_CHARACTER_NAME_DATA, CHAR_UDP_RESTORE_DELETE_INFO, CharacterDatabase, AccountMgr::GetCharactersCount(), LANG_CHARACTER_DELETED_SKIP_ACCOUNT, LANG_CHARACTER_DELETED_SKIP_FULL, LANG_CHARACTER_DELETED_SKIP_NAME, character_commandscript::DeletedInfo::lowGuid, character_commandscript::DeletedInfo::name, ChatHandler::PSendSysMessage(), and sCharacterCache.

Referenced by HandleCharacterDeletedRestoreCommand().

◆ HandleCharacterEraseCommand()

static bool character_commandscript::HandleCharacterEraseCommand ( ChatHandler handler,
PlayerIdentifier  player 
)
inlinestatic

Handles the '.character erase' command which completly delete a character from the DB

See also
Player::DeleteFromDB
Parameters
argsthe search string which either contains a player GUID or a part of the character-name
743 {
744 uint32 accountId;
745 if (Player* target = player.GetConnectedPlayer())
746 {
747 accountId = target->GetSession()->GetAccountId();
748 target->GetSession()->KickPlayer("HandleCharacterEraseCommand GM Command deleting character");
749 }
750 else
751 {
752 accountId = sCharacterCache->GetCharacterAccountIdByGuid(player.GetGUID());
753 }
754
755 std::string accountName;
756 AccountMgr::GetName(accountId, accountName);
757
758 Player::DeleteFromDB(player.GetGUID().GetCounter(), accountId, true, true);
759 handler->PSendSysMessage(LANG_CHARACTER_DELETED, player.GetName().c_str(), player.GetGUID().GetCounter(), accountName.c_str(), accountId);
760
761 return true;
762 }
@ LANG_CHARACTER_DELETED
Definition: Language.h:837
ObjectGuid GetGUID() const
Definition: ChatCommandTags.h:181
std::string const & GetName() const
Definition: ChatCommandTags.h:180
Player * GetConnectedPlayer() const
Definition: ChatCommandTags.h:183
LowType GetCounter() const
Definition: ObjectGuid.h:147

References Player::DeleteFromDB(), Acore::ChatCommands::PlayerIdentifier::GetConnectedPlayer(), ObjectGuid::GetCounter(), Acore::ChatCommands::PlayerIdentifier::GetGUID(), Acore::ChatCommands::PlayerIdentifier::GetName(), AccountMgr::GetName(), LANG_CHARACTER_DELETED, ChatHandler::PSendSysMessage(), and sCharacterCache.

Referenced by GetCommands().

◆ HandleCharacterLevel()

static void character_commandscript::HandleCharacterLevel ( Player player,
ObjectGuid  playerGuid,
uint32  oldLevel,
uint32  newLevel,
ChatHandler handler 
)
inlinestatic
250 {
251 if (player)
252 {
253 player->GiveLevel(newLevel);
254 player->InitTalentForLevel();
255 player->SetUInt32Value(PLAYER_XP, 0);
256
257 if (handler->needReportToTarget(player))
258 {
259 if (oldLevel == newLevel)
261 else if (oldLevel < newLevel)
262 ChatHandler(player->GetSession()).PSendSysMessage(LANG_YOURS_LEVEL_UP, handler->GetNameLink().c_str(), newLevel);
263 else // if (oldlevel > newlevel)
264 ChatHandler(player->GetSession()).PSendSysMessage(LANG_YOURS_LEVEL_DOWN, handler->GetNameLink().c_str(), newLevel);
265 }
266 }
267 else
268 {
269 // Update level and reset XP, everything else will be updated at login
270 auto* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_LEVEL);
271 stmt->SetData(0, uint8(newLevel));
272 stmt->SetData(1, playerGuid.GetCounter());
273 CharacterDatabase.Execute(stmt);
274
275 sCharacterCache->UpdateCharacterLevel(playerGuid, newLevel);
276 }
277 }
@ CHAR_UPD_LEVEL
Definition: CharacterDatabase.h:295
@ PLAYER_XP
Definition: UpdateFields.h:339
@ LANG_YOURS_LEVEL_UP
Definition: Language.h:596
@ LANG_YOURS_LEVEL_PROGRESS_RESET
Definition: Language.h:598
@ LANG_YOURS_LEVEL_DOWN
Definition: Language.h:597
Definition: Chat.h:38
virtual bool needReportToTarget(Player *chr) const
Definition: Chat.cpp:776
void SetUInt32Value(uint16 index, uint32 value)
Definition: Object.cpp:650
void InitTalentForLevel()
Definition: Player.cpp:2520
void GiveLevel(uint8 level)
Definition: Player.cpp:2418
WorldSession * GetSession() const
Definition: Player.h:1948

References CHAR_UPD_LEVEL, CharacterDatabase, ObjectGuid::GetCounter(), ChatHandler::GetNameLink(), Player::GetSession(), Player::GiveLevel(), Player::InitTalentForLevel(), LANG_YOURS_LEVEL_DOWN, LANG_YOURS_LEVEL_PROGRESS_RESET, LANG_YOURS_LEVEL_UP, ChatHandler::needReportToTarget(), PLAYER_XP, ChatHandler::PSendSysMessage(), sCharacterCache, and Object::SetUInt32Value().

Referenced by HandleCharacterLevelCommand(), and HandleLevelUpCommand().

◆ HandleCharacterLevelCommand()

static bool character_commandscript::HandleCharacterLevelCommand ( ChatHandler handler,
Optional< PlayerIdentifier player,
int16  newlevel 
)
inlinestatic
440 {
441 if (!player)
442 player = PlayerIdentifier::FromTargetOrSelf(handler);
443
444 if (!player)
445 return false;
446
447 uint8 oldlevel = player->IsConnected() ? player->GetConnectedPlayer()->GetLevel() : sCharacterCache->GetCharacterLevelByGuid(player->GetGUID());
448
449 if (newlevel < 1)
450 return false; // invalid level
451
452 if (newlevel > DEFAULT_MAX_LEVEL) // hardcoded maximum level
453 newlevel = DEFAULT_MAX_LEVEL;
454
455 HandleCharacterLevel(player->GetConnectedPlayer(), player->GetGUID(), oldlevel, newlevel, handler);
456
457 if (!handler->GetSession() || (handler->GetSession()->GetPlayer() != player->GetConnectedPlayer())) // including chr == NULL
458 handler->PSendSysMessage(LANG_YOU_CHANGE_LVL, handler->playerLink(*player).c_str(), newlevel);
459
460 return true;
461 }
@ LANG_YOU_CHANGE_LVL
Definition: Language.h:161
#define DEFAULT_MAX_LEVEL
Definition: DBCEnums.h:41
static void HandleCharacterLevel(Player *player, ObjectGuid playerGuid, uint32 oldLevel, uint32 newLevel, ChatHandler *handler)
Definition: cs_character.cpp:249

References DEFAULT_MAX_LEVEL, Acore::ChatCommands::PlayerIdentifier::FromTargetOrSelf(), WorldSession::GetPlayer(), ChatHandler::GetSession(), HandleCharacterLevel(), LANG_YOU_CHANGE_LVL, ChatHandler::playerLink(), ChatHandler::PSendSysMessage(), and sCharacterCache.

Referenced by GetCommands().

◆ HandleCharacterRenameCommand()

static bool character_commandscript::HandleCharacterRenameCommand ( ChatHandler handler,
Optional< PlayerIdentifier player,
Optional< bool >  reserveName,
Optional< std::string_view >  newNameV 
)
inlinestatic
329 {
330 if (!player && newNameV)
331 return false;
332
333 if (!player)
334 player = PlayerIdentifier::FromTarget(handler);
335
336 if (!player)
337 return false;
338
339 if (handler->HasLowerSecurity(nullptr, player->GetGUID()))
340 return false;
341
342 if (newNameV)
343 {
344 std::string newName{ *newNameV };
345 if (!normalizePlayerName(newName))
346 {
348 handler->SetSentErrorMessage(true);
349 return false;
350 }
351
352 if (ObjectMgr::CheckPlayerName(newName, true) != CHAR_NAME_SUCCESS)
353 {
355 handler->SetSentErrorMessage(true);
356 return false;
357 }
358
359 if (sObjectMgr->IsReservedName(newName))
360 {
362 handler->SetSentErrorMessage(true);
363 return false;
364 }
365
366 if (sObjectMgr->IsProfanityName(newName))
367 {
369 handler->SetSentErrorMessage(true);
370 return false;
371 }
372
374 stmt->SetData(0, newName);
375 PreparedQueryResult result = CharacterDatabase.Query(stmt);
376 if (result)
377 {
378 handler->PSendSysMessage(LANG_RENAME_PLAYER_ALREADY_EXISTS, newName.c_str());
379 handler->SetSentErrorMessage(true);
380 return false;
381 }
382
383 // Remove declined name from db
384 stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_DECLINED_NAME);
385 stmt->SetData(0, player->GetGUID().GetCounter());
386 CharacterDatabase.Execute(stmt);
387
388 if (Player* target = player->GetConnectedPlayer())
389 {
390 target->SetName(newName);
391
392 ObjectAccessor::UpdatePlayerNameMapReference(player->GetName(), target);
393
394 if (WorldSession* session = target->GetSession())
395 session->KickPlayer("HandleCharacterRenameCommand GM Command renaming character");
396 }
397 else
398 {
399 stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_NAME_BY_GUID);
400 stmt->SetData(0, newName);
401 stmt->SetData(1, player->GetGUID().GetCounter());
402 CharacterDatabase.Execute(stmt);
403 }
404
405 sCharacterCache->UpdateCharacterData(player->GetGUID(), newName);
406
407 handler->PSendSysMessage(LANG_RENAME_PLAYER_WITH_NEW_NAME, player->GetName().c_str(), newName.c_str());
408 }
409 else
410 {
411 if (Player* target = player->GetConnectedPlayer())
412 {
413 handler->PSendSysMessage(LANG_RENAME_PLAYER, handler->GetNameLink(target).c_str());
414 target->SetAtLoginFlag(AT_LOGIN_RENAME);
415 }
416 else
417 {
418 // check offline security
419 if (handler->HasLowerSecurity(nullptr, player->GetGUID()))
420 return false;
421
422 handler->PSendSysMessage(LANG_RENAME_PLAYER_GUID, handler->playerLink(*player).c_str(), player->GetGUID().GetCounter());
423
425 stmt->SetData(0, uint16(AT_LOGIN_RENAME));
426 stmt->SetData(1, player->GetGUID().GetCounter());
427 CharacterDatabase.Execute(stmt);
428 }
429 }
430
431 if (reserveName)
432 {
433 sObjectMgr->AddReservedPlayerName(player->GetName());
434 }
435
436 return true;
437 }
@ CHAR_SEL_CHECK_NAME
Definition: CharacterDatabase.h:37
@ CHAR_DEL_DECLINED_NAME
Definition: CharacterDatabase.h:138
@ CHAR_UPD_NAME_BY_GUID
Definition: CharacterDatabase.h:137
@ AT_LOGIN_RENAME
Definition: Player.h:601
#define sObjectMgr
Definition: ObjectMgr.h:1640
@ LANG_RENAME_PLAYER
Definition: Language.h:295
@ LANG_RENAME_PLAYER_WITH_NEW_NAME
Definition: Language.h:129
@ LANG_PROFANITY_NAME
Definition: Language.h:221
@ LANG_BAD_VALUE
Definition: Language.h:147
@ LANG_RESERVED_NAME
Definition: Language.h:206
@ LANG_RENAME_PLAYER_ALREADY_EXISTS
Definition: Language.h:128
@ LANG_RENAME_PLAYER_GUID
Definition: Language.h:296
@ CHAR_NAME_SUCCESS
Definition: SharedDefines.h:3391
void UpdatePlayerNameMapReference(std::string oldname, Player *player)
Definition: ObjectAccessor.cpp:351
bool HasLowerSecurity(Player *target, ObjectGuid guid=ObjectGuid::Empty, bool strong=false)
Definition: Chat.cpp:53
static uint8 CheckPlayerName(std::string_view name, bool create=false)
Definition: ObjectMgr.cpp:8355
Player session in the World.
Definition: WorldSession.h:330

References AT_LOGIN_RENAME, CHAR_DEL_DECLINED_NAME, CHAR_NAME_SUCCESS, CHAR_SEL_CHECK_NAME, CHAR_UPD_ADD_AT_LOGIN_FLAG, CHAR_UPD_NAME_BY_GUID, CharacterDatabase, ObjectMgr::CheckPlayerName(), Acore::ChatCommands::PlayerIdentifier::FromTarget(), ChatHandler::GetNameLink(), ChatHandler::HasLowerSecurity(), LANG_BAD_VALUE, LANG_PROFANITY_NAME, LANG_RENAME_PLAYER, LANG_RENAME_PLAYER_ALREADY_EXISTS, LANG_RENAME_PLAYER_GUID, LANG_RENAME_PLAYER_WITH_NEW_NAME, LANG_RESERVED_NAME, normalizePlayerName(), ChatHandler::playerLink(), ChatHandler::PSendSysMessage(), sCharacterCache, ChatHandler::SendSysMessage(), PreparedStatementBase::SetData(), ChatHandler::SetSentErrorMessage(), sObjectMgr, and ObjectAccessor::UpdatePlayerNameMapReference().

Referenced by GetCommands().

◆ HandleCharacterReputationCommand()

static bool character_commandscript::HandleCharacterReputationCommand ( ChatHandler handler,
Optional< PlayerIdentifier player 
)
inlinestatic
537 {
538 if (!player)
539 player = PlayerIdentifier::FromTargetOrSelf(handler);
540 if (!player || !player->IsConnected())
541 {
543 handler->SetSentErrorMessage(true);
544 return false;
545 }
546
547 Player const* target = player->GetConnectedPlayer();
548 LocaleConstant loc = handler->GetSessionDbcLocale();
549
550 FactionStateList const& targetFSL = target->GetReputationMgr().GetStateList();
551 for (FactionStateList::const_iterator itr = targetFSL.begin(); itr != targetFSL.end(); ++itr)
552 {
553 FactionState const& faction = itr->second;
554 FactionEntry const* factionEntry = sFactionStore.LookupEntry(faction.ID);
555 char const* factionName = factionEntry ? factionEntry->name[loc] : "#Not found#";
556 ReputationRank rank = target->GetReputationMgr().GetRank(factionEntry);
557 std::string rankName = handler->GetAcoreString(ReputationRankStrIndex[rank]);
558 std::ostringstream ss;
559 if (handler->GetSession())
560 ss << faction.ID << " - |cffffffff|Hfaction:" << faction.ID << "|h[" << factionName << ' ' << localeNames[loc] << "]|h|r";
561 else
562 ss << faction.ID << " - " << factionName << ' ' << localeNames[loc];
563
564 ss << ' ' << rankName << " (" << target->GetReputationMgr().GetReputation(factionEntry) << ')';
565
566 if (faction.Flags & FACTION_FLAG_VISIBLE)
567 ss << handler->GetAcoreString(LANG_FACTION_VISIBLE);
568 if (faction.Flags & FACTION_FLAG_AT_WAR)
569 ss << handler->GetAcoreString(LANG_FACTION_ATWAR);
570 if (faction.Flags & FACTION_FLAG_PEACE_FORCED)
572 if (faction.Flags & FACTION_FLAG_HIDDEN)
573 ss << handler->GetAcoreString(LANG_FACTION_HIDDEN);
576 if (faction.Flags & FACTION_FLAG_INACTIVE)
578
579 handler->SendSysMessage(ss.str().c_str());
580 }
581
582 return true;
583 }
char const * localeNames[TOTAL_LOCALES]
Definition: Common.cpp:20
LocaleConstant
Definition: Common.h:74
DBCStorage< FactionEntry > sFactionStore(FactionEntryfmt)
@ LANG_FACTION_PEACE_FORCED
Definition: Language.h:355
@ LANG_FACTION_ATWAR
Definition: Language.h:354
@ LANG_FACTION_INVISIBLE_FORCED
Definition: Language.h:357
@ LANG_FACTION_HIDDEN
Definition: Language.h:356
@ LANG_FACTION_INACTIVE
Definition: Language.h:358
@ LANG_FACTION_VISIBLE
Definition: Language.h:353
constexpr std::array< uint32, MAX_REPUTATION_RANK > ReputationRankStrIndex
Definition: ReputationMgr.h:28
std::map< RepListID, FactionState > FactionStateList
Definition: ReputationMgr.h:52
@ FACTION_FLAG_INACTIVE
Definition: DBCEnums.h:317
@ FACTION_FLAG_PEACE_FORCED
Definition: DBCEnums.h:316
@ FACTION_FLAG_INVISIBLE_FORCED
Definition: DBCEnums.h:315
@ FACTION_FLAG_HIDDEN
Definition: DBCEnums.h:314
@ FACTION_FLAG_VISIBLE
Definition: DBCEnums.h:312
@ FACTION_FLAG_AT_WAR
Definition: DBCEnums.h:313
ReputationRank
Definition: SharedDefines.h:151
virtual LocaleConstant GetSessionDbcLocale() const
Definition: Chat.cpp:782
virtual char const * GetAcoreString(uint32 entry) const
Definition: Chat.cpp:42
ReputationMgr & GetReputationMgr()
Definition: Player.h:2076
Definition: ReputationMgr.h:42
uint32 ID
Definition: ReputationMgr.h:43
uint8 Flags
Definition: ReputationMgr.h:46
FactionStateList const & GetStateList() const
Definition: ReputationMgr.h:80
int32 GetReputation(uint32 faction_id) const
Definition: ReputationMgr.cpp:78
ReputationRank GetRank(FactionEntry const *factionEntry) const
Definition: ReputationMgr.cpp:125
Definition: DBCStructure.h:898
char const * name[16]
Definition: DBCStructure.h:910

References FACTION_FLAG_AT_WAR, FACTION_FLAG_HIDDEN, FACTION_FLAG_INACTIVE, FACTION_FLAG_INVISIBLE_FORCED, FACTION_FLAG_PEACE_FORCED, FACTION_FLAG_VISIBLE, FactionState::Flags, Acore::ChatCommands::PlayerIdentifier::FromTargetOrSelf(), ChatHandler::GetAcoreString(), ReputationMgr::GetRank(), ReputationMgr::GetReputation(), Player::GetReputationMgr(), ChatHandler::GetSession(), ChatHandler::GetSessionDbcLocale(), ReputationMgr::GetStateList(), FactionState::ID, LANG_FACTION_ATWAR, LANG_FACTION_HIDDEN, LANG_FACTION_INACTIVE, LANG_FACTION_INVISIBLE_FORCED, LANG_FACTION_PEACE_FORCED, LANG_FACTION_VISIBLE, LANG_PLAYER_NOT_FOUND, localeNames, FactionEntry::name, ReputationRankStrIndex, ChatHandler::SendSysMessage(), ChatHandler::SetSentErrorMessage(), and sFactionStore.

Referenced by GetCommands().

◆ HandleCharacterTitlesCommand()

static bool character_commandscript::HandleCharacterTitlesCommand ( ChatHandler handler,
Optional< PlayerIdentifier player 
)
inlinestatic
280 {
281 if (!player)
282 player = PlayerIdentifier::FromTargetOrSelf(handler);
283
284 if (!player || !player->IsConnected())
285 {
287 handler->SetSentErrorMessage(true);
288 return false;
289 }
290
291 Player const* target = player->GetConnectedPlayer();
292
293 LocaleConstant loc = handler->GetSessionDbcLocale();
294 char const* knownStr = handler->GetAcoreString(LANG_KNOWN);
295
296 // Search in CharTitles.dbc
297 for (uint32 id = 0; id < sCharTitlesStore.GetNumRows(); id++)
298 {
299 CharTitlesEntry const* titleInfo = sCharTitlesStore.LookupEntry(id);
300
301 if (titleInfo && target->HasTitle(titleInfo))
302 {
303 char const* name = target->getGender() == GENDER_MALE ? titleInfo->nameMale[loc] : titleInfo->nameFemale[loc];
304 if (!*name)
305 name = (target->getGender() == GENDER_MALE ? titleInfo->nameMale[sWorld->GetDefaultDbcLocale()] : titleInfo->nameFemale[sWorld->GetDefaultDbcLocale()]);
306
307 if (!*name)
308 continue;
309
310 char const* activeStr = "";
311 if (target->GetUInt32Value(PLAYER_CHOSEN_TITLE) == titleInfo->bit_index)
312 activeStr = handler->GetAcoreString(LANG_ACTIVE);
313
314 std::string titleName = Acore::StringFormat(name, player->GetName().c_str());
315
316 // send title in "id (idx:idx) - [namedlink locale]" format
317 if (handler->GetSession())
318 handler->PSendSysMessage(LANG_TITLE_LIST_CHAT, id, titleInfo->bit_index, id, titleName.c_str(), localeNames[loc], knownStr, activeStr);
319 else
320 handler->PSendSysMessage(LANG_TITLE_LIST_CONSOLE, id, titleInfo->bit_index, name, localeNames[loc], knownStr, activeStr);
321 }
322 }
323
324 return true;
325 }
DBCStorage< CharTitlesEntry > sCharTitlesStore(CharTitlesEntryfmt)
@ PLAYER_CHOSEN_TITLE
Definition: UpdateFields.h:324
@ LANG_KNOWN
Definition: Language.h:63
@ LANG_TITLE_LIST_CHAT
Definition: Language.h:390
@ LANG_ACTIVE
Definition: Language.h:67
@ LANG_TITLE_LIST_CONSOLE
Definition: Language.h:391
@ GENDER_MALE
Definition: SharedDefines.h:60
std::string StringFormat(Format &&fmt, Args &&... args)
Default AC string format function.
Definition: StringFormat.h:29
uint32 GetUInt32Value(uint16 index) const
Definition: Object.cpp:305
bool HasTitle(uint32 bitIndex) const
Definition: Player.cpp:13218
uint8 getGender() const
Definition: Unit.h:1428
Definition: DBCStructure.h:632
uint32 bit_index
Definition: DBCStructure.h:639
char const * nameMale[16]
Definition: DBCStructure.h:635
char const * nameFemale[16]
Definition: DBCStructure.h:637

References CharTitlesEntry::bit_index, Acore::ChatCommands::PlayerIdentifier::FromTargetOrSelf(), GENDER_MALE, ChatHandler::GetAcoreString(), Unit::getGender(), ChatHandler::GetSession(), ChatHandler::GetSessionDbcLocale(), Object::GetUInt32Value(), Player::HasTitle(), LANG_ACTIVE, LANG_KNOWN, LANG_PLAYER_NOT_FOUND, LANG_TITLE_LIST_CHAT, LANG_TITLE_LIST_CONSOLE, localeNames, CharTitlesEntry::nameFemale, CharTitlesEntry::nameMale, PLAYER_CHOSEN_TITLE, ChatHandler::PSendSysMessage(), sCharTitlesStore, ChatHandler::SendSysMessage(), ChatHandler::SetSentErrorMessage(), Acore::StringFormat(), and sWorld.

Referenced by GetCommands().

◆ HandleLevelUpCommand()

static bool character_commandscript::HandleLevelUpCommand ( ChatHandler handler,
Optional< PlayerIdentifier player,
int16  level 
)
inlinestatic
765 {
766 if (!player)
767 player = PlayerIdentifier::FromTargetOrSelf(handler);
768
769 if (!player)
770 return false;
771
772 uint8 oldlevel = player->IsConnected() ? player->GetConnectedPlayer()->GetLevel() : sCharacterCache->GetCharacterLevelByGuid(player->GetGUID());
773 int16 newlevel = static_cast<int16>(oldlevel) + level;
774
775 if (newlevel < 1)
776 newlevel = 1;
777
778 if (newlevel > STRONG_MAX_LEVEL) // hardcoded maximum level
779 newlevel = STRONG_MAX_LEVEL;
780
781 HandleCharacterLevel(player->GetConnectedPlayer(), player->GetGUID(), oldlevel, newlevel, handler);
782
783 if (!handler->GetSession() || (handler->GetSession()->GetPlayer() != player->GetConnectedPlayer())) // including chr == NULL
784 handler->PSendSysMessage(LANG_YOU_CHANGE_LVL, handler->playerLink(*player).c_str(), newlevel);
785
786 return true;
787 }
std::int16_t int16
Definition: Define.h:105
#define STRONG_MAX_LEVEL
Definition: DBCEnums.h:49

References Acore::ChatCommands::PlayerIdentifier::FromTargetOrSelf(), WorldSession::GetPlayer(), ChatHandler::GetSession(), HandleCharacterLevel(), LANG_YOU_CHANGE_LVL, ChatHandler::playerLink(), ChatHandler::PSendSysMessage(), sCharacterCache, and STRONG_MAX_LEVEL.

Referenced by GetCommands().

◆ HandlePDumpCopyCommand()

static bool character_commandscript::HandlePDumpCopyCommand ( ChatHandler handler,
PlayerIdentifier  player,
AccountIdentifier  account,
Optional< std::string_view >  characterName,
Optional< ObjectGuid::LowType characterGUID 
)
inlinestatic
856 {
857 std::string name;
858 if (!ValidatePDumpTarget(handler, name, characterName, characterGUID))
859 return false;
860
861 std::string dump;
862 switch (PlayerDumpWriter().WriteDumpToString(dump, player.GetGUID().GetCounter()))
863 {
864 case DUMP_SUCCESS:
865 break;
868 handler->SetSentErrorMessage(true);
869 return false;
870 case DUMP_FILE_OPEN_ERROR: // this error code should not happen
871 default:
873 handler->SetSentErrorMessage(true);
874 return false;
875 }
876
877 switch (PlayerDumpReader().LoadDumpFromString(dump, account, name, characterGUID.value_or(0)))
878 {
879 case DUMP_SUCCESS:
880 break;
882 handler->PSendSysMessage(LANG_ACCOUNT_CHARACTER_LIST_FULL, account.GetName().c_str(), account.GetID());
883 handler->SetSentErrorMessage(true);
884 return false;
885 case DUMP_FILE_OPEN_ERROR: // this error code should not happen
886 case DUMP_FILE_BROKEN: // this error code should not happen
887 default:
889 handler->SetSentErrorMessage(true);
890 return false;
891 }
892
893 // Original TC Notes from Refactor vvv
894 //ToDo: use a new trinity_string for this commands
896
897 return true;
898 }
@ LANG_COMMAND_EXPORT_DELETED_CHAR
Definition: Language.h:892
@ LANG_COMMAND_IMPORT_FAILED
Definition: Language.h:499
@ LANG_COMMAND_EXPORT_FAILED
Definition: Language.h:501
@ LANG_COMMAND_IMPORT_SUCCESS
Definition: Language.h:498
@ DUMP_FILE_OPEN_ERROR
Definition: PlayerDump.h:58
@ DUMP_CHARACTER_DELETED
Definition: PlayerDump.h:61
@ DUMP_SUCCESS
Definition: PlayerDump.h:57
@ DUMP_TOO_MANY_CHARS
Definition: PlayerDump.h:59
@ DUMP_FILE_BROKEN
Definition: PlayerDump.h:60
uint32 GetID() const
Definition: ChatCommandTags.h:159
std::string const & GetName() const
Definition: ChatCommandTags.h:160
Definition: PlayerDump.h:78
Definition: PlayerDump.h:98
static bool ValidatePDumpTarget(ChatHandler *handler, std::string &name, Optional< std::string_view > characterName, Optional< ObjectGuid::LowType > characterGUID)
Definition: cs_character.cpp:789

References DUMP_CHARACTER_DELETED, DUMP_FILE_BROKEN, DUMP_FILE_OPEN_ERROR, DUMP_SUCCESS, DUMP_TOO_MANY_CHARS, ObjectGuid::GetCounter(), Acore::ChatCommands::PlayerIdentifier::GetGUID(), Acore::ChatCommands::AccountIdentifier::GetID(), Acore::ChatCommands::AccountIdentifier::GetName(), LANG_ACCOUNT_CHARACTER_LIST_FULL, LANG_COMMAND_EXPORT_DELETED_CHAR, LANG_COMMAND_EXPORT_FAILED, LANG_COMMAND_IMPORT_FAILED, LANG_COMMAND_IMPORT_SUCCESS, ChatHandler::PSendSysMessage(), ChatHandler::SetSentErrorMessage(), and ValidatePDumpTarget().

◆ HandlePDumpLoadCommand()

static bool character_commandscript::HandlePDumpLoadCommand ( ChatHandler handler,
std::string  fileName,
AccountIdentifier  account,
Optional< std::string_view >  characterName,
Optional< ObjectGuid::LowType characterGUID 
)
inlinestatic
824 {
825 std::string name;
826 if (!ValidatePDumpTarget(handler, name, characterName, characterGUID))
827 return false;
828
829 switch (PlayerDumpReader().LoadDumpFromFile(fileName, account, name, characterGUID.value_or(0)))
830 {
831 case DUMP_SUCCESS:
833 break;
835 handler->PSendSysMessage(LANG_FILE_OPEN_FAIL, fileName.c_str());
836 handler->SetSentErrorMessage(true);
837 return false;
838 case DUMP_FILE_BROKEN:
839 handler->PSendSysMessage(LANG_DUMP_BROKEN, fileName.c_str());
840 handler->SetSentErrorMessage(true);
841 return false;
843 handler->PSendSysMessage(LANG_ACCOUNT_CHARACTER_LIST_FULL, account.GetName().c_str(), account.GetID());
844 handler->SetSentErrorMessage(true);
845 return false;
846 default:
848 handler->SetSentErrorMessage(true);
849 return false;
850 }
851
852 return true;
853 }
@ LANG_DUMP_BROKEN
Definition: Language.h:876
@ LANG_FILE_OPEN_FAIL
Definition: Language.h:874

References DUMP_FILE_BROKEN, DUMP_FILE_OPEN_ERROR, DUMP_SUCCESS, DUMP_TOO_MANY_CHARS, Acore::ChatCommands::AccountIdentifier::GetID(), Acore::ChatCommands::AccountIdentifier::GetName(), LANG_ACCOUNT_CHARACTER_LIST_FULL, LANG_COMMAND_IMPORT_FAILED, LANG_COMMAND_IMPORT_SUCCESS, LANG_DUMP_BROKEN, LANG_FILE_OPEN_FAIL, ChatHandler::PSendSysMessage(), ChatHandler::SetSentErrorMessage(), and ValidatePDumpTarget().

Referenced by GetCommands().

◆ HandlePDumpWriteCommand()

static bool character_commandscript::HandlePDumpWriteCommand ( ChatHandler handler,
std::string  fileName,
PlayerIdentifier  player 
)
inlinestatic
901 {
902 switch (PlayerDumpWriter().WriteDumpToFile(fileName, player.GetGUID().GetCounter()))
903 {
904 case DUMP_SUCCESS:
906 break;
908 handler->PSendSysMessage(LANG_FILE_OPEN_FAIL, fileName.c_str());
909 handler->SetSentErrorMessage(true);
910 return false;
913 handler->SetSentErrorMessage(true);
914 return false;
915 default:
917 handler->SetSentErrorMessage(true);
918 return false;
919 }
920
921 return true;
922 }
@ LANG_COMMAND_EXPORT_SUCCESS
Definition: Language.h:500

References DUMP_CHARACTER_DELETED, DUMP_FILE_OPEN_ERROR, DUMP_SUCCESS, ObjectGuid::GetCounter(), Acore::ChatCommands::PlayerIdentifier::GetGUID(), LANG_COMMAND_EXPORT_DELETED_CHAR, LANG_COMMAND_EXPORT_FAILED, LANG_COMMAND_EXPORT_SUCCESS, LANG_FILE_OPEN_FAIL, ChatHandler::PSendSysMessage(), and ChatHandler::SetSentErrorMessage().

Referenced by GetCommands().

◆ ValidatePDumpTarget()

static bool character_commandscript::ValidatePDumpTarget ( ChatHandler handler,
std::string &  name,
Optional< std::string_view >  characterName,
Optional< ObjectGuid::LowType characterGUID 
)
inlinestatic
790 {
791 if (characterName)
792 {
793 name.assign(*characterName);
794 // normalize the name if specified and check if it exists
795 if (!normalizePlayerName(name))
796 {
798 handler->SetSentErrorMessage(true);
799 return false;
800 }
801
803 {
805 handler->SetSentErrorMessage(true);
806 return false;
807 }
808 }
809
810 if (characterGUID)
811 {
812 if (sCharacterCache->GetCharacterAccountIdByGuid(ObjectGuid(HighGuid::Player, *characterGUID)))
813 {
814 handler->PSendSysMessage(LANG_CHARACTER_GUID_IN_USE, *characterGUID);
815 handler->SetSentErrorMessage(true);
816 return false;
817 }
818 }
819
820 return true;
821 }
@ LANG_CHARACTER_GUID_IN_USE
Definition: Language.h:879
@ LANG_INVALID_CHARACTER_NAME
Definition: Language.h:877

References CHAR_NAME_SUCCESS, ObjectMgr::CheckPlayerName(), LANG_CHARACTER_GUID_IN_USE, LANG_INVALID_CHARACTER_NAME, normalizePlayerName(), ChatHandler::PSendSysMessage(), sCharacterCache, and ChatHandler::SetSentErrorMessage().

Referenced by HandlePDumpCopyCommand(), and HandlePDumpLoadCommand().