From b3686c88532a0c34d8a18453f1be7b30e58de411 Mon Sep 17 00:00:00 2001 From: Ovahlord Date: Thu, 23 May 2019 13:21:04 +0200 Subject: [PATCH] Core/Transports: optimized several places in transport code --- src/server/game/Entities/GameObject/GameObject.cpp | 6 +++++- src/server/game/Entities/Transport/Transport.cpp | 14 +++----------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/server/game/Entities/GameObject/GameObject.cpp b/src/server/game/Entities/GameObject/GameObject.cpp index 90aefbb821..a2a6500d79 100644 --- a/src/server/game/Entities/GameObject/GameObject.cpp +++ b/src/server/game/Entities/GameObject/GameObject.cpp @@ -931,7 +931,11 @@ bool GameObject::LoadFromDB(ObjectGuid::LowType spawnId, Map* map, bool addToMap m_spawnId = spawnId; m_respawnCompatibilityMode = ((data->spawnGroupData->flags & SPAWNGROUP_FLAG_COMPATIBILITY_MODE) != 0); - if (!Create(map->GenerateLowGuid(), entry, map, phaseMask, data->spawnPoint, data->rotation, animprogress, go_state, artKit, !m_respawnCompatibilityMode)) + + uint32 gameObjectType = sObjectMgr->GetGameObjectTypeByEntry(entry); + ObjectGuid::LowType lowGuid = gameObjectType == GAMEOBJECT_TYPE_TRANSPORT ? map->GenerateLowGuid() : map->GenerateLowGuid(); + + if (!Create(lowGuid, entry, map, phaseMask, data->spawnPoint, data->rotation, animprogress, go_state, artKit, !m_respawnCompatibilityMode)) return false; PhasingHandler::InitDbPhaseShift(GetPhaseShift(), data->phaseUseFlags, data->phaseId, data->phaseGroup); diff --git a/src/server/game/Entities/Transport/Transport.cpp b/src/server/game/Entities/Transport/Transport.cpp index 3f09b2690d..05f4341731 100644 --- a/src/server/game/Entities/Transport/Transport.cpp +++ b/src/server/game/Entities/Transport/Transport.cpp @@ -37,7 +37,7 @@ Transport::Transport() : GameObject(), _passengerTeleportItr(_passengers.begin()), _currentTransportTime(0), _destinationStopFrameTime(0), _alignmentTransportTime(0), _lastStopFrameTime(0), _isDynamicTransport(false), _initialRelocate(false) { - m_updateFlag |= UPDATEFLAG_TRANSPORT; + m_updateFlag |= UPDATEFLAG_TRANSPORT | UPDATEFLAG_LOWGUID | UPDATEFLAG_STATIONARY_POSITION | UPDATEFLAG_ROTATION; } Transport::~Transport() @@ -162,8 +162,6 @@ bool Transport::Create(ObjectGuid::LowType guidlow, uint32 entry, Map* map, uint if (!dynamic) SetRespawnCompatibilityMode(); - guidlow = map->GenerateLowGuid(); - if (!Transport::CreateTransport(guidlow, entry, map->GetId(), pos, animprogress)) return false; @@ -221,7 +219,6 @@ bool Transport::Create(ObjectGuid::LowType guidlow, uint32 entry, Map* map, uint SetGoState(GO_STATE_TRANSPORT_ACTIVE); SetPathProgress(pathProgress + stopTimer); - SetDestinationStopFrameTime(stopTimer); SetCurrentTransportTime(stopTimer); @@ -298,10 +295,8 @@ void Transport::Update(uint32 diff) if (IsDynamicTransport()) { - SetPathProgress(GetPathProgress() + diff); - SetCurrentTransportTime(GetCurrentTransportTime() + diff); - if (GetCurrentTransportTime() >= GetTransportPeriod()) + if (GetCurrentTransportTime() > GetTransportPeriod()) SetCurrentTransportTime(GetCurrentTransportTime() % GetTransportPeriod()); } else @@ -312,8 +307,6 @@ void Transport::Update(uint32 diff) if (GetCurrentTransportTime() == GetDestinationStopFrameTime()) return; - SetPathProgress(GetPathProgress() + diff); - // GOState has changed before previous state was reached, move to new destination immediately if (GetCurrentTransportTime() < GetDestinationStopFrameTime()) SetCurrentTransportTime(0); @@ -332,8 +325,6 @@ void Transport::Update(uint32 diff) int32 destinationTime = GetDestinationStopFrameTime(); bool backwardsMovement = destinationTime < currentTime; - SetPathProgress(GetPathProgress() + std::max(0, int32(backwardsMovement ? (diff * -1) : diff))); - if (!backwardsMovement) { // GOState has changed before previous state was reached, move to new destination immediately @@ -373,6 +364,7 @@ void Transport::Update(uint32 diff) } } + SetPathProgress(getMSTime() + GetCurrentTransportTime()); RelocateToProgress(GetCurrentTransportTime()); }