mirror of
https://github.com/liyunfan1223/azerothcore-wotlk.git
synced 2026-08-08 15:58:04 +00:00
fix(Core/ObjectAcessor): Fix crash caused by forced character renames (#13527)
This commit is contained in:
@@ -100,6 +100,11 @@ namespace PlayerNameMapHolder
|
|||||||
PlayerNameMap.erase(p->GetName());
|
PlayerNameMap.erase(p->GetName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RemoveByName(std::string const& name)
|
||||||
|
{
|
||||||
|
PlayerNameMap.erase(name);
|
||||||
|
}
|
||||||
|
|
||||||
Player* Find(std::string const& name)
|
Player* Find(std::string const& name)
|
||||||
{
|
{
|
||||||
std::string charName(name);
|
std::string charName(name);
|
||||||
@@ -290,3 +295,9 @@ void ObjectAccessor::RemoveObject(Player* player)
|
|||||||
HashMapHolder<Player>::Remove(player);
|
HashMapHolder<Player>::Remove(player);
|
||||||
PlayerNameMapHolder::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<>
|
template<>
|
||||||
void RemoveObject(Player* player);
|
void RemoveObject(Player* player);
|
||||||
|
|
||||||
|
void UpdatePlayerNameMapReference(std::string oldname, Player* player);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -381,6 +381,8 @@ public:
|
|||||||
{
|
{
|
||||||
target->SetName(newName);
|
target->SetName(newName);
|
||||||
|
|
||||||
|
ObjectAccessor::UpdatePlayerNameMapReference(player->GetName(), target);
|
||||||
|
|
||||||
if (WorldSession* session = target->GetSession())
|
if (WorldSession* session = target->GetSession())
|
||||||
session->KickPlayer("HandleCharacterRenameCommand GM Command renaming character");
|
session->KickPlayer("HandleCharacterRenameCommand GM Command renaming character");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user