@@ -6797,47 +6797,54 @@ bool CClientGame::TriggerBrowserRequestResultEvent(const std::unordered_set<SStr
67976797 return GetRootEntity ()->CallEvent (" onClientBrowserWhitelistChange" , Arguments, false );
67986798}
67996799
6800- void CClientGame::RestreamModel (unsigned short usModel )
6800+ bool CClientGame::RestreamModel (std:: uint16_t model )
68016801{
68026802 // Is this a vehicle ID?
6803- if (CClientVehicleManager::IsValidModel (usModel ))
6803+ if (CClientVehicleManager::IsValidModel (model ))
68046804 {
68056805 // Stream the vehicles of that model out so we have no
68066806 // loaded when we do the restore. The streamer will
68076807 // eventually stream them back in with async loading.
6808- m_pManager->GetVehicleManager ()->RestreamVehicles (usModel);
6809- }
6808+ m_pManager->GetVehicleManager ()->RestreamVehicles (model);
68106809
6810+ return true ;
6811+ }
68116812 // Is this an object ID?
6812- else if (CClientObjectManager::IsValidModel (usModel ))
6813+ else if (CClientObjectManager::IsValidModel (model ))
68136814 {
6814- if (CClientPedManager::IsValidWeaponModel (usModel ))
6815+ if (CClientPedManager::IsValidWeaponModel (model ))
68156816 {
68166817 // Stream the weapon of that model out so we have no
68176818 // loaded when we do the restore. The streamer will
68186819 // eventually stream them back in with async loading.
6819- m_pManager->GetPedManager ()->RestreamWeapon (usModel );
6820- m_pManager->GetPickupManager ()->RestreamPickups (usModel );
6820+ m_pManager->GetPedManager ()->RestreamWeapon (model );
6821+ m_pManager->GetPickupManager ()->RestreamPickups (model );
68216822 }
68226823 // Stream the objects of that model out so we have no
68236824 // loaded when we do the restore. The streamer will
68246825 // eventually stream them back in with async loading.
6825- m_pManager->GetObjectManager ()->RestreamObjects (usModel);
6826- g_pGame->GetModelInfo (usModel)->RestreamIPL ();
6826+ m_pManager->GetObjectManager ()->RestreamObjects (model);
6827+ g_pGame->GetModelInfo (model)->RestreamIPL ();
6828+
6829+ return true ;
68276830 }
68286831 // Is this an ped ID?
6829- else if (CClientPlayerManager::IsValidModel (usModel ))
6832+ else if (CClientPlayerManager::IsValidModel (model ))
68306833 {
68316834 // Stream the ped of that model out so we have no
68326835 // loaded when we do the restore. The streamer will
68336836 // eventually stream them back in with async loading.
6834- m_pManager->GetPedManager ()->RestreamPeds (usModel);
6835- }
6836- else
6837+ m_pManager->GetPedManager ()->RestreamPeds (model);
68376838
6838- // 'Restream' upgrades after model replacement to propagate visual changes with immediate effect
6839- if (CClientObjectManager::IsValidModel (usModel) && CVehicleUpgrades::IsUpgrade (usModel))
6840- m_pManager->GetVehicleManager ()->RestreamVehicleUpgrades (usModel);
6839+ return true ;
6840+ }
6841+ // 'Restream' upgrades after model replacement to propagate visual changes with immediate effect
6842+ else if (CClientObjectManager::IsValidModel (model) && CVehicleUpgrades::IsUpgrade (model))
6843+ {
6844+ m_pManager->GetVehicleManager ()->RestreamVehicleUpgrades (model);
6845+ return true ;
6846+ }
6847+ return false ;
68416848}
68426849
68436850void CClientGame::RestreamWorld ()
@@ -6858,6 +6865,55 @@ void CClientGame::RestreamWorld()
68586865 g_pGame->GetStreaming ()->ReinitStreaming ();
68596866}
68606867
6868+ void CClientGame::Restream (std::optional<RestreamOption> option)
6869+ {
6870+ if (!option.has_value ())
6871+ option = RestreamOption::ALL;
6872+
6873+ if (option == RestreamOption::ALL || option == RestreamOption::VEHICLES)
6874+ {
6875+ for (const auto & model : m_pManager->GetModelManager ()->GetModelsByType (eClientModelType::VEHICLE))
6876+ {
6877+ g_pClientGame->GetModelCacheManager ()->OnRestreamModel (model->GetModelID ());
6878+ }
6879+
6880+ m_pManager->GetVehicleManager ()->RestreamAllVehicles ();
6881+ }
6882+
6883+ if (option == RestreamOption::ALL || option == RestreamOption::PEDS)
6884+ {
6885+ for (const auto & model : m_pManager->GetModelManager ()->GetModelsByType (eClientModelType::PED))
6886+ {
6887+ g_pClientGame->GetModelCacheManager ()->OnRestreamModel (model->GetModelID ());
6888+ }
6889+
6890+ m_pManager->GetPedManager ()->RestreamAllPeds ();
6891+ }
6892+
6893+ if (option == RestreamOption::ALL || option == RestreamOption::OBJECTS)
6894+ {
6895+ static constexpr eClientModelType restreamTypes[] = {eClientModelType::OBJECT, eClientModelType::OBJECT_DAMAGEABLE, eClientModelType::TIMED_OBJECT,
6896+ eClientModelType::CLUMP};
6897+
6898+ for (eClientModelType type : restreamTypes)
6899+ {
6900+ for (const auto & model : m_pManager->GetModelManager ()->GetModelsByType (type))
6901+ {
6902+ g_pClientGame->GetModelCacheManager ()->OnRestreamModel (model->GetModelID ());
6903+ }
6904+ }
6905+
6906+ m_pManager->GetObjectManager ()->RestreamAllObjects ();
6907+ m_pManager->GetPickupManager ()->RestreamAllPickups ();
6908+ }
6909+
6910+ if (option == RestreamOption::ALL)
6911+ {
6912+ g_pGame->GetStreaming ()->RemoveBigBuildings ();
6913+ g_pGame->GetStreaming ()->ReinitStreaming ();
6914+ }
6915+ }
6916+
68616917void CClientGame::ReinitMarkers ()
68626918{
68636919 g_pGame->Get3DMarkers ()->ReinitMarkers ();
0 commit comments