Fixed LS Customs camera being stuck on certain vehicles. (#2539)

This commit is contained in:
gir489 2023-12-14 04:58:24 -05:00 committed by GitHub
parent 228ce6b25e
commit da498bebb2
3 changed files with 24 additions and 10 deletions

View File

@ -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<int*>() = 2;
*script_local(g.m_modshop_thread->m_stack, 2238).as<ControllerInputs*>() = ControllerInputs::INPUT_FRONTEND_LT;
*scr_locals::carmod_shop::maintainer.set(g.m_modshop_thread->m_stack).at(scr_locals::carmod_shop::state).as<PINT>() = 2;
*scr_locals::carmod_shop::input_button.set(g.m_modshop_thread->m_stack).as<ControllerInputs*>() = 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<bool*>() && 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<bool*>() && 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<bool*>() = false;
*script_local(g.m_modshop_thread->m_stack, 731).at(638).as<int*>() = -1;
*script_local(g.m_modshop_thread->m_stack, 731).at(409).as<Vehicle*>() = self::veh;
*scr_locals::carmod_shop::ready.set(g.m_modshop_thread->m_stack).as<PBOOL*>() = FALSE;
*scr_locals::carmod_shop::maintainer.set(g.m_modshop_thread->m_stack).at(scr_locals::carmod_shop::vehicle_state).as<int*>() = -1;
*scr_locals::carmod_shop::maintainer.set(g.m_modshop_thread->m_stack).at(scr_locals::carmod_shop::vehicle_ent_id).as<Vehicle*>() = self::veh;
if (*script_local(g.m_modshop_thread->m_stack, 731).at(446).as<int*>() == 0)
*script_local(g.m_modshop_thread->m_stack, 731).at(446).as<int*>() = 2;
if (*scr_locals::carmod_shop::maintainer.set(g.m_modshop_thread->m_stack).at(scr_locals::carmod_shop::state).as<PINT>() == 0)
*scr_locals::carmod_shop::maintainer.set(g.m_modshop_thread->m_stack).at(scr_locals::carmod_shop::state).as<PINT>() = 2;
scr_functions::modshop_loop.call(g.m_modshop_thread, gta_util::find_script_program(RAGE_JOAAT("carmod_shop")), {});
}

View File

@ -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",

View File

@ -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"
}
}