mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-15 23:20:36 +01:00
Core/Players: Allow teleporting to a specific instance id
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -75,7 +75,9 @@ void WorldSession::HandleMoveWorldportAck()
|
||||
player->m_InstanceValid = true;
|
||||
|
||||
Map* oldMap = player->GetMap();
|
||||
Map* newMap = sMapMgr->CreateMap(loc.GetMapId(), player);
|
||||
Map* newMap = GetPlayer()->GetTeleportDestInstanceId() ?
|
||||
sMapMgr->FindMap(loc.GetMapId(), *GetPlayer()->GetTeleportDestInstanceId()) :
|
||||
sMapMgr->CreateMap(loc.GetMapId(), GetPlayer());
|
||||
|
||||
if (player->IsInWorld())
|
||||
{
|
||||
|
||||
@@ -250,7 +250,7 @@ public:
|
||||
// before GM
|
||||
float x, y, z;
|
||||
gmPlayer->GetClosePoint(x, y, z, player->GetCombatReach());
|
||||
player->TeleportTo(gmPlayer->GetMapId(), x, y, z, player->GetOrientation());
|
||||
player->TeleportTo(gmPlayer->GetMapId(), x, y, z, player->GetOrientation(), 0, gmPlayer->GetInstanceId());
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -454,7 +454,7 @@ public:
|
||||
float x, y, z;
|
||||
target->GetClosePoint(x, y, z, _player->GetCombatReach(), 1.0f);
|
||||
|
||||
_player->TeleportTo(target->GetMapId(), x, y, z, _player->GetAbsoluteAngle(target), TELE_TO_GM_MODE);
|
||||
_player->TeleportTo(target->GetMapId(), x, y, z, _player->GetAbsoluteAngle(target), TELE_TO_GM_MODE, target->GetInstanceId());
|
||||
PhasingHandler::InheritPhaseShift(_player, target);
|
||||
_player->UpdateObjectVisibility();
|
||||
}
|
||||
@@ -578,7 +578,7 @@ public:
|
||||
// before GM
|
||||
float x, y, z;
|
||||
_player->GetClosePoint(x, y, z, target->GetCombatReach());
|
||||
target->TeleportTo(_player->GetMapId(), x, y, z, target->GetOrientation());
|
||||
target->TeleportTo(_player->GetMapId(), x, y, z, target->GetOrientation(), 0, map->GetInstanceId());
|
||||
PhasingHandler::InheritPhaseShift(target, _player);
|
||||
target->UpdateObjectVisibility();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user