From 08fc24add5d11bcc5cc75f872e55410e55e14e18 Mon Sep 17 00:00:00 2001 From: FileEX Date: Thu, 21 Aug 2025 00:00:09 +0200 Subject: [PATCH 1/6] The end of synchronization for blowVehicle and a few other functions --- .../logic/CStaticFunctionDefinitions.cpp | 44 +++++-------------- .../logic/luadefs/CLuaVehicleDefs.cpp | 6 +++ 2 files changed, 17 insertions(+), 33 deletions(-) diff --git a/Client/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp b/Client/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp index 544d0ad26a..9796bbf21a 100644 --- a/Client/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp +++ b/Client/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp @@ -1076,6 +1076,9 @@ bool CStaticFunctionDefinitions::SetElementPosition(CClientEntity& Entity, const { RUN_CHILDREN(SetElementPosition(**iter, vecPosition)) + if (!Entity.IsLocalEntity()) + return false; + if (bWarp) Entity.Teleport(vecPosition); else @@ -1491,6 +1494,9 @@ bool CStaticFunctionDefinitions::SetElementHealth(CClientEntity& Entity, float f { RUN_CHILDREN(SetElementHealth(**iter, fHealth)) + if (!Entity.IsLocalEntity()) + return false; + switch (Entity.GetType()) { case CCLIENTPED: @@ -2907,41 +2913,13 @@ bool CStaticFunctionDefinitions::BlowVehicle(CClientEntity& Entity, std::optiona return false; CClientVehicle& vehicle = static_cast(Entity); - VehicleBlowFlags blow; + if (!vehicle.IsLocalEntity()) + return false; + VehicleBlowFlags blow; + blow.withExplosion = withExplosion.value_or(true); - - if (vehicle.IsLocalEntity()) - { - vehicle.Blow(blow); - } - else - { - CVector position; - vehicle.GetPosition(position); - - const auto type = vehicle.GetType(); - const auto state = (blow.withExplosion ? VehicleBlowState::AWAITING_EXPLOSION_SYNC : VehicleBlowState::BLOWN); - eExplosionType explosion; - - switch (type) - { - case CLIENTVEHICLE_CAR: - explosion = EXP_TYPE_CAR; - break; - case CLIENTVEHICLE_HELI: - explosion = EXP_TYPE_HELI; - break; - case CLIENTVEHICLE_BOAT: - explosion = EXP_TYPE_BOAT; - break; - default: - explosion = EXP_TYPE_CAR; - } - - g_pClientGame->SendExplosionSync(position, explosion, &Entity, state); - } - + vehicle.Blow(blow); return true; } diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp b/Client/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp index 219c8cb6a4..0cdd608a4b 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp +++ b/Client/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp @@ -2518,6 +2518,12 @@ int CLuaVehicleDefs::SetVehicleHandling(lua_State* luaVM) if (!argStream.HasErrors()) { + if (!pVehicle->IsLocalEntity()) + { + lua_pushboolean(luaVM, false); + return 1; + } + if (argStream.NextIsString()) { SString strProperty; From f4cdc453d0137d3c9baf6acdad5ce77678854a04 Mon Sep 17 00:00:00 2001 From: FileEX Date: Thu, 21 Aug 2025 11:20:14 +0200 Subject: [PATCH 2/6] Changes --- .../mods/deathmatch/logic/CStaticFunctionDefinitions.cpp | 7 +++++-- Client/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp | 6 ------ 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/Client/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp b/Client/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp index 9796bbf21a..47678f272d 100644 --- a/Client/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp +++ b/Client/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp @@ -1076,8 +1076,11 @@ bool CStaticFunctionDefinitions::SetElementPosition(CClientEntity& Entity, const { RUN_CHILDREN(SetElementPosition(**iter, vecPosition)) - if (!Entity.IsLocalEntity()) - return false; + if (Entity.GetType() == CCLIENTVEHICLE) + { + if (!Entity.IsLocalEntity() && !static_cast(Entity).IsSyncing()) + return false; + } if (bWarp) Entity.Teleport(vecPosition); diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp b/Client/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp index 0cdd608a4b..219c8cb6a4 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp +++ b/Client/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp @@ -2518,12 +2518,6 @@ int CLuaVehicleDefs::SetVehicleHandling(lua_State* luaVM) if (!argStream.HasErrors()) { - if (!pVehicle->IsLocalEntity()) - { - lua_pushboolean(luaVM, false); - return 1; - } - if (argStream.NextIsString()) { SString strProperty; From 3a75606eaaf86ae3698e64062a6c648ac45fcf19 Mon Sep 17 00:00:00 2001 From: FileEX Date: Thu, 21 Aug 2025 11:33:59 +0200 Subject: [PATCH 3/6] Update CStaticFunctionDefinitions.cpp --- Client/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Client/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp b/Client/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp index 47678f272d..dd2a10047f 100644 --- a/Client/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp +++ b/Client/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp @@ -1078,7 +1078,8 @@ bool CStaticFunctionDefinitions::SetElementPosition(CClientEntity& Entity, const if (Entity.GetType() == CCLIENTVEHICLE) { - if (!Entity.IsLocalEntity() && !static_cast(Entity).IsSyncing()) + CClientPed* driver = static_cast(Entity).GetOccupant(0); + if (!Entity.IsLocalEntity() && !static_cast(Entity).IsSyncing() && (driver && !driver->IsLocalPlayer())) return false; } From 443d745e1018aab1f84f6cee4380caf8dd1b5175 Mon Sep 17 00:00:00 2001 From: FileEX Date: Thu, 21 Aug 2025 11:50:30 +0200 Subject: [PATCH 4/6] Review --- Client/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Client/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp b/Client/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp index dd2a10047f..821594a28e 100644 --- a/Client/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp +++ b/Client/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp @@ -1079,7 +1079,7 @@ bool CStaticFunctionDefinitions::SetElementPosition(CClientEntity& Entity, const if (Entity.GetType() == CCLIENTVEHICLE) { CClientPed* driver = static_cast(Entity).GetOccupant(0); - if (!Entity.IsLocalEntity() && !static_cast(Entity).IsSyncing() && (driver && !driver->IsLocalPlayer())) + if (!Entity.IsLocalEntity() && !static_cast(Entity).IsSyncing() && (!driver || !driver->IsLocalPlayer())) return false; } From 9f29b2a5e8b921efc91e4d01b114764bc12f12d6 Mon Sep 17 00:00:00 2001 From: FileEX Date: Thu, 21 Aug 2025 23:11:44 +0200 Subject: [PATCH 5/6] Update CStaticFunctionDefinitions.cpp --- Client/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Client/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp b/Client/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp index 821594a28e..a06ca37b24 100644 --- a/Client/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp +++ b/Client/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp @@ -1498,9 +1498,6 @@ bool CStaticFunctionDefinitions::SetElementHealth(CClientEntity& Entity, float f { RUN_CHILDREN(SetElementHealth(**iter, fHealth)) - if (!Entity.IsLocalEntity()) - return false; - switch (Entity.GetType()) { case CCLIENTPED: @@ -1508,6 +1505,8 @@ bool CStaticFunctionDefinitions::SetElementHealth(CClientEntity& Entity, float f { // Grab the model CClientPed& Ped = static_cast(Entity); + if (Ped.IsLocalPlayer()) + return false; // Set the new health Ped.SetHealth(Clamp(0.0f, fHealth, Ped.GetMaxHealth())); From 58484bed3ec56b7edc71e51f312b4faea30ce360 Mon Sep 17 00:00:00 2001 From: FileEX Date: Sun, 24 Aug 2025 12:47:26 +0200 Subject: [PATCH 6/6] Changes --- .../logic/CStaticFunctionDefinitions.cpp | 41 ++++++++++++++++--- 1 file changed, 36 insertions(+), 5 deletions(-) diff --git a/Client/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp b/Client/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp index a06ca37b24..c752503628 100644 --- a/Client/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp +++ b/Client/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp @@ -2916,13 +2916,44 @@ bool CStaticFunctionDefinitions::BlowVehicle(CClientEntity& Entity, std::optiona return false; CClientVehicle& vehicle = static_cast(Entity); - if (!vehicle.IsLocalEntity()) - return false; - VehicleBlowFlags blow; - blow.withExplosion = withExplosion.value_or(true); - vehicle.Blow(blow); + + if (vehicle.IsLocalEntity()) + { + vehicle.Blow(blow); + } + else + { + CClientPed* driver = vehicle.GetOccupant(0); + if (!static_cast(vehicle).IsSyncing() && (!driver || !driver->IsLocalPlayer())) + return false; + + CVector position; + vehicle.GetPosition(position); + + const auto type = vehicle.GetType(); + const auto state = (blow.withExplosion ? VehicleBlowState::AWAITING_EXPLOSION_SYNC : VehicleBlowState::BLOWN); + eExplosionType explosion; + + switch (type) + { + case CLIENTVEHICLE_CAR: + explosion = EXP_TYPE_CAR; + break; + case CLIENTVEHICLE_HELI: + explosion = EXP_TYPE_HELI; + break; + case CLIENTVEHICLE_BOAT: + explosion = EXP_TYPE_BOAT; + break; + default: + explosion = EXP_TYPE_CAR; + } + + g_pClientGame->SendExplosionSync(position, explosion, &Entity, state); + } + return true; }