From 399a5d3dec8adf830e1cac7b2306d1b2f1f411f8 Mon Sep 17 00:00:00 2001 From: gir489 <100792176+gir489returns@users.noreply.github.com> Date: Tue, 26 Mar 2024 18:37:50 -0400 Subject: [PATCH] refactor: Bad design around the preview service (#2877) Closes #2875 Closes #2675 Closes #2077 --- src/views/vehicle/spawn/view_persist_car.cpp | 4 +--- src/views/vehicle/spawn/view_pv.cpp | 7 ++---- src/views/vehicle/view_spawn_vehicle.cpp | 6 ++--- src/views/world/view_spawn_ped.cpp | 24 ++++++++------------ 4 files changed, 15 insertions(+), 26 deletions(-) diff --git a/src/views/vehicle/spawn/view_persist_car.cpp b/src/views/vehicle/spawn/view_persist_car.cpp index e72f550c..341e8e42 100644 --- a/src/views/vehicle/spawn/view_persist_car.cpp +++ b/src/views/vehicle/spawn/view_persist_car.cpp @@ -141,9 +141,7 @@ namespace big } else if (ImGui::IsItemHovered()) { - g_fiber_pool->queue_job([pair] { - g_model_preview_service->show_vehicle_persisted(pair); - }); + g_model_preview_service->show_vehicle_persisted(pair); } ImGui::SameLine(); diff --git a/src/views/vehicle/spawn/view_pv.cpp b/src/views/vehicle/spawn/view_pv.cpp index 75701021..fcd6939a 100644 --- a/src/views/vehicle/spawn/view_pv.cpp +++ b/src/views/vehicle/spawn/view_pv.cpp @@ -228,11 +228,8 @@ namespace big } else if (ImGui::IsItemHovered()) { - g_fiber_pool->queue_job([&personal_veh] { - g_model_preview_service->show_vehicle( - vehicle::get_owned_mods_from_vehicle_idx(personal_veh->get_vehicle_idx()), - g.clone_pv.spawn_maxed); - }); + g_model_preview_service->show_vehicle(vehicle::get_owned_mods_from_vehicle_idx(personal_veh->get_vehicle_idx()), + g.clone_pv.spawn_maxed); } } } diff --git a/src/views/vehicle/view_spawn_vehicle.cpp b/src/views/vehicle/view_spawn_vehicle.cpp index a608762c..1d9c1933 100644 --- a/src/views/vehicle/view_spawn_vehicle.cpp +++ b/src/views/vehicle/view_spawn_vehicle.cpp @@ -153,10 +153,8 @@ namespace big } else if (ImGui::IsItemHovered()) { - g_fiber_pool->queue_job([] { - g_model_preview_service->show_vehicle(vehicle::get_owned_mods_from_vehicle(self::veh), - g.spawn_vehicle.spawn_maxed); - }); + g_model_preview_service->show_vehicle(vehicle::get_owned_mods_from_vehicle(self::veh), + g.spawn_vehicle.spawn_maxed); } } } diff --git a/src/views/world/view_spawn_ped.cpp b/src/views/world/view_spawn_ped.cpp index ffa46c95..e4714afe 100644 --- a/src/views/world/view_spawn_ped.cpp +++ b/src/views/world/view_spawn_ped.cpp @@ -292,11 +292,9 @@ namespace big } else if (ImGui::IsItemHovered()) { - g_fiber_pool->queue_job([] { - Ped ped = self::ped; - Hash hash = ENTITY::GET_ENTITY_MODEL(ped); - g_model_preview_service->show_ped(hash, ped); - }); + Ped ped = self::ped; + Hash hash = ENTITY::GET_ENTITY_MODEL(ped); + g_model_preview_service->show_ped(hash, ped); } if (selected_ped_player_id == -1) @@ -323,15 +321,13 @@ namespace big } else if (ImGui::IsItemHovered()) { - g_fiber_pool->queue_job([plyr_id] { - auto plyr = g_player_service->get_by_id(plyr_id); - if (plyr) - { - Ped ped = PLAYER::GET_PLAYER_PED_SCRIPT_INDEX(plyr->id()); - Hash hash = ENTITY::GET_ENTITY_MODEL(ped); - g_model_preview_service->show_ped(hash, ped); - } - }); + auto plyr = g_player_service->get_by_id(plyr_id); + if (plyr) + { + Ped ped = PLAYER::GET_PLAYER_PED_SCRIPT_INDEX(plyr->id()); + Hash hash = ENTITY::GET_ENTITY_MODEL(ped); + g_model_preview_service->show_ped(hash, ped); + } } ImGui::PopID();