diff options
author | Treeston <treeston.mmoc@gmail.com> | 2016-09-16 13:09:16 +0200 |
---|---|---|
committer | joschiwald <joschiwald.trinity@gmail.com> | 2017-02-28 20:25:20 +0100 |
commit | 9b4ad0022b2e6278f6feb9300e974db0cb8fd5d5 (patch) | |
tree | d8603c557ec1194d1ff8dcba18ebe34142e7b415 /src | |
parent | 5c28f11c750866a4d3aff69ae865f5c58727b4c5 (diff) |
Map/Instances: Greatly simplify PermBindAllPlayers logic. (#17940)
(cherry picked from commit cf628880d586b049fa376e4533154d78d02a8ce8)
Diffstat (limited to 'src')
-rw-r--r-- | src/server/game/Entities/Unit/Unit.cpp | 9 | ||||
-rw-r--r-- | src/server/game/Maps/Map.cpp | 31 | ||||
-rw-r--r-- | src/server/game/Maps/Map.h | 2 | ||||
-rw-r--r-- | src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kalecgos.cpp | 12 |
4 files changed, 21 insertions, 33 deletions
diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 6553cb5a1ca..bd104032a10 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -13123,14 +13123,7 @@ void Unit::Kill(Unit* victim, bool durabilityLoss) if (instanceMap->IsRaidOrHeroicDungeon()) { if (creature->GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_INSTANCE_BIND) - { - // if the boss killed itself we still need to bind players to the instance - if (!creditedPlayer && instanceMap->HavePlayers()) - creditedPlayer = instanceMap->GetPlayers().getFirst()->GetSource(); - - if (creditedPlayer) - ((InstanceMap*)instanceMap)->PermBindAllPlayers(creditedPlayer); - } + ((InstanceMap*)instanceMap)->PermBindAllPlayers(); } else { diff --git a/src/server/game/Maps/Map.cpp b/src/server/game/Maps/Map.cpp index b8b539ad91f..9acccfef64c 100644 --- a/src/server/game/Maps/Map.cpp +++ b/src/server/game/Maps/Map.cpp @@ -3524,7 +3524,7 @@ bool InstanceMap::Reset(uint8 method) return m_mapRefManager.isEmpty(); } -void InstanceMap::PermBindAllPlayers(Player* source) +void InstanceMap::PermBindAllPlayers() { if (!IsDungeon()) return; @@ -3532,31 +3532,36 @@ void InstanceMap::PermBindAllPlayers(Player* source) InstanceSave* save = sInstanceSaveMgr->GetInstanceSave(GetInstanceId()); if (!save) { - TC_LOG_ERROR("maps", "Cannot bind player (%s, Name: %s), because no instance save is available for instance map (Name: %s, Entry: %u, InstanceId: %u)!", source->GetGUID().ToString().c_str(), source->GetName().c_str(), source->GetMap()->GetMapName(), source->GetMapId(), GetInstanceId()); + TC_LOG_ERROR("maps", "Cannot bind players to instance map (Name: %s, Entry: %u, Difficulty: %u, ID: %u) because no instance save is available!", GetMapName(), GetId(), GetDifficultyID(), GetInstanceId()); return; } - Group* group = source->GetGroup(); - // group members outside the instance group don't get bound + // perm bind all players that are currently inside the instance for (MapRefManager::iterator itr = m_mapRefManager.begin(); itr != m_mapRefManager.end(); ++itr) { Player* player = itr->GetSource(); - // players inside an instance cannot be bound to other instances - // some players may already be permanently bound, in this case nothing happens + // never instance bind GMs with GM mode enabled + if (player->IsGameMaster()) + continue; + InstancePlayerBind* bind = player->GetBoundInstance(save->GetMapId(), save->GetDifficultyID()); - if (!bind || !bind->perm) + if (bind && bind->perm) + { + TC_LOG_ERROR("maps", "Player (GUID: " UI64FMTD ", Name: %s) is in instance map (Name: %s, Entry: %u, Difficulty: %u, ID: %u) that is being bound, but already has a save for the map on ID %u!", player->GetGUID().GetCounter(), player->GetName().c_str(), GetMapName(), GetId(), GetDifficultyID(), GetInstanceId(), save->GetInstanceId()); + } + else { player->BindToInstance(save, true); WorldPackets::Instance::InstanceSaveCreated data; data.Gm = player->IsGameMaster(); player->GetSession()->SendPacket(data.Write()); - if (!player->IsGameMaster()) - player->GetSession()->SendCalendarRaidLockout(save, true); - } + player->GetSession()->SendCalendarRaidLockout(save, true); - // if the leader is not in the instance the group will not get a perm bind - if (group && group->GetLeaderGUID() == player->GetGUID()) - group->BindToInstance(save, true); + // if group leader is in instance, group also gets bound + if (Group* group = player->GetGroup()) + if (group->GetLeaderGUID() == player->GetGUID()) + group->BindToInstance(save, true); + } } } diff --git a/src/server/game/Maps/Map.h b/src/server/game/Maps/Map.h index 3ab00c42486..5bf52ca0301 100644 --- a/src/server/game/Maps/Map.h +++ b/src/server/game/Maps/Map.h @@ -779,7 +779,7 @@ class TC_GAME_API InstanceMap : public Map InstanceScenario* GetInstanceScenario() { return i_scenario; } InstanceScenario const* GetInstanceScenario() const { return i_scenario; } void SetInstanceScenario(InstanceScenario* scenario) { i_scenario = scenario; } - void PermBindAllPlayers(Player* source); + void PermBindAllPlayers(); void UnloadAll() override; EnterState CannotEnter(Player* player) override; void SendResetWarnings(uint32 timeLeft) const; diff --git a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kalecgos.cpp b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kalecgos.cpp index c08af5ed74e..299293088ba 100644 --- a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kalecgos.cpp +++ b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kalecgos.cpp @@ -368,17 +368,7 @@ public: if (isFriendly) { me->setDeathState(JUST_DIED); - - Map::PlayerList const& players = me->GetMap()->GetPlayers(); - if (!players.isEmpty()) - { - for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr) - { - Player* player = itr->GetSource(); - if (player) - me->GetMap()->ToInstanceMap()->PermBindAllPlayers(player); - } - } + me->GetMap()->ToInstanceMap()->PermBindAllPlayers(); } else { |