Core/Transports: optimized several places in transport code
This commit is contained in:
1 parent
473a6e8128
commit
b3686c8853
2 files changed
+8
-12
No files matched your search
@@ -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<HighGuid::GameObject>(), 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<HighGuid::Transport>() : map->GenerateLowGuid<HighGuid::GameObject>();
|
||||
|
||||
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);
|
||||
|
||||
@@ -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<HighGuid::Transport>();
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user