fix(Core/ObjectAcessor): Fix crash caused by forced character renames (#13527)
This commit is contained in:
parent
c54d56c7d0
commit
e55d7cb951
3 changed files with 15 additions and 0 deletions
|
|
@ -100,6 +100,11 @@ namespace PlayerNameMapHolder
|
|||
PlayerNameMap.erase(p->GetName());
|
||||
}
|
||||
|
||||
void RemoveByName(std::string const& name)
|
||||
{
|
||||
PlayerNameMap.erase(name);
|
||||
}
|
||||
|
||||
Player* Find(std::string const& name)
|
||||
{
|
||||
std::string charName(name);
|
||||
|
|
@ -290,3 +295,9 @@ void ObjectAccessor::RemoveObject(Player* player)
|
|||
HashMapHolder<Player>::Remove(player);
|
||||
PlayerNameMapHolder::Remove(player);
|
||||
}
|
||||
|
||||
void ObjectAccessor::UpdatePlayerNameMapReference(std::string oldname, Player* player)
|
||||
{
|
||||
PlayerNameMapHolder::RemoveByName(oldname);
|
||||
PlayerNameMapHolder::Insert(player);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -106,6 +106,8 @@ namespace ObjectAccessor
|
|||
|
||||
template<>
|
||||
void RemoveObject(Player* player);
|
||||
|
||||
void UpdatePlayerNameMapReference(std::string oldname, Player* player);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -381,6 +381,8 @@ public:
|
|||
{
|
||||
target->SetName(newName);
|
||||
|
||||
ObjectAccessor::UpdatePlayerNameMapReference(player->GetName(), target);
|
||||
|
||||
if (WorldSession* session = target->GetSession())
|
||||
session->KickPlayer("HandleCharacterRenameCommand GM Command renaming character");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue