fix(Core): fix chests not despawning when opened in group (2) (#5387)
* fix(Core): fix chests not despawning when opened in group * fix(Core): fix crashes in pr #5371 * Replaced nullptr checks * Used if with initializer instead of separate scope
This commit is contained in:
@@ -58,6 +58,7 @@ GameObject::GameObject() : WorldObject(false), MovableMapObject(),
|
|||||||
m_lootGenerationTime = 0;
|
m_lootGenerationTime = 0;
|
||||||
|
|
||||||
ResetLootMode(); // restore default loot mode
|
ResetLootMode(); // restore default loot mode
|
||||||
|
loot.sourceGameObject = this;
|
||||||
m_stationaryPosition.Relocate(0.0f, 0.0f, 0.0f, 0.0f);
|
m_stationaryPosition.Relocate(0.0f, 0.0f, 0.0f, 0.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1493,6 +1493,16 @@ void Group::CountTheRoll(Rolls::iterator rollI, Map* allowedMap)
|
|||||||
item->is_blocked = false;
|
item->is_blocked = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Loot* loot = roll->getLoot(); loot && loot->isLooted() && loot->sourceGameObject)
|
||||||
|
{
|
||||||
|
const GameObjectTemplate* goInfo = loot->sourceGameObject->GetGOInfo();
|
||||||
|
if (goInfo && goInfo->type == GAMEOBJECT_TYPE_CHEST)
|
||||||
|
{
|
||||||
|
// Deactivate chest if the last item was rolled in group
|
||||||
|
loot->sourceGameObject->SetLootState(GO_JUST_DEACTIVATED);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
RollId.erase(rollI);
|
RollId.erase(rollI);
|
||||||
delete roll;
|
delete roll;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -111,6 +111,7 @@ enum LootSlotType
|
|||||||
class Player;
|
class Player;
|
||||||
class LootStore;
|
class LootStore;
|
||||||
class ConditionMgr;
|
class ConditionMgr;
|
||||||
|
class GameObject;
|
||||||
struct Loot;
|
struct Loot;
|
||||||
|
|
||||||
struct LootStoreItem
|
struct LootStoreItem
|
||||||
@@ -313,6 +314,7 @@ struct Loot
|
|||||||
|
|
||||||
// GUID of container that holds this loot (item_instance.entry), set for items that can be looted
|
// GUID of container that holds this loot (item_instance.entry), set for items that can be looted
|
||||||
ObjectGuid containerGUID;
|
ObjectGuid containerGUID;
|
||||||
|
GameObject* sourceGameObject{nullptr};
|
||||||
|
|
||||||
Loot(uint32 _gold = 0) : gold(_gold) { }
|
Loot(uint32 _gold = 0) : gold(_gold) { }
|
||||||
~Loot() { clear(); }
|
~Loot() { clear(); }
|
||||||
|
|||||||
Reference in New Issue
Block a user