mirror of
https://github.com/liyunfan1223/azerothcore-wotlk.git
synced 2026-08-09 00:08:01 +00:00
feat(Core): add argument to .character rename to add name to reserved_name (#6163)
This commit is contained in:
@@ -0,0 +1,3 @@
|
|||||||
|
INSERT INTO `version_db_world` (`sql_rev`) VALUES ('1622479207694702700');
|
||||||
|
|
||||||
|
UPDATE `command` SET `help` = 'Syntax: .character rename [$name] [reserveName]\r\n\r\nMark the character (selected in-game or with the $name argument) for rename at next login.\r\n\r\nIf [reserveName] is 1 then the player''s current name is added to the list of reserved names.' WHERE `command`.`name` = 'character rename';
|
||||||
@@ -574,4 +574,7 @@ void CharacterDatabaseConnection::DoPrepareStatements()
|
|||||||
// Recovery Item
|
// Recovery Item
|
||||||
PrepareStatement(CHAR_INS_RECOVERY_ITEM, "INSERT INTO recovery_item (Guid, ItemEntry, Count) VALUES (?, ?, ?)", CONNECTION_SYNCH);
|
PrepareStatement(CHAR_INS_RECOVERY_ITEM, "INSERT INTO recovery_item (Guid, ItemEntry, Count) VALUES (?, ?, ?)", CONNECTION_SYNCH);
|
||||||
PrepareStatement(CHAR_DEL_RECOVERY_ITEM, "DELETE FROM recovery_item WHERE Guid = ? AND ItemEntry = ? AND Count = ? ORDER BY Id DESC LIMIT 1", CONNECTION_ASYNC);
|
PrepareStatement(CHAR_DEL_RECOVERY_ITEM, "DELETE FROM recovery_item WHERE Guid = ? AND ItemEntry = ? AND Count = ? ORDER BY Id DESC LIMIT 1", CONNECTION_ASYNC);
|
||||||
|
|
||||||
|
// Character names
|
||||||
|
PrepareStatement(CHAR_INS_RESERVED_PLAYER_NAME, "INSERT IGNORE INTO reserved_name (name) VALUES (?)", CONNECTION_ASYNC);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -507,6 +507,8 @@ enum CharacterDatabaseStatements
|
|||||||
CHAR_INS_RECOVERY_ITEM,
|
CHAR_INS_RECOVERY_ITEM,
|
||||||
CHAR_DEL_RECOVERY_ITEM,
|
CHAR_DEL_RECOVERY_ITEM,
|
||||||
|
|
||||||
|
CHAR_INS_RESERVED_PLAYER_NAME,
|
||||||
|
|
||||||
MAX_CHARACTERDATABASE_STATEMENTS
|
MAX_CHARACTERDATABASE_STATEMENTS
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -7553,6 +7553,26 @@ bool ObjectMgr::IsReservedName(const std::string& name) const
|
|||||||
return _reservedNamesStore.find(wstr) != _reservedNamesStore.end();
|
return _reservedNamesStore.find(wstr) != _reservedNamesStore.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ObjectMgr::AddReservedPlayerName(std::string const& name)
|
||||||
|
{
|
||||||
|
if (!IsReservedName(name))
|
||||||
|
{
|
||||||
|
std::wstring wstr;
|
||||||
|
if (!Utf8toWStr(name, wstr))
|
||||||
|
{
|
||||||
|
LOG_ERROR("server", "Could not add invalid name to reserved player names: %s", name.c_str());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
wstrToLower(wstr);
|
||||||
|
|
||||||
|
_reservedNamesStore.insert(wstr);
|
||||||
|
|
||||||
|
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_RESERVED_PLAYER_NAME);
|
||||||
|
stmt->setString(0, name);
|
||||||
|
CharacterDatabase.Execute(stmt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
enum LanguageType
|
enum LanguageType
|
||||||
{
|
{
|
||||||
LT_BASIC_LATIN = 0x0000,
|
LT_BASIC_LATIN = 0x0000,
|
||||||
|
|||||||
@@ -1255,6 +1255,7 @@ public:
|
|||||||
// reserved names
|
// reserved names
|
||||||
void LoadReservedPlayersNames();
|
void LoadReservedPlayersNames();
|
||||||
[[nodiscard]] bool IsReservedName(std::string const& name) const;
|
[[nodiscard]] bool IsReservedName(std::string const& name) const;
|
||||||
|
void AddReservedPlayerName(std::string const& name);
|
||||||
|
|
||||||
// name with valid structure and symbols
|
// name with valid structure and symbols
|
||||||
static uint8 CheckPlayerName(std::string const& name, bool create = false);
|
static uint8 CheckPlayerName(std::string const& name, bool create = false);
|
||||||
|
|||||||
@@ -302,10 +302,20 @@ public:
|
|||||||
//rename characters
|
//rename characters
|
||||||
static bool HandleCharacterRenameCommand(ChatHandler* handler, char const* args)
|
static bool HandleCharacterRenameCommand(ChatHandler* handler, char const* args)
|
||||||
{
|
{
|
||||||
|
char* nameStr = strtok((char*)args, " ");
|
||||||
|
char* reserveNameStr = strtok(nullptr, " ");
|
||||||
|
|
||||||
|
if (!reserveNameStr && nameStr && atoi(nameStr) == 1)
|
||||||
|
{
|
||||||
|
reserveNameStr = nameStr;
|
||||||
|
nameStr = nullptr;
|
||||||
|
}
|
||||||
|
bool reserveName = reserveNameStr != nullptr && atoi(reserveNameStr) == 1;
|
||||||
|
|
||||||
Player* target;
|
Player* target;
|
||||||
ObjectGuid targetGuid;
|
ObjectGuid targetGuid;
|
||||||
std::string targetName;
|
std::string targetName;
|
||||||
if (!handler->extractPlayerTarget((char*)args, &target, &targetGuid, &targetName))
|
if (!handler->extractPlayerTarget(nameStr, &target, &targetGuid, &targetName))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (target)
|
if (target)
|
||||||
@@ -332,6 +342,11 @@ public:
|
|||||||
CharacterDatabase.Execute(stmt);
|
CharacterDatabase.Execute(stmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (reserveName)
|
||||||
|
{
|
||||||
|
sObjectMgr->AddReservedPlayerName(targetName);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user