From 207e5457f9fca9e638168b1f26ec210116d7ad7d Mon Sep 17 00:00:00 2001 From: gir489 <100792176+gir489returns@users.noreply.github.com> Date: Wed, 27 Sep 2023 03:41:24 -0400 Subject: [PATCH] Fixed persist outfit thinking the player was showering when they were not (#2203) * Fixed a crash emanating from mobile_service::register_vehicles if the vehicle needed to be refreshed. --- src/backend/looped/self/persist_outfit.cpp | 23 ++++++++++++++++++++-- src/gta/enums.hpp | 16 +++++++++++++++ src/services/mobile/mobile_service.cpp | 6 ++++-- 3 files changed, 41 insertions(+), 4 deletions(-) diff --git a/src/backend/looped/self/persist_outfit.cpp b/src/backend/looped/self/persist_outfit.cpp index 345ba5ae..ce17da34 100644 --- a/src/backend/looped/self/persist_outfit.cpp +++ b/src/backend/looped/self/persist_outfit.cpp @@ -4,9 +4,27 @@ #include "natives.hpp" #include "pointers.hpp" #include "services/outfit/outfit_service.hpp" +#include "gta/enums.hpp" namespace big { + inline bool is_taking_shower(Hash model) + { + int offset = 0; + switch (model) + { + case RAGE_JOAAT("mp_m_freemode_01"): break; + case RAGE_JOAAT("mp_f_freemode_01"): + { + offset = 1; + break; + } + default: return false; //For non-normal models + } + + return PED::GET_PED_DRAWABLE_VARIATION(self::ped, ComponentId::AUXILIARY) == 15 && PED::GET_PED_DRAWABLE_VARIATION(self::ped, ComponentId::TORSO) == 15 && PED::GET_PED_DRAWABLE_VARIATION(self::ped, ComponentId::LEGS) == (14 + offset); + } + void looped::self_persist_outfit() { if (g.self.persist_outfit.empty()) @@ -15,7 +33,8 @@ namespace big if (g_local_player == nullptr || PED::IS_PED_DEAD_OR_DYING(self::ped, TRUE) || STREAMING::IS_PLAYER_SWITCH_IN_PROGRESS() || DLC::GET_IS_LOADING_SCREEN_ACTIVE()) return; //Dead or Loading - if (PED::GET_PED_DRAWABLE_VARIATION(self::ped, 5) == 0 && PED::GET_PED_DRAWABLE_VARIATION(self::ped, 4) >= 14 && PED::GET_PED_DRAWABLE_VARIATION(self::ped, 4) <= 18) + auto model = ENTITY::GET_ENTITY_MODEL(self::ped); + if (is_taking_shower(model)) return; //Showering if (g.self.persist_outfits_mis && NETWORK::NETWORK_IS_ACTIVITY_SESSION()) @@ -33,7 +52,7 @@ namespace big i >> outfit; } - if (outfit.contains("model") && outfit["model"].get() == ENTITY::GET_ENTITY_MODEL(self::ped)) + if (outfit.contains("model") && outfit["model"].get() == model) outfit_service::apply_outfit(outfit, false); } } \ No newline at end of file diff --git a/src/gta/enums.hpp b/src/gta/enums.hpp index 5cbe0795..e567041b 100644 --- a/src/gta/enums.hpp +++ b/src/gta/enums.hpp @@ -2057,4 +2057,20 @@ enum CameraMode : int THIRD_PERSON_FAR = 2, CINEMATIC = 3, FIRST_PERSON = 4, +}; + +enum ComponentId : int +{ + HEAD, + BEARD, + HAIR, + TORSO, + LEGS, + HANDS, + FOOT, + ACCESSORIES_NECK, + ACCESSORIES_1, + ACCESSORIES_2, + DECALS, + AUXILIARY }; \ No newline at end of file diff --git a/src/services/mobile/mobile_service.cpp b/src/services/mobile/mobile_service.cpp index 3034a2b2..64aa9959 100644 --- a/src/services/mobile/mobile_service.cpp +++ b/src/services/mobile/mobile_service.cpp @@ -358,8 +358,10 @@ namespace big it->second = veh->get_display_name(); m_personal_vehicles.emplace(veh->get_display_name(), std::move(veh)); } - - m_personal_vehicles[veh->get_display_name()]->set_garage(); + else + { + m_personal_vehicles[veh->get_display_name()]->set_garage(); + } continue; }