From 1bf1dd22640815ead2173a6d6b007ffd7264f172 Mon Sep 17 00:00:00 2001 From: psiberx Date: Sun, 18 Aug 2024 16:06:37 +0300 Subject: [PATCH] Add vehicle lights callback --- scripts/Callback/Events/VehicleLightControlEvent.reds | 1 - src/App/Callback/Controllers/VehicleLightControlHook.hpp | 6 +++--- src/App/Callback/Events/VehicleLightControlEvent.hpp | 1 - src/Red/Addresses/Library.hpp | 2 +- src/Red/VehicleController.hpp | 4 ++-- src/pch.hpp | 1 + 6 files changed, 7 insertions(+), 8 deletions(-) diff --git a/scripts/Callback/Events/VehicleLightControlEvent.reds b/scripts/Callback/Events/VehicleLightControlEvent.reds index 8dca8e9c..b2fd1c6b 100644 --- a/scripts/Callback/Events/VehicleLightControlEvent.reds +++ b/scripts/Callback/Events/VehicleLightControlEvent.reds @@ -1,5 +1,4 @@ public native class VehicleLightControlEvent extends EntityLifecycleEvent { public native func IsEnabled() -> Bool - public native func GetLightType() -> vehicleELightType public native func IsLightType(lightType: vehicleELightType) -> Bool } diff --git a/src/App/Callback/Controllers/VehicleLightControlHook.hpp b/src/App/Callback/Controllers/VehicleLightControlHook.hpp index 1232efd2..b1a82437 100644 --- a/src/App/Callback/Controllers/VehicleLightControlHook.hpp +++ b/src/App/Callback/Controllers/VehicleLightControlHook.hpp @@ -13,7 +13,7 @@ class VehicleLightControlHook , public Core::HookingAgent { public: - constexpr static auto EventName = Red::CName("Vehicle/ToggleLights"); + constexpr static auto EventName = Red::CName("Vehicle/ToggleAuxLights"); Core::Map GetEvents() override { @@ -23,12 +23,12 @@ class VehicleLightControlHook protected: bool OnActivateHook() override { - return IsHooked() || HookAfter(&OnToggleLights); + return IsHooked() || HookAfter(&OnToggleLights); } bool OnDeactivateHook() override { - return !IsHooked() || Unhook(); + return !IsHooked() || Unhook(); } inline static void OnToggleLights(Red::vehicleController* aController, bool aEnable, Red::vehicleELightType aLightType) diff --git a/src/App/Callback/Events/VehicleLightControlEvent.hpp b/src/App/Callback/Events/VehicleLightControlEvent.hpp index ec3eedee..241b61a5 100644 --- a/src/App/Callback/Events/VehicleLightControlEvent.hpp +++ b/src/App/Callback/Events/VehicleLightControlEvent.hpp @@ -34,5 +34,4 @@ RTTI_DEFINE_CLASS(App::VehicleLightControlEvent, { RTTI_PARENT(App::EntityLifecycleEvent); RTTI_METHOD(IsLightType); RTTI_GETTER(enabled); - RTTI_GETTER(lightType); }); diff --git a/src/Red/Addresses/Library.hpp b/src/Red/Addresses/Library.hpp index d10f009b..950e2775 100644 --- a/src/Red/Addresses/Library.hpp +++ b/src/Red/Addresses/Library.hpp @@ -126,7 +126,7 @@ constexpr uint32_t ResourceSerializer_OnResourceReady = 1147149338; constexpr uint32_t TagSystem_AssignTag = 1239092911; constexpr uint32_t TagSystem_UnassignTag = 1875775378; -constexpr uint32_t VehicleController_ToggleLights = 3642563117; +constexpr uint32_t VehicleController_ToggleAuxLights = 1883248814; constexpr uint32_t VehicleSystem_ToggleGarageVehicle = 3027836941; diff --git a/src/Red/VehicleController.hpp b/src/Red/VehicleController.hpp index 81d1d7dd..350d1837 100644 --- a/src/Red/VehicleController.hpp +++ b/src/Red/VehicleController.hpp @@ -2,7 +2,7 @@ namespace Raw::VehicleController { -constexpr auto ToggleLights = Core::RawFunc< - /* addr = */ Red::AddressLib::VehicleController_ToggleLights, +constexpr auto ToggleAuxLights = Core::RawFunc< + /* addr = */ Red::AddressLib::VehicleController_ToggleAuxLights, /* type = */ void (*)(Red::vehicleController* aController, bool aEnable, Red::vehicleELightType aLightType)>(); } diff --git a/src/pch.hpp b/src/pch.hpp index da9cf5b2..0bfe1435 100644 --- a/src/pch.hpp +++ b/src/pch.hpp @@ -159,6 +159,7 @@ #include #include #include +#include #include #include #include