48 std::span<ChatCommandBuilder const>
GetCommands()
const override
70 {
"deleted", characterDeletedCommandTable },
80 {
"character", characterCommandTable },
82 {
"pdump", pdumpCommandTable },
110 if (!searchString.empty())
122 std::string normalizedName(searchString);
141 Field* fields = result->Fetch();
145 info.
guid = ObjectGuid::Create<HighGuid::Player>(fields[0].GetUInt64());
152 foundList.push_back(info);
154 while (result->NextRow());
179 for (DeletedInfoList::const_iterator itr = foundList.begin(); itr != foundList.end(); ++itr)
185 Trinity::ToString(itr->guid.GetCounter()), itr->name.c_str(), itr->accountName.empty() ?
"<Not existing>" : itr->accountName.c_str(),
186 itr->accountId, dateStr.c_str());
189 Trinity::ToString(itr->guid.GetCounter()), itr->name.c_str(), itr->accountName.empty() ?
"<Not existing>" : itr->accountName.c_str(),
190 itr->accountId, dateStr.c_str());
242 if (!player || !player->IsConnected())
249 Player const* target = player->GetConnectedPlayer();
259 if (titleInfo && target->
HasTitle(titleInfo))
267 char const* activeStr =
"";
287 if (!player && newNameV)
300 std::string newName{ *newNameV };
337 stmt->
setUInt64(0, player->GetGUID().GetCounter());
340 if (
Player* target = player->GetConnectedPlayer())
342 target->SetName(newName);
345 session->KickPlayer(
"HandleCharacterRenameCommand GM Command renaming character");
351 stmt->
setUInt64(1, player->GetGUID().GetCounter());
361 if (
Player* player = session->GetPlayer())
362 sLog->OutCommand(session->GetAccountId(),
"GM {} (Account: {}) forced rename {} to player {} (Account: {})", player->GetName(), session->GetAccountId(), newName, player->GetName(),
sCharacterCache->GetCharacterAccountIdByGuid(player->GetGUID()));
365 sLog->OutCommand(0,
"CONSOLE forced rename '{}' to '{}' ({})", player->GetName(), newName, player->GetGUID().ToString());
369 if (
Player* target = player->GetConnectedPlayer())
384 stmt->
setUInt64(1, player->GetGUID().GetCounter());
400 if (
Player* target = player->GetConnectedPlayer())
410 stmt->
setUInt64(1, player->GetGUID().GetCounter());
424 if (
Player* target = player->GetConnectedPlayer())
434 stmt->
setUInt64(1, player->GetGUID().GetCounter());
448 if (
Player* target = player->GetConnectedPlayer())
458 stmt->
setUInt64(1, player->GetGUID().GetCounter());
482 if (newAccount.
GetID() == oldAccountId)
495 if (
Player* onlinePlayer = player->GetConnectedPlayer())
496 onlinePlayer->GetSession()->KickPlayer(
"HandleCharacterChangeAccountCommand GM Command transferring character to another account");
500 charStmt->
setUInt64(1, player->GetGUID().GetCounter());
503 sWorld->UpdateRealmCharCount(oldAccountId);
510 std::string logString =
Trinity::StringFormat(
"changed ownership of player {} ({}) from account {} to account {}", player->GetName(), player->GetGUID().ToString(), oldAccountId, newAccount.
GetID());
513 if (
Player* player = session->GetPlayer())
514 sLog->OutCommand(session->GetAccountId(),
"GM {} (Account: {}) {}", player->GetName(), session->GetAccountId(), logString);
525 if (!player || !player->IsConnected())
532 Player const* target = player->GetConnectedPlayer();
536 for (FactionStateList::const_iterator itr = targetFSL.begin(); itr != targetFSL.end(); ++itr)
540 char const* factionName = factionEntry ? factionEntry->
Name[loc] :
"#Not found#";
542 std::ostringstream ss;
544 ss << faction.
ID <<
" - |cffffffff|Hfaction:" << faction.
ID <<
"|h[" << factionName <<
' ' <<
localeNames[loc] <<
"]|h|r";
546 ss << faction.
ID <<
" - " << factionName <<
' ' <<
localeNames[loc];
586 if (foundList.empty())
617 if (foundList.empty())
630 for (DeletedInfoList::iterator itr = foundList.begin(); itr != foundList.end(); ++itr)
635 if (foundList.size() == 1)
637 std::string newName{ *newCharName };
641 delInfo.
name = newName;
675 if (foundList.empty())
686 for (DeletedInfoList::const_iterator itr = foundList.begin(); itr != foundList.end(); ++itr)
708 keepDays =
static_cast<int32>(*days);
709 else if (keepDays <= 0)
722 accountId = target->GetSession()->GetAccountId();
723 target->GetSession()->KickPlayer(
"HandleCharacterEraseCommand GM Command deleting character");
728 std::string accountName;
744 uint8 oldlevel =
static_cast<uint8>(player->IsConnected() ? player->GetConnectedPlayer()->GetLevel() :
sCharacterCache->GetCharacterLevelByGuid(*player));
752 if (
Player* target = player->GetConnectedPlayer())
754 target->GiveLevel(
static_cast<uint8>(newlevel));
755 target->InitTalentForLevel();
760 if (oldlevel == newlevel)
762 else if (oldlevel <
static_cast<uint8>(newlevel))
773 stmt->
setUInt64(1, player->GetGUID().GetCounter());
790 uint8 oldlevel =
static_cast<uint8>(player->IsConnected() ? player->GetConnectedPlayer()->GetLevel() :
sCharacterCache->GetCharacterLevelByGuid(*player));
791 int16 newlevel =
static_cast<int16>(oldlevel) + level;
799 if (
Player* target = player->GetConnectedPlayer())
801 target->GiveLevel(
static_cast<uint8>(newlevel));
802 target->InitTalentForLevel();
807 if (oldlevel == newlevel)
809 else if (oldlevel <
static_cast<uint8>(newlevel))
820 stmt->
setUInt64(1, player->GetGUID().GetCounter());
852 switch (
PlayerDumpReader().LoadDumpFromString(dump, account, name, characterGUID.value_or(0)))
880 switch (
PlayerDumpReader().LoadDumpFromFile(fileName, account, name, characterGUID.value_or(0)))
910 name.assign(*characterName);
929 if (
sCharacterCache->GetCharacterCacheByGuid(ObjectGuid::Create<HighGuid::Player>(*characterGUID)))
@ CHAR_SEL_CHAR_DEL_INFO_BY_NAME
@ CHAR_DEL_CHAR_DECLINED_NAME
@ CHAR_SEL_CHAR_DEL_INFO_BY_GUID
@ CHAR_UPD_ACCOUNT_BY_GUID
@ CHAR_UPD_ADD_AT_LOGIN_FLAG
@ CHAR_UPD_RESTORE_DELETE_INFO
char const * localeNames[TOTAL_LOCALES]
DB2Storage< CharTitlesEntry > sCharTitlesStore("CharTitles.db2", &CharTitlesLoadInfo::Instance)
DB2Storage< FactionEntry > sFactionStore("Faction.db2", &FactionLoadInfo::Instance)
std::shared_ptr< PreparedResultSet > PreparedQueryResult
DatabaseWorkerPool< CharacterDatabaseConnection > CharacterDatabase
Accessor to the character database.
@ LANG_FACTION_PEACE_FORCED
@ LANG_CHARACTER_DELETED_SKIP_NAME
@ LANG_CHARACTER_DELETED_LIST_LINE_CHAT
@ LANG_CHARACTER_DELETED_ERR_RENAME
@ LANG_CHARACTER_DELETED_LIST_HEADER
@ LANG_CHARACTER_DELETED_LIST_LINE_CONSOLE
@ LANG_FACTION_INVISIBLE_FORCED
@ LANG_COMMAND_EXPORT_DELETED_CHAR
@ LANG_CHARACTER_GUID_IN_USE
@ LANG_CUSTOMIZE_PLAYER_GUID
@ LANG_ACCOUNT_CHARACTER_LIST_FULL
@ LANG_RENAME_PLAYER_WITH_NEW_NAME
@ LANG_CHARACTER_DELETED_RESTORE
@ LANG_COMMAND_EXPORT_SUCCESS
@ LANG_CHARACTER_DELETED_SKIP_FULL
@ LANG_CHARACTER_DELETED_LIST_EMPTY
@ LANG_CHARACTER_DELETED_LIST_BAR
@ LANG_TITLE_LIST_CONSOLE
@ LANG_COMMAND_IMPORT_FAILED
@ LANG_YOURS_LEVEL_PROGRESS_RESET
@ LANG_COMMAND_EXPORT_FAILED
@ LANG_RENAME_PLAYER_ALREADY_EXISTS
@ LANG_CHARACTER_DELETED_SKIP_ACCOUNT
@ LANG_RENAME_PLAYER_GUID
@ LANG_CHANGEACCOUNT_SUCCESS
@ LANG_INVALID_CHARACTER_NAME
@ LANG_COMMAND_IMPORT_SUCCESS
@ LANG_CHARACTER_DELETED_DELETE
bool normalizePlayerName(std::string &name)
std::optional< T > Optional
Optional helper class to wrap optional values within.
@ AT_LOGIN_CHANGE_FACTION
std::map< RepListID, FactionState > FactionStateList
std::string TimeToTimestampStr(time_t t)
static uint32 GetCharactersCount(uint32 accountId)
static bool GetName(uint32 accountId, std::string &name)
std::string playerLink(std::string const &name) const
WorldSession * GetSession()
virtual LocaleConstant GetSessionDbcLocale() const
virtual std::string GetNameLink() const
bool HasLowerSecurity(Player *target, ObjectGuid guid, bool strong=false)
static std::string PGetParseString(std::string_view fmt, Args &&... args) noexcept
void SetSentErrorMessage(bool val)
void PSendSysMessage(char const *fmt, Args &&... args)
virtual void SendSysMessage(std::string_view str, bool escapeCharacters=false)
virtual bool needReportToTarget(Player *chr) const
virtual char const * GetTrinityString(uint32 entry) const
constexpr bool HasFlag(T flag) const
Class used to access individual fields of database query result.
uint32 GetUInt32() const noexcept
std::string GetString() const noexcept
int64 GetInt64() const noexcept
LowType GetCounter() const
std::string ToString() const
static ResponseCodes CheckPlayerName(std::string_view name, LocaleConstant locale, bool create=false)
UF::UpdateField< UF::PlayerData, int32(WowCS::EntityFragment::CGObject), TYPEID_PLAYER > m_playerData
static void DeleteOldCharacters()
Gender GetNativeGender() const override
bool HasTitle(uint32 bitIndex) const
static void DeleteFromDB(ObjectGuid playerguid, uint32 accountId, bool updateRealmChars=true, bool deleteFinally=false)
ReputationMgr & GetReputationMgr()
void setUInt16(uint8 index, uint16 value)
void setString(uint8 index, std::string &&value)
void setUInt32(uint8 index, uint32 value)
void setUInt64(uint8 index, uint64 value)
void setUInt8(uint8 index, uint8 value)
std::string GetReputationRankName(FactionEntry const *factionEntry) const
FactionStateList const & GetStateList() const
int32 GetReputation(uint32 faction_id) const
Player session in the World.
Player * GetPlayer() const
static bool GetDeletedCharacterInfoList(DeletedInfoList &foundList, std::string_view searchString)
static bool HandlePDumpLoadCommand(ChatHandler *handler, std::string fileName, AccountIdentifier account, Optional< std::string_view > characterName, Optional< ObjectGuid::LowType > characterGUID)
static bool HandleCharacterDeletedDeleteCommand(ChatHandler *handler, std::string_view needle)
static bool HandleLevelUpCommand(ChatHandler *handler, Optional< PlayerIdentifier > player, int16 level)
static bool HandleCharacterDeletedRestoreCommand(ChatHandler *handler, std::string_view needle, Optional< std::string_view > const &newCharName, Optional< AccountIdentifier > const &newAccount)
static bool HandleCharacterLevelCommand(ChatHandler *handler, Optional< PlayerIdentifier > player, int16 newlevel)
static void HandleCharacterDeletedRestoreHelper(DeletedInfo const &delInfo, ChatHandler *handler)
static bool HandlePDumpCopyCommand(ChatHandler *handler, PlayerIdentifier player, AccountIdentifier account, Optional< std::string_view > characterName, Optional< ObjectGuid::LowType > characterGUID)
static bool HandleCharacterCustomizeCommand(ChatHandler *handler, Optional< PlayerIdentifier > player)
static bool HandleCharacterRenameCommand(ChatHandler *handler, Optional< PlayerIdentifier > player, Optional< std::string_view > newNameV)
static bool HandleCharacterChangeRaceCommand(ChatHandler *handler, Optional< PlayerIdentifier > player)
static bool HandleCharacterDeletedOldCommand(ChatHandler *, Optional< uint16 > days)
static bool HandleCharacterChangeAccountCommand(ChatHandler *handler, Optional< PlayerIdentifier > player, AccountIdentifier newAccount)
static bool ValidatePDumpTarget(ChatHandler *handler, std::string &name, Optional< std::string_view > characterName, Optional< ObjectGuid::LowType > characterGUID)
static bool HandleCharacterTitlesCommand(ChatHandler *handler, Optional< PlayerIdentifier > player)
character_commandscript()
static void HandleCharacterDeletedListHelper(DeletedInfoList const &foundList, ChatHandler *handler)
static bool HandlePDumpWriteCommand(ChatHandler *handler, std::string fileName, PlayerIdentifier player)
std::span< ChatCommandBuilder const > GetCommands() const override
static bool HandleCharacterReputationCommand(ChatHandler *handler, Optional< PlayerIdentifier > player)
static bool HandleCharacterEraseCommand(ChatHandler *handler, PlayerIdentifier player)
static bool HandleCharacterDeletedListCommand(ChatHandler *handler, Optional< std::string_view > const &needle)
static bool HandleCharacterChangeFactionCommand(ChatHandler *handler, Optional< PlayerIdentifier > player)
std::list< DeletedInfo > DeletedInfoList
void AddSC_character_commandscript()
@ CONFIG_CHARDELETE_KEEP_DAYS
@ CONFIG_CHARACTERS_PER_REALM
ChatCommandBuilder const [] ChatCommandTable
std::string ToString(Type &&val, Params &&... params)
std::string StringFormat(FormatString< Args... > fmt, Args &&... args) noexcept
Default TC string format function.
@ RBAC_PERM_COMMAND_CHARACTER_CHANGERACE
@ RBAC_PERM_COMMAND_PDUMP_COPY
@ RBAC_PERM_COMMAND_CHARACTER_DELETED_OLD
@ RBAC_PERM_COMMAND_LEVELUP
@ RBAC_PERM_COMMAND_CHARACTER_LEVEL
@ RBAC_PERM_COMMAND_CHARACTER_DELETED_DELETE
@ RBAC_PERM_SKIP_CHECK_CHARACTER_CREATION_RESERVEDNAME
@ RBAC_PERM_COMMAND_CHARACTER_CHANGEFACTION
@ RBAC_PERM_COMMAND_CHARACTER_TITLES
@ RBAC_PERM_COMMAND_CHARACTER_CUSTOMIZE
@ RBAC_PERM_COMMAND_CHARACTER_CHANGEACCOUNT
@ RBAC_PERM_COMMAND_CHARACTER_RENAME
@ RBAC_PERM_COMMAND_CHARACTER_ERASE
@ RBAC_PERM_COMMAND_PDUMP_LOAD
@ RBAC_PERM_COMMAND_CHARACTER_REPUTATION
@ RBAC_PERM_COMMAND_CHARACTER_DELETED_LIST
@ RBAC_PERM_COMMAND_CHARACTER_DELETED_RESTORE
@ RBAC_PERM_COMMAND_PDUMP_WRITE
EnumFlag< ReputationFlags > Flags
std::string const & GetName() const
Player * GetConnectedPlayer() const
ObjectGuid GetGUID() const
static Optional< PlayerIdentifier > FromTarget(ChatHandler *handler)
std::string const & GetName() const
static Optional< PlayerIdentifier > FromTargetOrSelf(ChatHandler *handler)
std::string name
the character name
std::string accountName
the account name
time_t deleteDate
the date at which the character has been deleted
ObjectGuid guid
the GUID from the character
uint32 accountId
the account id