fix(Core/Items): destroy invalid own guild/arena charters (#7211)

- Closes #6642
This commit is contained in:
UltraNix
2021-08-06 16:26:49 +02:00
committed by GitHub
parent 7bddd69c95
commit 0f6dccd98c

View File

@@ -5,6 +5,7 @@
#include "DatabaseEnv.h"
#include "Log.h"
#include "PetitionMgr.h"
#include "Player.h"
#include "QueryResult.h"
#include "Timer.h"
@@ -99,6 +100,18 @@ void PetitionMgr::RemovePetitionByOwnerAndType(ObjectGuid ownerGuid, uint8 type)
{
if (itr->second.ownerGuid == ownerGuid && (!type || type == itr->second.petitionType))
{
// Remove invalid charter item
if (type == itr->second.petitionType)
{
if (Player* owner = ObjectAccessor::FindConnectedPlayer(ownerGuid))
{
if (Item* item = owner->GetItemByGuid(itr->first))
{
owner->DestroyItem(item->GetBagSlot(), item->GetSlot(), true);
}
}
}
// remove signatures
SignatureStore.erase(itr->first);
PetitionStore.erase(itr++);