From 505a1e7b3d1626632ddd63835a92ec9b610e2a2c Mon Sep 17 00:00:00 2001 From: Xenius97 Date: Thu, 13 Nov 2025 12:58:58 +0100 Subject: [PATCH 01/10] Implement SetVehicleSmokeTrailEnabled for serverside --- Client/mods/deathmatch/logic/rpc/CVehicleRPCs.cpp | 14 ++++++++++++++ Client/mods/deathmatch/logic/rpc/CVehicleRPCs.h | 1 + .../deathmatch/logic/luadefs/CLuaVehicleDefs.cpp | 12 +++++++++++- .../deathmatch/logic/luadefs/CLuaVehicleDefs.h | 2 ++ Shared/sdk/net/rpc_enums.h | 2 ++ 5 files changed, 30 insertions(+), 1 deletion(-) diff --git a/Client/mods/deathmatch/logic/rpc/CVehicleRPCs.cpp b/Client/mods/deathmatch/logic/rpc/CVehicleRPCs.cpp index 0d318c75467..9ab1cbb539e 100644 --- a/Client/mods/deathmatch/logic/rpc/CVehicleRPCs.cpp +++ b/Client/mods/deathmatch/logic/rpc/CVehicleRPCs.cpp @@ -54,6 +54,7 @@ void CVehicleRPCs::LoadFunctions() AddHandler(SET_VEHICLE_PLATE_TEXT, SetVehiclePlateText, "setVehiclePlateText"); AddHandler(SPAWN_VEHICLE_FLYING_COMPONENT, SpawnVehicleFlyingComponent, "spawnVehicleFlyingComponent"); AddHandler(SET_VEHICLE_NITRO_ACTIVATED, SetVehicleNitroActivated, "SetVehicleNitroActivated"); + AddHandler(SET_VEHICLE_SMOKE_TRAIL_ENABLED, SetVehicleSmokeTrailEnabled, "SetVehicleSmokeTrailEnabled"); } void CVehicleRPCs::DestroyAllVehicles(NetBitStreamInterface& bitStream) @@ -693,3 +694,16 @@ void CVehicleRPCs::SetVehicleNitroActivated(CClientEntity* pSourceEntity, NetBit vehicle->SetNitroLevel(vehicle->GetNitroLevel() + 1.0001f); } +void CVehicleRPCs::SetVehicleSmokeTrailEnabled(CClientEntity* pSourceEntity, NetBitStreamInterface& bitStream) +{ + bool state = bitStream.ReadBit(); + CClientVehicle* vehicle = m_pVehicleManager->Get(pSourceEntity->GetID()); + if (!vehicle) + return; + + std::uint16_t model = vehicle->GetModel(); + if (model != 512 && model != 513) + return; + + vehicle->SetSmokeTrailEnabled(state); +} diff --git a/Client/mods/deathmatch/logic/rpc/CVehicleRPCs.h b/Client/mods/deathmatch/logic/rpc/CVehicleRPCs.h index c1649abd4bf..e49b6f42e07 100644 --- a/Client/mods/deathmatch/logic/rpc/CVehicleRPCs.h +++ b/Client/mods/deathmatch/logic/rpc/CVehicleRPCs.h @@ -59,4 +59,5 @@ class CVehicleRPCs : public CRPCFunctions DECLARE_ELEMENT_RPC(SetVehiclePlateText); DECLARE_ELEMENT_RPC(SpawnVehicleFlyingComponent); DECLARE_ELEMENT_RPC(SetVehicleNitroActivated); + DECLARE_ELEMENT_RPC(SetVehicleSmokeTrailEnabled); }; diff --git a/Server/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp b/Server/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp index 13d72615fcd..0bccdabb809 100644 --- a/Server/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp +++ b/Server/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp @@ -128,6 +128,7 @@ void CLuaVehicleDefs::LoadFunctions() {"getVehicleSirenParams", GetVehicleSirenParams}, {"setVehiclePlateText", SetVehiclePlateText}, {"setVehicleNitroActivated", ArgumentParser}, + {"setVehicleSmokeTrailEnabled", ArgumentParser}, }; // Add functions @@ -3059,4 +3060,13 @@ bool CLuaVehicleDefs::SetVehicleNitroActivated(CVehicle* vehicle, bool state) no m_pPlayerManager->BroadcastOnlyJoined(CElementRPCPacket(vehicle, SET_VEHICLE_NITRO_ACTIVATED, *BitStream.pBitStream)); return true; -} \ No newline at end of file +} + +bool CLuaVehicleDefs::SetVehicleSmokeTrailEnabled(CVehicle* vehicle, bool state) noexcept +{ + CBitStream BitStream; + BitStream.pBitStream->WriteBit(state); + + m_pPlayerManager->BroadcastOnlyJoined(CElementRPCPacket(vehicle, SET_VEHICLE_SMOKE_TRAIL_ENABLED, *BitStream.pBitStream)); + return true; +} diff --git a/Server/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.h b/Server/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.h index 38652371c00..c468071d2dc 100644 --- a/Server/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.h +++ b/Server/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.h @@ -128,4 +128,6 @@ class CLuaVehicleDefs : public CLuaDefs static bool SpawnVehicleFlyingComponent(CVehicle* const vehicle, std::uint8_t nodeIndex, std::optional componentCollisionType, std::optional removalTime); static bool SetVehicleNitroActivated(CVehicle* vehicle, bool state) noexcept; + static bool SetVehicleSmokeTrailEnabled(CVehicle* vehicle, bool state) noexcept; + static bool IsVehicleSmokeTrailEnabled(CVehicle* vehicle) noexcept; }; diff --git a/Shared/sdk/net/rpc_enums.h b/Shared/sdk/net/rpc_enums.h index 84c7518bc45..7dc4d62436a 100644 --- a/Shared/sdk/net/rpc_enums.h +++ b/Shared/sdk/net/rpc_enums.h @@ -290,6 +290,8 @@ enum eElementRPCFunctions SPAWN_VEHICLE_FLYING_COMPONENT, SET_VEHICLE_NITRO_ACTIVATED, + + SET_VEHICLE_SMOKE_TRAIL_ENABLED, SET_ELEMENT_ON_FIRE, From e27a78f7764fdced683bcaa06044f65d3474f03d Mon Sep 17 00:00:00 2001 From: Xenius97 Date: Thu, 13 Nov 2025 13:14:13 +0100 Subject: [PATCH 02/10] no need for this --- Client/mods/deathmatch/logic/rpc/CVehicleRPCs.cpp | 14 -------------- Client/mods/deathmatch/logic/rpc/CVehicleRPCs.h | 1 - Shared/sdk/net/rpc_enums.h | 2 -- 3 files changed, 17 deletions(-) diff --git a/Client/mods/deathmatch/logic/rpc/CVehicleRPCs.cpp b/Client/mods/deathmatch/logic/rpc/CVehicleRPCs.cpp index 9ab1cbb539e..0d318c75467 100644 --- a/Client/mods/deathmatch/logic/rpc/CVehicleRPCs.cpp +++ b/Client/mods/deathmatch/logic/rpc/CVehicleRPCs.cpp @@ -54,7 +54,6 @@ void CVehicleRPCs::LoadFunctions() AddHandler(SET_VEHICLE_PLATE_TEXT, SetVehiclePlateText, "setVehiclePlateText"); AddHandler(SPAWN_VEHICLE_FLYING_COMPONENT, SpawnVehicleFlyingComponent, "spawnVehicleFlyingComponent"); AddHandler(SET_VEHICLE_NITRO_ACTIVATED, SetVehicleNitroActivated, "SetVehicleNitroActivated"); - AddHandler(SET_VEHICLE_SMOKE_TRAIL_ENABLED, SetVehicleSmokeTrailEnabled, "SetVehicleSmokeTrailEnabled"); } void CVehicleRPCs::DestroyAllVehicles(NetBitStreamInterface& bitStream) @@ -694,16 +693,3 @@ void CVehicleRPCs::SetVehicleNitroActivated(CClientEntity* pSourceEntity, NetBit vehicle->SetNitroLevel(vehicle->GetNitroLevel() + 1.0001f); } -void CVehicleRPCs::SetVehicleSmokeTrailEnabled(CClientEntity* pSourceEntity, NetBitStreamInterface& bitStream) -{ - bool state = bitStream.ReadBit(); - CClientVehicle* vehicle = m_pVehicleManager->Get(pSourceEntity->GetID()); - if (!vehicle) - return; - - std::uint16_t model = vehicle->GetModel(); - if (model != 512 && model != 513) - return; - - vehicle->SetSmokeTrailEnabled(state); -} diff --git a/Client/mods/deathmatch/logic/rpc/CVehicleRPCs.h b/Client/mods/deathmatch/logic/rpc/CVehicleRPCs.h index e49b6f42e07..c1649abd4bf 100644 --- a/Client/mods/deathmatch/logic/rpc/CVehicleRPCs.h +++ b/Client/mods/deathmatch/logic/rpc/CVehicleRPCs.h @@ -59,5 +59,4 @@ class CVehicleRPCs : public CRPCFunctions DECLARE_ELEMENT_RPC(SetVehiclePlateText); DECLARE_ELEMENT_RPC(SpawnVehicleFlyingComponent); DECLARE_ELEMENT_RPC(SetVehicleNitroActivated); - DECLARE_ELEMENT_RPC(SetVehicleSmokeTrailEnabled); }; diff --git a/Shared/sdk/net/rpc_enums.h b/Shared/sdk/net/rpc_enums.h index 7dc4d62436a..84c7518bc45 100644 --- a/Shared/sdk/net/rpc_enums.h +++ b/Shared/sdk/net/rpc_enums.h @@ -290,8 +290,6 @@ enum eElementRPCFunctions SPAWN_VEHICLE_FLYING_COMPONENT, SET_VEHICLE_NITRO_ACTIVATED, - - SET_VEHICLE_SMOKE_TRAIL_ENABLED, SET_ELEMENT_ON_FIRE, From 013cafcb430346059a9569558417c8faa507c7d0 Mon Sep 17 00:00:00 2001 From: Xenius97 Date: Thu, 13 Nov 2025 13:19:33 +0100 Subject: [PATCH 03/10] work --- .../logic/CStaticFunctionDefinitions.cpp | 5 ++++ .../logic/CStaticFunctionDefinitions.h | 1 + .../logic/luadefs/CLuaVehicleDefs.cpp | 24 +++++++++++++++---- .../logic/luadefs/CLuaVehicleDefs.h | 2 +- 4 files changed, 27 insertions(+), 5 deletions(-) diff --git a/Server/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp b/Server/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp index 52695b056fc..1953b68e990 100644 --- a/Server/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp +++ b/Server/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp @@ -12668,3 +12668,8 @@ bool CStaticFunctionDefinitions::SpawnVehicleFlyingComponent(CVehicle* const veh return true; } + +bool CStaticFunctionDefinitions::IsVehicleSmokeTrailEnabled(CVehicle* const vehicle) +{ + return vehicle->IsSmokeTrailEnabled(); +} diff --git a/Server/mods/deathmatch/logic/CStaticFunctionDefinitions.h b/Server/mods/deathmatch/logic/CStaticFunctionDefinitions.h index 388f38b4439..a4773fba16f 100644 --- a/Server/mods/deathmatch/logic/CStaticFunctionDefinitions.h +++ b/Server/mods/deathmatch/logic/CStaticFunctionDefinitions.h @@ -296,6 +296,7 @@ class CStaticFunctionDefinitions static bool GetEntryHandling(const CHandlingEntry* pEntry, eHandlingProperty eProperty, std::string& strValue); static bool GetEntryHandling(const CHandlingEntry* pEntry, eHandlingProperty eProperty, unsigned int& uiValue); static bool GetEntryHandling(const CHandlingEntry* pEntry, eHandlingProperty eProperty, unsigned char& ucValue); + static bool IsVehicleSmokeTrailEnabled(CVehicle* const vehicle); // Vehicle set functions static bool FixVehicle(CElement* pElement); diff --git a/Server/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp b/Server/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp index 0bccdabb809..2ffd0132173 100644 --- a/Server/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp +++ b/Server/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp @@ -69,6 +69,7 @@ void CLuaVehicleDefs::LoadFunctions() {"isVehicleBlown", ArgumentParserWarn}, {"getVehicleHeadLightColor", GetVehicleHeadLightColor}, {"getVehicleDoorOpenRatio", GetVehicleDoorOpenRatio}, + {"isVehicleSmokeTrailEnabled", IsVehicleSmokeTrailEnabled}, // Vehicle set funcs {"fixVehicle", FixVehicle}, @@ -210,6 +211,7 @@ void CLuaVehicleDefs::AddClass(lua_State* luaVM) lua_classfunction(luaVM, "isRespawnable", "isVehicleRespawnable"); lua_classfunction(luaVM, "getRespawnDelay", "getVehicleRespawnDelay"); lua_classfunction(luaVM, "getIdleRespawnDelay", "getVehicleIdleRespawnDelay"); + lua_classfunction(luaVM, "isSmokeTrailEnabled", "isVehicleSmokeTrailEnabled"); lua_classfunction(luaVM, "setColor", "setVehicleColor"); lua_classfunction(luaVM, "setDamageProof", "setVehicleDamageProof"); @@ -245,6 +247,7 @@ void CLuaVehicleDefs::AddClass(lua_State* luaVM) lua_classfunction(luaVM, "setTrainPosition", "setTrainPosition"); lua_classfunction(luaVM, "setTrainSpeed", "setTrainSpeed"); // Reduce confusion lua_classfunction(luaVM, "spawnFlyingComponent", "spawnVehicleFlyingComponent"); + lua_classfunction(luaVM, "setSmokeTrailEnabled", "setVehicleSmokeTrailEnabled"); lua_classvariable(luaVM, "damageProof", "setVehicleDamageProof", "isVehicleDamageProof"); lua_classvariable(luaVM, "locked", "setVehicleLocked", "isVehicleLocked"); @@ -3064,9 +3067,22 @@ bool CLuaVehicleDefs::SetVehicleNitroActivated(CVehicle* vehicle, bool state) no bool CLuaVehicleDefs::SetVehicleSmokeTrailEnabled(CVehicle* vehicle, bool state) noexcept { - CBitStream BitStream; - BitStream.pBitStream->WriteBit(state); - - m_pPlayerManager->BroadcastOnlyJoined(CElementRPCPacket(vehicle, SET_VEHICLE_SMOKE_TRAIL_ENABLED, *BitStream.pBitStream)); + vehicle->SetSmokeTrailEnabled(state); return true; } + +int CLuaVehicleDefs::IsVehicleSmokeTrailEnabled(lua_State* luaVM) +{ + CVehicle* pVehicle; + CScriptArgReader argStream(luaVM); + argStream.ReadUserData(pVehicle); + if (!argStream.HasErrors()) + { + lua_pushboolean(luaVM, CStaticFunctionDefinitions::IsVehicleSmokeTrailEnabled(pVehicle)); + return 1; + } + else + m_pScriptDebugging->LogCustom(luaVM, argStream.GetFullErrorMessage()); + lua_pushboolean(luaVM, false); + return 1; +} diff --git a/Server/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.h b/Server/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.h index c468071d2dc..bf4dfc28957 100644 --- a/Server/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.h +++ b/Server/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.h @@ -67,6 +67,7 @@ class CLuaVehicleDefs : public CLuaDefs static bool IsVehicleBlown(CVehicle* vehicle); LUA_DECLARE(GetVehicleHeadLightColor); LUA_DECLARE(GetVehicleDoorOpenRatio); + LUA_DECLARE(IsVehicleSmokeTrailEnabled); // Vehicle set functions LUA_DECLARE(FixVehicle); @@ -129,5 +130,4 @@ class CLuaVehicleDefs : public CLuaDefs static bool SpawnVehicleFlyingComponent(CVehicle* const vehicle, std::uint8_t nodeIndex, std::optional componentCollisionType, std::optional removalTime); static bool SetVehicleNitroActivated(CVehicle* vehicle, bool state) noexcept; static bool SetVehicleSmokeTrailEnabled(CVehicle* vehicle, bool state) noexcept; - static bool IsVehicleSmokeTrailEnabled(CVehicle* vehicle) noexcept; }; From ca9a6951d645972ca0ba7836b81cf3cdab43ba3e Mon Sep 17 00:00:00 2001 From: Xenius97 Date: Thu, 13 Nov 2025 13:19:36 +0100 Subject: [PATCH 04/10] Revert "no need for this" This reverts commit e27a78f7764fdced683bcaa06044f65d3474f03d. --- Client/mods/deathmatch/logic/rpc/CVehicleRPCs.cpp | 14 ++++++++++++++ Client/mods/deathmatch/logic/rpc/CVehicleRPCs.h | 1 + Shared/sdk/net/rpc_enums.h | 2 ++ 3 files changed, 17 insertions(+) diff --git a/Client/mods/deathmatch/logic/rpc/CVehicleRPCs.cpp b/Client/mods/deathmatch/logic/rpc/CVehicleRPCs.cpp index 0d318c75467..9ab1cbb539e 100644 --- a/Client/mods/deathmatch/logic/rpc/CVehicleRPCs.cpp +++ b/Client/mods/deathmatch/logic/rpc/CVehicleRPCs.cpp @@ -54,6 +54,7 @@ void CVehicleRPCs::LoadFunctions() AddHandler(SET_VEHICLE_PLATE_TEXT, SetVehiclePlateText, "setVehiclePlateText"); AddHandler(SPAWN_VEHICLE_FLYING_COMPONENT, SpawnVehicleFlyingComponent, "spawnVehicleFlyingComponent"); AddHandler(SET_VEHICLE_NITRO_ACTIVATED, SetVehicleNitroActivated, "SetVehicleNitroActivated"); + AddHandler(SET_VEHICLE_SMOKE_TRAIL_ENABLED, SetVehicleSmokeTrailEnabled, "SetVehicleSmokeTrailEnabled"); } void CVehicleRPCs::DestroyAllVehicles(NetBitStreamInterface& bitStream) @@ -693,3 +694,16 @@ void CVehicleRPCs::SetVehicleNitroActivated(CClientEntity* pSourceEntity, NetBit vehicle->SetNitroLevel(vehicle->GetNitroLevel() + 1.0001f); } +void CVehicleRPCs::SetVehicleSmokeTrailEnabled(CClientEntity* pSourceEntity, NetBitStreamInterface& bitStream) +{ + bool state = bitStream.ReadBit(); + CClientVehicle* vehicle = m_pVehicleManager->Get(pSourceEntity->GetID()); + if (!vehicle) + return; + + std::uint16_t model = vehicle->GetModel(); + if (model != 512 && model != 513) + return; + + vehicle->SetSmokeTrailEnabled(state); +} diff --git a/Client/mods/deathmatch/logic/rpc/CVehicleRPCs.h b/Client/mods/deathmatch/logic/rpc/CVehicleRPCs.h index c1649abd4bf..e49b6f42e07 100644 --- a/Client/mods/deathmatch/logic/rpc/CVehicleRPCs.h +++ b/Client/mods/deathmatch/logic/rpc/CVehicleRPCs.h @@ -59,4 +59,5 @@ class CVehicleRPCs : public CRPCFunctions DECLARE_ELEMENT_RPC(SetVehiclePlateText); DECLARE_ELEMENT_RPC(SpawnVehicleFlyingComponent); DECLARE_ELEMENT_RPC(SetVehicleNitroActivated); + DECLARE_ELEMENT_RPC(SetVehicleSmokeTrailEnabled); }; diff --git a/Shared/sdk/net/rpc_enums.h b/Shared/sdk/net/rpc_enums.h index 84c7518bc45..7dc4d62436a 100644 --- a/Shared/sdk/net/rpc_enums.h +++ b/Shared/sdk/net/rpc_enums.h @@ -290,6 +290,8 @@ enum eElementRPCFunctions SPAWN_VEHICLE_FLYING_COMPONENT, SET_VEHICLE_NITRO_ACTIVATED, + + SET_VEHICLE_SMOKE_TRAIL_ENABLED, SET_ELEMENT_ON_FIRE, From 7ffcb087a211ff354e216c756319d401ec59ab73 Mon Sep 17 00:00:00 2001 From: Xenius97 Date: Thu, 13 Nov 2025 13:21:53 +0100 Subject: [PATCH 05/10] fixes --- Server/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Server/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp b/Server/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp index 2ffd0132173..0702363509f 100644 --- a/Server/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp +++ b/Server/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp @@ -3067,7 +3067,10 @@ bool CLuaVehicleDefs::SetVehicleNitroActivated(CVehicle* vehicle, bool state) no bool CLuaVehicleDefs::SetVehicleSmokeTrailEnabled(CVehicle* vehicle, bool state) noexcept { - vehicle->SetSmokeTrailEnabled(state); + CBitStream BitStream; + BitStream.pBitStream->WriteBit(state); + + m_pPlayerManager->BroadcastOnlyJoined(CElementRPCPacket(vehicle, SET_VEHICLE_SMOKE_TRAIL_ENABLED, *BitStream.pBitStream)); return true; } From 0559598600580138ea3a58132f09c006fd105959 Mon Sep 17 00:00:00 2001 From: Xenius97 Date: Thu, 13 Nov 2025 16:10:28 +0100 Subject: [PATCH 06/10] Fixes --- Server/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp | 2 +- Shared/sdk/net/rpc_enums.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Server/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp b/Server/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp index 0702363509f..abb40ce038c 100644 --- a/Server/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp +++ b/Server/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp @@ -3065,7 +3065,7 @@ bool CLuaVehicleDefs::SetVehicleNitroActivated(CVehicle* vehicle, bool state) no return true; } -bool CLuaVehicleDefs::SetVehicleSmokeTrailEnabled(CVehicle* vehicle, bool state) noexcept +bool CLuaVehicleDefs::SetVehicleSmokeTrailEnabled(CVehicle* vehicle, bool state) { CBitStream BitStream; BitStream.pBitStream->WriteBit(state); diff --git a/Shared/sdk/net/rpc_enums.h b/Shared/sdk/net/rpc_enums.h index 7dc4d62436a..fa7128576f8 100644 --- a/Shared/sdk/net/rpc_enums.h +++ b/Shared/sdk/net/rpc_enums.h @@ -291,9 +291,9 @@ enum eElementRPCFunctions SET_VEHICLE_NITRO_ACTIVATED, - SET_VEHICLE_SMOKE_TRAIL_ENABLED, - SET_ELEMENT_ON_FIRE, + SET_VEHICLE_SMOKE_TRAIL_ENABLED, + NUM_RPC_FUNCS // Add above this line }; From 48c0eccdcd60030372c55f71ae11f034d8f60fb3 Mon Sep 17 00:00:00 2001 From: Xenius97 Date: Thu, 13 Nov 2025 16:45:31 +0100 Subject: [PATCH 07/10] Requested changes --- .../deathmatch/logic/rpc/CVehicleRPCs.cpp | 4 ---- .../logic/CStaticFunctionDefinitions.cpp | 5 ---- .../logic/luadefs/CLuaVehicleDefs.cpp | 23 ++++++++----------- .../logic/luadefs/CLuaVehicleDefs.h | 4 ++-- 4 files changed, 11 insertions(+), 25 deletions(-) diff --git a/Client/mods/deathmatch/logic/rpc/CVehicleRPCs.cpp b/Client/mods/deathmatch/logic/rpc/CVehicleRPCs.cpp index 9ab1cbb539e..378ae3680e4 100644 --- a/Client/mods/deathmatch/logic/rpc/CVehicleRPCs.cpp +++ b/Client/mods/deathmatch/logic/rpc/CVehicleRPCs.cpp @@ -701,9 +701,5 @@ void CVehicleRPCs::SetVehicleSmokeTrailEnabled(CClientEntity* pSourceEntity, Net if (!vehicle) return; - std::uint16_t model = vehicle->GetModel(); - if (model != 512 && model != 513) - return; - vehicle->SetSmokeTrailEnabled(state); } diff --git a/Server/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp b/Server/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp index 1953b68e990..52695b056fc 100644 --- a/Server/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp +++ b/Server/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp @@ -12668,8 +12668,3 @@ bool CStaticFunctionDefinitions::SpawnVehicleFlyingComponent(CVehicle* const veh return true; } - -bool CStaticFunctionDefinitions::IsVehicleSmokeTrailEnabled(CVehicle* const vehicle) -{ - return vehicle->IsSmokeTrailEnabled(); -} diff --git a/Server/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp b/Server/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp index abb40ce038c..4219a5f553d 100644 --- a/Server/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp +++ b/Server/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp @@ -69,7 +69,7 @@ void CLuaVehicleDefs::LoadFunctions() {"isVehicleBlown", ArgumentParserWarn}, {"getVehicleHeadLightColor", GetVehicleHeadLightColor}, {"getVehicleDoorOpenRatio", GetVehicleDoorOpenRatio}, - {"isVehicleSmokeTrailEnabled", IsVehicleSmokeTrailEnabled}, + {"isVehicleSmokeTrailEnabled", ArgumentParser}, // Vehicle set funcs {"fixVehicle", FixVehicle}, @@ -3067,6 +3067,12 @@ bool CLuaVehicleDefs::SetVehicleNitroActivated(CVehicle* vehicle, bool state) no bool CLuaVehicleDefs::SetVehicleSmokeTrailEnabled(CVehicle* vehicle, bool state) { + std::uint16_t model = vehicle->GetModel(); + if (model != 512 && model != 513) + return false; + + vehicle->SetSmokeTrailEnabled(state); + CBitStream BitStream; BitStream.pBitStream->WriteBit(state); @@ -3074,18 +3080,7 @@ bool CLuaVehicleDefs::SetVehicleSmokeTrailEnabled(CVehicle* vehicle, bool state) return true; } -int CLuaVehicleDefs::IsVehicleSmokeTrailEnabled(lua_State* luaVM) +bool CLuaVehicleDefs::IsVehicleSmokeTrailEnabled(CVehicle* vehicle) { - CVehicle* pVehicle; - CScriptArgReader argStream(luaVM); - argStream.ReadUserData(pVehicle); - if (!argStream.HasErrors()) - { - lua_pushboolean(luaVM, CStaticFunctionDefinitions::IsVehicleSmokeTrailEnabled(pVehicle)); - return 1; - } - else - m_pScriptDebugging->LogCustom(luaVM, argStream.GetFullErrorMessage()); - lua_pushboolean(luaVM, false); - return 1; + return vehicle->IsSmokeTrailEnabled(); } diff --git a/Server/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.h b/Server/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.h index bf4dfc28957..c07a3603de9 100644 --- a/Server/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.h +++ b/Server/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.h @@ -67,7 +67,6 @@ class CLuaVehicleDefs : public CLuaDefs static bool IsVehicleBlown(CVehicle* vehicle); LUA_DECLARE(GetVehicleHeadLightColor); LUA_DECLARE(GetVehicleDoorOpenRatio); - LUA_DECLARE(IsVehicleSmokeTrailEnabled); // Vehicle set functions LUA_DECLARE(FixVehicle); @@ -129,5 +128,6 @@ class CLuaVehicleDefs : public CLuaDefs static bool SpawnVehicleFlyingComponent(CVehicle* const vehicle, std::uint8_t nodeIndex, std::optional componentCollisionType, std::optional removalTime); static bool SetVehicleNitroActivated(CVehicle* vehicle, bool state) noexcept; - static bool SetVehicleSmokeTrailEnabled(CVehicle* vehicle, bool state) noexcept; + static bool SetVehicleSmokeTrailEnabled(CVehicle* vehicle, bool state); + static bool IsVehicleSmokeTrailEnabled(CVehicle* vehicle); }; From 1e04144c327f5ab382760383e07156dd07940fab Mon Sep 17 00:00:00 2001 From: Xenius97 Date: Thu, 13 Nov 2025 17:21:17 +0100 Subject: [PATCH 08/10] Fixes --- Client/mods/deathmatch/logic/CPacketHandler.cpp | 7 +++++++ Server/mods/deathmatch/logic/packets/CEntityAddPacket.cpp | 1 + 2 files changed, 8 insertions(+) diff --git a/Client/mods/deathmatch/logic/CPacketHandler.cpp b/Client/mods/deathmatch/logic/CPacketHandler.cpp index 339110ff311..62456186cd1 100644 --- a/Client/mods/deathmatch/logic/CPacketHandler.cpp +++ b/Client/mods/deathmatch/logic/CPacketHandler.cpp @@ -3448,6 +3448,13 @@ void CPacketHandler::Packet_EntityAdd(NetBitStreamInterface& bitStream) bool bIsDerailable = bitStream.ReadBit(); bool bTrainDirection = bitStream.ReadBit(); bool bTaxiLightState = bitStream.ReadBit(); + bool bSmokeTrailEnabled = bitStream.ReadBit(); + + // Set smoke trail for appropriate vehicles + if (usModel == 512 || usModel == 513) + { + pVehicle->SetSmokeTrailEnabled(bSmokeTrailEnabled); + } // If the vehicle has a landing gear, set landing gear state if (CClientVehicleManager::HasLandingGears(usModel)) diff --git a/Server/mods/deathmatch/logic/packets/CEntityAddPacket.cpp b/Server/mods/deathmatch/logic/packets/CEntityAddPacket.cpp index f87a776f1ea..4dfb6638d0b 100644 --- a/Server/mods/deathmatch/logic/packets/CEntityAddPacket.cpp +++ b/Server/mods/deathmatch/logic/packets/CEntityAddPacket.cpp @@ -577,6 +577,7 @@ bool CEntityAddPacket::Write(NetBitStreamInterface& BitStream) const BitStream.WriteBit(pVehicle->IsDerailable()); BitStream.WriteBit(pVehicle->GetTrainDirection()); BitStream.WriteBit(pVehicle->IsTaxiLightOn()); + BitStream.WriteBit(pVehicle->IsSmokeTrailEnabled()); // Write alpha SEntityAlphaSync alpha; From c99e79de11bfb8334f7ce332a8a4fcf4918686d7 Mon Sep 17 00:00:00 2001 From: Xenius97 Date: Thu, 13 Nov 2025 17:27:06 +0100 Subject: [PATCH 09/10] add missing oop stuff --- Client/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp | 1 + Server/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp | 1 + 2 files changed, 2 insertions(+) diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp b/Client/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp index 94945f0fbc5..01ce59562e2 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp +++ b/Client/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp @@ -374,6 +374,7 @@ void CLuaVehicleDefs::AddClass(lua_State* luaVM) lua_classvariable(luaVM, "wheelScale", "setVehicleWheelScale", "getVehicleWheelScale"); lua_classvariable(luaVM, "rotorState", "setVehicleRotorState", "getVehicleRotorState"); lua_classvariable(luaVM, "audioSettings", nullptr, "getVehicleAudioSettings"); + lua_classvariable(luaVM, "smokeTrailEnabled", "setVehicleSmokeTrailEnabled", "isVehicleSmokeTrailEnabled"); lua_registerclass(luaVM, "Vehicle", "Element"); } diff --git a/Server/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp b/Server/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp index 4219a5f553d..17f1a2dd599 100644 --- a/Server/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp +++ b/Server/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp @@ -290,6 +290,7 @@ void CLuaVehicleDefs::AddClass(lua_State* luaVM) lua_classvariable(luaVM, "sirens", NULL, "getVehicleSirens"); lua_classvariable(luaVM, "handling", nullptr, "getVehicleHandling"); lua_classvariable(luaVM, "occupant", NULL, "getVehicleOccupant"); + lua_classvariable(luaVM, "smokeTrailEnabled", "setVehicleSmokeTrailEnabled", "isVehicleSmokeTrailEnabled"); lua_registerclass(luaVM, "Vehicle", "Element"); } From 81aa7456d1f393c063523d83f3deb4eead452477 Mon Sep 17 00:00:00 2001 From: Xenius97 Date: Thu, 13 Nov 2025 22:37:38 +0100 Subject: [PATCH 10/10] typo --- Server/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp | 2 +- Server/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Server/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp b/Server/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp index 17f1a2dd599..862aba293d7 100644 --- a/Server/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp +++ b/Server/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp @@ -3081,7 +3081,7 @@ bool CLuaVehicleDefs::SetVehicleSmokeTrailEnabled(CVehicle* vehicle, bool state) return true; } -bool CLuaVehicleDefs::IsVehicleSmokeTrailEnabled(CVehicle* vehicle) +bool CLuaVehicleDefs::IsVehicleSmokeTrailEnabled(CVehicle* vehicle) noexcept { return vehicle->IsSmokeTrailEnabled(); } diff --git a/Server/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.h b/Server/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.h index c07a3603de9..b3d4cf2c78f 100644 --- a/Server/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.h +++ b/Server/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.h @@ -129,5 +129,5 @@ class CLuaVehicleDefs : public CLuaDefs static bool SpawnVehicleFlyingComponent(CVehicle* const vehicle, std::uint8_t nodeIndex, std::optional componentCollisionType, std::optional removalTime); static bool SetVehicleNitroActivated(CVehicle* vehicle, bool state) noexcept; static bool SetVehicleSmokeTrailEnabled(CVehicle* vehicle, bool state); - static bool IsVehicleSmokeTrailEnabled(CVehicle* vehicle); + static bool IsVehicleSmokeTrailEnabled(CVehicle* vehicle) noexcept; };