Merge branch 'azerothcore:master' into Playerbot

This commit is contained in:
ZhengPeiRu21
2022-10-24 16:21:51 -06:00
committed by GitHub
3 changed files with 15 additions and 0 deletions

View File

@@ -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);
}

View File

@@ -106,6 +106,8 @@ namespace ObjectAccessor
template<>
void RemoveObject(Player* player);
void UpdatePlayerNameMapReference(std::string oldname, Player* player);
}
#endif

View File

@@ -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");
}