From f0aa601c18a4d5c503aa7033127136aeedc43aa3 Mon Sep 17 00:00:00 2001 From: gir489 <100792176+gir489returns@users.noreply.github.com> Date: Thu, 14 Dec 2023 04:58:24 -0500 Subject: [PATCH] Fixed LS Customs camera being stuck on certain vehicles. (#2539) --- src/backend/looped/vehicle/ls_customs.cpp | 17 +++++++++-------- src/backend/script_patches.hpp | 6 ++++-- src/core/scr_globals.hpp | 11 +++++++++++ 3 files changed, 24 insertions(+), 10 deletions(-) diff --git a/src/backend/looped/vehicle/ls_customs.cpp b/src/backend/looped/vehicle/ls_customs.cpp index 418d0dfd..6e83bdf1 100644 --- a/src/backend/looped/vehicle/ls_customs.cpp +++ b/src/backend/looped/vehicle/ls_customs.cpp @@ -1,4 +1,5 @@ #include "backend/looped/looped.hpp" +#include "backend/looped/looped.hpp" #include "gta/enums.hpp" #include "gta_util.hpp" #include "script_function.hpp" @@ -51,8 +52,8 @@ namespace big g_script_patcher_service->update(); scr_functions::setup_modshop.call_latent(g.m_modshop_thread, gta_util::find_script_program(RAGE_JOAAT("carmod_shop")), {45, 0, 18, 0}, bModshopReady); - *script_local(g.m_modshop_thread->m_stack, 731).at(446).as() = 2; - *script_local(g.m_modshop_thread->m_stack, 2238).as() = ControllerInputs::INPUT_FRONTEND_LT; + *scr_locals::carmod_shop::maintainer.set(g.m_modshop_thread->m_stack).at(scr_locals::carmod_shop::state).as() = 2; + *scr_locals::carmod_shop::input_button.set(g.m_modshop_thread->m_stack).as() = ControllerInputs::INPUT_FRONTEND_LT; } }); bLastLsCustoms = true; @@ -82,18 +83,18 @@ namespace big { PAD::DISABLE_CONTROL_ACTION(0, (int)ControllerInputs::INPUT_VEH_CIN_CAM, true); - if (*script_local(g.m_modshop_thread->m_stack, 2467).as() && PAD::IS_CONTROL_JUST_PRESSED(2, (int)ControllerInputs::INPUT_FRONTEND_ACCEPT)) + if (*scr_locals::carmod_shop::enabled_state.set(g.m_modshop_thread->m_stack).as() && PAD::IS_CONTROL_JUST_PRESSED(2, (int)ControllerInputs::INPUT_FRONTEND_ACCEPT)) g.vehicle.ls_customs = false; } if (g.vehicle.ls_customs && bModshopReady && g.m_modshop_thread && g.m_modshop_thread->m_stack) { - *script_local(g.m_modshop_thread->m_stack, 2419).as() = false; - *script_local(g.m_modshop_thread->m_stack, 731).at(638).as() = -1; - *script_local(g.m_modshop_thread->m_stack, 731).at(409).as() = self::veh; + *scr_locals::carmod_shop::ready.set(g.m_modshop_thread->m_stack).as() = FALSE; + *scr_locals::carmod_shop::maintainer.set(g.m_modshop_thread->m_stack).at(scr_locals::carmod_shop::vehicle_state).as() = -1; + *scr_locals::carmod_shop::maintainer.set(g.m_modshop_thread->m_stack).at(scr_locals::carmod_shop::vehicle_ent_id).as() = self::veh; - if (*script_local(g.m_modshop_thread->m_stack, 731).at(446).as() == 0) - *script_local(g.m_modshop_thread->m_stack, 731).at(446).as() = 2; + if (*scr_locals::carmod_shop::maintainer.set(g.m_modshop_thread->m_stack).at(scr_locals::carmod_shop::state).as() == 0) + *scr_locals::carmod_shop::maintainer.set(g.m_modshop_thread->m_stack).at(scr_locals::carmod_shop::state).as() = 2; scr_functions::modshop_loop.call(g.m_modshop_thread, gta_util::find_script_program(RAGE_JOAAT("carmod_shop")), {}); } diff --git a/src/backend/script_patches.hpp b/src/backend/script_patches.hpp index d16924d4..3fc168e9 100644 --- a/src/backend/script_patches.hpp +++ b/src/backend/script_patches.hpp @@ -60,8 +60,10 @@ namespace big 5, {0x2E, 0x01, 0x00}, &g.vehicle.ls_customs}); // disable camera - g_script_patcher_service->add_patch({RAGE_JOAAT("carmod_shop"), "carmod_shop1", "2D 02 10 00 00 2C", 5, {0x71, 0x2E, 0x02, 0x01}, nullptr}); - g_script_patcher_service->add_patch({RAGE_JOAAT("carmod_shop"), "carmod_shop2", "2D 00 B8 00 00", 5, {0x2E, 0x00, 0x00}, nullptr}); + g_script_patcher_service->add_patch( + {RAGE_JOAAT("carmod_shop"), "carmod_shop1", "2D 02 10 00 00 2C", 5, {0x71, 0x2E, 0x02, 0x01}, &g.vehicle.ls_customs}); + g_script_patcher_service->add_patch( + {RAGE_JOAAT("carmod_shop"), "carmod_shop2", "2D 00 B8 00 00", 5, {0x2E, 0x00, 0x00}, &g.vehicle.ls_customs}); g_script_patcher_service->add_patch({RAGE_JOAAT("carmod_shop"), "allow all vehicles", "2D 03 16 00 00 5D", 5, {0x72, 0x2E, 0x03, 0x01}, nullptr}); // allow all vehicles g_script_patcher_service->add_patch({RAGE_JOAAT("carmod_shop"), "allow all vehicles 2", diff --git a/src/core/scr_globals.hpp b/src/core/scr_globals.hpp index e0478ac2..d31b5e82 100644 --- a/src/core/scr_globals.hpp +++ b/src/core/scr_globals.hpp @@ -106,4 +106,15 @@ namespace big::scr_locals // func_\d+\((&.Local_\d+(, )?){9}\); inline static script_local mobile(18955); } + + namespace carmod_shop + { + inline static script_local maintainer(733); //P"4F ? ? 47 ? ? 73 58 ? ? 4F ? ? 25 ?" +1 W="maintainer" +3 W ="state" + inline static auto state = 446; + inline static script_local input_button(1865); //P"51 ? ? 70 51 ? ? 50 ? ? 51 ? ?" +1 W="input_button" + inline static script_local enabled_state(2095); //P"51 ? ? 71 51 ? ? 71 51 ? ? 71 61 ? ? ?" +1 W="enabled_state" + inline static script_local ready(2046); //P"51 ? ? 50 ? ? 2A" +1 W="ready" + inline static auto vehicle_state = 638; //P"4F ? ? 46 ? ? 4F ? ?" +4 W ="vehicle_ent_id" + inline static auto vehicle_ent_id = 409; //P"4F ? ? 47 ? ? 39 ? 55 ? ? 38 ? 73" +4 W ="vehicle_ent_id" + } } \ No newline at end of file