From 0570f2aa3bfb13d83d19081de9500c41d4964b4e Mon Sep 17 00:00:00 2001 From: hondacrx Date: Sun, 18 Mar 2018 20:13:53 -0400 Subject: [PATCH] Core/Movement: Fixed transport teleports on the same map (and teleporting on transports too) --- Source/Game/Entities/GameObject/GameObject.cs | 2 +- Source/Game/Entities/Transport.cs | 7 +++++-- Source/Game/Maps/Map.cs | 2 +- Source/Game/Network/Packets/MovementPackets.cs | 2 +- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Source/Game/Entities/GameObject/GameObject.cs b/Source/Game/Entities/GameObject/GameObject.cs index a95a85b41..44a372f6f 100644 --- a/Source/Game/Entities/GameObject/GameObject.cs +++ b/Source/Game/Entities/GameObject/GameObject.cs @@ -2734,7 +2734,7 @@ namespace Game.Entities public ObjectGuid lootingGroupLowGUID; // used to find group which is looting long m_packedRotation; Quaternion m_worldRotation; - Position m_stationaryPosition; + public Position m_stationaryPosition { get; set; } GameObjectAI m_AI; ushort _animKitId; diff --git a/Source/Game/Entities/Transport.cs b/Source/Game/Entities/Transport.cs index a2401413f..b358818c8 100644 --- a/Source/Game/Entities/Transport.cs +++ b/Source/Game/Entities/Transport.cs @@ -519,8 +519,10 @@ namespace Game.Entities public void UpdatePosition(float x, float y, float z, float o) { bool newActive = GetMap().IsGridLoaded(x, y); + Cell oldCell = new Cell(GetPositionX(), GetPositionY()); Relocate(x, y, z, o); + m_stationaryPosition.SetOrientation(o); UpdateModelPosition(); UpdatePassengerPositions(_passengers); @@ -533,7 +535,7 @@ namespace Game.Entities */ if (_staticPassengers.Empty() && newActive) // 1. and 2. LoadStaticPassengers(); - else if (!_staticPassengers.Empty() && !newActive && new Cell(x, y).DiffGrid(new Cell(GetPositionX(), GetPositionY()))) // 3. + else if (!_staticPassengers.Empty() && !newActive && oldCell.DiffGrid(new Cell(GetPositionX(), GetPositionY()))) // 3. UnloadStaticPassengers(); else UpdatePassengerPositions(_staticPassengers); @@ -632,6 +634,8 @@ namespace Game.Entities } else { + UpdatePosition(x, y, z, o); + // Teleport players, they need to know it foreach (var obj in _passengers) { @@ -651,7 +655,6 @@ namespace Game.Entities } } - UpdatePosition(x, y, z, o); return false; } } diff --git a/Source/Game/Maps/Map.cs b/Source/Game/Maps/Map.cs index 33e70031f..1c17d0ab1 100644 --- a/Source/Game/Maps/Map.cs +++ b/Source/Game/Maps/Map.cs @@ -3096,7 +3096,7 @@ namespace Game.Maps public Creature GetCreature(ObjectGuid guid) { - if (!guid.IsCreature()) + if (!guid.IsCreatureOrVehicle()) return null; return (Creature)_objectsStore.LookupByKey(guid); diff --git a/Source/Game/Network/Packets/MovementPackets.cs b/Source/Game/Network/Packets/MovementPackets.cs index 482bbcdfa..82e686f6b 100644 --- a/Source/Game/Network/Packets/MovementPackets.cs +++ b/Source/Game/Network/Packets/MovementPackets.cs @@ -545,8 +545,8 @@ namespace Game.Network.Packets _worldPacket.WriteFloat(Facing); _worldPacket.WriteUInt8(PreloadWorld); - _worldPacket.WriteBit(Vehicle.HasValue); _worldPacket.WriteBit(TransportGUID.HasValue); + _worldPacket.WriteBit(Vehicle.HasValue); _worldPacket.FlushBits(); if (Vehicle.HasValue)