From 5058165d9debaaf44c23baba860feceef60e4299 Mon Sep 17 00:00:00 2001 From: Proxy-99 <77501848+Proxy-99@users.noreply.github.com> Date: Sat, 7 Sep 2024 21:44:21 +0300 Subject: [PATCH 01/13] add function addVehicleSirens client side --- .../deathmatch/logic/luadefs/CLuaVehicleDefs.cpp | 16 ++++++++++++++++ .../deathmatch/logic/luadefs/CLuaVehicleDefs.h | 1 + 2 files changed, 17 insertions(+) diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp b/Client/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp index b35bfee24b..67eb103198 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp +++ b/Client/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp @@ -104,6 +104,7 @@ void CLuaVehicleDefs::LoadFunctions() {"setVehicleDoorsUndamageable", SetVehicleDoorsUndamageable}, {"setVehicleSirensOn", SetVehicleSirensOn}, {"addVehicleUpgrade", AddVehicleUpgrade}, + {"addVehicleSirens", ArgumentParser}, {"removeVehicleUpgrade", RemoveVehicleUpgrade}, {"setVehicleDoorState", SetVehicleDoorState}, {"setVehicleWheelStates", SetVehicleWheelStates}, @@ -4273,3 +4274,18 @@ std::variant> CLuaVehicleDefs::OOP_GetVehicleEntryP return entryPoints; } + +bool CLuaVehicleDefs::addVehicleSirens(CClientVehicle* vehicle, unsigned char ucSirenType, unsigned char ucSirenCount) +{ + + if (ucSirenType >= 1 && ucSirenType <= 6) + { + if (ucSirenCount <= SIREN_COUNT_MAX) + { + vehicle->GiveVehicleSirens(ucSirenType, ucSirenCount); + } + } + + return true; +} + diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.h b/Client/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.h index 5c2e908d58..ba43f63f72 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.h +++ b/Client/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.h @@ -165,6 +165,7 @@ class CLuaVehicleDefs : public CLuaDefs const std::optional eWheelGroup); static bool SetVehicleModelWheelSize(const unsigned short usModel, const eResizableVehicleWheelGroup eWheelGroup, const float fWheelSize); static int GetVehicleWheelFrictionState(CClientVehicle* pVehicle, unsigned char wheel); + static bool addVehicleSirens(CClientVehicle* vehicle, unsigned char ucSirenType, unsigned char ucSirenCount); // Components LUA_DECLARE(SetVehicleComponentPosition); From dcb36f0dde0d6e412df15ca25f2a3257f7c213ed Mon Sep 17 00:00:00 2001 From: Proxy-99 <77501848+Proxy-99@users.noreply.github.com> Date: Sat, 7 Sep 2024 21:47:13 +0300 Subject: [PATCH 02/13] checks --- Client/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp b/Client/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp index 67eb103198..326b8dd139 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp +++ b/Client/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp @@ -4277,6 +4277,11 @@ std::variant> CLuaVehicleDefs::OOP_GetVehicleEntryP bool CLuaVehicleDefs::addVehicleSirens(CClientVehicle* vehicle, unsigned char ucSirenType, unsigned char ucSirenCount) { + /* + unsigned long ucModel = 0; + ucModel = vehicle->GetModel(); + CVehicleNames::GetVehicleTypeName(ucModel); + */ if (ucSirenType >= 1 && ucSirenType <= 6) { From 0df9b1a464ac3362f897a75caa5a43902f92029c Mon Sep 17 00:00:00 2001 From: Proxy-99 <77501848+Proxy-99@users.noreply.github.com> Date: Sat, 7 Sep 2024 22:09:07 +0300 Subject: [PATCH 03/13] flags --- Client/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp b/Client/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp index 326b8dd139..76e781a110 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp +++ b/Client/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp @@ -4287,7 +4287,10 @@ bool CLuaVehicleDefs::addVehicleSirens(CClientVehicle* vehicle, unsigned char uc { if (ucSirenCount <= SIREN_COUNT_MAX) { - vehicle->GiveVehicleSirens(ucSirenType, ucSirenCount); + + + vehicle->GiveVehicleSirens(ucSirenType, ucSirenCount); + // vehicle->SetVehicleFlags(bEnable360, bEnableRandomiser, bEnableLOSCheck, bEnableSilent); } } From c02f4ae44b821a91f155c24008b53d5a446ef9eb Mon Sep 17 00:00:00 2001 From: Proxy-99 <77501848+Proxy-99@users.noreply.github.com> Date: Sun, 8 Sep 2024 17:26:50 +0300 Subject: [PATCH 04/13] flags optional arguments --- Client/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp | 9 ++++----- Client/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.h | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp b/Client/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp index 76e781a110..7d952ba708 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp +++ b/Client/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp @@ -4275,7 +4275,7 @@ std::variant> CLuaVehicleDefs::OOP_GetVehicleEntryP return entryPoints; } -bool CLuaVehicleDefs::addVehicleSirens(CClientVehicle* vehicle, unsigned char ucSirenType, unsigned char ucSirenCount) +bool CLuaVehicleDefs::addVehicleSirens(CClientVehicle* vehicle, unsigned char ucSirenType, unsigned char ucSirenCount, std::optional bEnable360, std::optional bEnableLOSCheck , std::optional bEnableRandomiser, std::optional bEnableSilent) { /* unsigned long ucModel = 0; @@ -4287,13 +4287,12 @@ bool CLuaVehicleDefs::addVehicleSirens(CClientVehicle* vehicle, unsigned char uc { if (ucSirenCount <= SIREN_COUNT_MAX) { - - vehicle->GiveVehicleSirens(ucSirenType, ucSirenCount); - // vehicle->SetVehicleFlags(bEnable360, bEnableRandomiser, bEnableLOSCheck, bEnableSilent); + vehicle->SetVehicleFlags(bEnable360.value_or(false), bEnableRandomiser.value_or(true), bEnableLOSCheck.value_or(true), bEnableSilent.value_or(false)); + return true; } } - return true; + return false; } diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.h b/Client/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.h index ba43f63f72..078412b379 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.h +++ b/Client/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.h @@ -165,7 +165,7 @@ class CLuaVehicleDefs : public CLuaDefs const std::optional eWheelGroup); static bool SetVehicleModelWheelSize(const unsigned short usModel, const eResizableVehicleWheelGroup eWheelGroup, const float fWheelSize); static int GetVehicleWheelFrictionState(CClientVehicle* pVehicle, unsigned char wheel); - static bool addVehicleSirens(CClientVehicle* vehicle, unsigned char ucSirenType, unsigned char ucSirenCount); + static bool addVehicleSirens(CClientVehicle* vehicle, unsigned char ucSirenType, unsigned char ucSirenCount, std::optional bEnable360, std::optional bEnableLOSCheck, std::optional bEnableRandomiser, std::optional bEnableSilent ); // Components LUA_DECLARE(SetVehicleComponentPosition); From f2ee03cdb33cfd702f8070fb184b3710ebfa533c Mon Sep 17 00:00:00 2001 From: Proxy-99 <77501848+Proxy-99@users.noreply.github.com> Date: Sun, 8 Sep 2024 17:40:44 +0300 Subject: [PATCH 05/13] types checks --- .../deathmatch/logic/luadefs/CLuaVehicleDefs.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp b/Client/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp index 7d952ba708..a33bbaa0b1 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp +++ b/Client/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp @@ -4277,22 +4277,21 @@ std::variant> CLuaVehicleDefs::OOP_GetVehicleEntryP bool CLuaVehicleDefs::addVehicleSirens(CClientVehicle* vehicle, unsigned char ucSirenType, unsigned char ucSirenCount, std::optional bEnable360, std::optional bEnableLOSCheck , std::optional bEnableRandomiser, std::optional bEnableSilent) { - /* - unsigned long ucModel = 0; - ucModel = vehicle->GetModel(); - CVehicleNames::GetVehicleTypeName(ucModel); - */ + eClientVehicleType vehicleType = vehicle->GetVehicleType(); - if (ucSirenType >= 1 && ucSirenType <= 6) + if (vehicleType != CLIENTVEHICLE_PLANE && vehicleType != CLIENTVEHICLE_BOAT && vehicleType != CLIENTVEHICLE_TRAILER && vehicleType != CLIENTVEHICLE_HELI && + vehicleType != CLIENTVEHICLE_BIKE && vehicleType != CLIENTVEHICLE_BMX) { - if (ucSirenCount <= SIREN_COUNT_MAX) + if (ucSirenType >= 1 && ucSirenType <= 6) { + if (ucSirenCount <= SIREN_COUNT_MAX) + { vehicle->GiveVehicleSirens(ucSirenType, ucSirenCount); vehicle->SetVehicleFlags(bEnable360.value_or(false), bEnableRandomiser.value_or(true), bEnableLOSCheck.value_or(true), bEnableSilent.value_or(false)); return true; + } } } - return false; } From 5071e29d5fbc74aeaf488fce4b0a4d24a075c8ac Mon Sep 17 00:00:00 2001 From: Proxy-99 <77501848+Proxy-99@users.noreply.github.com> Date: Sun, 8 Sep 2024 17:58:55 +0300 Subject: [PATCH 06/13] RemoveVehicleSirens --- .../mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp | 11 +++++++++-- .../mods/deathmatch/logic/luadefs/CLuaVehicleDefs.h | 3 ++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp b/Client/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp index a33bbaa0b1..ebd06b9cee 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp +++ b/Client/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp @@ -104,8 +104,9 @@ void CLuaVehicleDefs::LoadFunctions() {"setVehicleDoorsUndamageable", SetVehicleDoorsUndamageable}, {"setVehicleSirensOn", SetVehicleSirensOn}, {"addVehicleUpgrade", AddVehicleUpgrade}, - {"addVehicleSirens", ArgumentParser}, + {"addVehicleSirens", ArgumentParser}, {"removeVehicleUpgrade", RemoveVehicleUpgrade}, + {"removeVehicleSirens", ArgumentParser}, {"setVehicleDoorState", SetVehicleDoorState}, {"setVehicleWheelStates", SetVehicleWheelStates}, {"setVehicleLightState", SetVehicleLightState}, @@ -4275,7 +4276,7 @@ std::variant> CLuaVehicleDefs::OOP_GetVehicleEntryP return entryPoints; } -bool CLuaVehicleDefs::addVehicleSirens(CClientVehicle* vehicle, unsigned char ucSirenType, unsigned char ucSirenCount, std::optional bEnable360, std::optional bEnableLOSCheck , std::optional bEnableRandomiser, std::optional bEnableSilent) +bool CLuaVehicleDefs::AddVehicleSirens(CClientVehicle* vehicle, unsigned char ucSirenType, unsigned char ucSirenCount, std::optional bEnable360, std::optional bEnableLOSCheck , std::optional bEnableRandomiser, std::optional bEnableSilent) { eClientVehicleType vehicleType = vehicle->GetVehicleType(); @@ -4295,3 +4296,9 @@ bool CLuaVehicleDefs::addVehicleSirens(CClientVehicle* vehicle, unsigned char uc return false; } +bool CLuaVehicleDefs::RemoveVehicleSirens(CClientVehicle* vehicle) +{ + vehicle->RemoveVehicleSirens(); + return true; +} + diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.h b/Client/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.h index 078412b379..63f33f4b6c 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.h +++ b/Client/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.h @@ -165,7 +165,8 @@ class CLuaVehicleDefs : public CLuaDefs const std::optional eWheelGroup); static bool SetVehicleModelWheelSize(const unsigned short usModel, const eResizableVehicleWheelGroup eWheelGroup, const float fWheelSize); static int GetVehicleWheelFrictionState(CClientVehicle* pVehicle, unsigned char wheel); - static bool addVehicleSirens(CClientVehicle* vehicle, unsigned char ucSirenType, unsigned char ucSirenCount, std::optional bEnable360, std::optional bEnableLOSCheck, std::optional bEnableRandomiser, std::optional bEnableSilent ); + static bool AddVehicleSirens(CClientVehicle* vehicle, unsigned char ucSirenType, unsigned char ucSirenCount, std::optional bEnable360, std::optional bEnableLOSCheck, std::optional bEnableRandomiser, std::optional bEnableSilent ); + static bool RemoveVehicleSirens(CClientVehicle* vehicle); // Components LUA_DECLARE(SetVehicleComponentPosition); From 2b5304d5ce46706c387ca3da946e7cf0c9148b71 Mon Sep 17 00:00:00 2001 From: Proxy-99 <77501848+Proxy-99@users.noreply.github.com> Date: Sun, 8 Sep 2024 20:01:54 +0300 Subject: [PATCH 07/13] review fixes --- .../deathmatch/logic/luadefs/CLuaVehicleDefs.cpp | 15 +++++++-------- .../deathmatch/logic/luadefs/CLuaVehicleDefs.h | 2 +- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp b/Client/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp index ebd06b9cee..d843620a3c 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp +++ b/Client/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp @@ -4276,20 +4276,19 @@ std::variant> CLuaVehicleDefs::OOP_GetVehicleEntryP return entryPoints; } -bool CLuaVehicleDefs::AddVehicleSirens(CClientVehicle* vehicle, unsigned char ucSirenType, unsigned char ucSirenCount, std::optional bEnable360, std::optional bEnableLOSCheck , std::optional bEnableRandomiser, std::optional bEnableSilent) +bool CLuaVehicleDefs::AddVehicleSirens(CClientVehicle* vehicle, std::uint8_t sirenType, std::uint8_t sirenCount, std::optional enable360, std::optional enableLOSCheck, std::optional enableRandomiser, std::optional enableSilent) { eClientVehicleType vehicleType = vehicle->GetVehicleType(); - if (vehicleType != CLIENTVEHICLE_PLANE && vehicleType != CLIENTVEHICLE_BOAT && vehicleType != CLIENTVEHICLE_TRAILER && vehicleType != CLIENTVEHICLE_HELI && - vehicleType != CLIENTVEHICLE_BIKE && vehicleType != CLIENTVEHICLE_BMX) + if (vehicleType == CLIENTVEHICLE_CAR) { - if (ucSirenType >= 1 && ucSirenType <= 6) + if (sirenType >= 1 && sirenType <= 6) { - if (ucSirenCount <= SIREN_COUNT_MAX) + if (sirenCount <= SIREN_COUNT_MAX) { - vehicle->GiveVehicleSirens(ucSirenType, ucSirenCount); - vehicle->SetVehicleFlags(bEnable360.value_or(false), bEnableRandomiser.value_or(true), bEnableLOSCheck.value_or(true), bEnableSilent.value_or(false)); - return true; + vehicle->GiveVehicleSirens(sirenType, sirenCount); + vehicle->SetVehicleFlags(enable360.value_or(false), enableRandomiser.value_or(true), enableLOSCheck.value_or(true), enableSilent.value_or(false)); + return true; } } } diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.h b/Client/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.h index 63f33f4b6c..bc1bb66af1 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.h +++ b/Client/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.h @@ -165,7 +165,7 @@ class CLuaVehicleDefs : public CLuaDefs const std::optional eWheelGroup); static bool SetVehicleModelWheelSize(const unsigned short usModel, const eResizableVehicleWheelGroup eWheelGroup, const float fWheelSize); static int GetVehicleWheelFrictionState(CClientVehicle* pVehicle, unsigned char wheel); - static bool AddVehicleSirens(CClientVehicle* vehicle, unsigned char ucSirenType, unsigned char ucSirenCount, std::optional bEnable360, std::optional bEnableLOSCheck, std::optional bEnableRandomiser, std::optional bEnableSilent ); + static bool AddVehicleSirens(CClientVehicle* vehicle, std::uint8_t sirenType, std::uint8_t sirenCount, std::optional enable360, std::optional enableLOSCheck, std::optional enableRandomiser, std::optional enableSilent ); static bool RemoveVehicleSirens(CClientVehicle* vehicle); // Components From b4bfbeace64daa4e81f86383ae8bef893fb14ea7 Mon Sep 17 00:00:00 2001 From: Proxy-99 <77501848+Proxy-99@users.noreply.github.com> Date: Sun, 8 Sep 2024 20:54:15 +0300 Subject: [PATCH 08/13] review --- .../logic/luadefs/CLuaVehicleDefs.cpp | 25 ++++++++++--------- .../logic/luadefs/CLuaVehicleDefs.h | 4 +-- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp b/Client/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp index d843620a3c..deaf222ac3 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp +++ b/Client/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp @@ -4276,26 +4276,27 @@ std::variant> CLuaVehicleDefs::OOP_GetVehicleEntryP return entryPoints; } -bool CLuaVehicleDefs::AddVehicleSirens(CClientVehicle* vehicle, std::uint8_t sirenType, std::uint8_t sirenCount, std::optional enable360, std::optional enableLOSCheck, std::optional enableRandomiser, std::optional enableSilent) +bool CLuaVehicleDefs::AddVehicleSirens(CClientVehicle* vehicle, std::uint8_t sirenType, std::uint8_t sirenCount, std::optional enable360, std::optional enableLOSCheck, std::optional enableRandomiser, std::optional enableSilent) noexcept { eClientVehicleType vehicleType = vehicle->GetVehicleType(); - if (vehicleType == CLIENTVEHICLE_CAR) + if (vehicleType != CLIENTVEHICLE_CAR && vehicleType != CLIENTVEHICLE_MONSTERTRUCK && vehicleType != CLIENTVEHICLE_QUADBIKE && vehicleType != CLIENTVEHICLE_TRAIN) + return false; + + if (sirenType < 1 || sirenType > 6) + return false; + + if (sirenCount <= SIREN_COUNT_MAX) { - if (sirenType >= 1 && sirenType <= 6) - { - if (sirenCount <= SIREN_COUNT_MAX) - { - vehicle->GiveVehicleSirens(sirenType, sirenCount); - vehicle->SetVehicleFlags(enable360.value_or(false), enableRandomiser.value_or(true), enableLOSCheck.value_or(true), enableSilent.value_or(false)); - return true; - } - } + vehicle->GiveVehicleSirens(sirenType, sirenCount); + vehicle->SetVehicleFlags(enable360.value_or(false), enableRandomiser.value_or(true), enableLOSCheck.value_or(true), enableSilent.value_or(false)); + return true; } + return false; } -bool CLuaVehicleDefs::RemoveVehicleSirens(CClientVehicle* vehicle) +bool CLuaVehicleDefs::RemoveVehicleSirens(CClientVehicle* vehicle) noexcept { vehicle->RemoveVehicleSirens(); return true; diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.h b/Client/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.h index bc1bb66af1..32ecfa6449 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.h +++ b/Client/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.h @@ -165,8 +165,8 @@ class CLuaVehicleDefs : public CLuaDefs const std::optional eWheelGroup); static bool SetVehicleModelWheelSize(const unsigned short usModel, const eResizableVehicleWheelGroup eWheelGroup, const float fWheelSize); static int GetVehicleWheelFrictionState(CClientVehicle* pVehicle, unsigned char wheel); - static bool AddVehicleSirens(CClientVehicle* vehicle, std::uint8_t sirenType, std::uint8_t sirenCount, std::optional enable360, std::optional enableLOSCheck, std::optional enableRandomiser, std::optional enableSilent ); - static bool RemoveVehicleSirens(CClientVehicle* vehicle); + static bool AddVehicleSirens(CClientVehicle* vehicle, std::uint8_t sirenType, std::uint8_t sirenCount, std::optional enable360, std::optional enableLOSCheck, std::optional enableRandomiser, std::optional enableSilent ) noexcept; + static bool RemoveVehicleSirens(CClientVehicle* vehicle) noexcept; // Components LUA_DECLARE(SetVehicleComponentPosition); From f435812125d908c6689e78a26a998fdf015f3f80 Mon Sep 17 00:00:00 2001 From: Proxy-99 <77501848+Proxy-99@users.noreply.github.com> Date: Thu, 12 Sep 2024 17:38:59 +0300 Subject: [PATCH 09/13] Review --- .../logic/luadefs/CLuaVehicleDefs.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp b/Client/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp index deaf222ac3..3910c942c2 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp +++ b/Client/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp @@ -4276,24 +4276,22 @@ std::variant> CLuaVehicleDefs::OOP_GetVehicleEntryP return entryPoints; } -bool CLuaVehicleDefs::AddVehicleSirens(CClientVehicle* vehicle, std::uint8_t sirenType, std::uint8_t sirenCount, std::optional enable360, std::optional enableLOSCheck, std::optional enableRandomiser, std::optional enableSilent) noexcept +bool CLuaVehicleDefs::AddVehicleSirens(CClientVehicle* vehicle, std::uint8_t sirenType, std::uint8_t sirenCount, std::optional enable360, std::optional enableLOSCheck, std::optional enableRandomiser, std::optional enableSilent) noexcept { eClientVehicleType vehicleType = vehicle->GetVehicleType(); - if (vehicleType != CLIENTVEHICLE_CAR && vehicleType != CLIENTVEHICLE_MONSTERTRUCK && vehicleType != CLIENTVEHICLE_QUADBIKE && vehicleType != CLIENTVEHICLE_TRAIN) + if (vehicleType != CLIENTVEHICLE_CAR && vehicleType != CLIENTVEHICLE_MONSTERTRUCK && vehicleType != CLIENTVEHICLE_QUADBIKE && vehicleType != CLIENTVEHICLE_TRAIN) return false; if (sirenType < 1 || sirenType > 6) return false; - if (sirenCount <= SIREN_COUNT_MAX) - { - vehicle->GiveVehicleSirens(sirenType, sirenCount); - vehicle->SetVehicleFlags(enable360.value_or(false), enableRandomiser.value_or(true), enableLOSCheck.value_or(true), enableSilent.value_or(false)); - return true; - } - - return false; + if (sirenCount < 0 || sirenCount > SIREN_COUNT_MAX) + return false; + + vehicle->GiveVehicleSirens(sirenType, sirenCount); + vehicle->SetVehicleFlags(enable360.value_or(false), enableRandomiser.value_or(true), enableLOSCheck.value_or(true), enableSilent.value_or(false)); + return true; } bool CLuaVehicleDefs::RemoveVehicleSirens(CClientVehicle* vehicle) noexcept From 3898fb913231893a4c0e199ed5dc2b8ac22bc557 Mon Sep 17 00:00:00 2001 From: Proxy-99 <77501848+Proxy-99@users.noreply.github.com> Date: Thu, 12 Sep 2024 17:40:48 +0300 Subject: [PATCH 10/13] spaces fixes --- Client/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.h b/Client/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.h index 32ecfa6449..c035d9901a 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.h +++ b/Client/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.h @@ -165,7 +165,8 @@ class CLuaVehicleDefs : public CLuaDefs const std::optional eWheelGroup); static bool SetVehicleModelWheelSize(const unsigned short usModel, const eResizableVehicleWheelGroup eWheelGroup, const float fWheelSize); static int GetVehicleWheelFrictionState(CClientVehicle* pVehicle, unsigned char wheel); - static bool AddVehicleSirens(CClientVehicle* vehicle, std::uint8_t sirenType, std::uint8_t sirenCount, std::optional enable360, std::optional enableLOSCheck, std::optional enableRandomiser, std::optional enableSilent ) noexcept; + + static bool AddVehicleSirens(CClientVehicle* vehicle, std::uint8_t sirenType, std::uint8_t sirenCount, std::optional enable360, std::optional enableLOSCheck, std::optional enableRandomiser, std::optional enableSilent) noexcept; static bool RemoveVehicleSirens(CClientVehicle* vehicle) noexcept; // Components From 2edd2adf2522e3289bd7f9ddc0c21f63cafd2c99 Mon Sep 17 00:00:00 2001 From: Proxy-99 <77501848+Proxy-99@users.noreply.github.com> Date: Thu, 12 Sep 2024 18:06:13 +0300 Subject: [PATCH 11/13] Refactor addVehicleSirens server side --- .../logic/luadefs/CLuaVehicleDefs.cpp | 2 +- .../logic/CStaticFunctionDefinitions.cpp | 58 +++++++++---------- 2 files changed, 29 insertions(+), 31 deletions(-) diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp b/Client/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp index 3910c942c2..82dece545e 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp +++ b/Client/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp @@ -4280,7 +4280,7 @@ bool CLuaVehicleDefs::AddVehicleSirens(CClientVehicle* vehicle, std::uint8_t sir { eClientVehicleType vehicleType = vehicle->GetVehicleType(); - if (vehicleType != CLIENTVEHICLE_CAR && vehicleType != CLIENTVEHICLE_MONSTERTRUCK && vehicleType != CLIENTVEHICLE_QUADBIKE && vehicleType != CLIENTVEHICLE_TRAIN) + if (vehicleType != CLIENTVEHICLE_CAR && vehicleType != CLIENTVEHICLE_MONSTERTRUCK && vehicleType != CLIENTVEHICLE_QUADBIKE) return false; if (sirenType < 1 || sirenType > 6) diff --git a/Server/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp b/Server/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp index ad06e54a70..80a95eb44f 100644 --- a/Server/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp +++ b/Server/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp @@ -4931,40 +4931,38 @@ bool CStaticFunctionDefinitions::GiveVehicleSirens(CVehicle* pVehicle, unsigned assert(pVehicle); eVehicleType vehicleType = CVehicleManager::GetVehicleType(pVehicle->GetModel()); // Won't work with below. - if (vehicleType != VEHICLE_PLANE && vehicleType != VEHICLE_BOAT && vehicleType != VEHICLE_TRAILER && vehicleType != VEHICLE_HELI && - vehicleType != VEHICLE_BIKE && vehicleType != VEHICLE_BMX) - { - if (ucSirenType >= 1 && ucSirenType <= 6) - { - if (ucSirenCount <= SIREN_COUNT_MAX) - { - pVehicle->m_tSirenBeaconInfo.m_bOverrideSirens = true; + if (vehicleType != VEHICLE_CAR && vehicleType != VEHICLE_MONSTERTRUCK && vehicleType != VEHICLE_QUADBIKE) + return false; - pVehicle->m_tSirenBeaconInfo.m_ucSirenCount = ucSirenCount; - pVehicle->m_tSirenBeaconInfo.m_ucSirenType = ucSirenType; + if (ucSirenType < 1 || ucSirenType > 6) + return false; - pVehicle->m_tSirenBeaconInfo.m_b360Flag = tSirenInfo.m_b360Flag; - pVehicle->m_tSirenBeaconInfo.m_bDoLOSCheck = tSirenInfo.m_bDoLOSCheck; - pVehicle->m_tSirenBeaconInfo.m_bUseRandomiser = tSirenInfo.m_bUseRandomiser; - pVehicle->m_tSirenBeaconInfo.m_bSirenSilent = tSirenInfo.m_bSirenSilent; + if (ucSirenCount < 0 || ucSirenCount > SIREN_COUNT_MAX) + return false; - SVehicleSirenAddSync tSirenSync; - tSirenSync.data.m_bOverrideSirens = pVehicle->m_tSirenBeaconInfo.m_bOverrideSirens; - tSirenSync.data.m_b360Flag = pVehicle->m_tSirenBeaconInfo.m_b360Flag; - tSirenSync.data.m_bDoLOSCheck = pVehicle->m_tSirenBeaconInfo.m_bDoLOSCheck; - tSirenSync.data.m_bEnableSilent = pVehicle->m_tSirenBeaconInfo.m_bSirenSilent; - tSirenSync.data.m_bUseRandomiser = pVehicle->m_tSirenBeaconInfo.m_bUseRandomiser; - tSirenSync.data.m_ucSirenCount = pVehicle->m_tSirenBeaconInfo.m_ucSirenCount; - tSirenSync.data.m_ucSirenType = pVehicle->m_tSirenBeaconInfo.m_ucSirenType; + pVehicle->m_tSirenBeaconInfo.m_bOverrideSirens = true; - CBitStream BitStream; - BitStream.pBitStream->Write(&tSirenSync); - m_pPlayerManager->BroadcastOnlyJoined(CElementRPCPacket(pVehicle, GIVE_VEHICLE_SIRENS, *BitStream.pBitStream)); - return true; - } - } - } - return false; + pVehicle->m_tSirenBeaconInfo.m_ucSirenCount = ucSirenCount; + pVehicle->m_tSirenBeaconInfo.m_ucSirenType = ucSirenType; + + pVehicle->m_tSirenBeaconInfo.m_b360Flag = tSirenInfo.m_b360Flag; + pVehicle->m_tSirenBeaconInfo.m_bDoLOSCheck = tSirenInfo.m_bDoLOSCheck; + pVehicle->m_tSirenBeaconInfo.m_bUseRandomiser = tSirenInfo.m_bUseRandomiser; + pVehicle->m_tSirenBeaconInfo.m_bSirenSilent = tSirenInfo.m_bSirenSilent; + + SVehicleSirenAddSync tSirenSync; + tSirenSync.data.m_bOverrideSirens = pVehicle->m_tSirenBeaconInfo.m_bOverrideSirens; + tSirenSync.data.m_b360Flag = pVehicle->m_tSirenBeaconInfo.m_b360Flag; + tSirenSync.data.m_bDoLOSCheck = pVehicle->m_tSirenBeaconInfo.m_bDoLOSCheck; + tSirenSync.data.m_bEnableSilent = pVehicle->m_tSirenBeaconInfo.m_bSirenSilent; + tSirenSync.data.m_bUseRandomiser = pVehicle->m_tSirenBeaconInfo.m_bUseRandomiser; + tSirenSync.data.m_ucSirenCount = pVehicle->m_tSirenBeaconInfo.m_ucSirenCount; + tSirenSync.data.m_ucSirenType = pVehicle->m_tSirenBeaconInfo.m_ucSirenType; + + CBitStream BitStream; + BitStream.pBitStream->Write(&tSirenSync); + m_pPlayerManager->BroadcastOnlyJoined(CElementRPCPacket(pVehicle, GIVE_VEHICLE_SIRENS, *BitStream.pBitStream)); + return true; } bool CStaticFunctionDefinitions::SetVehicleSirens(CVehicle* pVehicle, unsigned char ucSirenID, SSirenInfo tSirenInfo) From 57cc1aaad1d981d93de230cb1c82fda43988b0e9 Mon Sep 17 00:00:00 2001 From: Proxy-99 <77501848+Proxy-99@users.noreply.github.com> Date: Sat, 14 Sep 2024 13:33:01 +0300 Subject: [PATCH 12/13] fix --- Server/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Server/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp b/Server/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp index 80a95eb44f..6c7a3cb192 100644 --- a/Server/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp +++ b/Server/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp @@ -4937,7 +4937,7 @@ bool CStaticFunctionDefinitions::GiveVehicleSirens(CVehicle* pVehicle, unsigned if (ucSirenType < 1 || ucSirenType > 6) return false; - if (ucSirenCount < 0 || ucSirenCount > SIREN_COUNT_MAX) + if (ucSirenCount > SIREN_COUNT_MAX) return false; pVehicle->m_tSirenBeaconInfo.m_bOverrideSirens = true; From 1e36fc8e7ce717a57644581cfb84b59531b1243f Mon Sep 17 00:00:00 2001 From: Uladzislau Nikalayevich Date: Tue, 15 Oct 2024 17:22:26 +0300 Subject: [PATCH 13/13] Add new line at end of the file --- Client/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp b/Client/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp index b1e27a1567..edf034142f 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp +++ b/Client/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp @@ -4365,4 +4365,4 @@ bool CLuaVehicleDefs::RemoveVehicleSirens(CClientVehicle* vehicle) noexcept { vehicle->RemoveVehicleSirens(); return true; -} \ No newline at end of file +}