Map/Instances: Greatly simplify PermBindAllPlayers logic. (#17940)
This commit is contained in:
1 parent
56e3e69dba
commit
226762216a
4 files changed
+21
-33
No files matched your search
@@ -3248,7 +3248,7 @@ bool InstanceMap::Reset(uint8 method)
|
||||
return m_mapRefManager.isEmpty();
|
||||
}
|
||||
|
||||
void InstanceMap::PermBindAllPlayers(Player* source)
|
||||
void InstanceMap::PermBindAllPlayers()
|
||||
{
|
||||
if (!IsDungeon())
|
||||
return;
|
||||
@@ -3256,31 +3256,36 @@ void InstanceMap::PermBindAllPlayers(Player* source)
|
||||
InstanceSave* save = sInstanceSaveMgr->GetInstanceSave(GetInstanceId());
|
||||
if (!save)
|
||||
{
|
||||
TC_LOG_ERROR("maps", "Cannot bind player (GUID: %u, Name: %s), because no instance save is available for instance map (Name: %s, Entry: %u, InstanceId: %u)!", source->GetGUID().GetCounter(), 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(), GetDifficulty(), 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->GetDifficulty());
|
||||
if (!bind || !bind->perm)
|
||||
if (bind && bind->perm)
|
||||
{
|
||||
TC_LOG_ERROR("maps", "Player (GUID: %u, 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(), GetDifficulty(), GetInstanceId(), save->GetInstanceId());
|
||||
}
|
||||
else
|
||||
{
|
||||
player->BindToInstance(save, true);
|
||||
WorldPacket data(SMSG_INSTANCE_SAVE_CREATED, 4);
|
||||
data << uint32(0);
|
||||
player->GetSession()->SendPacket(&data);
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user