diff options
| author | Shauren <shauren.trinity@gmail.com> | 2022-05-14 20:40:24 +0200 |
|---|---|---|
| committer | Shauren <shauren.trinity@gmail.com> | 2022-05-14 20:40:24 +0200 |
| commit | 25c0aaa83fede6cd5214da00bb08a21c0b28c4be (patch) | |
| tree | 2ba5f8d0fa8f162fe2fd50b4b7e7faa89e96bf81 /src/server/game/Entities | |
| parent | 19b052d939ade28e95a6aed405a620a6ee966af8 (diff) | |
Core/Players: Allow teleporting to a specific instance id
Diffstat (limited to 'src/server/game/Entities')
| -rw-r--r-- | src/server/game/Entities/Player/Player.cpp | 18 | ||||
| -rw-r--r-- | src/server/game/Entities/Player/Player.h | 16 |
2 files changed, 25 insertions, 9 deletions
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index 73d93a994d9..9c753a87360 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -289,6 +289,9 @@ Player::Player(WorldSession* session) : Unit(true), m_sceneMgr(this) // Player summoning m_summon_expire = 0; + m_summon_instanceId = 0; + + m_recall_instanceId = 0; m_unitMovedByMe = this; m_playerMovingMe = this; @@ -1306,7 +1309,7 @@ uint8 Player::GetChatFlags() 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)) { @@ -1372,7 +1375,7 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati if (duel && GetMapId() != mapid && GetMap()->GetGameObject(m_playerData->DuelArbiter)) 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); @@ -1385,6 +1388,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; } @@ -1404,6 +1408,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()); @@ -1451,6 +1456,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; } @@ -1520,6 +1526,7 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati oldmap->RemovePlayerFromMap(this, 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) @@ -1543,9 +1550,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() @@ -25509,6 +25516,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(); WorldPackets::Movement::SummonRequest summonRequest; summonRequest.SummonerGUID = summoner->GetGUID(); @@ -25542,7 +25550,7 @@ void Player::SummonIfPossible(bool agree) UpdateCriteria(CriteriaType::AcceptSummon, 1); RemoveAurasWithInterruptFlags(SpellAuraInterruptFlags::Summon); - TeleportTo(m_summon_location); + TeleportTo(m_summon_location, 0, m_summon_instanceId); } void Player::RemoveItemDurations(Item* item) diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h index 38e49656374..72eb188b026 100644 --- a/src/server/game/Entities/Player/Player.h +++ b/src/server/game/Entities/Player/Player.h @@ -1148,8 +1148,8 @@ class TC_GAME_API Player : public Unit, public GridObject<Player> void SetObjectScale(float scale) override; - bool TeleportTo(uint32 mapid, float x, float y, float z, float orientation, uint32 options = 0); - bool TeleportTo(WorldLocation const& loc, uint32 options = 0); + bool TeleportTo(uint32 mapid, float x, float y, float z, float orientation, uint32 options = 0, Optional<uint32> instanceId = {}); + bool TeleportTo(WorldLocation const& loc, uint32 options = 0, Optional<uint32> instanceId = {}); bool TeleportToBGEntryPoint(); bool HasSummonPending() const; @@ -2194,6 +2194,7 @@ class TC_GAME_API Player : public Unit, public GridObject<Player> void SetSkillPermBonus(uint32 pos, uint16 bonus) { SetUpdateFieldValue(m_values.ModifyValue(&Player::m_activePlayerData).ModifyValue(&UF::ActivePlayerData::Skill).ModifyValue(&UF::SkillInfo::SkillPermBonus, pos), bonus); } WorldLocation& GetTeleportDest() { return m_teleport_dest; } + Optional<uint32> GetTeleportDestInstanceId() const { return m_teleport_instanceId; } uint32 GetTeleportOptions() const { return m_teleport_options; } bool IsBeingTeleported() const { return IsBeingTeleportedNear() || IsBeingTeleportedFar(); } bool IsBeingTeleportedNear() const { return mSemaphoreTeleport_Near; } @@ -2454,8 +2455,12 @@ class TC_GAME_API Player : public Unit, public GridObject<Player> uint32 GetSaveTimer() const { return m_nextSave; } void SetSaveTimer(uint32 timer) { m_nextSave = timer; } - void SaveRecallPosition() { m_recall_location.WorldRelocate(*this); } - void Recall() { TeleportTo(m_recall_location); } + void SaveRecallPosition() + { + m_recall_location.WorldRelocate(*this); + m_recall_instanceId = GetInstanceId(); + } + void Recall() { TeleportTo(m_recall_location, 0, m_recall_instanceId); } void SetHomebind(WorldLocation const& loc, uint32 areaId); void SendBindPointUpdate() const; @@ -3070,9 +3075,11 @@ class TC_GAME_API Player : public Unit, public GridObject<Player> // Player summoning time_t m_summon_expire; WorldLocation m_summon_location; + uint32 m_summon_instanceId; // Recall position WorldLocation m_recall_location; + uint32 m_recall_instanceId; DeclinedName *m_declinedname; Runes *m_runes; @@ -3124,6 +3131,7 @@ class TC_GAME_API Player : public Unit, public GridObject<Player> // Current teleport data WorldLocation m_teleport_dest; + Optional<uint32> m_teleport_instanceId; uint32 m_teleport_options; bool mSemaphoreTeleport_Near; bool mSemaphoreTeleport_Far; |
