fix(Core/Commands): limit .character deleted list results to 50 (#25779)
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -99,14 +99,17 @@ public:
|
||||
|
||||
typedef std::list<DeletedInfo> DeletedInfoList;
|
||||
|
||||
static constexpr std::size_t MAX_DELETED_CHAR_RESULTS = 50;
|
||||
|
||||
/**
|
||||
* Collects all GUIDs (and related info) from deleted characters which are still in the database.
|
||||
*
|
||||
* @param foundList a reference to an std::list which will be filled with info data
|
||||
* @param searchString the search string which either contains a player GUID or a part fo the character-name
|
||||
* @param searchString the search string which either contains a player GUID or a part of the character-name
|
||||
* @param limitResults if true, caps results at MAX_DELETED_CHAR_RESULTS + 1 using a DB-level LIMIT
|
||||
* @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 searchString, bool limitResults = false)
|
||||
{
|
||||
PreparedQueryResult result;
|
||||
CharacterDatabasePreparedStatement* stmt = nullptr;
|
||||
@@ -125,7 +128,8 @@ public:
|
||||
if (!normalizePlayerName(searchString))
|
||||
return false;
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_DEL_INFO_BY_NAME);
|
||||
CharacterDatabaseStatements nameStmt = limitResults ? CHAR_SEL_CHAR_DEL_INFO_BY_NAME_LIMIT : CHAR_SEL_CHAR_DEL_INFO_BY_NAME;
|
||||
stmt = CharacterDatabase.GetPreparedStatement(nameStmt);
|
||||
stmt->SetData(0, searchString);
|
||||
result = CharacterDatabase.Query(stmt);
|
||||
}
|
||||
@@ -590,7 +594,7 @@ public:
|
||||
if (needleStr)
|
||||
needle.assign(*needleStr);
|
||||
DeletedInfoList foundList;
|
||||
if (!GetDeletedCharacterInfoList(foundList, needle))
|
||||
if (!GetDeletedCharacterInfoList(foundList, needle, true))
|
||||
return false;
|
||||
|
||||
// if no characters have been found, output a warning
|
||||
@@ -600,8 +604,15 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
bool truncated = foundList.size() > MAX_DELETED_CHAR_RESULTS;
|
||||
if (truncated)
|
||||
foundList.resize(MAX_DELETED_CHAR_RESULTS);
|
||||
|
||||
HandleCharacterDeletedListHelper(foundList, handler);
|
||||
|
||||
if (truncated)
|
||||
handler->SendSysMessage(LANG_CHARACTER_DELETED_LIST_LIMIT);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user