@@ -1090,7 +1090,10 @@ void CClientVehicle::SetModelBlocking(unsigned short usModel, unsigned char ucVa
10901090
10911091 SetSirenOrAlarmActive (false );
10921092
1093- // clear our component data to regenerate it
1093+ // Cache current component visibility and clear data so it can be regenerated.
1094+ m_ComponentVisibilityBackup.clear ();
1095+ for (const auto & pair : m_ComponentData)
1096+ m_ComponentVisibilityBackup[pair.first ] = pair.second .m_bVisible ;
10941097 m_ComponentData.clear ();
10951098
10961099 // Reset stored dummy positions
@@ -1118,7 +1121,11 @@ void CClientVehicle::SetVariant(unsigned char ucVariant, unsigned char ucVariant
11181121 m_ucVariation = ucVariant;
11191122 m_ucVariation2 = ucVariant2;
11201123
1121- // clear our component data to regenerate it
1124+ // Cache visibility so component state survives variant changes
1125+ m_ComponentVisibilityBackup.clear ();
1126+ for (const auto & pair : m_ComponentData)
1127+ m_ComponentVisibilityBackup[pair.first ] = pair.second .m_bVisible ;
1128+ // Clear component data to regenerate it on next create
11221129 m_ComponentData.clear ();
11231130
11241131 ReCreate ();
@@ -2858,6 +2865,22 @@ void CClientVehicle::Create()
28582865 }
28592866 }
28602867 }
2868+
2869+ // Merge saved visibility data from previous variant/handling updates
2870+ if (!m_ComponentVisibilityBackup.empty ())
2871+ {
2872+ for (const auto & pair : m_ComponentVisibilityBackup)
2873+ {
2874+ auto it = m_ComponentData.find (pair.first );
2875+ if (it != m_ComponentData.end ())
2876+ {
2877+ it->second .m_bVisible = pair.second ;
2878+ SetComponentVisible (pair.first , pair.second );
2879+ }
2880+ }
2881+ m_ComponentVisibilityBackup.clear ();
2882+ }
2883+
28612884 // Grab our component data
28622885 std::map<SString, SVehicleComponentData>::iterator iter = m_ComponentData.begin ();
28632886 // Loop through our component data
0 commit comments