Skip to content

Commit

Permalink
Fixed #8714 (Vehicle door/component desync on vehicle stream-in/out)
Browse files Browse the repository at this point in the history
  • Loading branch information
sbx320 authored and ccw808 committed Jan 8, 2016
1 parent 1f65b46 commit 65a5578
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 13 deletions.
41 changes: 28 additions & 13 deletions MTA10/mods/shared_logic/CClientVehicle.cpp
Expand Up @@ -171,6 +171,9 @@ CClientVehicle::CClientVehicle ( CClientManager* pManager, ElementID ID, unsigne

// reset our fall through map count
m_ucFellThroughMapCount = 1;

// We've not yet been streamed in
m_bJustStreamedIn = false;
}


Expand Down Expand Up @@ -2259,6 +2262,28 @@ void CClientVehicle::StreamedInPulse ( void )
// Make sure the vehicle doesn't go too far down
if ( m_pVehicle )
{
if ( m_bJustStreamedIn )
{
// Apply door & panel states. This cannot be done in Create()
// due to issues upon setting the visibility of new RwFrames

// Does this car have a damage model?
if ( HasDamageModel( ) )
{
// Set the damage model doors
CDamageManager* pDamageManager = m_pVehicle->GetDamageManager( );

for ( int i = 0; i < MAX_DOORS; i++ )
pDamageManager->SetDoorStatus( static_cast < eDoors > ( i ), m_ucDoorStates[i] );
for ( int i = 0; i < MAX_PANELS; i++ )
pDamageManager->SetPanelStatus( static_cast < ePanels > ( i ), m_ucPanelStates[i] );
for ( int i = 0; i < MAX_LIGHTS; i++ )
pDamageManager->SetLightStatus( static_cast < eLights > ( i ), m_ucLightStates[i] );
}

m_bJustStreamedIn = false;
}

if ( m_bBlowNextFrame )
{
Blow ( false );
Expand Down Expand Up @@ -2752,19 +2777,6 @@ void CClientVehicle::Create ( void )
m_pVehicle->SetTurretRotation ( m_fTurretHorizontal, m_fTurretVertical );
}

// Does this car have a damage model?
if ( HasDamageModel () )
{
// Set the damage model doors
CDamageManager* pDamageManager = m_pVehicle->GetDamageManager ();

for ( int i = 0; i < MAX_DOORS; i++ )
pDamageManager->SetDoorStatus ( static_cast < eDoors > ( i ), m_ucDoorStates [i] );
for ( int i = 0; i < MAX_PANELS; i++ )
pDamageManager->SetPanelStatus ( static_cast < ePanels > ( i ), m_ucPanelStates [i] );
for ( int i = 0; i < MAX_LIGHTS; i++ )
pDamageManager->SetLightStatus ( static_cast < eLights > ( i ), m_ucLightStates [i] );
}
for ( int i = 0; i < MAX_WHEELS; i++ )
SetWheelStatus ( i, m_ucWheelStates [i], true );

Expand Down Expand Up @@ -2924,6 +2936,9 @@ void CClientVehicle::Create ( void )
// store our spawn position in case we fall through the map
m_matCreate = m_Matrix;

// We've just been streamed in
m_bJustStreamedIn = true;

// Tell the streamer we've created this object
NotifyCreate ();
}
Expand Down
1 change: 1 addition & 0 deletions MTA10/mods/shared_logic/CClientVehicle.h
Expand Up @@ -600,6 +600,7 @@ class CClientVehicle : public CClientStreamElement
float m_fTrainSpeed;
float m_fTrainPosition;
uchar m_ucTrackID;
bool m_bJustStreamedIn;

// Time dependent error compensation interpolation
struct
Expand Down

0 comments on commit 65a5578

Please sign in to comment.