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
 
- Public Member Functions inherited from ScriptObject
virtual bool IsDatabaseBound () const
 
virtual bool isAfterLoadScript () const
 
virtual void checkValidity ()
 
const std::string & GetName () const
 
uint16 GetTotalAvailableHooks ()
 

Static Public Member Functions

static bool GetDeletedCharacterInfoList (DeletedInfoList &foundList, std::string searchString, bool limitResults=false)
 
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)
 

Static Public Attributes

static constexpr std::size_t MAX_DELETED_CHAR_RESULTS = 50
 

Additional Inherited Members

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

Detailed Description

Member Typedef Documentation

◆ DeletedInfoList

Constructor & Destructor Documentation

◆ character_commandscript()

character_commandscript::character_commandscript ( )
inline
39: CommandScript("character_commandscript") { }
Definition CommandScript.h:25

Member Function Documentation

◆ GetCommands()

ChatCommandTable character_commandscript::GetCommands ( ) const
inlineoverridevirtual

Implements CommandScript.

42 {
43 static ChatCommandTable pdumpCommandTable =
44 {
48 };
49
50 static ChatCommandTable characterDeletedCommandTable =
51 {
56 };
57
58 static ChatCommandTable characterCheckCommandTable =
59 {
63 };
64
65 static ChatCommandTable characterCommandTable =
66 {
71 { "check", characterCheckCommandTable },
73 { "deleted", characterDeletedCommandTable },
78 };
79
80 static ChatCommandTable commandTable =
81 {
82 { "character", characterCommandTable },
83 { "levelup", HandleLevelUpCommand, rbac::RBAC_PERM_COMMAND_LEVELUP, Console::No },
84 { "pdump", pdumpCommandTable }
85 };
86
87 return commandTable;
88 }
static bool HandleCharacterChangeAccountCommand(ChatHandler *handler, std::string accountName, Optional< PlayerIdentifier > player)
Definition cs_character.cpp:1061
static bool HandleCharacterDeletedListCommand(ChatHandler *handler, Optional< std::string_view > needleStr)
Definition cs_character.cpp:595
static bool HandleCharacterCheckBankCommand(ChatHandler *handler)
Definition cs_character.cpp:912
static bool HandlePDumpLoadCommand(ChatHandler *handler, std::string fileName, AccountIdentifier account, Optional< std::string_view > characterName, Optional< ObjectGuid::LowType > characterGUID)
Definition cs_character.cpp:822
static bool HandleCharacterDeletedPurgeCommand(ChatHandler *, Optional< uint16 > days)
Definition cs_character.cpp:723
static bool HandleLevelUpCommand(ChatHandler *handler, Optional< PlayerIdentifier > player, int16 level)
Definition cs_character.cpp:766
static bool HandleCharacterRenameCommand(ChatHandler *handler, Optional< PlayerIdentifier > player, Optional< bool > reserveName, Optional< std::string_view > newNameV)
Definition cs_character.cpp:332
static bool HandleCharacterLevelCommand(ChatHandler *handler, Optional< PlayerIdentifier > player, int16 newlevel)
Definition cs_character.cpp:439
static bool HandlePDumpCopyCommand(ChatHandler *handler, PlayerIdentifier player, AccountIdentifier account, Optional< std::string_view > characterName, Optional< ObjectGuid::LowType > characterGUID)
Definition cs_character.cpp:850
static bool HandleCharacterCustomizeCommand(ChatHandler *handler, Optional< PlayerIdentifier > player)
Definition cs_character.cpp:464
static bool HandleCharacterCheckProfessionCommand(ChatHandler *handler)
Definition cs_character.cpp:983
static bool HandleCharacterDeletedDeleteCommand(ChatHandler *handler, std::string needle)
Definition cs_character.cpp:690
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:284
static bool HandlePDumpWriteCommand(ChatHandler *handler, std::string fileName, PlayerIdentifier player)
Definition cs_character.cpp:891
static bool HandleCharacterReputationCommand(ChatHandler *handler, Optional< PlayerIdentifier > player)
Definition cs_character.cpp:536
static bool HandleCharacterEraseCommand(ChatHandler *handler, PlayerIdentifier player)
Definition cs_character.cpp:744
static bool HandleCharacterCheckBagCommand(ChatHandler *handler, uint8 BagSlot)
Definition cs_character.cpp:918
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:634
std::vector< ChatCommandBuilder > ChatCommandTable
Definition ChatCommand.h:46
@ RBAC_PERM_COMMAND_CHARACTER_CHANGERACE
Definition RBAC.h:172
@ RBAC_PERM_COMMAND_CHARACTER_CHECK_PROFESSION
Definition RBAC.h:675
@ RBAC_PERM_COMMAND_PDUMP_COPY
Definition RBAC.h:646
@ RBAC_PERM_COMMAND_CHARACTER_DELETED_OLD
Definition RBAC.h:176
@ RBAC_PERM_COMMAND_LEVELUP
Definition RBAC.h:182
@ RBAC_PERM_COMMAND_CHARACTER_LEVEL
Definition RBAC.h:178
@ RBAC_PERM_COMMAND_CHARACTER_DELETED_DELETE
Definition RBAC.h:173
@ RBAC_PERM_COMMAND_CHARACTER_CHANGEFACTION
Definition RBAC.h:171
@ RBAC_PERM_COMMAND_CHARACTER_TITLES
Definition RBAC.h:181
@ RBAC_PERM_COMMAND_CHARACTER_CUSTOMIZE
Definition RBAC.h:170
@ RBAC_PERM_COMMAND_CHARACTER_CHANGEACCOUNT
Definition RBAC.h:527
@ RBAC_PERM_COMMAND_CHARACTER_RENAME
Definition RBAC.h:179
@ RBAC_PERM_COMMAND_CHARACTER_ERASE
Definition RBAC.h:177
@ RBAC_PERM_COMMAND_CHARACTER_CHECK_BAG
Definition RBAC.h:674
@ RBAC_PERM_COMMAND_PDUMP_LOAD
Definition RBAC.h:183
@ RBAC_PERM_COMMAND_CHARACTER_REPUTATION
Definition RBAC.h:180
@ RBAC_PERM_COMMAND_CHARACTER_DELETED_LIST
Definition RBAC.h:174
@ RBAC_PERM_COMMAND_CHARACTER_DELETED_RESTORE
Definition RBAC.h:175
@ RBAC_PERM_COMMAND_PDUMP_WRITE
Definition RBAC.h:184
@ RBAC_PERM_COMMAND_CHARACTER_CHECK_BANK
Definition RBAC.h:673

References HandleCharacterChangeAccountCommand(), HandleCharacterChangeFactionCommand(), HandleCharacterChangeRaceCommand(), HandleCharacterCheckBagCommand(), HandleCharacterCheckBankCommand(), HandleCharacterCheckProfessionCommand(), HandleCharacterCustomizeCommand(), HandleCharacterDeletedDeleteCommand(), HandleCharacterDeletedListCommand(), HandleCharacterDeletedPurgeCommand(), HandleCharacterDeletedRestoreCommand(), HandleCharacterEraseCommand(), HandleCharacterLevelCommand(), HandleCharacterRenameCommand(), HandleCharacterReputationCommand(), HandleCharacterTitlesCommand(), HandleLevelUpCommand(), HandlePDumpCopyCommand(), HandlePDumpLoadCommand(), HandlePDumpWriteCommand(), rbac::RBAC_PERM_COMMAND_CHARACTER_CHANGEACCOUNT, rbac::RBAC_PERM_COMMAND_CHARACTER_CHANGEFACTION, rbac::RBAC_PERM_COMMAND_CHARACTER_CHANGERACE, rbac::RBAC_PERM_COMMAND_CHARACTER_CHECK_BAG, rbac::RBAC_PERM_COMMAND_CHARACTER_CHECK_BANK, rbac::RBAC_PERM_COMMAND_CHARACTER_CHECK_PROFESSION, rbac::RBAC_PERM_COMMAND_CHARACTER_CUSTOMIZE, rbac::RBAC_PERM_COMMAND_CHARACTER_DELETED_DELETE, rbac::RBAC_PERM_COMMAND_CHARACTER_DELETED_LIST, rbac::RBAC_PERM_COMMAND_CHARACTER_DELETED_OLD, rbac::RBAC_PERM_COMMAND_CHARACTER_DELETED_RESTORE, rbac::RBAC_PERM_COMMAND_CHARACTER_ERASE, rbac::RBAC_PERM_COMMAND_CHARACTER_LEVEL, rbac::RBAC_PERM_COMMAND_CHARACTER_RENAME, rbac::RBAC_PERM_COMMAND_CHARACTER_REPUTATION, rbac::RBAC_PERM_COMMAND_CHARACTER_TITLES, rbac::RBAC_PERM_COMMAND_LEVELUP, rbac::RBAC_PERM_COMMAND_PDUMP_COPY, rbac::RBAC_PERM_COMMAND_PDUMP_LOAD, and rbac::RBAC_PERM_COMMAND_PDUMP_WRITE.

◆ GetDeletedCharacterInfoList()

static bool character_commandscript::GetDeletedCharacterInfoList ( DeletedInfoList foundList,
std::string  searchString,
bool  limitResults = false 
)
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 of the character-name
limitResultsif true, caps results at MAX_DELETED_CHAR_RESULTS + 1 using a DB-level LIMIT
Returns
returns false if there was a problem while selecting the characters (e.g. player name not normalizeable)
114 {
115 PreparedQueryResult result;
117 if (!searchString.empty())
118 {
119 // search by GUID
120 if (isNumeric(searchString.c_str()))
121 {
122 stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_DEL_INFO_BY_GUID);
123 stmt->SetData(0, *Acore::StringTo<uint32>(searchString));
124 result = CharacterDatabase.Query(stmt);
125 }
126 // search by name
127 else
128 {
129 if (!normalizePlayerName(searchString))
130 return false;
131
133 stmt = CharacterDatabase.GetPreparedStatement(nameStmt);
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 info.level = fields[4].Get<uint8>();
160 foundList.push_back(info);
161 } while (result->NextRow());
162 }
163
164 return true;
165 }
CharacterDatabaseStatements
Definition CharacterDatabase.h:24
@ CHAR_SEL_CHAR_DEL_INFO_BY_NAME
Definition CharacterDatabase.h:334
@ CHAR_SEL_CHAR_DEL_INFO
Definition CharacterDatabase.h:336
@ CHAR_SEL_CHAR_DEL_INFO_BY_GUID
Definition CharacterDatabase.h:333
@ CHAR_SEL_CHAR_DEL_INFO_BY_NAME_LIMIT
Definition CharacterDatabase.h:335
std::shared_ptr< PreparedResultSet > PreparedQueryResult
Definition DatabaseEnvFwd.h:45
DatabaseWorkerPool< CharacterDatabaseConnection > CharacterDatabase
Accessor to the character database.
Definition DatabaseEnv.cpp:21
std::uint8_t uint8
Definition Define.h:109
std::uint32_t uint32
Definition Define.h:107
bool normalizePlayerName(std::string &name)
Definition ObjectMgr.cpp:209
bool isNumeric(wchar_t wchar)
Definition Util.h:195
static bool GetName(uint32 accountId, std::string &name)
Definition AccountMgr.cpp:276
Class used to access individual fields of database query result.
Definition Field.h:98
std::enable_if_t< std::is_arithmetic_v< T >, T > Get() const
Definition Field.h:112
Acore::Types::is_default< T > SetData(const uint8 index, T value)
Definition PreparedStatement.h:77
Definition PreparedStatement.h:157

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, CHAR_SEL_CHAR_DEL_INFO_BY_NAME_LIMIT, CharacterDatabase, character_commandscript::DeletedInfo::deleteDate, Field::Get(), AccountMgr::GetName(), isNumeric(), character_commandscript::DeletedInfo::level, 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
1062 {
1063 if (!player)
1064 {
1065 player = PlayerIdentifier::FromTargetOrSelf(handler);
1066 }
1067
1068 if (!player)
1069 {
1071 return false;
1072 }
1073
1074 if (uint32 accountId = AccountMgr::GetId(accountName))
1075 {
1076 if (AccountMgr::GetCharactersCount(accountId) >= 10)
1077 {
1078 handler->SendErrorMessage(LANG_ACCOUNT_CHARACTER_LIST_FULL, accountName, accountId);
1079 return true;
1080 }
1081
1082 if (CharacterCacheEntry const* cache = sCharacterCache->GetCharacterCacheByName(player->GetName()))
1083 {
1084 std::string accName;
1085 AccountMgr::GetName(cache->AccountId, accName);
1086 handler->PSendSysMessage(LANG_CMD_CHAR_CHANGE_ACC_SUCCESS, player->GetName(), player->GetGUID().ToString(), accName, cache->AccountId, accountName, accountId);
1087 }
1088
1089 if (player->IsConnected())
1090 {
1091 player->GetConnectedPlayer()->GetSession()->KickPlayer("CMD char changeaccount");
1092 }
1093
1094 CharacterDatabase.Query("UPDATE characters SET account = {} WHERE guid = {}", accountId, player->GetGUID().GetCounter());
1095 sCharacterCache->UpdateCharacterAccountId(player->GetGUID(), accountId);
1096
1097 }
1098 else
1099 {
1100 handler->SendErrorMessage(LANG_ACCOUNT_NOT_EXIST, accountName);
1101 return true;
1102 }
1103
1104 return true;
1105 }
#define sCharacterCache
Definition CharacterCache.h:83
@ LANG_ACCOUNT_CHARACTER_LIST_FULL
Definition Language.h:914
@ LANG_PLAYER_NOT_FOUND
Definition Language.h:548
@ LANG_ACCOUNT_NOT_EXIST
Definition Language.h:451
@ LANG_CMD_CHAR_CHANGE_ACC_SUCCESS
Definition Language.h:1157
static uint32 GetCharactersCount(uint32 accountId)
Definition AccountMgr.cpp:314
static uint32 GetId(std::string const &username)
Definition AccountMgr.cpp:248
void PSendSysMessage(std::string_view str, bool escapeCharacters=false)
Definition Chat.cpp:219
void SendErrorMessage(uint32 entry)
Definition Chat.cpp:224
static Optional< PlayerIdentifier > FromTargetOrSelf(ChatHandler *handler)
Definition ChatCommandTags.h:189
Definition CharacterCache.h:28

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, and ChatHandler::SendErrorMessage().

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));
498 target->SetAtLoginFlag(AT_LOGIN_CHANGE_FACTION);
499 }
500 else
501 {
502 handler->PSendSysMessage(LANG_CUSTOMIZE_PLAYER_GUID, handler->playerLink(*player), player->GetGUID().ToString());
505 stmt->SetData(1, player->GetGUID().GetCounter());
506 CharacterDatabase.Execute(stmt);
507 }
508
509 return true;
510 }
@ CHAR_UPD_ADD_AT_LOGIN_FLAG
Definition CharacterDatabase.h:276
std::uint16_t uint16
Definition Define.h:108
@ LANG_CUSTOMIZE_PLAYER_GUID
Definition Language.h:396
@ LANG_CUSTOMIZE_PLAYER
Definition Language.h:395
@ AT_LOGIN_CHANGE_FACTION
Definition Player.h:592
virtual std::string GetNameLink() const
Definition Chat.h:198
std::string playerLink(std::string const &name) const
Definition Chat.h:231
Definition Player.h:1084
static Optional< PlayerIdentifier > FromTarget(ChatHandler *handler)
Definition ChatCommandTags.cpp:138

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));
522 target->SetAtLoginFlag(AT_LOGIN_CHANGE_RACE);
523 }
524 else
525 {
526 handler->PSendSysMessage(LANG_CUSTOMIZE_PLAYER_GUID, handler->playerLink(*player), player->GetGUID().ToString());
529 stmt->SetData(1, player->GetGUID().GetCounter());
530 CharacterDatabase.Execute(stmt);
531 }
532
533 return true;
534 }
@ AT_LOGIN_CHANGE_RACE
Definition Player.h:593

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
919 {
920 Player* target = handler->getSelectedPlayerOrSelf();
921
922 if (!target)
923 return false;
924
925 uint8 Counter = 0;
926 switch (BagSlot)
927 {
928 case 2:
929 BagSlot = 19;
930 break;
931 case 3:
932 BagSlot = 20;
933 break;
934 case 4:
935 BagSlot = 21;
936 break;
937 case 5:
938 BagSlot = 22;
939 break;
940 default:
941 BagSlot = 1;
942 break;
943 }
944
945 handler->PSendSysMessage("--------------------------------------");
946
947 if (BagSlot == 1)
948 {
949 for (uint32 i = 23; i < 39; i++)
950 {
951 if (Item* item = target->GetItemByPos(INVENTORY_SLOT_BAG_0, i))
952 {
953 Counter++;
954 std::ostringstream ItemString;
955 ItemString << std::hex << ItemQualityColors[item->GetTemplate()->Quality];
956
957 handler->PSendSysMessage("{} - |c{}|Hitem:{}:0:0:0:0:0:0:0:0:0|h[{}]|h|r - {}", Counter, ItemString.str(), item->GetEntry(), item->GetTemplate()->Name1, item->GetCount());
958 }
959 }
960 }
961 else
962 {
963 if (Bag* bag = target->GetBagByPos(BagSlot))
964 {
965 for (uint32 i = 0; i < bag->GetBagSize(); i++)
966 {
967 if (Item* item = target->GetItemByPos(BagSlot, i))
968 {
969 Counter++;
970 std::ostringstream ItemString;
971 ItemString << std::hex << ItemQualityColors[item->GetTemplate()->Quality];
972
973 handler->PSendSysMessage("{} - |c{}|Hitem:{}:0:0:0:0:0:0:0:0:0|h[{}]|h|r - {}", Counter, ItemString.str(), item->GetEntry(), item->GetTemplate()->Name1, item->GetCount());
974 }
975 }
976 }
977 }
978
979 handler->PSendSysMessage("--------------------------------------");
980 return true;
981 }
#define INVENTORY_SLOT_BAG_0
Definition Player.h:656
const uint32 ItemQualityColors[MAX_ITEM_QUALITY]
Definition SharedDefines.h:341
Definition Bag.h:28
Player * getSelectedPlayerOrSelf() const
Definition Chat.cpp:426
Definition Item.h:220
Bag * GetBagByPos(uint8 slot) const
Definition PlayerStorage.cpp:460
Item * GetItemByPos(uint16 pos) const
Definition PlayerStorage.cpp:444

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
913 {
914 handler->GetSession()->SendShowBank(handler->GetSession()->GetPlayer()->GetGUID());
915 return true;
916 }
WorldSession * GetSession()
Definition Chat.h:242
static ObjectGuid GetGUID(Object const *o)
Definition Object.h:114
Player * GetPlayer() const
Definition WorldSession.h:454
void SendShowBank(ObjectGuid guid)
Definition BankHandler.cpp:186

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

Referenced by GetCommands().

◆ HandleCharacterCheckProfessionCommand()

static bool character_commandscript::HandleCharacterCheckProfessionCommand ( ChatHandler handler)
inlinestatic
984 {
985 Player* player = handler->getSelectedPlayerOrSelf();
986
987 if (!player)
988 return false;
989
990 uint8 Counter = 0;
991
992 handler->PSendSysMessage("--------------------------------------");
993
994 for (uint32 i = 1; i < sSkillLineStore.GetNumRows(); ++i)
995 {
996 SkillLineEntry const* SkillInfo = sSkillLineStore.LookupEntry(i);
997
998 if (!SkillInfo)
999 continue;
1000
1001 if ((SkillInfo->categoryId != SKILL_CATEGORY_PROFESSION) && !SkillInfo->canLink)
1002 continue;
1003
1004 uint32 SkillID = SkillInfo->id;
1005
1006 if (player->HasSkill(SkillID))
1007 {
1008 Counter++;
1009
1010 switch (SkillID)
1011 {
1012 case SKILL_ALCHEMY:
1013 handler->PSendSysMessage("{} - Alchemy - {}", Counter, player->GetSkillValue(SkillID));
1014 break;
1016 handler->PSendSysMessage("{} - Blacksmithing - {}", Counter, player->GetSkillValue(SkillID));
1017 break;
1018 case SKILL_ENCHANTING:
1019 handler->PSendSysMessage("{} - Enchanting - {}", Counter, player->GetSkillValue(SkillID));
1020 break;
1021 case SKILL_ENGINEERING:
1022 handler->PSendSysMessage("{} - Engineering - {}", Counter, player->GetSkillValue(SkillID));
1023 break;
1024 case SKILL_INSCRIPTION:
1025 handler->PSendSysMessage("{} - Inscription - {}", Counter, player->GetSkillValue(SkillID));
1026 break;
1028 handler->PSendSysMessage("{} - Jewelcrafting - {}", Counter, player->GetSkillValue(SkillID));
1029 break;
1031 handler->PSendSysMessage("{} - Leatherworking - {}", Counter, player->GetSkillValue(SkillID));
1032 break;
1033 case SKILL_TAILORING:
1034 handler->PSendSysMessage("{} - Tailoring - {}", Counter, player->GetSkillValue(SkillID));
1035 break;
1036 case SKILL_SKINNING:
1037 handler->PSendSysMessage("{} - Skinning - {}", Counter, player->GetSkillValue(SkillID));
1038 break;
1039 case SKILL_HERBALISM:
1040 handler->PSendSysMessage("{} - Herbalism - {}", Counter, player->GetSkillValue(SkillID));
1041 break;
1042 case SKILL_MINING:
1043 handler->PSendSysMessage("{} - Mining - {}", Counter, player->GetSkillValue(SkillID));
1044 break;
1045 case SKILL_COOKING:
1046 handler->PSendSysMessage("{} - Cooking - {}", Counter, player->GetSkillValue(SkillID));
1047 break;
1048 case SKILL_FIRST_AID:
1049 handler->PSendSysMessage("{} - First Aid - {}", Counter, player->GetSkillValue(SkillID));
1050 break;
1051 default:
1052 break;
1053 }
1054 }
1055 }
1056
1057 handler->PSendSysMessage("--------------------------------------");
1058 return true;
1059 }
DBCStorage< SkillLineEntry > sSkillLineStore(SkillLinefmt)
@ SKILL_CATEGORY_PROFESSION
Definition SharedDefines.h:3311
@ SKILL_INSCRIPTION
Definition SharedDefines.h:3235
@ SKILL_COOKING
Definition SharedDefines.h:3151
@ SKILL_BLACKSMITHING
Definition SharedDefines.h:3142
@ SKILL_LEATHERWORKING
Definition SharedDefines.h:3143
@ SKILL_TAILORING
Definition SharedDefines.h:3155
@ SKILL_MINING
Definition SharedDefines.h:3152
@ SKILL_ENGINEERING
Definition SharedDefines.h:3156
@ SKILL_FIRST_AID
Definition SharedDefines.h:3125
@ SKILL_SKINNING
Definition SharedDefines.h:3194
@ SKILL_ALCHEMY
Definition SharedDefines.h:3144
@ SKILL_ENCHANTING
Definition SharedDefines.h:3187
@ SKILL_JEWELCRAFTING
Definition SharedDefines.h:3218
@ SKILL_HERBALISM
Definition SharedDefines.h:3148
uint16 GetSkillValue(uint32 skill) const
Definition Player.cpp:5450
bool HasSkill(uint32 skill) const
Definition Player.cpp:5429
Definition DBCStructure.h:1583
uint32 id
Definition DBCStructure.h:1584
int32 categoryId
Definition DBCStructure.h:1585
uint32 canLink
Definition DBCStructure.h:1594

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));
474 target->SetAtLoginFlag(AT_LOGIN_CUSTOMIZE);
475 }
476 else
477 {
478 handler->PSendSysMessage(LANG_CUSTOMIZE_PLAYER_GUID, handler->playerLink(*player), player->GetGUID().ToString());
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:589

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
691 {
692 DeletedInfoList foundList;
693 if (!GetDeletedCharacterInfoList(foundList, needle))
694 return false;
695
696 if (foundList.empty())
697 {
699 return false;
700 }
701
703 HandleCharacterDeletedListHelper(foundList, handler);
704
705 // Call the appropriate function to delete them (current account for deleted characters is 0)
706 for (DeletedInfoList::const_iterator itr = foundList.begin(); itr != foundList.end(); ++itr)
707 Player::DeleteFromDB(itr->lowGuid, 0, false, true);
708
709 return true;
710 }
@ LANG_CHARACTER_DELETED_LIST_EMPTY
Definition Language.h:886
@ LANG_CHARACTER_DELETED_DELETE
Definition Language.h:888
virtual void SendSysMessage(std::string_view str, bool escapeCharacters=false)
Definition Chat.cpp:168
static void DeleteFromDB(ObjectGuid::LowType lowGuid, uint32 accountId, bool updateRealmChars, bool deleteFinally)
Definition Player.cpp:3909
static bool GetDeletedCharacterInfoList(DeletedInfoList &foundList, std::string searchString, bool limitResults=false)
Definition cs_character.cpp:113
static void HandleCharacterDeletedListHelper(DeletedInfoList const &foundList, ChatHandler *handler)
Definition cs_character.cpp:177
std::list< DeletedInfo > DeletedInfoList
Definition cs_character.cpp:101

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

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
596 {
597 std::string needle;
598 if (needleStr)
599 needle.assign(*needleStr);
600 DeletedInfoList foundList;
601 if (!GetDeletedCharacterInfoList(foundList, needle, true))
602 return false;
603
604 // if no characters have been found, output a warning
605 if (foundList.empty())
606 {
608 return false;
609 }
610
611 bool truncated = foundList.size() > MAX_DELETED_CHAR_RESULTS;
612 if (truncated)
613 foundList.resize(MAX_DELETED_CHAR_RESULTS);
614
615 HandleCharacterDeletedListHelper(foundList, handler);
616
617 if (truncated)
619
620 return true;
621 }
@ LANG_CHARACTER_DELETED_LIST_LIMIT
Definition Language.h:1492
static constexpr std::size_t MAX_DELETED_CHAR_RESULTS
Definition cs_character.cpp:103

References GetDeletedCharacterInfoList(), HandleCharacterDeletedListHelper(), LANG_CHARACTER_DELETED_LIST_EMPTY, LANG_CHARACTER_DELETED_LIST_LIMIT, MAX_DELETED_CHAR_RESULTS, ChatHandler::SendErrorMessage(), and ChatHandler::SendSysMessage().

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
178 {
179 if (!handler->GetSession())
180 {
184 }
185
186 for (DeletedInfoList::const_iterator itr = foundList.begin(); itr != foundList.end(); ++itr)
187 {
188 std::string dateStr = Acore::Time::TimeToTimestampStr(Seconds(itr->deleteDate));
189
190 if (!handler->GetSession())
192 itr->lowGuid, itr->name, uint32(itr->level),
193 itr->accountName.empty() ? "<Not existing>" : itr->accountName,
194 itr->accountId, dateStr);
195 else
197 itr->lowGuid, itr->name, uint32(itr->level),
198 itr->accountName.empty() ? "<Not existing>" : itr->accountName,
199 itr->accountId, dateStr);
200 }
201
202 if (!handler->GetSession())
204 }
std::chrono::seconds Seconds
Seconds shorthand typedef.
Definition Duration.h:30
@ LANG_CHARACTER_DELETED_LIST_LINE_CHAT
Definition Language.h:893
@ LANG_CHARACTER_DELETED_LIST_HEADER
Definition Language.h:883
@ LANG_CHARACTER_DELETED_LIST_LINE_CONSOLE
Definition Language.h:884
@ LANG_CHARACTER_DELETED_LIST_BAR
Definition Language.h:885
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
724 {
725 int32 keepDays = static_cast<int32>(sWorld->getIntConfig(CONFIG_CHARDELETE_KEEP_DAYS));
726
727 if (days)
728 keepDays = static_cast<int32>(*days);
729 else if (keepDays <= 0) // config option value 0 -> disabled and can't be used
730 return false;
731
732 Player::DeleteOldCharacters(static_cast<uint32>(keepDays));
733
734 return true;
735 }
std::int32_t int32
Definition Define.h:103
@ CONFIG_CHARDELETE_KEEP_DAYS
Definition WorldConfig.h:309
static void DeleteOldCharacters()
Definition Player.cpp:4259
#define sWorld
Definition World.h:317

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
635 {
636 DeletedInfoList foundList;
637 if (!GetDeletedCharacterInfoList(foundList, needle))
638 return false;
639
640 if (foundList.empty())
641 {
643 return false;
644 }
645
647 HandleCharacterDeletedListHelper(foundList, handler);
648
649 if (!newCharName)
650 {
651 // Drop nonexisting account cases
652 for (DeletedInfoList::iterator itr = foundList.begin(); itr != foundList.end(); ++itr)
654 return true;
655 }
656
657 if (foundList.size() == 1)
658 {
659 std::string newName{ *newCharName };
660 DeletedInfo delInfo = foundList.front();
661
662 // update name
663 delInfo.name = newName;
664
665 // if new account provided update deleted info
666 if (newAccount)
667 {
668 delInfo.accountId = newAccount->GetID();
669 delInfo.accountName = newAccount->GetName();
670 }
671
672 HandleCharacterDeletedRestoreHelper(delInfo, handler);
673 return true;
674 }
675
677 return false;
678 }
@ LANG_CHARACTER_DELETED_ERR_RENAME
Definition Language.h:889
@ LANG_CHARACTER_DELETED_RESTORE
Definition Language.h:887
static void HandleCharacterDeletedRestoreHelper(DeletedInfo const &delInfo, ChatHandler *handler)
Definition cs_character.cpp:216

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::SendErrorMessage(), and ChatHandler::SendSysMessage().

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
217 {
218 if (delInfo.accountName.empty()) // account does not exist
219 {
220 handler->PSendSysMessage(LANG_CHARACTER_DELETED_SKIP_ACCOUNT, delInfo.name, delInfo.lowGuid, delInfo.accountId);
221 return;
222 }
223
224 // check character count
225 uint32 charcount = AccountMgr::GetCharactersCount(delInfo.accountId);
226 if (charcount >= 10)
227 {
228 handler->PSendSysMessage(LANG_CHARACTER_DELETED_SKIP_FULL, delInfo.name, delInfo.lowGuid, delInfo.accountId);
229 return;
230 }
231
232 if (sCharacterCache->GetCharacterGuidByName(delInfo.name))
233 {
234 handler->PSendSysMessage(LANG_CHARACTER_DELETED_SKIP_NAME, delInfo.name, delInfo.lowGuid, delInfo.accountId);
235 return;
236 }
237
238 auto* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UDP_RESTORE_DELETE_INFO);
239 stmt->SetData(0, delInfo.name);
240 stmt->SetData(1, delInfo.accountId);
241 stmt->SetData(2, delInfo.lowGuid);
242 CharacterDatabase.Execute(stmt);
243
244 stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHARACTER_NAME_DATA);
245 stmt->SetData(0, delInfo.lowGuid);
246 if (PreparedQueryResult result = CharacterDatabase.Query(stmt))
247 {
248 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>());
249 }
250 }
@ CHAR_UDP_RESTORE_DELETE_INFO
Definition CharacterDatabase.h:296
@ CHAR_SEL_CHARACTER_NAME_DATA
Definition CharacterDatabase.h:52
@ LANG_CHARACTER_DELETED_SKIP_NAME
Definition Language.h:892
@ LANG_CHARACTER_DELETED_SKIP_FULL
Definition Language.h:891
@ LANG_CHARACTER_DELETED_SKIP_ACCOUNT
Definition Language.h:890
Definition ObjectGuid.h:118

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, Player, 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
745 {
746 uint32 accountId;
747 if (Player* target = player.GetConnectedPlayer())
748 {
749 accountId = target->GetSession()->GetAccountId();
750 target->GetSession()->KickPlayer("HandleCharacterEraseCommand GM Command deleting character");
751 }
752 else
753 {
754 accountId = sCharacterCache->GetCharacterAccountIdByGuid(player.GetGUID());
755 }
756
757 std::string accountName;
758 AccountMgr::GetName(accountId, accountName);
759
760 Player::DeleteFromDB(player.GetGUID().GetCounter(), accountId, true, true);
761 handler->PSendSysMessage(LANG_CHARACTER_DELETED, player.GetName(), player.GetGUID().ToString(), accountName, accountId);
762
763 return true;
764 }
@ LANG_CHARACTER_DELETED
Definition Language.h:876
LowType GetCounter() const
Definition ObjectGuid.h:145
std::string ToString() const
Definition ObjectGuid.cpp:47
ObjectGuid GetGUID() const
Definition ChatCommandTags.h:181
std::string const & GetName() const
Definition ChatCommandTags.h:180
Player * GetConnectedPlayer() const
Definition ChatCommandTags.h:183

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

Referenced by GetCommands().

◆ HandleCharacterLevel()

static void character_commandscript::HandleCharacterLevel ( Player player,
ObjectGuid  playerGuid,
uint32  oldLevel,
uint32  newLevel,
ChatHandler handler 
)
inlinestatic
253 {
254 if (player)
255 {
256 player->GiveLevel(newLevel);
257 player->InitTalentForLevel();
258 player->SetUInt32Value(PLAYER_XP, 0);
259
260 if (handler->needReportToTarget(player))
261 {
262 if (oldLevel == newLevel)
264 else if (oldLevel < newLevel)
265 ChatHandler(player->GetSession()).PSendSysMessage(LANG_YOURS_LEVEL_UP, handler->GetNameLink(), newLevel);
266 else // if (oldlevel > newlevel)
268 }
269 }
270 else
271 {
272 // Update level and reset XP, everything else will be updated at login
273 auto* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_LEVEL);
274 stmt->SetData(0, uint8(newLevel));
275 stmt->SetData(1, playerGuid.GetCounter());
276 CharacterDatabase.Execute(stmt);
277
278 sAchievementMgr->UpdateAchievementCriteriaForOfflinePlayer(playerGuid.GetCounter(), ACHIEVEMENT_CRITERIA_TYPE_REACH_LEVEL);
279
280 sCharacterCache->UpdateCharacterLevel(playerGuid, newLevel);
281 }
282 }
#define sAchievementMgr
Definition AchievementMgr.h:451
@ CHAR_UPD_LEVEL
Definition CharacterDatabase.h:298
@ ACHIEVEMENT_CRITERIA_TYPE_REACH_LEVEL
Definition DBCEnums.h:124
@ LANG_YOURS_LEVEL_UP
Definition Language.h:622
@ LANG_YOURS_LEVEL_PROGRESS_RESET
Definition Language.h:624
@ LANG_YOURS_LEVEL_DOWN
Definition Language.h:623
@ PLAYER_XP
Definition UpdateFields.h:339
Definition Chat.h:37
virtual bool needReportToTarget(Player *chr) const
Definition Chat.cpp:872
void InitTalentForLevel()
Definition Player.cpp:2545
void GiveLevel(uint8 level)
Definition Player.cpp:2432
WorldSession * GetSession() const
Definition Player.h:2020
void SetUInt32Value(uint16 index, uint32 value)
Definition Unit.cpp:17358

References ACHIEVEMENT_CRITERIA_TYPE_REACH_LEVEL, 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(), sAchievementMgr, sCharacterCache, and Unit::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), newlevel);
459
460 return true;
461 }
#define DEFAULT_MAX_LEVEL
Definition DBCEnums.h:35
@ LANG_YOU_CHANGE_LVL
Definition Language.h:165
static void HandleCharacterLevel(Player *player, ObjectGuid playerGuid, uint32 oldLevel, uint32 newLevel, ChatHandler *handler)
Definition cs_character.cpp:252

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
333 {
334 if (!player && newNameV)
335 return false;
336
337 if (!player)
338 player = PlayerIdentifier::FromTarget(handler);
339
340 if (!player)
341 return false;
342
343 if (handler->HasLowerSecurity(nullptr, player->GetGUID()))
344 return false;
345
346 if (newNameV)
347 {
348 std::string newName{ *newNameV };
349 if (!normalizePlayerName(newName))
350 {
352 return false;
353 }
354
356 if (res != CHAR_NAME_SUCCESS)
357 {
358 switch (res)
359 {
362 break;
365 break;
366 default:
368 break;
369 }
370
371 return false;
372 }
373
375 stmt->SetData(0, newName);
376 PreparedQueryResult result = CharacterDatabase.Query(stmt);
377 if (result)
378 {
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(), newName);
408 }
409 else
410 {
411 if (Player* target = player->GetConnectedPlayer())
412 {
413 handler->PSendSysMessage(LANG_RENAME_PLAYER, handler->GetNameLink(target));
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), player->GetGUID().ToString());
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
@ LANG_RENAME_PLAYER
Definition Language.h:303
@ LANG_RENAME_PLAYER_WITH_NEW_NAME
Definition Language.h:133
@ LANG_PROFANITY_NAME
Definition Language.h:229
@ LANG_BAD_VALUE
Definition Language.h:151
@ LANG_RESERVED_NAME
Definition Language.h:210
@ LANG_RENAME_PLAYER_ALREADY_EXISTS
Definition Language.h:132
@ LANG_RENAME_PLAYER_GUID
Definition Language.h:304
#define sObjectMgr
Definition ObjectMgr.h:1723
@ AT_LOGIN_RENAME
Definition Player.h:586
ResponseCodes
Definition SharedDefines.h:3569
@ CHAR_NAME_RESERVED
Definition SharedDefines.h:3676
@ CHAR_NAME_PROFANE
Definition SharedDefines.h:3675
@ CHAR_NAME_SUCCESS
Definition SharedDefines.h:3668
bool HasLowerSecurity(Player *target, ObjectGuid guid=ObjectGuid::Empty, bool strong=false)
Definition Chat.cpp:65
static uint8 CheckPlayerName(std::string_view name, bool create=false)
Definition ObjectMgr.cpp:9273
Player session in the World.
Definition WorldSession.h:384
void UpdatePlayerNameMapReference(std::string oldname, Player *player)
Definition ObjectAccessor.cpp:346

References AT_LOGIN_RENAME, CHAR_DEL_DECLINED_NAME, CHAR_NAME_PROFANE, CHAR_NAME_RESERVED, 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::SendErrorMessage(), PreparedStatementBase::SetData(), 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 return false;
544 }
545
546 Player const* target = player->GetConnectedPlayer();
547 LocaleConstant loc = handler->GetSessionDbcLocale();
548
549 FactionStateList const& targetFSL = target->GetReputationMgr().GetStateList();
550 for (FactionStateList::const_iterator itr = targetFSL.begin(); itr != targetFSL.end(); ++itr)
551 {
552 FactionState const& faction = itr->second;
553 FactionEntry const* factionEntry = sFactionStore.LookupEntry(faction.ID);
554 char const* factionName = factionEntry ? factionEntry->name[loc] : "#Not found#";
555 ReputationRank rank = target->GetReputationMgr().GetRank(factionEntry);
556 std::string rankName = handler->GetAcoreString(ReputationRankStrIndex[rank]);
557 std::ostringstream ss;
558 if (handler->GetSession())
559 ss << faction.ID << " - |cffffffff|Hfaction:" << faction.ID << "|h[" << factionName << ' ' << localeNames[loc] << "]|h|r";
560 else
561 ss << faction.ID << " - " << factionName << ' ' << localeNames[loc];
562
563 ss << ' ' << rankName << " (" << target->GetReputationMgr().GetReputation(factionEntry) << ')';
564
565 if (faction.Flags & FACTION_FLAG_VISIBLE)
566 ss << handler->GetAcoreString(LANG_FACTION_VISIBLE);
567 if (faction.Flags & FACTION_FLAG_AT_WAR)
568 ss << handler->GetAcoreString(LANG_FACTION_ATWAR);
569 if (faction.Flags & FACTION_FLAG_PEACE_FORCED)
571 if (faction.Flags & FACTION_FLAG_HIDDEN)
572 ss << handler->GetAcoreString(LANG_FACTION_HIDDEN);
575 if (faction.Flags & FACTION_FLAG_INACTIVE)
577
578 handler->SendSysMessage(ss.str().c_str());
579 }
580
581 return true;
582 }
char const * localeNames[TOTAL_LOCALES]
Definition Common.cpp:20
LocaleConstant
Definition Common.h:117
@ FACTION_FLAG_INACTIVE
Definition DBCEnums.h:312
@ FACTION_FLAG_PEACE_FORCED
Definition DBCEnums.h:311
@ FACTION_FLAG_INVISIBLE_FORCED
Definition DBCEnums.h:310
@ FACTION_FLAG_HIDDEN
Definition DBCEnums.h:309
@ FACTION_FLAG_VISIBLE
Definition DBCEnums.h:307
@ FACTION_FLAG_AT_WAR
Definition DBCEnums.h:308
DBCStorage< FactionEntry > sFactionStore(FactionEntryfmt)
@ LANG_FACTION_PEACE_FORCED
Definition Language.h:364
@ LANG_FACTION_ATWAR
Definition Language.h:363
@ LANG_FACTION_INVISIBLE_FORCED
Definition Language.h:366
@ LANG_FACTION_HIDDEN
Definition Language.h:365
@ LANG_FACTION_INACTIVE
Definition Language.h:367
@ LANG_FACTION_VISIBLE
Definition Language.h:362
constexpr std::array< uint32, MAX_REPUTATION_RANK > ReputationRankStrIndex
Definition ReputationMgr.h:27
std::map< RepListID, FactionState > FactionStateList
Definition ReputationMgr.h:51
ReputationRank
Definition SharedDefines.h:156
virtual LocaleConstant GetSessionDbcLocale() const
Definition Chat.cpp:878
virtual std::string GetAcoreString(uint32 entry) const
Definition Chat.cpp:42
ReputationMgr & GetReputationMgr()
Definition Player.h:2145
FactionStateList const & GetStateList() const
Definition ReputationMgr.h:79
int32 GetReputation(uint32 faction_id) const
Definition ReputationMgr.cpp:78
ReputationRank GetRank(FactionEntry const *factionEntry) const
Definition ReputationMgr.cpp:125
Definition DBCStructure.h:907
char const * name[16]
Definition DBCStructure.h:919
Definition ReputationMgr.h:41
uint32 ID
Definition ReputationMgr.h:42
uint8 Flags
Definition ReputationMgr.h:45

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::SendErrorMessage(), ChatHandler::SendSysMessage(), and sFactionStore.

Referenced by GetCommands().

◆ HandleCharacterTitlesCommand()

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

Referenced by GetCommands().

◆ HandleLevelUpCommand()

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

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
851 {
852 std::string name;
853 if (!ValidatePDumpTarget(handler, name, characterName, characterGUID))
854 return false;
855
856 std::string dump;
857 switch (PlayerDumpWriter().WriteDumpToString(dump, player.GetGUID().GetCounter()))
858 {
859 case DUMP_SUCCESS:
860 break;
863 return false;
864 case DUMP_FILE_OPEN_ERROR: // this error code should not happen
865 default:
867 return false;
868 }
869
870 switch (PlayerDumpReader().LoadDumpFromString(dump, account, name, characterGUID.value_or(0)))
871 {
872 case DUMP_SUCCESS:
873 break;
875 handler->SendErrorMessage(LANG_ACCOUNT_CHARACTER_LIST_FULL, account.GetName(), account.GetID());
876 return false;
877 case DUMP_FILE_OPEN_ERROR: // this error code should not happen
878 case DUMP_FILE_BROKEN: // this error code should not happen
879 default:
881 return false;
882 }
883
884 // Original TC Notes from Refactor vvv
885 //ToDo: use a new acore_string for this commands
887
888 return true;
889 }
@ LANG_COMMAND_EXPORT_DELETED_CHAR
Definition Language.h:931
@ LANG_COMMAND_IMPORT_FAILED
Definition Language.h:525
@ LANG_COMMAND_EXPORT_FAILED
Definition Language.h:527
@ LANG_COMMAND_IMPORT_SUCCESS
Definition Language.h:524
@ DUMP_FILE_OPEN_ERROR
Definition PlayerDump.h:55
@ DUMP_CHARACTER_DELETED
Definition PlayerDump.h:58
@ DUMP_SUCCESS
Definition PlayerDump.h:54
@ DUMP_TOO_MANY_CHARS
Definition PlayerDump.h:56
@ DUMP_FILE_BROKEN
Definition PlayerDump.h:57
Definition PlayerDump.h:95
Definition PlayerDump.h:75
static bool ValidatePDumpTarget(ChatHandler *handler, std::string &name, Optional< std::string_view > characterName, Optional< ObjectGuid::LowType > characterGUID)
Definition cs_character.cpp:791
uint32 GetID() const
Definition ChatCommandTags.h:159
std::string const & GetName() const
Definition ChatCommandTags.h:160

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::SendErrorMessage(), and ValidatePDumpTarget().

Referenced by GetCommands().

◆ HandlePDumpLoadCommand()

static bool character_commandscript::HandlePDumpLoadCommand ( ChatHandler handler,
std::string  fileName,
AccountIdentifier  account,
Optional< std::string_view >  characterName,
Optional< ObjectGuid::LowType characterGUID 
)
inlinestatic
823 {
824 std::string name;
825 if (!ValidatePDumpTarget(handler, name, characterName, characterGUID))
826 return false;
827
828 switch (PlayerDumpReader().LoadDumpFromFile(fileName, account, name, characterGUID.value_or(0)))
829 {
830 case DUMP_SUCCESS:
832 break;
834 handler->SendErrorMessage(LANG_FILE_OPEN_FAIL, fileName);
835 return false;
836 case DUMP_FILE_BROKEN:
837 handler->SendErrorMessage(LANG_DUMP_BROKEN, fileName);
838 return false;
840 handler->SendErrorMessage(LANG_ACCOUNT_CHARACTER_LIST_FULL, account.GetName(), account.GetID());
841 return false;
842 default:
844 return false;
845 }
846
847 return true;
848 }
@ LANG_DUMP_BROKEN
Definition Language.h:915
@ LANG_FILE_OPEN_FAIL
Definition Language.h:913

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::SendErrorMessage(), and ValidatePDumpTarget().

Referenced by GetCommands().

◆ HandlePDumpWriteCommand()

static bool character_commandscript::HandlePDumpWriteCommand ( ChatHandler handler,
std::string  fileName,
PlayerIdentifier  player 
)
inlinestatic
892 {
893 switch (PlayerDumpWriter().WriteDumpToFile(fileName, player.GetGUID().GetCounter()))
894 {
895 case DUMP_SUCCESS:
897 break;
899 handler->SendErrorMessage(LANG_FILE_OPEN_FAIL, fileName);
900 return false;
903 return false;
904 default:
906 return false;
907 }
908
909 return true;
910 }
@ LANG_COMMAND_EXPORT_SUCCESS
Definition Language.h:526

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::SendErrorMessage().

Referenced by GetCommands().

◆ ValidatePDumpTarget()

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

References CHAR_NAME_SUCCESS, ObjectMgr::CheckPlayerName(), LANG_CHARACTER_GUID_IN_USE, LANG_INVALID_CHARACTER_NAME, normalizePlayerName(), Player, sCharacterCache, and ChatHandler::SendErrorMessage().

Referenced by HandlePDumpCopyCommand(), and HandlePDumpLoadCommand().

Member Data Documentation

◆ MAX_DELETED_CHAR_RESULTS

constexpr std::size_t character_commandscript::MAX_DELETED_CHAR_RESULTS = 50
staticconstexpr

The documentation for this class was generated from the following file: