diff --git a/Client/mods/deathmatch/logic/CClientObject.cpp b/Client/mods/deathmatch/logic/CClientObject.cpp index de1cdaad50c..8137a191a2e 100644 --- a/Client/mods/deathmatch/logic/CClientObject.cpp +++ b/Client/mods/deathmatch/logic/CClientObject.cpp @@ -222,6 +222,13 @@ void CClientObject::SetOrientation(const CVector& vecPosition, const CVector& ve void CClientObject::ModelRequestCallback(CModelInfo* pModelInfo) { + // The model loading may take a while and there's a chance of object being moved to other dimension. + if (!IsVisibleInAllDimensions() && GetDimension() != m_pStreamer->GetDimension()) + { + NotifyUnableToCreate(); + return; + } + // Create our object Create(); } diff --git a/Client/mods/deathmatch/logic/CClientPed.cpp b/Client/mods/deathmatch/logic/CClientPed.cpp index 6b6c4190f2c..666bc9d94d1 100644 --- a/Client/mods/deathmatch/logic/CClientPed.cpp +++ b/Client/mods/deathmatch/logic/CClientPed.cpp @@ -4041,6 +4041,13 @@ void CClientPed::ReCreateGameEntity() void CClientPed::ModelRequestCallback(CModelInfo* pModelInfo) { + // The model loading may take a while and there's a chance of ped being moved to other dimension. + if (!IsVisibleInAllDimensions() && GetDimension() != m_pStreamer->GetDimension()) + { + NotifyUnableToCreate(); + return; + } + // If we have a player loaded if (m_pPlayerPed) { diff --git a/Client/mods/deathmatch/logic/CClientStreamElement.h b/Client/mods/deathmatch/logic/CClientStreamElement.h index 57eed53a90e..eb3ae101d17 100644 --- a/Client/mods/deathmatch/logic/CClientStreamElement.h +++ b/Client/mods/deathmatch/logic/CClientStreamElement.h @@ -53,8 +53,7 @@ class CClientStreamElement : public CClientEntity void SetStreamRow(CClientStreamSectorRow* pRow) { m_pStreamRow = pRow; } void SetStreamSector(CClientStreamSector* pSector) { m_pStreamSector = pSector; } void SetExpDistance(float fDistance) { m_fExpDistance = fDistance; } - - CClientStreamer* m_pStreamer; + CClientStreamSectorRow* m_pStreamRow; CClientStreamSector* m_pStreamSector; CVector m_vecStreamPosition; @@ -62,8 +61,9 @@ class CClientStreamElement : public CClientEntity unsigned short m_usStreamReferences, m_usStreamReferencesScript; protected: - bool m_bStreamedIn; - bool m_bAttemptingToStreamIn; + CClientStreamer* m_pStreamer; + bool m_bStreamedIn; + bool m_bAttemptingToStreamIn; public: float m_fCachedRadius; diff --git a/Client/mods/deathmatch/logic/CClientStreamer.h b/Client/mods/deathmatch/logic/CClientStreamer.h index da690293871..9e81fedbdfe 100644 --- a/Client/mods/deathmatch/logic/CClientStreamer.h +++ b/Client/mods/deathmatch/logic/CClientStreamer.h @@ -35,6 +35,8 @@ class CClientStreamer std::list::iterator ActiveElementsBegin() { return m_ActiveElements.begin(); } std::list::iterator ActiveElementsEnd() { return m_ActiveElements.end(); } + std::uint16_t GetDimension() const noexcept { return m_usDimension; } + private: void CreateSectors(std::list* pList, CVector2D& vecSize, CVector2D& vecBottomLeft, CVector2D& vecTopRight); void ConnectSector(CClientStreamSector* pSector); diff --git a/Client/mods/deathmatch/logic/CClientVehicle.cpp b/Client/mods/deathmatch/logic/CClientVehicle.cpp index 3e135186014..1aab6442188 100644 --- a/Client/mods/deathmatch/logic/CClientVehicle.cpp +++ b/Client/mods/deathmatch/logic/CClientVehicle.cpp @@ -3084,6 +3084,13 @@ void CClientVehicle::ReCreate() void CClientVehicle::ModelRequestCallback(CModelInfo* pModelInfo) { + // The model loading may take a while and there's a chance of vehicle being moved to other dimension. + if (!IsVisibleInAllDimensions() && GetDimension() != m_pStreamer->GetDimension()) + { + NotifyUnableToCreate(); + return; + } + // Create the vehicle. The model is now loaded. Create(); }