diff options
author | Shauren <shauren.trinity@gmail.com> | 2023-09-19 10:59:04 +0200 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2023-09-19 10:59:04 +0200 |
commit | 47fc3cb852324119e81c01015b7cc4f39d43e559 (patch) | |
tree | 033cdd8511b6b5e46a9fdbb3a847ce43f3179180 /src/server/game/DungeonFinding/LFGMgr.cpp | |
parent | fa77874ffba8c0ce92d6d01414bd3d164506cfa5 (diff) |
Core/Instances: Kill instance_encounters table, it is no longer neccessary
Diffstat (limited to 'src/server/game/DungeonFinding/LFGMgr.cpp')
-rw-r--r-- | src/server/game/DungeonFinding/LFGMgr.cpp | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/src/server/game/DungeonFinding/LFGMgr.cpp b/src/server/game/DungeonFinding/LFGMgr.cpp index 9d990ff17f9..e99faab32c1 100644 --- a/src/server/game/DungeonFinding/LFGMgr.cpp +++ b/src/server/game/DungeonFinding/LFGMgr.cpp @@ -43,7 +43,7 @@ namespace lfg { LFGDungeonData::LFGDungeonData() : id(0), name(), map(0), type(0), expansion(0), group(0), contentTuningId(0), - difficulty(DIFFICULTY_NONE), seasonal(false), x(0.0f), y(0.0f), z(0.0f), o(0.0f), requiredItemLevel(0) + difficulty(DIFFICULTY_NONE), seasonal(false), x(0.0f), y(0.0f), z(0.0f), o(0.0f), requiredItemLevel(0), finalDungeonEncounterId(0) { } @@ -51,8 +51,10 @@ LFGDungeonData::LFGDungeonData(LFGDungeonsEntry const* dbc) : id(dbc->ID), name( type(uint8(dbc->TypeID)), expansion(uint8(dbc->ExpansionLevel)), group(uint8(dbc->GroupID)), contentTuningId(uint32(dbc->ContentTuningID)), difficulty(Difficulty(dbc->DifficultyID)), seasonal((dbc->Flags[0] & LFG_FLAG_SEASONAL) != 0), x(0.0f), y(0.0f), z(0.0f), o(0.0f), - requiredItemLevel(0) + requiredItemLevel(0), finalDungeonEncounterId(0) { + if (JournalEncounterEntry const* journalEncounter = sJournalEncounterStore.LookupEntry(dbc->FinalEncounterID)) + finalDungeonEncounterId = journalEncounter->DungeonEncounterID; } LFGMgr::LFGMgr() : m_QueueTimer(0), m_lfgProposalId(1), @@ -1440,9 +1442,33 @@ void LFGMgr::TeleportPlayer(Player* player, bool out, bool fromOpcode /*= false* } /** + Check if dungeon can be rewarded, if any. + + @param[in] gguid Group guid + @param[in] dungeonEncounterIds DungeonEncounter that was just completed + @param[in] currMap Map of the instance where encounter was completed +*/ +void LFGMgr::OnDungeonEncounterDone(ObjectGuid gguid, std::array<uint32, 4> const& dungeonEncounterIds, Map const* currMap) +{ + if (GetState(gguid) == LFG_STATE_FINISHED_DUNGEON) // Shouldn't happen. Do not reward multiple times + { + TC_LOG_DEBUG("lfg.dungeon.finish", "Group: {} already rewarded", gguid.ToString()); + return; + } + + uint32 gDungeonId = GetDungeon(gguid); + LFGDungeonData const* dungeonDone = GetLFGDungeon(gDungeonId); + // LFGDungeons can point to a DungeonEncounter from any difficulty so we need this kind of lenient check + if (std::find(dungeonEncounterIds.begin(), dungeonEncounterIds.end(), dungeonDone->finalDungeonEncounterId) == dungeonEncounterIds.end()) + return; + + FinishDungeon(gguid, gDungeonId, currMap); +} + +/** Finish a dungeon and give reward, if any. - @param[in] guid Group guid + @param[in] gguid Group guid @param[in] dungeonId Dungeonid */ void LFGMgr::FinishDungeon(ObjectGuid gguid, const uint32 dungeonId, Map const* currMap) |