From 567d645c57f806a2c9dcff1ceed78f1a69ecd249 Mon Sep 17 00:00:00 2001 From: samr46 Date: Wed, 19 Feb 2025 21:13:37 +0200 Subject: [PATCH] Add new world special property (vehicleburnexplosions) --- Client/game_sa/CGameSA.cpp | 19 +++++++++++++++++++ Client/game_sa/CGameSA.h | 4 ++++ Client/mods/deathmatch/logic/CClientGame.cpp | 8 ++++++++ .../mods/deathmatch/logic/CPacketHandler.cpp | 1 + Client/sdk/game/CGame.h | 3 +++ Server/mods/deathmatch/logic/CGame.cpp | 4 ++++ .../logic/packets/CMapInfoPacket.cpp | 1 + Shared/mods/deathmatch/logic/Enums.cpp | 1 + Shared/mods/deathmatch/logic/Enums.h | 1 + Shared/sdk/net/SyncStructures.h | 18 ++++++++++++++++++ Shared/sdk/net/bitstream.h | 4 ++++ 11 files changed, 64 insertions(+) diff --git a/Client/game_sa/CGameSA.cpp b/Client/game_sa/CGameSA.cpp index 49992830d94..698bbe2216d 100644 --- a/Client/game_sa/CGameSA.cpp +++ b/Client/game_sa/CGameSA.cpp @@ -902,6 +902,25 @@ void CGameSA::SetIgnoreFireStateEnabled(bool isEnabled) m_isIgnoreFireStateEnabled = isEnabled; } +void CGameSA::SetVehicleBurnExplosionsEnabled(bool isEnabled) +{ + if (isEnabled == m_isVehicleBurnExplosionsEnabled) + return; + + if (isEnabled) + { + MemCpy((void*)0x6A74EA, "\xE8\x61\xF5\x08\x00", 5); // CAutomobile::ProcessCarOnFireAndExplode + MemCpy((void*)0x737929, "\xE8\x22\xF1\xFF\xFF", 5); // CExplosion::Update + } + else + { + MemSet((void*)0x6A74EA, 0x90, 5); + MemSet((void*)0x737929, 0x90, 5); + } + + m_isVehicleBurnExplosionsEnabled = isEnabled; +} + bool CGameSA::PerformChecks() { std::map::iterator it; diff --git a/Client/game_sa/CGameSA.h b/Client/game_sa/CGameSA.h index 5c659d458dc..2bd6ec96c7a 100644 --- a/Client/game_sa/CGameSA.h +++ b/Client/game_sa/CGameSA.h @@ -253,6 +253,9 @@ class CGameSA : public CGame bool IsIgnoreFireStateEnabled() const noexcept override { return m_isIgnoreFireStateEnabled; } void SetIgnoreFireStateEnabled(bool isEnabled) override; + bool IsVehicleBurnExplosionsEnabled() const noexcept override { return m_isVehicleBurnExplosionsEnabled; } + void SetVehicleBurnExplosionsEnabled(bool isEnabled) override; + unsigned long GetMinuteDuration(); void SetMinuteDuration(unsigned long ulTime); @@ -384,6 +387,7 @@ class CGameSA : public CGame bool m_isGameWorldRemoved{false}; bool m_isExtendedWaterCannonsEnabled{false}; bool m_isIgnoreFireStateEnabled{false}; + bool m_isVehicleBurnExplosionsEnabled{true}; static unsigned int& ClumpOffset; diff --git a/Client/mods/deathmatch/logic/CClientGame.cpp b/Client/mods/deathmatch/logic/CClientGame.cpp index b8a89c11094..5a27695cb49 100644 --- a/Client/mods/deathmatch/logic/CClientGame.cpp +++ b/Client/mods/deathmatch/logic/CClientGame.cpp @@ -6051,6 +6051,9 @@ bool CClientGame::SetWorldSpecialProperty(const WorldSpecialProperty property, c case WorldSpecialProperty::FLYINGCOMPONENTS: m_pVehicleManager->SetSpawnFlyingComponentEnabled(enabled); break; + case WorldSpecialProperty::VEHICLEBURNEXPLOSIONS: + g_pGame->SetVehicleBurnExplosionsEnabled(enabled); + break; default: return false; } @@ -6095,6 +6098,8 @@ bool CClientGame::IsWorldSpecialProperty(const WorldSpecialProperty property) return g_pGame->IsIgnoreFireStateEnabled(); case WorldSpecialProperty::FLYINGCOMPONENTS: return m_pVehicleManager->IsSpawnFlyingComponentEnabled(); + case WorldSpecialProperty::VEHICLEBURNEXPLOSIONS: + return g_pGame->IsVehicleBurnExplosionsEnabled(); } return false; @@ -6812,6 +6817,9 @@ void CClientGame::ResetWorldProperties(const ResetWorldPropsInfo& resetPropsInfo g_pGame->SetRoadSignsTextEnabled(true); g_pGame->SetExtendedWaterCannonsEnabled(true); g_pGame->SetTunnelWeatherBlendEnabled(true); + g_pGame->SetIgnoreFireStateEnabled(false); + m_pVehicleManager->SetSpawnFlyingComponentEnabled(true); + g_pGame->SetVehicleBurnExplosionsEnabled(true); } // Reset all setWorldProperty to default diff --git a/Client/mods/deathmatch/logic/CPacketHandler.cpp b/Client/mods/deathmatch/logic/CPacketHandler.cpp index 094812d816b..a6d5cf4ec1b 100644 --- a/Client/mods/deathmatch/logic/CPacketHandler.cpp +++ b/Client/mods/deathmatch/logic/CPacketHandler.cpp @@ -2401,6 +2401,7 @@ void CPacketHandler::Packet_MapInfo(NetBitStreamInterface& bitStream) g_pClientGame->SetWorldSpecialProperty(WorldSpecialProperty::TUNNELWEATHERBLEND, wsProps.data5.tunnelweatherblend); g_pClientGame->SetWorldSpecialProperty(WorldSpecialProperty::IGNOREFIRESTATE, wsProps.data6.ignoreFireState); g_pClientGame->SetWorldSpecialProperty(WorldSpecialProperty::FLYINGCOMPONENTS, wsProps.data7.flyingcomponents); + g_pClientGame->SetWorldSpecialProperty(WorldSpecialProperty::VEHICLEBURNEXPLOSIONS, wsProps.data8.vehicleburnexplosions); float fJetpackMaxHeight = 100; if (!bitStream.Read(fJetpackMaxHeight)) diff --git a/Client/sdk/game/CGame.h b/Client/sdk/game/CGame.h index a87225a0246..46c20ebace3 100644 --- a/Client/sdk/game/CGame.h +++ b/Client/sdk/game/CGame.h @@ -234,6 +234,9 @@ class __declspec(novtable) CGame virtual bool IsIgnoreFireStateEnabled() const noexcept = 0; virtual void SetIgnoreFireStateEnabled(bool isEnabled) = 0; + virtual bool IsVehicleBurnExplosionsEnabled() const noexcept = 0; + virtual void SetVehicleBurnExplosionsEnabled(bool isEnabled) = 0; + virtual CWeapon* CreateWeapon() = 0; virtual CWeaponStat* CreateWeaponStat(eWeaponType weaponType, eWeaponSkill weaponSkill) = 0; diff --git a/Server/mods/deathmatch/logic/CGame.cpp b/Server/mods/deathmatch/logic/CGame.cpp index 0d684789dfd..cc64b4a79fb 100644 --- a/Server/mods/deathmatch/logic/CGame.cpp +++ b/Server/mods/deathmatch/logic/CGame.cpp @@ -261,6 +261,7 @@ CGame::CGame() : m_FloodProtect(4, 30000, 30000) // Max of 4 connecti m_WorldSpecialProps[WorldSpecialProperty::TUNNELWEATHERBLEND] = true; m_WorldSpecialProps[WorldSpecialProperty::IGNOREFIRESTATE] = false; m_WorldSpecialProps[WorldSpecialProperty::FLYINGCOMPONENTS] = true; + m_WorldSpecialProps[WorldSpecialProperty::VEHICLEBURNEXPLOSIONS] = true; m_JetpackWeapons[WEAPONTYPE_MICRO_UZI] = true; m_JetpackWeapons[WEAPONTYPE_TEC9] = true; @@ -4517,6 +4518,9 @@ void CGame::ResetWorldProperties(const ResetWorldPropsInfo& resetPropsInfo) g_pGame->SetWorldSpecialPropertyEnabled(WorldSpecialProperty::ROADSIGNSTEXT, true); g_pGame->SetWorldSpecialPropertyEnabled(WorldSpecialProperty::EXTENDEDWATERCANNONS, true); g_pGame->SetWorldSpecialPropertyEnabled(WorldSpecialProperty::TUNNELWEATHERBLEND, true); + g_pGame->SetWorldSpecialPropertyEnabled(WorldSpecialProperty::IGNOREFIRESTATE, false); + g_pGame->SetWorldSpecialPropertyEnabled(WorldSpecialProperty::FLYINGCOMPONENTS, true); + g_pGame->SetWorldSpecialPropertyEnabled(WorldSpecialProperty::VEHICLEBURNEXPLOSIONS, true); } // Reset all weather stuff like heat haze, wind velocity etc diff --git a/Server/mods/deathmatch/logic/packets/CMapInfoPacket.cpp b/Server/mods/deathmatch/logic/packets/CMapInfoPacket.cpp index 2bbe9f9f646..9f6b4f96509 100644 --- a/Server/mods/deathmatch/logic/packets/CMapInfoPacket.cpp +++ b/Server/mods/deathmatch/logic/packets/CMapInfoPacket.cpp @@ -194,6 +194,7 @@ bool CMapInfoPacket::Write(NetBitStreamInterface& BitStream) const wsProps.data5.tunnelweatherblend = g_pGame->IsWorldSpecialPropertyEnabled(WorldSpecialProperty::TUNNELWEATHERBLEND); wsProps.data6.ignoreFireState = g_pGame->IsWorldSpecialPropertyEnabled(WorldSpecialProperty::IGNOREFIRESTATE); wsProps.data7.flyingcomponents = g_pGame->IsWorldSpecialPropertyEnabled(WorldSpecialProperty::FLYINGCOMPONENTS); + wsProps.data8.vehicleburnexplosions = g_pGame->IsWorldSpecialPropertyEnabled(WorldSpecialProperty::VEHICLEBURNEXPLOSIONS); BitStream.Write(&wsProps); } diff --git a/Shared/mods/deathmatch/logic/Enums.cpp b/Shared/mods/deathmatch/logic/Enums.cpp index 28f0ffe7a20..f87bf942974 100644 --- a/Shared/mods/deathmatch/logic/Enums.cpp +++ b/Shared/mods/deathmatch/logic/Enums.cpp @@ -103,6 +103,7 @@ ADD_ENUM(WorldSpecialProperty::ROADSIGNSTEXT, "roadsignstext") ADD_ENUM(WorldSpecialProperty::TUNNELWEATHERBLEND, "tunnelweatherblend") ADD_ENUM(WorldSpecialProperty::IGNOREFIRESTATE, "ignorefirestate") ADD_ENUM(WorldSpecialProperty::FLYINGCOMPONENTS, "flyingcomponents") +ADD_ENUM(WorldSpecialProperty::VEHICLEBURNEXPLOSIONS, "vehicleburnexplosions") IMPLEMENT_ENUM_CLASS_END("world-special-property") IMPLEMENT_ENUM_BEGIN(ePacketID) diff --git a/Shared/mods/deathmatch/logic/Enums.h b/Shared/mods/deathmatch/logic/Enums.h index bf3a9b9fe46..9210328e8b3 100644 --- a/Shared/mods/deathmatch/logic/Enums.h +++ b/Shared/mods/deathmatch/logic/Enums.h @@ -93,6 +93,7 @@ enum class WorldSpecialProperty TUNNELWEATHERBLEND, IGNOREFIRESTATE, FLYINGCOMPONENTS, + VEHICLEBURNEXPLOSIONS, }; DECLARE_ENUM_CLASS(WorldSpecialProperty); diff --git a/Shared/sdk/net/SyncStructures.h b/Shared/sdk/net/SyncStructures.h index afa32a05f0a..5c3d0009586 100644 --- a/Shared/sdk/net/SyncStructures.h +++ b/Shared/sdk/net/SyncStructures.h @@ -2079,6 +2079,10 @@ struct SWorldSpecialPropertiesStateSync : public ISyncStructure { BITCOUNT7 = 1 }; + enum + { + BITCOUNT8 = 1 + }; bool Read(NetBitStreamInterface& bitStream) { @@ -2112,6 +2116,11 @@ struct SWorldSpecialPropertiesStateSync : public ISyncStructure isOK &= bitStream.ReadBits(reinterpret_cast(&data7), BITCOUNT7); else data7.flyingcomponents = true; + + if (bitStream.Can(eBitStreamVersion::WorldSpecialProperty_VehicleBurnExplosions)) + isOK &= bitStream.ReadBits(reinterpret_cast(&data8), BITCOUNT8); + else + data8.vehicleburnexplosions = true; //// Example for adding item: // if (bitStream.Can(eBitStreamVersion::YourProperty)) @@ -2142,6 +2151,9 @@ struct SWorldSpecialPropertiesStateSync : public ISyncStructure if (bitStream.Can(eBitStreamVersion::WorldSpecialProperty_FlyingComponents)) bitStream.WriteBits(reinterpret_cast(&data7), BITCOUNT7); + if (bitStream.Can(eBitStreamVersion::WorldSpecialProperty_VehicleBurnExplosions)) + bitStream.WriteBits(reinterpret_cast(&data8), BITCOUNT8); + //// Example for adding item: // if (bitStream.Can(eBitStreamVersion::YourProperty)) // bitStream.WriteBits(reinterpret_cast(&data9), BITCOUNT9); @@ -2193,6 +2205,11 @@ struct SWorldSpecialPropertiesStateSync : public ISyncStructure { bool flyingcomponents : 1; } data7; + + struct + { + bool vehicleburnexplosions : 1; + } data8; SWorldSpecialPropertiesStateSync() { @@ -2215,6 +2232,7 @@ struct SWorldSpecialPropertiesStateSync : public ISyncStructure data5.tunnelweatherblend = true; data6.ignoreFireState = false; data7.flyingcomponents = true; + data8.vehicleburnexplosions = true; } }; diff --git a/Shared/sdk/net/bitstream.h b/Shared/sdk/net/bitstream.h index f0a61b66667..f9a7169aab5 100644 --- a/Shared/sdk/net/bitstream.h +++ b/Shared/sdk/net/bitstream.h @@ -612,6 +612,10 @@ enum class eBitStreamVersion : unsigned short // 2025-01-29 PedSync_CameraRotation, + // Add "vehicleburnexplosions" to setWorldSpecialPropertyEnabled + // 2025-02-20 + WorldSpecialProperty_VehicleBurnExplosions, + // This allows us to automatically increment the BitStreamVersion when things are added to this enum. // Make sure you only add things above this comment. Next,