Core/Transports: Delayed adding transport model to next tick after teleporting to fix race conditions happening when teleporting transport happens at the same time as destination map balances its dynamic LoS tree
This commit is contained in:
1 parent
0594b1d838
commit
5c60976046
3 files changed
+20
-3
No files matched your search
@@ -143,7 +143,12 @@ void GameObject::AddToWorld()
|
||||
// The state can be changed after GameObject::Create but before GameObject::AddToWorld
|
||||
bool toggledState = GetGoType() == GAMEOBJECT_TYPE_CHEST ? getLootState() == GO_READY : (GetGoState() == GO_STATE_READY || IsTransport());
|
||||
if (m_model)
|
||||
GetMap()->InsertGameObjectModel(*m_model);
|
||||
{
|
||||
if (Transport* trans = ToTransport())
|
||||
trans->SetDelayedAddModelToMap();
|
||||
else
|
||||
GetMap()->InsertGameObjectModel(*m_model);
|
||||
}
|
||||
|
||||
EnableCollision(toggledState);
|
||||
WorldObject::AddToWorld();
|
||||
|
||||
@@ -35,7 +35,8 @@
|
||||
|
||||
Transport::Transport() : GameObject(),
|
||||
_transportInfo(NULL), _isMoving(true), _pendingStop(false),
|
||||
_triggeredArrivalEvent(false), _triggeredDepartureEvent(false), _passengerTeleportItr(_passengers.begin())
|
||||
_triggeredArrivalEvent(false), _triggeredDepartureEvent(false),
|
||||
_passengerTeleportItr(_passengers.begin()), _delayedAddModel(false)
|
||||
{
|
||||
m_updateFlag = UPDATEFLAG_TRANSPORT | UPDATEFLAG_LOWGUID | UPDATEFLAG_STATIONARY_POSITION | UPDATEFLAG_ROTATION;
|
||||
}
|
||||
@@ -186,6 +187,14 @@ void Transport::Update(uint32 diff)
|
||||
return; // Update more in new map thread
|
||||
}
|
||||
|
||||
// Add model to map after we are fully done with moving maps
|
||||
if (_delayedAddModel)
|
||||
{
|
||||
_delayedAddModel = false;
|
||||
if (m_model)
|
||||
GetMap()->InsertGameObjectModel(*m_model);
|
||||
}
|
||||
|
||||
// Set position
|
||||
_positionChangeTimer.Update(diff);
|
||||
if (_positionChangeTimer.Passed())
|
||||
@@ -625,7 +634,6 @@ bool Transport::TeleportTransport(uint32 newMapid, float x, float y, float z, fl
|
||||
}
|
||||
|
||||
Relocate(x, y, z, o);
|
||||
UpdateModelPosition();
|
||||
GetMap()->AddToMap<Transport>(this);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -95,6 +95,8 @@ class Transport : public GameObject, public TransportBase
|
||||
|
||||
void EnableMovement(bool enabled);
|
||||
|
||||
void SetDelayedAddModelToMap() { _delayedAddModel = true; }
|
||||
|
||||
TransportTemplate const* GetTransportTemplate() const { return _transportInfo; }
|
||||
|
||||
private:
|
||||
@@ -123,6 +125,8 @@ class Transport : public GameObject, public TransportBase
|
||||
PassengerSet _passengers;
|
||||
PassengerSet::iterator _passengerTeleportItr;
|
||||
PassengerSet _staticPassengers;
|
||||
|
||||
bool _delayedAddModel;
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in new issue
Block a user