Core/Players: Allow teleporting to a specific instance id

This commit is contained in:
Shauren authored and Ovahlord committed 2023-01-09 11:22:58 +01:00
1 parent ce0c09b429
commit 5f8f854794
5 files changed
+31 -13

No files matched your search

+13 -5
View File
@@ -312,6 +312,9 @@ Player::Player(WorldSession* session): Unit(true)
// Player summoning
m_summon_expire = 0;
m_summon_instanceId = 0;
m_recall_instanceId = 0;
m_seer = this;
@@ -1416,7 +1419,7 @@ uint8 Player::GetChatTag() const
return tag;
}
bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientation, uint32 options)
bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientation, uint32 options /*= 0*/, Optional<uint32> instanceId /*= {}*/)
{
if (!MapManager::IsValidMapCoord(mapid, x, y, z, orientation))
{
@@ -1481,7 +1484,7 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati
if (duel && GetMapId() != mapid && GetMap()->GetGameObject(GetGuidValue(PLAYER_DUEL_ARBITER)))
DuelComplete(DUEL_FLED);
if (GetMapId() == mapid)
if (GetMapId() == mapid && (!instanceId || GetInstanceId() == instanceId))
{
//lets reset far teleport flag if it wasn't reset during chained teleport
SetSemaphoreTeleportFar(false);
@@ -1494,6 +1497,7 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati
SetSemaphoreTeleportNear(true);
//lets save teleport destination for player
m_teleport_dest = WorldLocation(mapid, x, y, z, orientation);
m_teleport_instanceId = {};
m_teleport_options = options;
return true;
}
@@ -1510,6 +1514,7 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati
// this will be used instead of the current location in SaveToDB
m_teleport_dest = WorldLocation(mapid, x, y, z, orientation);
m_teleport_instanceId = {};
m_teleport_options = options;
SetFallInformation(0, GetPositionZ());
@@ -1571,6 +1576,7 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati
SetSemaphoreTeleportFar(true);
//lets save teleport destination for player
m_teleport_dest = WorldLocation(mapid, x, y, z, orientation);
m_teleport_instanceId = instanceId;
m_teleport_options = options;
return true;
}
@@ -1639,6 +1645,7 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati
PurgeAndApplyPendingMovementChanges(false);
m_teleport_dest = WorldLocation(mapid, x, y, z, orientation);
m_teleport_instanceId = instanceId;
m_teleport_options = options;
SetFallInformation(0, GetPositionZ());
// if the player is saved before worldportack (at logout for example)
@@ -1662,9 +1669,9 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati
return true;
}
bool Player::TeleportTo(WorldLocation const& loc, uint32 options /*= 0*/)
bool Player::TeleportTo(WorldLocation const& loc, uint32 options /*= 0*/, Optional<uint32> instanceId /*= {}*/)
{
return TeleportTo(loc.GetMapId(), loc.GetPositionX(), loc.GetPositionY(), loc.GetPositionZ(), loc.GetOrientation(), options);
return TeleportTo(loc.GetMapId(), loc.GetPositionX(), loc.GetPositionY(), loc.GetPositionZ(), loc.GetOrientation(), options, instanceId);
}
bool Player::TeleportToBGEntryPoint()
@@ -23735,6 +23742,7 @@ void Player::SendSummonRequestFrom(Unit* summoner)
m_summon_expire = GameTime::GetGameTime() + MAX_PLAYER_SUMMON_DELAY;
m_summon_location.WorldRelocate(*summoner);
m_summon_instanceId = summoner->GetInstanceId();
WorldPacket data(SMSG_SUMMON_REQUEST, 8 + 4 + 4);
data << uint64(summoner->GetGUID()); // summoner guid
@@ -23772,7 +23780,7 @@ void Player::SummonIfPossible(bool agree)
UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_ACCEPTED_SUMMONINGS, 1);
RemoveAurasWithInterruptFlags(SpellAuraInterruptFlags::Summon);
TeleportTo(m_summon_location);
TeleportTo(m_summon_location, 0, m_summon_instanceId);
}
void Player::RemoveItemDurations(Item* item)