Skip to content

Commit 1dff560

Browse files
authored
Fix model streaming (PR #4201)
1 parent fd955a8 commit 1dff560

File tree

5 files changed

+27
-4
lines changed

5 files changed

+27
-4
lines changed

Client/mods/deathmatch/logic/CClientObject.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,13 @@ void CClientObject::SetOrientation(const CVector& vecPosition, const CVector& ve
222222

223223
void CClientObject::ModelRequestCallback(CModelInfo* pModelInfo)
224224
{
225+
// The model loading may take a while and there's a chance of object being moved to other dimension.
226+
if (!IsVisibleInAllDimensions() && GetDimension() != m_pStreamer->GetDimension())
227+
{
228+
NotifyUnableToCreate();
229+
return;
230+
}
231+
225232
// Create our object
226233
Create();
227234
}

Client/mods/deathmatch/logic/CClientPed.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4041,6 +4041,13 @@ void CClientPed::ReCreateGameEntity()
40414041

40424042
void CClientPed::ModelRequestCallback(CModelInfo* pModelInfo)
40434043
{
4044+
// The model loading may take a while and there's a chance of ped being moved to other dimension.
4045+
if (!IsVisibleInAllDimensions() && GetDimension() != m_pStreamer->GetDimension())
4046+
{
4047+
NotifyUnableToCreate();
4048+
return;
4049+
}
4050+
40444051
// If we have a player loaded
40454052
if (m_pPlayerPed)
40464053
{

Client/mods/deathmatch/logic/CClientStreamElement.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,17 @@ class CClientStreamElement : public CClientEntity
5353
void SetStreamRow(CClientStreamSectorRow* pRow) { m_pStreamRow = pRow; }
5454
void SetStreamSector(CClientStreamSector* pSector) { m_pStreamSector = pSector; }
5555
void SetExpDistance(float fDistance) { m_fExpDistance = fDistance; }
56-
57-
CClientStreamer* m_pStreamer;
56+
5857
CClientStreamSectorRow* m_pStreamRow;
5958
CClientStreamSector* m_pStreamSector;
6059
CVector m_vecStreamPosition;
6160
float m_fExpDistance;
6261
unsigned short m_usStreamReferences, m_usStreamReferencesScript;
6362

6463
protected:
65-
bool m_bStreamedIn;
66-
bool m_bAttemptingToStreamIn;
64+
CClientStreamer* m_pStreamer;
65+
bool m_bStreamedIn;
66+
bool m_bAttemptingToStreamIn;
6767

6868
public:
6969
float m_fCachedRadius;

Client/mods/deathmatch/logic/CClientStreamer.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ class CClientStreamer
3535
std::list<CClientStreamElement*>::iterator ActiveElementsBegin() { return m_ActiveElements.begin(); }
3636
std::list<CClientStreamElement*>::iterator ActiveElementsEnd() { return m_ActiveElements.end(); }
3737

38+
std::uint16_t GetDimension() const noexcept { return m_usDimension; }
39+
3840
private:
3941
void CreateSectors(std::list<CClientStreamSectorRow*>* pList, CVector2D& vecSize, CVector2D& vecBottomLeft, CVector2D& vecTopRight);
4042
void ConnectSector(CClientStreamSector* pSector);

Client/mods/deathmatch/logic/CClientVehicle.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3084,6 +3084,13 @@ void CClientVehicle::ReCreate()
30843084

30853085
void CClientVehicle::ModelRequestCallback(CModelInfo* pModelInfo)
30863086
{
3087+
// The model loading may take a while and there's a chance of vehicle being moved to other dimension.
3088+
if (!IsVisibleInAllDimensions() && GetDimension() != m_pStreamer->GetDimension())
3089+
{
3090+
NotifyUnableToCreate();
3091+
return;
3092+
}
3093+
30873094
// Create the vehicle. The model is now loaded.
30883095
Create();
30893096
}

0 commit comments

Comments
 (0)