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)
 
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, uint16 totalAvailableHooks=0)
 
virtual ~ScriptObject ()=default
 

Detailed Description

Member Typedef Documentation

◆ DeletedInfoList

Constructor & Destructor Documentation

◆ character_commandscript()

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

Member Function Documentation

◆ GetCommands()

ChatCommandTable character_commandscript::GetCommands ( ) const
inlineoverridevirtual

Implements CommandScript.

41 {
42 static ChatCommandTable pdumpCommandTable =
43 {
44 { "load", HandlePDumpLoadCommand, SEC_ADMINISTRATOR, Console::Yes },
45 { "write", HandlePDumpWriteCommand, SEC_ADMINISTRATOR, Console::Yes }
46 };
47
48 static ChatCommandTable characterDeletedCommandTable =
49 {
50 { "delete", HandleCharacterDeletedDeleteCommand, SEC_CONSOLE, Console::Yes },
52 { "restore", HandleCharacterDeletedRestoreCommand, SEC_ADMINISTRATOR, Console::Yes },
53 { "purge", HandleCharacterDeletedPurgeCommand, SEC_CONSOLE, Console::Yes }
54 };
55
56 static ChatCommandTable characterCheckCommandTable =
57 {
58 { "bank", HandleCharacterCheckBankCommand, SEC_GAMEMASTER, Console::Yes },
59 { "bag", HandleCharacterCheckBagCommand, SEC_GAMEMASTER, Console::Yes },
60 { "profession", HandleCharacterCheckProfessionCommand, SEC_GAMEMASTER, Console::Yes }
61 };
62
63 static ChatCommandTable characterCommandTable =
64 {
65 { "customize", HandleCharacterCustomizeCommand, SEC_GAMEMASTER, Console::Yes },
66 { "changefaction", HandleCharacterChangeFactionCommand, SEC_GAMEMASTER, Console::Yes },
67 { "changerace", HandleCharacterChangeRaceCommand, SEC_GAMEMASTER, Console::Yes },
68 { "changeaccount", HandleCharacterChangeAccountCommand, SEC_ADMINISTRATOR, Console::Yes },
69 { "check", characterCheckCommandTable },
70 { "erase", HandleCharacterEraseCommand, SEC_CONSOLE, Console::Yes },
71 { "deleted", characterDeletedCommandTable },
72 { "level", HandleCharacterLevelCommand, SEC_GAMEMASTER, Console::Yes },
73 { "rename", HandleCharacterRenameCommand, SEC_GAMEMASTER, Console::Yes },
74 { "reputation", HandleCharacterReputationCommand, SEC_GAMEMASTER, Console::Yes },
75 { "titles", HandleCharacterTitlesCommand, SEC_GAMEMASTER, Console::Yes }
76 };
77
78 static ChatCommandTable commandTable =
79 {
80 { "character", characterCommandTable },
81 { "levelup", HandleLevelUpCommand, SEC_GAMEMASTER, Console::No },
82 { "pdump", pdumpCommandTable }
83 };
84
85 return commandTable;
86 }
@ SEC_ADMINISTRATOR
Definition Common.h:60
@ SEC_GAMEMASTER
Definition Common.h:59
@ SEC_CONSOLE
Definition Common.h:61
static bool HandleCharacterChangeAccountCommand(ChatHandler *handler, std::string accountName, Optional< PlayerIdentifier > player)
Definition cs_character.cpp:1044
static bool HandleCharacterDeletedListCommand(ChatHandler *handler, Optional< std::string_view > needleStr)
Definition cs_character.cpp:585
static bool HandleCharacterCheckBankCommand(ChatHandler *handler)
Definition cs_character.cpp:895
static bool HandlePDumpLoadCommand(ChatHandler *handler, std::string fileName, AccountIdentifier account, Optional< std::string_view > characterName, Optional< ObjectGuid::LowType > characterGUID)
Definition cs_character.cpp:805
static bool HandleCharacterDeletedPurgeCommand(ChatHandler *, Optional< uint16 > days)
Definition cs_character.cpp:706
static bool HandleLevelUpCommand(ChatHandler *handler, Optional< PlayerIdentifier > player, int16 level)
Definition cs_character.cpp:749
static bool HandleCharacterRenameCommand(ChatHandler *handler, Optional< PlayerIdentifier > player, Optional< bool > reserveName, Optional< std::string_view > newNameV)
Definition cs_character.cpp:322
static bool HandleCharacterLevelCommand(ChatHandler *handler, Optional< PlayerIdentifier > player, int16 newlevel)
Definition cs_character.cpp:429
static bool HandleCharacterCustomizeCommand(ChatHandler *handler, Optional< PlayerIdentifier > player)
Definition cs_character.cpp:454
static bool HandleCharacterCheckProfessionCommand(ChatHandler *handler)
Definition cs_character.cpp:966
static bool HandleCharacterDeletedDeleteCommand(ChatHandler *handler, std::string needle)
Definition cs_character.cpp:673
static bool HandleCharacterChangeRaceCommand(ChatHandler *handler, Optional< PlayerIdentifier > player)
Definition cs_character.cpp:502
static bool HandleCharacterTitlesCommand(ChatHandler *handler, Optional< PlayerIdentifier > player)
Definition cs_character.cpp:274
static bool HandlePDumpWriteCommand(ChatHandler *handler, std::string fileName, PlayerIdentifier player)
Definition cs_character.cpp:874
static bool HandleCharacterReputationCommand(ChatHandler *handler, Optional< PlayerIdentifier > player)
Definition cs_character.cpp:526
static bool HandleCharacterEraseCommand(ChatHandler *handler, PlayerIdentifier player)
Definition cs_character.cpp:727
static bool HandleCharacterCheckBagCommand(ChatHandler *handler, uint8 BagSlot)
Definition cs_character.cpp:901
static bool HandleCharacterChangeFactionCommand(ChatHandler *handler, Optional< PlayerIdentifier > player)
Definition cs_character.cpp:478
static bool HandleCharacterDeletedRestoreCommand(ChatHandler *handler, std::string needle, Optional< std::string_view > newCharName, Optional< AccountIdentifier > newAccount)
Definition cs_character.cpp:617
std::vector< ChatCommandBuilder > ChatCommandTable
Definition ChatCommand.h:46

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)
108 {
109 PreparedQueryResult result;
111 if (!searchString.empty())
112 {
113 // search by GUID
114 if (isNumeric(searchString.c_str()))
115 {
116 stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_DEL_INFO_BY_GUID);
117 stmt->SetData(0, *Acore::StringTo<uint32>(searchString));
118 result = CharacterDatabase.Query(stmt);
119 }
120 // search by name
121 else
122 {
123 if (!normalizePlayerName(searchString))
124 return false;
125
126 stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_DEL_INFO_BY_NAME);
127 stmt->SetData(0, searchString);
128 result = CharacterDatabase.Query(stmt);
129 }
130 }
131 else
132 {
133 stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_DEL_INFO);
134 result = CharacterDatabase.Query(stmt);
135 }
136
137 if (result)
138 {
139 do
140 {
141 Field* fields = result->Fetch();
142
143 DeletedInfo info;
144
145 info.lowGuid = fields[0].Get<uint32>();
146 info.name = fields[1].Get<std::string>();
147 info.accountId = fields[2].Get<uint32>();
148
149 // account name will be empty for nonexisting account
150 AccountMgr::GetName(info.accountId, info.accountName);
151 info.deleteDate = time_t(fields[3].Get<uint32>());
152 foundList.push_back(info);
153 } while (result->NextRow());
154 }
155
156 return true;
157 }
@ CHAR_SEL_CHAR_DEL_INFO_BY_NAME
Definition CharacterDatabase.h:333
@ CHAR_SEL_CHAR_DEL_INFO
Definition CharacterDatabase.h:334
@ CHAR_SEL_CHAR_DEL_INFO_BY_GUID
Definition CharacterDatabase.h:332
std::shared_ptr< PreparedResultSet > PreparedQueryResult
Definition DatabaseEnvFwd.h:45
DatabaseWorkerPool< CharacterDatabaseConnection > CharacterDatabase
Accessor to the character database.
Definition DatabaseEnv.cpp:21
std::uint32_t uint32
Definition Define.h:107
bool normalizePlayerName(std::string &name)
Definition ObjectMgr.cpp:208
bool isNumeric(wchar_t wchar)
Definition Util.h:204
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
bool GetName(uint32 accountId, std::string &name)
Definition AccountMgr.cpp:257

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
1045 {
1046 if (!player)
1047 {
1048 player = PlayerIdentifier::FromTargetOrSelf(handler);
1049 }
1050
1051 if (!player)
1052 {
1054 return false;
1055 }
1056
1057 if (uint32 accountId = AccountMgr::GetId(accountName))
1058 {
1059 if (AccountMgr::GetCharactersCount(accountId) >= 10)
1060 {
1061 handler->SendErrorMessage(LANG_ACCOUNT_CHARACTER_LIST_FULL, accountName, accountId);
1062 return true;
1063 }
1064
1065 if (CharacterCacheEntry const* cache = sCharacterCache->GetCharacterCacheByName(player->GetName()))
1066 {
1067 std::string accName;
1068 AccountMgr::GetName(cache->AccountId, accName);
1069 handler->PSendSysMessage(LANG_CMD_CHAR_CHANGE_ACC_SUCCESS, player->GetName(), player->GetGUID().ToString(), accName, cache->AccountId, accountName, accountId);
1070 }
1071
1072 if (player->IsConnected())
1073 {
1074 player->GetConnectedPlayer()->GetSession()->KickPlayer("CMD char changeaccount");
1075 }
1076
1077 CharacterDatabase.Query("UPDATE characters SET account = {} WHERE guid = {}", accountId, player->GetGUID().GetCounter());
1078 sCharacterCache->UpdateCharacterAccountId(player->GetGUID(), accountId);
1079
1080 }
1081 else
1082 {
1083 handler->SendErrorMessage(LANG_ACCOUNT_NOT_EXIST, accountName);
1084 return true;
1085 }
1086
1087 return true;
1088 }
#define sCharacterCache
Definition CharacterCache.h:83
@ LANG_ACCOUNT_CHARACTER_LIST_FULL
Definition Language.h:903
@ LANG_PLAYER_NOT_FOUND
Definition Language.h:540
@ LANG_ACCOUNT_NOT_EXIST
Definition Language.h:443
@ LANG_CMD_CHAR_CHANGE_ACC_SUCCESS
Definition Language.h:1143
void PSendSysMessage(std::string_view str, bool escapeCharacters=false)
Definition Chat.cpp:211
void SendErrorMessage(uint32 entry)
Definition Chat.cpp:216
uint32 GetCharactersCount(uint32 accountId)
Definition AccountMgr.cpp:295
uint32 GetId(std::string const &username)
Definition AccountMgr.cpp:229
static Optional< PlayerIdentifier > FromTargetOrSelf(ChatHandler *handler)
Definition ChatCommandTags.h:184
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
479 {
480 if (!player)
481 player = PlayerIdentifier::FromTarget(handler);
482 if (!player)
483 return false;
484
485 if (Player* target = player->GetConnectedPlayer())
486 {
487 handler->PSendSysMessage(LANG_CUSTOMIZE_PLAYER, handler->GetNameLink(target));
488 target->SetAtLoginFlag(AT_LOGIN_CHANGE_FACTION);
489 }
490 else
491 {
492 handler->PSendSysMessage(LANG_CUSTOMIZE_PLAYER_GUID, handler->playerLink(*player), player->GetGUID().ToString());
495 stmt->SetData(1, player->GetGUID().GetCounter());
496 CharacterDatabase.Execute(stmt);
497 }
498
499 return true;
500 }
@ 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:388
@ LANG_CUSTOMIZE_PLAYER
Definition Language.h:387
@ AT_LOGIN_CHANGE_FACTION
Definition Player.h:612
virtual std::string GetNameLink() const
Definition Chat.h:198
std::string playerLink(std::string const &name) const
Definition Chat.h:231
Definition Player.h:1082
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
503 {
504 if (!player)
505 player = PlayerIdentifier::FromTarget(handler);
506 if (!player)
507 return false;
508
509 if (Player* target = player->GetConnectedPlayer())
510 {
511 handler->PSendSysMessage(LANG_CUSTOMIZE_PLAYER, handler->GetNameLink(target));
512 target->SetAtLoginFlag(AT_LOGIN_CHANGE_RACE);
513 }
514 else
515 {
516 handler->PSendSysMessage(LANG_CUSTOMIZE_PLAYER_GUID, handler->playerLink(*player), player->GetGUID().ToString());
519 stmt->SetData(1, player->GetGUID().GetCounter());
520 CharacterDatabase.Execute(stmt);
521 }
522
523 return true;
524 }
@ AT_LOGIN_CHANGE_RACE
Definition Player.h:613

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
902 {
903 Player* target = handler->getSelectedPlayerOrSelf();
904
905 if (!target)
906 return false;
907
908 uint8 Counter = 0;
909 switch (BagSlot)
910 {
911 case 2:
912 BagSlot = 19;
913 break;
914 case 3:
915 BagSlot = 20;
916 break;
917 case 4:
918 BagSlot = 21;
919 break;
920 case 5:
921 BagSlot = 22;
922 break;
923 default:
924 BagSlot = 1;
925 break;
926 }
927
928 handler->PSendSysMessage("--------------------------------------");
929
930 if (BagSlot == 1)
931 {
932 for (uint32 i = 23; i < 39; i++)
933 {
934 if (Item* item = target->GetItemByPos(INVENTORY_SLOT_BAG_0, i))
935 {
936 Counter++;
937 std::ostringstream ItemString;
938 ItemString << std::hex << ItemQualityColors[item->GetTemplate()->Quality];
939
940 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());
941 }
942 }
943 }
944 else
945 {
946 if (Bag* bag = target->GetBagByPos(BagSlot))
947 {
948 for (uint32 i = 0; i < bag->GetBagSize(); i++)
949 {
950 if (Item* item = target->GetItemByPos(BagSlot, i))
951 {
952 Counter++;
953 std::ostringstream ItemString;
954 ItemString << std::hex << ItemQualityColors[item->GetTemplate()->Quality];
955
956 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());
957 }
958 }
959 }
960 }
961
962 handler->PSendSysMessage("--------------------------------------");
963 return true;
964 }
std::uint8_t uint8
Definition Define.h:109
#define INVENTORY_SLOT_BAG_0
Definition Player.h:676
const uint32 ItemQualityColors[MAX_ITEM_QUALITY]
Definition SharedDefines.h:353
Definition Bag.h:28
Player * getSelectedPlayerOrSelf() const
Definition Chat.cpp:418
Definition Item.h:220
Bag * GetBagByPos(uint8 slot) const
Definition PlayerStorage.cpp:457
Item * GetItemByPos(uint16 pos) const
Definition PlayerStorage.cpp:441

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
896 {
897 handler->GetSession()->SendShowBank(handler->GetSession()->GetPlayer()->GetGUID());
898 return true;
899 }
WorldSession * GetSession()
Definition Chat.h:242
static ObjectGuid GetGUID(Object const *o)
Definition Object.h:113
Player * GetPlayer() const
Definition WorldSession.h:376
void SendShowBank(ObjectGuid guid)
Definition BankHandler.cpp:188

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

Referenced by GetCommands().

◆ HandleCharacterCheckProfessionCommand()

static bool character_commandscript::HandleCharacterCheckProfessionCommand ( ChatHandler handler)
inlinestatic
967 {
968 Player* player = handler->getSelectedPlayerOrSelf();
969
970 if (!player)
971 return false;
972
973 uint8 Counter = 0;
974
975 handler->PSendSysMessage("--------------------------------------");
976
977 for (uint32 i = 1; i < sSkillLineStore.GetNumRows(); ++i)
978 {
979 SkillLineEntry const* SkillInfo = sSkillLineStore.LookupEntry(i);
980
981 if (!SkillInfo)
982 continue;
983
984 if ((SkillInfo->categoryId != SKILL_CATEGORY_PROFESSION) && !SkillInfo->canLink)
985 continue;
986
987 uint32 SkillID = SkillInfo->id;
988
989 if (player->HasSkill(SkillID))
990 {
991 Counter++;
992
993 switch (SkillID)
994 {
995 case SKILL_ALCHEMY:
996 handler->PSendSysMessage("{} - Alchemy - {}", Counter, player->GetSkillValue(SkillID));
997 break;
999 handler->PSendSysMessage("{} - Blacksmithing - {}", Counter, player->GetSkillValue(SkillID));
1000 break;
1001 case SKILL_ENCHANTING:
1002 handler->PSendSysMessage("{} - Enchanting - {}", Counter, player->GetSkillValue(SkillID));
1003 break;
1004 case SKILL_ENGINEERING:
1005 handler->PSendSysMessage("{} - Engineering - {}", Counter, player->GetSkillValue(SkillID));
1006 break;
1007 case SKILL_INSCRIPTION:
1008 handler->PSendSysMessage("{} - Inscription - {}", Counter, player->GetSkillValue(SkillID));
1009 break;
1011 handler->PSendSysMessage("{} - Jewelcrafting - {}", Counter, player->GetSkillValue(SkillID));
1012 break;
1014 handler->PSendSysMessage("{} - Leatherworking - {}", Counter, player->GetSkillValue(SkillID));
1015 break;
1016 case SKILL_TAILORING:
1017 handler->PSendSysMessage("{} - Tailoring - {}", Counter, player->GetSkillValue(SkillID));
1018 break;
1019 case SKILL_SKINNING:
1020 handler->PSendSysMessage("{} - Skinning - {}", Counter, player->GetSkillValue(SkillID));
1021 break;
1022 case SKILL_HERBALISM:
1023 handler->PSendSysMessage("{} - Herbalism - {}", Counter, player->GetSkillValue(SkillID));
1024 break;
1025 case SKILL_MINING:
1026 handler->PSendSysMessage("{} - Mining - {}", Counter, player->GetSkillValue(SkillID));
1027 break;
1028 case SKILL_COOKING:
1029 handler->PSendSysMessage("{} - Cooking - {}", Counter, player->GetSkillValue(SkillID));
1030 break;
1031 case SKILL_FIRST_AID:
1032 handler->PSendSysMessage("{} - First Aid - {}", Counter, player->GetSkillValue(SkillID));
1033 break;
1034 default:
1035 break;
1036 }
1037 }
1038 }
1039
1040 handler->PSendSysMessage("--------------------------------------");
1041 return true;
1042 }
DBCStorage< SkillLineEntry > sSkillLineStore(SkillLinefmt)
@ SKILL_CATEGORY_PROFESSION
Definition SharedDefines.h:3078
@ SKILL_INSCRIPTION
Definition SharedDefines.h:3002
@ SKILL_COOKING
Definition SharedDefines.h:2918
@ SKILL_BLACKSMITHING
Definition SharedDefines.h:2909
@ SKILL_LEATHERWORKING
Definition SharedDefines.h:2910
@ SKILL_TAILORING
Definition SharedDefines.h:2922
@ SKILL_MINING
Definition SharedDefines.h:2919
@ SKILL_ENGINEERING
Definition SharedDefines.h:2923
@ SKILL_FIRST_AID
Definition SharedDefines.h:2892
@ SKILL_SKINNING
Definition SharedDefines.h:2961
@ SKILL_ALCHEMY
Definition SharedDefines.h:2911
@ SKILL_ENCHANTING
Definition SharedDefines.h:2954
@ SKILL_JEWELCRAFTING
Definition SharedDefines.h:2985
@ SKILL_HERBALISM
Definition SharedDefines.h:2915
uint16 GetSkillValue(uint32 skill) const
Definition Player.cpp:5457
bool HasSkill(uint32 skill) const
Definition Player.cpp:5436
Definition DBCStructure.h:1584
uint32 id
Definition DBCStructure.h:1585
int32 categoryId
Definition DBCStructure.h:1586
uint32 canLink
Definition DBCStructure.h:1595

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
455 {
456 if (!player)
457 player = PlayerIdentifier::FromTarget(handler);
458 if (!player)
459 return false;
460
461 if (Player* target = player->GetConnectedPlayer())
462 {
463 handler->PSendSysMessage(LANG_CUSTOMIZE_PLAYER, handler->GetNameLink(target));
464 target->SetAtLoginFlag(AT_LOGIN_CUSTOMIZE);
465 }
466 else
467 {
468 handler->PSendSysMessage(LANG_CUSTOMIZE_PLAYER_GUID, handler->playerLink(*player), player->GetGUID().ToString());
470 stmt->SetData(0, static_cast<uint16>(AT_LOGIN_CUSTOMIZE));
471 stmt->SetData(1, player->GetGUID().GetCounter());
472 CharacterDatabase.Execute(stmt);
473 }
474
475 return true;
476 }
@ AT_LOGIN_CUSTOMIZE
Definition Player.h:609

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
674 {
675 DeletedInfoList foundList;
676 if (!GetDeletedCharacterInfoList(foundList, needle))
677 return false;
678
679 if (foundList.empty())
680 {
682 return false;
683 }
684
686 HandleCharacterDeletedListHelper(foundList, handler);
687
688 // Call the appropriate function to delete them (current account for deleted characters is 0)
689 for (DeletedInfoList::const_iterator itr = foundList.begin(); itr != foundList.end(); ++itr)
690 Player::DeleteFromDB(itr->lowGuid, 0, false, true);
691
692 return true;
693 }
@ LANG_CHARACTER_DELETED_LIST_EMPTY
Definition Language.h:875
@ LANG_CHARACTER_DELETED_DELETE
Definition Language.h:877
virtual void SendSysMessage(std::string_view str, bool escapeCharacters=false)
Definition Chat.cpp:160
static void DeleteFromDB(ObjectGuid::LowType lowGuid, uint32 accountId, bool updateRealmChars, bool deleteFinally)
Definition Player.cpp:3974
static bool GetDeletedCharacterInfoList(DeletedInfoList &foundList, std::string searchString)
Definition cs_character.cpp:107
static void HandleCharacterDeletedListHelper(DeletedInfoList const &foundList, ChatHandler *handler)
Definition cs_character.cpp:169
std::list< DeletedInfo > DeletedInfoList
Definition cs_character.cpp:98

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
586 {
587 std::string needle;
588 if (needleStr)
589 needle.assign(*needleStr);
590 DeletedInfoList foundList;
591 if (!GetDeletedCharacterInfoList(foundList, needle))
592 return false;
593
594 // if no characters have been found, output a warning
595 if (foundList.empty())
596 {
598 return false;
599 }
600
601 HandleCharacterDeletedListHelper(foundList, handler);
602
603 return true;
604 }

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

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
170 {
171 if (!handler->GetSession())
172 {
176 }
177
178 for (DeletedInfoList::const_iterator itr = foundList.begin(); itr != foundList.end(); ++itr)
179 {
180 std::string dateStr = Acore::Time::TimeToTimestampStr(Seconds(itr->deleteDate));
181
182 if (!handler->GetSession())
184 itr->lowGuid, itr->name, itr->accountName.empty() ? "<Not existing>" : itr->accountName,
185 itr->accountId, dateStr);
186 else
188 itr->lowGuid, itr->name, itr->accountName.empty() ? "<Not existing>" : itr->accountName,
189 itr->accountId, dateStr);
190 }
191
192 if (!handler->GetSession())
194 }
std::chrono::seconds Seconds
Seconds shorthand typedef.
Definition Duration.h:30
@ LANG_CHARACTER_DELETED_LIST_LINE_CHAT
Definition Language.h:882
@ LANG_CHARACTER_DELETED_LIST_HEADER
Definition Language.h:872
@ LANG_CHARACTER_DELETED_LIST_LINE_CONSOLE
Definition Language.h:873
@ LANG_CHARACTER_DELETED_LIST_BAR
Definition Language.h:874
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
707 {
708 int32 keepDays = static_cast<int32>(sWorld->getIntConfig(CONFIG_CHARDELETE_KEEP_DAYS));
709
710 if (days)
711 keepDays = static_cast<int32>(*days);
712 else if (keepDays <= 0) // config option value 0 -> disabled and can't be used
713 return false;
714
715 Player::DeleteOldCharacters(static_cast<uint32>(keepDays));
716
717 return true;
718 }
std::int32_t int32
Definition Define.h:103
@ CONFIG_CHARDELETE_KEEP_DAYS
Definition IWorld.h:357
static void DeleteOldCharacters()
Definition Player.cpp:4324
#define sWorld
Definition World.h:357

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
618 {
619 DeletedInfoList foundList;
620 if (!GetDeletedCharacterInfoList(foundList, needle))
621 return false;
622
623 if (foundList.empty())
624 {
626 return false;
627 }
628
630 HandleCharacterDeletedListHelper(foundList, handler);
631
632 if (!newCharName)
633 {
634 // Drop nonexisting account cases
635 for (DeletedInfoList::iterator itr = foundList.begin(); itr != foundList.end(); ++itr)
637 return true;
638 }
639
640 if (foundList.size() == 1)
641 {
642 std::string newName{ *newCharName };
643 DeletedInfo delInfo = foundList.front();
644
645 // update name
646 delInfo.name = newName;
647
648 // if new account provided update deleted info
649 if (newAccount)
650 {
651 delInfo.accountId = newAccount->GetID();
652 delInfo.accountName = newAccount->GetName();
653 }
654
655 HandleCharacterDeletedRestoreHelper(delInfo, handler);
656 return true;
657 }
658
660 return false;
661 }
@ LANG_CHARACTER_DELETED_ERR_RENAME
Definition Language.h:878
@ LANG_CHARACTER_DELETED_RESTORE
Definition Language.h:876
static void HandleCharacterDeletedRestoreHelper(DeletedInfo const &delInfo, ChatHandler *handler)
Definition cs_character.cpp:206

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
207 {
208 if (delInfo.accountName.empty()) // account does not exist
209 {
210 handler->PSendSysMessage(LANG_CHARACTER_DELETED_SKIP_ACCOUNT, delInfo.name, delInfo.lowGuid, delInfo.accountId);
211 return;
212 }
213
214 // check character count
215 uint32 charcount = AccountMgr::GetCharactersCount(delInfo.accountId);
216 if (charcount >= 10)
217 {
218 handler->PSendSysMessage(LANG_CHARACTER_DELETED_SKIP_FULL, delInfo.name, delInfo.lowGuid, delInfo.accountId);
219 return;
220 }
221
222 if (sCharacterCache->GetCharacterGuidByName(delInfo.name))
223 {
224 handler->PSendSysMessage(LANG_CHARACTER_DELETED_SKIP_NAME, delInfo.name, delInfo.lowGuid, delInfo.accountId);
225 return;
226 }
227
228 auto* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UDP_RESTORE_DELETE_INFO);
229 stmt->SetData(0, delInfo.name);
230 stmt->SetData(1, delInfo.accountId);
231 stmt->SetData(2, delInfo.lowGuid);
232 CharacterDatabase.Execute(stmt);
233
234 stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHARACTER_NAME_DATA);
235 stmt->SetData(0, delInfo.lowGuid);
236 if (PreparedQueryResult result = CharacterDatabase.Query(stmt))
237 {
238 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>());
239 }
240 }
@ CHAR_UDP_RESTORE_DELETE_INFO
Definition CharacterDatabase.h:295
@ CHAR_SEL_CHARACTER_NAME_DATA
Definition CharacterDatabase.h:52
@ LANG_CHARACTER_DELETED_SKIP_NAME
Definition Language.h:881
@ LANG_CHARACTER_DELETED_SKIP_FULL
Definition Language.h:880
@ LANG_CHARACTER_DELETED_SKIP_ACCOUNT
Definition Language.h:879
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
728 {
729 uint32 accountId;
730 if (Player* target = player.GetConnectedPlayer())
731 {
732 accountId = target->GetSession()->GetAccountId();
733 target->GetSession()->KickPlayer("HandleCharacterEraseCommand GM Command deleting character");
734 }
735 else
736 {
737 accountId = sCharacterCache->GetCharacterAccountIdByGuid(player.GetGUID());
738 }
739
740 std::string accountName;
741 AccountMgr::GetName(accountId, accountName);
742
743 Player::DeleteFromDB(player.GetGUID().GetCounter(), accountId, true, true);
744 handler->PSendSysMessage(LANG_CHARACTER_DELETED, player.GetName(), player.GetGUID().ToString(), accountName, accountId);
745
746 return true;
747 }
@ LANG_CHARACTER_DELETED
Definition Language.h:865
LowType GetCounter() const
Definition ObjectGuid.h:145
std::string ToString() const
Definition ObjectGuid.cpp:47
ObjectGuid GetGUID() const
Definition ChatCommandTags.h:176
std::string const & GetName() const
Definition ChatCommandTags.h:175
Player * GetConnectedPlayer() const
Definition ChatCommandTags.h:178

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
243 {
244 if (player)
245 {
246 player->GiveLevel(newLevel);
247 player->InitTalentForLevel();
248 player->SetUInt32Value(PLAYER_XP, 0);
249
250 if (handler->needReportToTarget(player))
251 {
252 if (oldLevel == newLevel)
254 else if (oldLevel < newLevel)
255 ChatHandler(player->GetSession()).PSendSysMessage(LANG_YOURS_LEVEL_UP, handler->GetNameLink(), newLevel);
256 else // if (oldlevel > newlevel)
258 }
259 }
260 else
261 {
262 // Update level and reset XP, everything else will be updated at login
263 auto* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_LEVEL);
264 stmt->SetData(0, uint8(newLevel));
265 stmt->SetData(1, playerGuid.GetCounter());
266 CharacterDatabase.Execute(stmt);
267
268 sAchievementMgr->UpdateAchievementCriteriaForOfflinePlayer(playerGuid.GetCounter(), ACHIEVEMENT_CRITERIA_TYPE_REACH_LEVEL);
269
270 sCharacterCache->UpdateCharacterLevel(playerGuid, newLevel);
271 }
272 }
#define sAchievementMgr
Definition AchievementMgr.h:451
@ CHAR_UPD_LEVEL
Definition CharacterDatabase.h:297
@ ACHIEVEMENT_CRITERIA_TYPE_REACH_LEVEL
Definition DBCEnums.h:124
@ LANG_YOURS_LEVEL_UP
Definition Language.h:614
@ LANG_YOURS_LEVEL_PROGRESS_RESET
Definition Language.h:616
@ LANG_YOURS_LEVEL_DOWN
Definition Language.h:615
@ PLAYER_XP
Definition UpdateFields.h:339
Definition Chat.h:37
virtual bool needReportToTarget(Player *chr) const
Definition Chat.cpp:864
void InitTalentForLevel()
Definition Player.cpp:2566
void GiveLevel(uint8 level)
Definition Player.cpp:2453
WorldSession * GetSession() const
Definition Player.h:2007
void SetUInt32Value(uint16 index, uint32 value)
Definition Unit.cpp:21136

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
430 {
431 if (!player)
432 player = PlayerIdentifier::FromTargetOrSelf(handler);
433
434 if (!player)
435 return false;
436
437 uint8 oldlevel = player->IsConnected() ? player->GetConnectedPlayer()->GetLevel() : sCharacterCache->GetCharacterLevelByGuid(player->GetGUID());
438
439 if (newlevel < 1)
440 return false; // invalid level
441
442 if (newlevel > DEFAULT_MAX_LEVEL) // hardcoded maximum level
443 newlevel = DEFAULT_MAX_LEVEL;
444
445 HandleCharacterLevel(player->GetConnectedPlayer(), player->GetGUID(), oldlevel, newlevel, handler);
446
447 if (!handler->GetSession() || (handler->GetSession()->GetPlayer() != player->GetConnectedPlayer())) // including chr == NULL
448 handler->PSendSysMessage(LANG_YOU_CHANGE_LVL, handler->playerLink(*player), newlevel);
449
450 return true;
451 }
#define DEFAULT_MAX_LEVEL
Definition DBCEnums.h:35
@ LANG_YOU_CHANGE_LVL
Definition Language.h:162
static void HandleCharacterLevel(Player *player, ObjectGuid playerGuid, uint32 oldLevel, uint32 newLevel, ChatHandler *handler)
Definition cs_character.cpp:242

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
323 {
324 if (!player && newNameV)
325 return false;
326
327 if (!player)
328 player = PlayerIdentifier::FromTarget(handler);
329
330 if (!player)
331 return false;
332
333 if (handler->HasLowerSecurity(nullptr, player->GetGUID()))
334 return false;
335
336 if (newNameV)
337 {
338 std::string newName{ *newNameV };
339 if (!normalizePlayerName(newName))
340 {
342 return false;
343 }
344
346 if (res != CHAR_NAME_SUCCESS)
347 {
348 switch (res)
349 {
352 break;
355 break;
356 default:
358 break;
359 }
360
361 return false;
362 }
363
365 stmt->SetData(0, newName);
366 PreparedQueryResult result = CharacterDatabase.Query(stmt);
367 if (result)
368 {
370 return false;
371 }
372
373 // Remove declined name from db
374 stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_DECLINED_NAME);
375 stmt->SetData(0, player->GetGUID().GetCounter());
376 CharacterDatabase.Execute(stmt);
377
378 if (Player* target = player->GetConnectedPlayer())
379 {
380 target->SetName(newName);
381
382 ObjectAccessor::UpdatePlayerNameMapReference(player->GetName(), target);
383
384 if (WorldSession* session = target->GetSession())
385 session->KickPlayer("HandleCharacterRenameCommand GM Command renaming character");
386 }
387 else
388 {
389 stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_NAME_BY_GUID);
390 stmt->SetData(0, newName);
391 stmt->SetData(1, player->GetGUID().GetCounter());
392 CharacterDatabase.Execute(stmt);
393 }
394
395 sCharacterCache->UpdateCharacterData(player->GetGUID(), newName);
396
397 handler->PSendSysMessage(LANG_RENAME_PLAYER_WITH_NEW_NAME, player->GetName(), newName);
398 }
399 else
400 {
401 if (Player* target = player->GetConnectedPlayer())
402 {
403 handler->PSendSysMessage(LANG_RENAME_PLAYER, handler->GetNameLink(target));
404 target->SetAtLoginFlag(AT_LOGIN_RENAME);
405 }
406 else
407 {
408 // check offline security
409 if (handler->HasLowerSecurity(nullptr, player->GetGUID()))
410 return false;
411
412 handler->PSendSysMessage(LANG_RENAME_PLAYER_GUID, handler->playerLink(*player), player->GetGUID().ToString());
413
415 stmt->SetData(0, uint16(AT_LOGIN_RENAME));
416 stmt->SetData(1, player->GetGUID().GetCounter());
417 CharacterDatabase.Execute(stmt);
418 }
419 }
420
421 if (reserveName)
422 {
423 sObjectMgr->AddReservedPlayerName(player->GetName());
424 }
425
426 return true;
427 }
@ 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:296
@ LANG_RENAME_PLAYER_WITH_NEW_NAME
Definition Language.h:130
@ LANG_PROFANITY_NAME
Definition Language.h:222
@ LANG_BAD_VALUE
Definition Language.h:148
@ LANG_RESERVED_NAME
Definition Language.h:207
@ LANG_RENAME_PLAYER_ALREADY_EXISTS
Definition Language.h:129
@ LANG_RENAME_PLAYER_GUID
Definition Language.h:297
#define sObjectMgr
Definition ObjectMgr.h:1650
@ AT_LOGIN_RENAME
Definition Player.h:606
ResponseCodes
Definition SharedDefines.h:3336
@ CHAR_NAME_RESERVED
Definition SharedDefines.h:3443
@ CHAR_NAME_PROFANE
Definition SharedDefines.h:3442
@ CHAR_NAME_SUCCESS
Definition SharedDefines.h:3435
bool HasLowerSecurity(Player *target, ObjectGuid guid=ObjectGuid::Empty, bool strong=false)
Definition Chat.cpp:57
static uint8 CheckPlayerName(std::string_view name, bool create=false)
Definition ObjectMgr.cpp:8605
Player session in the World.
Definition WorldSession.h:330
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
527 {
528 if (!player)
529 player = PlayerIdentifier::FromTargetOrSelf(handler);
530 if (!player || !player->IsConnected())
531 {
533 return false;
534 }
535
536 Player const* target = player->GetConnectedPlayer();
537 LocaleConstant loc = handler->GetSessionDbcLocale();
538
539 FactionStateList const& targetFSL = target->GetReputationMgr().GetStateList();
540 for (FactionStateList::const_iterator itr = targetFSL.begin(); itr != targetFSL.end(); ++itr)
541 {
542 FactionState const& faction = itr->second;
543 FactionEntry const* factionEntry = sFactionStore.LookupEntry(faction.ID);
544 char const* factionName = factionEntry ? factionEntry->name[loc] : "#Not found#";
545 ReputationRank rank = target->GetReputationMgr().GetRank(factionEntry);
546 std::string rankName = handler->GetAcoreString(ReputationRankStrIndex[rank]);
547 std::ostringstream ss;
548 if (handler->GetSession())
549 ss << faction.ID << " - |cffffffff|Hfaction:" << faction.ID << "|h[" << factionName << ' ' << localeNames[loc] << "]|h|r";
550 else
551 ss << faction.ID << " - " << factionName << ' ' << localeNames[loc];
552
553 ss << ' ' << rankName << " (" << target->GetReputationMgr().GetReputation(factionEntry) << ')';
554
555 if (faction.Flags & FACTION_FLAG_VISIBLE)
556 ss << handler->GetAcoreString(LANG_FACTION_VISIBLE);
557 if (faction.Flags & FACTION_FLAG_AT_WAR)
558 ss << handler->GetAcoreString(LANG_FACTION_ATWAR);
559 if (faction.Flags & FACTION_FLAG_PEACE_FORCED)
561 if (faction.Flags & FACTION_FLAG_HIDDEN)
562 ss << handler->GetAcoreString(LANG_FACTION_HIDDEN);
565 if (faction.Flags & FACTION_FLAG_INACTIVE)
567
568 handler->SendSysMessage(ss.str().c_str());
569 }
570
571 return true;
572 }
char const * localeNames[TOTAL_LOCALES]
Definition Common.cpp:20
LocaleConstant
Definition Common.h:65
@ 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:356
@ LANG_FACTION_ATWAR
Definition Language.h:355
@ LANG_FACTION_INVISIBLE_FORCED
Definition Language.h:358
@ LANG_FACTION_HIDDEN
Definition Language.h:357
@ LANG_FACTION_INACTIVE
Definition Language.h:359
@ LANG_FACTION_VISIBLE
Definition Language.h:354
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:179
virtual LocaleConstant GetSessionDbcLocale() const
Definition Chat.cpp:870
virtual std::string GetAcoreString(uint32 entry) const
Definition Chat.cpp:41
ReputationMgr & GetReputationMgr()
Definition Player.h:2135
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
275 {
276 if (!player)
277 player = PlayerIdentifier::FromTargetOrSelf(handler);
278
279 if (!player || !player->IsConnected())
280 {
282 return false;
283 }
284
285 Player const* target = player->GetConnectedPlayer();
286
287 LocaleConstant loc = handler->GetSessionDbcLocale();
288 std::string knownStr = handler->GetAcoreString(LANG_KNOWN);
289
290 // Search in CharTitles.dbc
291 for (uint32 id = 0; id < sCharTitlesStore.GetNumRows(); id++)
292 {
293 CharTitlesEntry const* titleInfo = sCharTitlesStore.LookupEntry(id);
294
295 if (titleInfo && target->HasTitle(titleInfo))
296 {
297 char const* name = target->getGender() == GENDER_MALE ? titleInfo->nameMale[loc] : titleInfo->nameFemale[loc];
298 if (!*name)
299 name = (target->getGender() == GENDER_MALE ? titleInfo->nameMale[sWorld->GetDefaultDbcLocale()] : titleInfo->nameFemale[sWorld->GetDefaultDbcLocale()]);
300
301 if (!*name)
302 continue;
303
304 std::string activeStr = "";
305 if (target->GetUInt32Value(PLAYER_CHOSEN_TITLE) == titleInfo->bit_index)
306 activeStr = handler->GetAcoreString(LANG_ACTIVE);
307
308 std::string titleName = Acore::StringFormat(name, player->GetName());
309
310 // send title in "id (idx:idx) - [namedlink locale]" format
311 if (handler->GetSession())
312 handler->PSendSysMessage(LANG_TITLE_LIST_CHAT, id, titleInfo->bit_index, id, titleName, localeNames[loc], knownStr, activeStr);
313 else
314 handler->PSendSysMessage(LANG_TITLE_LIST_CONSOLE, id, titleInfo->bit_index, name, localeNames[loc], knownStr, activeStr);
315 }
316 }
317
318 return true;
319 }
DBCStorage< CharTitlesEntry > sCharTitlesStore(CharTitlesEntryfmt)
@ LANG_KNOWN
Definition Language.h:63
@ LANG_TITLE_LIST_CHAT
Definition Language.h:391
@ LANG_ACTIVE
Definition Language.h:67
@ LANG_TITLE_LIST_CONSOLE
Definition Language.h:392
@ GENDER_MALE
Definition SharedDefines.h:61
@ PLAYER_CHOSEN_TITLE
Definition UpdateFields.h:324
uint32 GetUInt32Value(uint16 index) const
Definition Object.cpp:305
bool HasTitle(uint32 bitIndex) const
Definition Player.cpp:13268
uint8 getGender() const
Definition Unit.h:798
std::string StringFormat(FormatString< Args... > fmt, Args &&... args)
Default AC string format function.
Definition StringFormat.h:34
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
750 {
751 if (!player)
752 player = PlayerIdentifier::FromTargetOrSelf(handler);
753
754 if (!player)
755 return false;
756
757 uint8 oldlevel = player->IsConnected() ? player->GetConnectedPlayer()->GetLevel() : sCharacterCache->GetCharacterLevelByGuid(player->GetGUID());
758 int16 newlevel = static_cast<int16>(oldlevel) + level;
759
760 if (newlevel < 1)
761 newlevel = 1;
762
763 if (newlevel > STRONG_MAX_LEVEL) // hardcoded maximum level
764 newlevel = STRONG_MAX_LEVEL;
765
766 HandleCharacterLevel(player->GetConnectedPlayer(), player->GetGUID(), oldlevel, newlevel, handler);
767
768 if (!handler->GetSession() || (handler->GetSession()->GetPlayer() != player->GetConnectedPlayer())) // including chr == NULL
769 handler->PSendSysMessage(LANG_YOU_CHANGE_LVL, handler->playerLink(*player), newlevel);
770
771 return true;
772 }
#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
834 {
835 std::string name;
836 if (!ValidatePDumpTarget(handler, name, characterName, characterGUID))
837 return false;
838
839 std::string dump;
840 switch (PlayerDumpWriter().WriteDumpToString(dump, player.GetGUID().GetCounter()))
841 {
842 case DUMP_SUCCESS:
843 break;
846 return false;
847 case DUMP_FILE_OPEN_ERROR: // this error code should not happen
848 default:
850 return false;
851 }
852
853 switch (PlayerDumpReader().LoadDumpFromString(dump, account, name, characterGUID.value_or(0)))
854 {
855 case DUMP_SUCCESS:
856 break;
858 handler->SendErrorMessage(LANG_ACCOUNT_CHARACTER_LIST_FULL, account.GetName(), account.GetID());
859 return false;
860 case DUMP_FILE_OPEN_ERROR: // this error code should not happen
861 case DUMP_FILE_BROKEN: // this error code should not happen
862 default:
864 return false;
865 }
866
867 // Original TC Notes from Refactor vvv
868 //ToDo: use a new acore_string for this commands
870
871 return true;
872 }
@ LANG_COMMAND_EXPORT_DELETED_CHAR
Definition Language.h:920
@ LANG_COMMAND_IMPORT_FAILED
Definition Language.h:517
@ LANG_COMMAND_EXPORT_FAILED
Definition Language.h:519
@ LANG_COMMAND_IMPORT_SUCCESS
Definition Language.h:516
@ 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:774
uint32 GetID() const
Definition ChatCommandTags.h:154
std::string const & GetName() const
Definition ChatCommandTags.h:155

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

◆ HandlePDumpLoadCommand()

static bool character_commandscript::HandlePDumpLoadCommand ( ChatHandler handler,
std::string  fileName,
AccountIdentifier  account,
Optional< std::string_view >  characterName,
Optional< ObjectGuid::LowType characterGUID 
)
inlinestatic
806 {
807 std::string name;
808 if (!ValidatePDumpTarget(handler, name, characterName, characterGUID))
809 return false;
810
811 switch (PlayerDumpReader().LoadDumpFromFile(fileName, account, name, characterGUID.value_or(0)))
812 {
813 case DUMP_SUCCESS:
815 break;
817 handler->SendErrorMessage(LANG_FILE_OPEN_FAIL, fileName);
818 return false;
819 case DUMP_FILE_BROKEN:
820 handler->SendErrorMessage(LANG_DUMP_BROKEN, fileName);
821 return false;
823 handler->SendErrorMessage(LANG_ACCOUNT_CHARACTER_LIST_FULL, account.GetName(), account.GetID());
824 return false;
825 default:
827 return false;
828 }
829
830 return true;
831 }
@ LANG_DUMP_BROKEN
Definition Language.h:904
@ LANG_FILE_OPEN_FAIL
Definition Language.h:902

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
875 {
876 switch (PlayerDumpWriter().WriteDumpToFile(fileName, player.GetGUID().GetCounter()))
877 {
878 case DUMP_SUCCESS:
880 break;
882 handler->SendErrorMessage(LANG_FILE_OPEN_FAIL, fileName);
883 return false;
886 return false;
887 default:
889 return false;
890 }
891
892 return true;
893 }
@ LANG_COMMAND_EXPORT_SUCCESS
Definition Language.h:518

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
775 {
776 if (characterName)
777 {
778 name.assign(*characterName);
779 // normalize the name if specified and check if it exists
780 if (!normalizePlayerName(name))
781 {
783 return false;
784 }
785
787 {
789 return false;
790 }
791 }
792
793 if (characterGUID)
794 {
795 if (sCharacterCache->GetCharacterAccountIdByGuid(ObjectGuid(HighGuid::Player, *characterGUID)))
796 {
797 handler->SendErrorMessage(LANG_CHARACTER_GUID_IN_USE, *characterGUID);
798 return false;
799 }
800 }
801
802 return true;
803 }
@ LANG_CHARACTER_GUID_IN_USE
Definition Language.h:907
@ LANG_INVALID_CHARACTER_NAME
Definition Language.h:905

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


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