fix(Scripts/MoltenCore): Solve edge case that caused Majordomo to spawn double adds (#10076)

* fix(Scripts/MoltenCore): Remove minions from Majordomo's spawn list if they still exist

* fix domo for good
This commit is contained in:
Skjalf
2022-01-09 11:02:42 -03:00
committed by GitHub
parent 14c0b62be5
commit 2eac8fd67b

View File

@@ -127,6 +127,7 @@ struct MajordomoAddData
uint32 creatureEntry; uint32 creatureEntry;
Position spawnPos; Position spawnPos;
MajordomoAddData() { }
MajordomoAddData(ObjectGuid _guid, uint32 _creatureEntry, Position _spawnPos) : guid(_guid), creatureEntry(_creatureEntry), spawnPos(_spawnPos) { } MajordomoAddData(ObjectGuid _guid, uint32 _creatureEntry, Position _spawnPos) : guid(_guid), creatureEntry(_creatureEntry), spawnPos(_spawnPos) { }
}; };
@@ -172,7 +173,7 @@ public:
if (summon) if (summon)
{ {
static_minionsGUIDS.insert(summon->GetGUID()); static_minionsGUIDS.insert(summon->GetGUID());
majordomoSummonsData.push_back(MajordomoAddData(summon->GetGUID(), summon->GetEntry(), summon->GetPosition())); majordomoSummonsData[summon->GetGUID().GetCounter()] = MajordomoAddData(summon->GetGUID(), summon->GetEntry(), summon->GetPosition());
} }
} }
} }
@@ -197,18 +198,19 @@ public:
events.SetPhase(PHASE_COMBAT); events.SetPhase(PHASE_COMBAT);
instance->SetBossState(DATA_MAJORDOMO_EXECUTUS, NOT_STARTED); instance->SetBossState(DATA_MAJORDOMO_EXECUTUS, NOT_STARTED);
for (auto summon : majordomoSummonsData) for (auto const& summon : majordomoSummonsData)
{ {
if (ObjectAccessor::GetCreature(*me, summon.guid)) if (ObjectAccessor::GetCreature(*me, summon.second.guid))
{ {
continue; continue;
} }
if (Creature* spawn = me->SummonCreature(summon.creatureEntry, summon.spawnPos)) if (Creature* spawn = me->SummonCreature(summon.second.creatureEntry, summon.second.spawnPos))
{ {
static_minionsGUIDS.erase(summon.guid); // Erase the guid from the previous, no longer existing, spawn. static_minionsGUIDS.erase(summon.second.guid); // Erase the guid from the previous, no longer existing, spawn.
static_minionsGUIDS.insert(spawn->GetGUID()); static_minionsGUIDS.insert(spawn->GetGUID());
summon.guid = spawn->GetGUID(); majordomoSummonsData.erase(summon.second.guid.GetCounter());
majordomoSummonsData[spawn->GetGUID().GetCounter()] = MajordomoAddData(spawn->GetGUID(), spawn->GetEntry(), spawn->GetPosition());
} }
} }
} }
@@ -521,7 +523,7 @@ public:
private: private:
GuidSet static_minionsGUIDS; // contained data should be changed on encounter completion GuidSet static_minionsGUIDS; // contained data should be changed on encounter completion
GuidSet aliveMinionsGUIDS; // used for calculations GuidSet aliveMinionsGUIDS; // used for calculations
std::list<MajordomoAddData> majordomoSummonsData; std::unordered_map<uint32, MajordomoAddData> majordomoSummonsData;
}; };
bool OnGossipHello(Player* player, Creature* creature) override bool OnGossipHello(Player* player, Creature* creature) override