@@ -1090,7 +1090,10 @@ void CClientVehicle::SetModelBlocking(unsigned short usModel, unsigned char ucVa
1090
1090
1091
1091
SetSirenOrAlarmActive (false );
1092
1092
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 ;
1094
1097
m_ComponentData.clear ();
1095
1098
1096
1099
// Reset stored dummy positions
@@ -1118,7 +1121,11 @@ void CClientVehicle::SetVariant(unsigned char ucVariant, unsigned char ucVariant
1118
1121
m_ucVariation = ucVariant;
1119
1122
m_ucVariation2 = ucVariant2;
1120
1123
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
1122
1129
m_ComponentData.clear ();
1123
1130
1124
1131
ReCreate ();
@@ -2858,6 +2865,22 @@ void CClientVehicle::Create()
2858
2865
}
2859
2866
}
2860
2867
}
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
+
2861
2884
// Grab our component data
2862
2885
std::map<SString, SVehicleComponentData>::iterator iter = m_ComponentData.begin ();
2863
2886
// Loop through our component data
0 commit comments