From eaa4ac74e9a08feabc5d5ed39fae7eb2d3148dff Mon Sep 17 00:00:00 2001 From: Shauren Date: Mon, 4 May 2026 18:43:11 +0200 Subject: [PATCH] Core/Commands: FIx .character deleted commands outputting full guid strings instead of just counters (full guids cannot be used as input for other .character deleted commands) --- .../world/master/2026_05_04_00_world.sql | 1 + src/server/scripts/Commands/cs_character.cpp | 38 +++++++++---------- 2 files changed, 20 insertions(+), 19 deletions(-) create mode 100644 sql/updates/world/master/2026_05_04_00_world.sql diff --git a/sql/updates/world/master/2026_05_04_00_world.sql b/sql/updates/world/master/2026_05_04_00_world.sql new file mode 100644 index 0000000000..7a7d091d89 --- /dev/null +++ b/sql/updates/world/master/2026_05_04_00_world.sql @@ -0,0 +1 @@ +UPDATE `trinity_string` SET `content_default`='| %10s | %20s | %15s (%10u) | %19s |' WHERE `entry`=1017; diff --git a/src/server/scripts/Commands/cs_character.cpp b/src/server/scripts/Commands/cs_character.cpp index 46a212288e..1c65c2079e 100644 --- a/src/server/scripts/Commands/cs_character.cpp +++ b/src/server/scripts/Commands/cs_character.cpp @@ -103,7 +103,7 @@ public: * @param searchString the search string which either contains a player GUID or a part fo the character-name * @return returns false if there was a problem while selecting the characters (e.g. player name not normalizeable) */ - static bool GetDeletedCharacterInfoList(DeletedInfoList& foundList, std::string& searchString) + static bool GetDeletedCharacterInfoList(DeletedInfoList& foundList, std::string_view searchString) { PreparedQueryResult result; CharacterDatabasePreparedStatement* stmt; @@ -119,11 +119,12 @@ public: // search by name else { - if (!normalizePlayerName(searchString)) + std::string normalizedName(searchString); + if (!normalizePlayerName(normalizedName)) return false; stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_DEL_INFO_BY_NAME); - stmt->setString(0, searchString); + stmt->setString(0, normalizedName); result = CharacterDatabase.Query(stmt); } } @@ -181,11 +182,11 @@ public: if (!handler->GetSession()) handler->PSendSysMessage(LANG_CHARACTER_DELETED_LIST_LINE_CONSOLE, - itr->guid.ToString().c_str(), itr->name.c_str(), itr->accountName.empty() ? "" : itr->accountName.c_str(), + Trinity::ToString(itr->guid.GetCounter()), itr->name.c_str(), itr->accountName.empty() ? "" : itr->accountName.c_str(), itr->accountId, dateStr.c_str()); else handler->PSendSysMessage(LANG_CHARACTER_DELETED_LIST_LINE_CHAT, - itr->guid.ToString().c_str(), itr->name.c_str(), itr->accountName.empty() ? "" : itr->accountName.c_str(), + Trinity::ToString(itr->guid.GetCounter()), itr->name.c_str(), itr->accountName.empty() ? "" : itr->accountName.c_str(), itr->accountId, dateStr.c_str()); } @@ -207,7 +208,7 @@ public: { if (delInfo.accountName.empty()) // account does not exist { - handler->PSendSysMessage(LANG_CHARACTER_DELETED_SKIP_ACCOUNT, delInfo.name.c_str(), delInfo.guid.ToString().c_str(), delInfo.accountId); + handler->PSendSysMessage(LANG_CHARACTER_DELETED_SKIP_ACCOUNT, delInfo.name.c_str(), Trinity::ToString(delInfo.guid.GetCounter()), delInfo.accountId); return; } @@ -215,13 +216,13 @@ public: uint32 charcount = AccountMgr::GetCharactersCount(delInfo.accountId); if (charcount >= sWorld->getIntConfig(CONFIG_CHARACTERS_PER_REALM)) { - handler->PSendSysMessage(LANG_CHARACTER_DELETED_SKIP_FULL, delInfo.name.c_str(), delInfo.guid.ToString().c_str(), delInfo.accountId); + handler->PSendSysMessage(LANG_CHARACTER_DELETED_SKIP_FULL, delInfo.name.c_str(), Trinity::ToString(delInfo.guid.GetCounter()), delInfo.accountId); return; } if (!sCharacterCache->GetCharacterGuidByName(delInfo.name).IsEmpty()) { - handler->PSendSysMessage(LANG_CHARACTER_DELETED_SKIP_NAME, delInfo.name.c_str(), delInfo.guid.ToString().c_str(), delInfo.accountId); + handler->PSendSysMessage(LANG_CHARACTER_DELETED_SKIP_NAME, delInfo.name.c_str(), Trinity::ToString(delInfo.guid.GetCounter()), delInfo.accountId); return; } @@ -573,15 +574,12 @@ public: * @see HandleCharacterDeletedDeleteCommand * @see DeletedInfoList * - * @param args the search string which either contains a player GUID or a part fo the character-name + * @param needle the search string which either contains a player GUID or a part fo the character-name */ - static bool HandleCharacterDeletedListCommand(ChatHandler* handler, Optional needleStr) + static bool HandleCharacterDeletedListCommand(ChatHandler* handler, Optional const& needle) { - std::string needle; - if (needleStr) - needle.assign(*needleStr); DeletedInfoList foundList; - if (!GetDeletedCharacterInfoList(foundList, needle)) + if (!GetDeletedCharacterInfoList(foundList, needle.value_or(""sv))) return false; // if no characters have been found, output a warning @@ -606,9 +604,11 @@ public: * @see HandleCharacterDeletedListCommand * @see HandleCharacterDeletedDeleteCommand * - * @param args the search string which either contains a player GUID or a part of the character-name + * @param needle the search string which either contains a player GUID or a part of the character-name + * @param newCharName new character name after restoring + * @param newAccount account to attach restored character to */ - static bool HandleCharacterDeletedRestoreCommand(ChatHandler* handler, std::string needle, Optional newCharName, Optional newAccount) + static bool HandleCharacterDeletedRestoreCommand(ChatHandler* handler, std::string_view needle, Optional const& newCharName, Optional const& newAccount) { DeletedInfoList foundList; if (!GetDeletedCharacterInfoList(foundList, needle)) @@ -664,9 +664,9 @@ public: * @see HandleCharacterDeletedListCommand * @see HandleCharacterDeletedRestoreCommand * - * @param args the search string which either contains a player GUID or a part fo the character-name + * @param needle the search string which either contains a player GUID or a part fo the character-name */ - static bool HandleCharacterDeletedDeleteCommand(ChatHandler* handler, std::string needle) + static bool HandleCharacterDeletedDeleteCommand(ChatHandler* handler, std::string_view needle) { DeletedInfoList foundList; if (!GetDeletedCharacterInfoList(foundList, needle)) @@ -698,7 +698,7 @@ public: * @see HandleCharacterDeletedListCommand * @see HandleCharacterDeletedRestoreCommand * - * @param args the search string which either contains a player GUID or a part fo the character-name + * @param days removes characters deleted more than this many days ago */ static bool HandleCharacterDeletedOldCommand(ChatHandler* /*handler*/, Optional days) {