diff options
| author | Shauren <shauren.trinity@gmail.com> | 2020-01-11 12:49:50 +0100 |
|---|---|---|
| committer | Shauren <shauren.trinity@gmail.com> | 2022-10-04 00:19:38 +0200 |
| commit | ddd0c7b152d65b980db0cc2d00f15ae62a602936 (patch) | |
| tree | 475eeed3e0e514cd480e87133a590dd0de4c2064 /src/server/game/Groups | |
| parent | 76be303351ae398b7f9e69e4c472cb5b05fce45e (diff) | |
Core/Instances: Reimplement resetting instances from UI
Diffstat (limited to 'src/server/game/Groups')
| -rw-r--r-- | src/server/game/Groups/Group.cpp | 40 | ||||
| -rw-r--r-- | src/server/game/Groups/Group.h | 4 |
2 files changed, 29 insertions, 15 deletions
diff --git a/src/server/game/Groups/Group.cpp b/src/server/game/Groups/Group.cpp index c799212b059..11f07340955 100644 --- a/src/server/game/Groups/Group.cpp +++ b/src/server/game/Groups/Group.cpp @@ -481,12 +481,6 @@ bool Group::AddMember(Player* player) if (!IsLeader(player->GetGUID()) && !isBGGroup() && !isBFGroup()) { - // reset the new member's instances, unless he is currently in one of them - // including raid/heroic instances that they are not permanently bound to! - player->ResetInstances(INSTANCE_RESET_GROUP_JOIN, false, false); - player->ResetInstances(INSTANCE_RESET_GROUP_JOIN, true, false); - player->ResetInstances(INSTANCE_RESET_GROUP_JOIN, true, true); - if (player->GetDungeonDifficultyID() != GetDungeonDifficultyID()) { player->SetDungeonDifficultyID(GetDungeonDifficultyID()); @@ -768,15 +762,11 @@ void Group::Disband(bool hideDestroy /* = false */) stmt->setUInt32(0, m_dbStoreId); trans->Append(stmt); - CharacterDatabase.CommitTransaction(trans); - - ResetInstances(INSTANCE_RESET_GROUP_DISBAND, false, false, nullptr); - ResetInstances(INSTANCE_RESET_GROUP_DISBAND, true, false, nullptr); - ResetInstances(INSTANCE_RESET_GROUP_DISBAND, true, true, nullptr); - stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_LFG_DATA); stmt->setUInt32(0, m_dbStoreId); - CharacterDatabase.Execute(stmt); + trans->Append(stmt); + + CharacterDatabase.CommitTransaction(trans); sGroupMgr->FreeGroupDbStoreId(this); } @@ -1359,8 +1349,30 @@ Difficulty Group::GetDifficultyID(MapEntry const* mapEntry) const return m_raidDifficulty; } -void Group::ResetInstances(InstanceResetMethod /*method*/, bool /*isRaid*/, bool /*isLegacy*/, Player* /*SendMsgTo*/) +void Group::ResetInstances(InstanceResetMethod method, Player* notifyPlayer) { + for (GroupInstanceReference& ref : m_ownedInstancesMgr) + { + InstanceMap* map = ref.GetSource(); + switch (map->Reset(method)) + { + case InstanceResetResult::Success: + notifyPlayer->SendResetInstanceSuccess(map->GetId()); + m_recentInstances.erase(map->GetId()); + break; + case InstanceResetResult::NotEmpty: + if (method == InstanceResetMethod::Manual) + notifyPlayer->SendResetInstanceFailed(INSTANCE_RESET_FAILED, map->GetId()); + else if (method == InstanceResetMethod::OnChangeDifficulty) + m_recentInstances.erase(map->GetId()); // map might not have been reset on difficulty change but we still don't want to zone in there again + break; + case InstanceResetResult::CannotReset: + m_recentInstances.erase(map->GetId()); // forget the instance, allows retrying different lockout with a new leader + break; + default: + break; + } + } } void Group::LinkOwnedInstance(GroupInstanceReference* ref) diff --git a/src/server/game/Groups/Group.h b/src/server/game/Groups/Group.h index 58b27fb459b..3b565aa9c6c 100644 --- a/src/server/game/Groups/Group.h +++ b/src/server/game/Groups/Group.h @@ -41,6 +41,8 @@ class WorldSession; struct ItemDisenchantLootEntry; struct MapEntry; +enum class InstanceResetMethod : uint8; +enum class InstanceResetResult : uint8; enum LootMethod : uint8; #define MAX_GROUP_SIZE 5 @@ -304,7 +306,7 @@ class TC_GAME_API Group Difficulty GetDungeonDifficultyID() const { return m_dungeonDifficulty; } Difficulty GetRaidDifficultyID() const { return m_raidDifficulty; } Difficulty GetLegacyRaidDifficultyID() const { return m_legacyRaidDifficulty; } - void ResetInstances(InstanceResetMethod method, bool isRaid, bool isLegacy, Player* SendMsgTo); + void ResetInstances(InstanceResetMethod method, Player* notifyPlayer); // -no description- //void SendInit(WorldSession* session); |
