@@ -171,6 +171,9 @@ CClientVehicle::CClientVehicle ( CClientManager* pManager, ElementID ID, unsigne
171171
172172 // reset our fall through map count
173173 m_ucFellThroughMapCount = 1 ;
174+
175+ // We've not yet been streamed in
176+ m_bJustStreamedIn = false ;
174177}
175178
176179
@@ -2259,6 +2262,28 @@ void CClientVehicle::StreamedInPulse ( void )
22592262 // Make sure the vehicle doesn't go too far down
22602263 if ( m_pVehicle )
22612264 {
2265+ if ( m_bJustStreamedIn )
2266+ {
2267+ // Apply door & panel states. This cannot be done in Create()
2268+ // due to issues upon setting the visibility of new RwFrames
2269+
2270+ // Does this car have a damage model?
2271+ if ( HasDamageModel ( ) )
2272+ {
2273+ // Set the damage model doors
2274+ CDamageManager* pDamageManager = m_pVehicle->GetDamageManager ( );
2275+
2276+ for ( int i = 0 ; i < MAX_DOORS; i++ )
2277+ pDamageManager->SetDoorStatus ( static_cast < eDoors > ( i ), m_ucDoorStates[i] );
2278+ for ( int i = 0 ; i < MAX_PANELS; i++ )
2279+ pDamageManager->SetPanelStatus ( static_cast < ePanels > ( i ), m_ucPanelStates[i] );
2280+ for ( int i = 0 ; i < MAX_LIGHTS; i++ )
2281+ pDamageManager->SetLightStatus ( static_cast < eLights > ( i ), m_ucLightStates[i] );
2282+ }
2283+
2284+ m_bJustStreamedIn = false ;
2285+ }
2286+
22622287 if ( m_bBlowNextFrame )
22632288 {
22642289 Blow ( false );
@@ -2752,19 +2777,6 @@ void CClientVehicle::Create ( void )
27522777 m_pVehicle->SetTurretRotation ( m_fTurretHorizontal, m_fTurretVertical );
27532778 }
27542779
2755- // Does this car have a damage model?
2756- if ( HasDamageModel () )
2757- {
2758- // Set the damage model doors
2759- CDamageManager* pDamageManager = m_pVehicle->GetDamageManager ();
2760-
2761- for ( int i = 0 ; i < MAX_DOORS; i++ )
2762- pDamageManager->SetDoorStatus ( static_cast < eDoors > ( i ), m_ucDoorStates [i] );
2763- for ( int i = 0 ; i < MAX_PANELS; i++ )
2764- pDamageManager->SetPanelStatus ( static_cast < ePanels > ( i ), m_ucPanelStates [i] );
2765- for ( int i = 0 ; i < MAX_LIGHTS; i++ )
2766- pDamageManager->SetLightStatus ( static_cast < eLights > ( i ), m_ucLightStates [i] );
2767- }
27682780 for ( int i = 0 ; i < MAX_WHEELS; i++ )
27692781 SetWheelStatus ( i, m_ucWheelStates [i], true );
27702782
@@ -2924,6 +2936,9 @@ void CClientVehicle::Create ( void )
29242936 // store our spawn position in case we fall through the map
29252937 m_matCreate = m_Matrix;
29262938
2939+ // We've just been streamed in
2940+ m_bJustStreamedIn = true ;
2941+
29272942 // Tell the streamer we've created this object
29282943 NotifyCreate ();
29292944 }
0 commit comments