diff --git a/Client/mods/deathmatch/logic/CNetAPI.cpp b/Client/mods/deathmatch/logic/CNetAPI.cpp index a6238512c7..1ce46c1267 100644 --- a/Client/mods/deathmatch/logic/CNetAPI.cpp +++ b/Client/mods/deathmatch/logic/CNetAPI.cpp @@ -1548,6 +1548,15 @@ void CNetAPI::ReadVehiclePuresync(CClientPlayer* pPlayer, CClientVehicle* pVehic pPlayer->SetLastPuresyncTime(CClientTime::GetTime()); pPlayer->IncrementVehicleSync(); pPlayer->SetLastPuresyncType(PURESYNC_TYPE_PURESYNC); + + if (BitStream.Can(eBitStreamVersion::IsVehicleNitroActivated_Serverside)) + { + float vehicleNitro; + if (!BitStream.Read(vehicleNitro)) + return; + + pVehicle->SetNitroLevel(vehicleNitro); + } } void CNetAPI::WriteVehiclePuresync(CClientPed* pPlayerModel, CClientVehicle* pVehicle, NetBitStreamInterface& BitStream) @@ -1768,6 +1777,9 @@ void CNetAPI::WriteVehiclePuresync(CClientPed* pPlayerModel, CClientVehicle* pVe // Write the sent position to the interpolator AddInterpolation(vecPosition); + + if (BitStream.Can(eBitStreamVersion::IsVehicleNitroActivated_Serverside)) + BitStream.Write(static_cast(pVehicle->GetNitroLevel())); } bool CNetAPI::ReadSmallKeysync(CControllerState& ControllerState, NetBitStreamInterface& BitStream) diff --git a/Server/mods/deathmatch/logic/CVehicle.h b/Server/mods/deathmatch/logic/CVehicle.h index 10de01e625..680817f732 100644 --- a/Server/mods/deathmatch/logic/CVehicle.h +++ b/Server/mods/deathmatch/logic/CVehicle.h @@ -280,6 +280,12 @@ class CVehicle final : public CElement CPed* GetJackingPed() { return m_pJackingPed; } void SetJackingPed(CPed* pPed); + float GetNitroLevel() const noexcept { return m_nitroLevel; } + void SetNitroLevel(float level) noexcept { m_nitroLevel = level; } + + bool IsNitroActivated() const noexcept { return m_nitroLevel > 0; } + void SetNitroActivated(bool activated) noexcept { m_nitroLevel = activated ? 1 : 0; } + bool IsInWater() { return m_bInWater; } void SetInWater(bool bInWater) { m_bInWater = bInWater; } @@ -453,6 +459,8 @@ class CVehicle final : public CElement bool m_bNeedsDimensionResync; ushort m_usLastUnoccupiedSyncDimension; + float m_nitroLevel; + public: // 'Safe' variables (that have no need for accessors) bool m_bDamageProof; uint m_uiDamageInfoSendPhase; diff --git a/Server/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.h b/Server/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.h index 3200e2ada3..9e8ef06b03 100644 --- a/Server/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.h +++ b/Server/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.h @@ -68,6 +68,10 @@ class CLuaVehicleDefs : public CLuaDefs LUA_DECLARE(GetVehicleHeadLightColor); LUA_DECLARE(GetVehicleDoorOpenRatio); + static bool IsVehicleNitroActivated(CVehicle* vehicle) noexcept; + static float GetVehicleNitroLevel(CVehicle* vehicle) noexcept; + static void SetVehicleNitroLevel(CVehicle* vehicle, std::int8_t level) noexcept; + // Vehicle set functions LUA_DECLARE(FixVehicle); LUA_DECLARE(SetVehicleRotation); diff --git a/Server/mods/deathmatch/logic/net/CSimVehiclePuresyncPacket.cpp b/Server/mods/deathmatch/logic/net/CSimVehiclePuresyncPacket.cpp index a89d2d3c3c..68d79121ce 100644 --- a/Server/mods/deathmatch/logic/net/CSimVehiclePuresyncPacket.cpp +++ b/Server/mods/deathmatch/logic/net/CSimVehiclePuresyncPacket.cpp @@ -251,6 +251,16 @@ bool CSimVehiclePuresyncPacket::Read(NetBitStreamInterface& BitStream) m_sharedControllerState.RightShoulder2 = BitStream.ReadBit() * 255; } + + if (BitStream.Can(eBitStreamVersion::IsVehicleNitroActivated_Serverside)) + { + float vehicleNitro; + if (!BitStream.Read(vehicleNitro)) + return false; + + m_Cache.VehNitroLevel = vehicleNitro; + } + // Success return true; } @@ -418,6 +428,11 @@ bool CSimVehiclePuresyncPacket::Write(NetBitStreamInterface& BitStream) const BitStream.Write(&damage); } + if (BitStream.Can(eBitStreamVersion::IsVehicleNitroActivated_Serverside)) + { + BitStream.Write(m_Cache.VehNitroLevel); + } + // Success return true; } diff --git a/Server/mods/deathmatch/logic/net/CSimVehiclePuresyncPacket.h b/Server/mods/deathmatch/logic/net/CSimVehiclePuresyncPacket.h index ead28e54b7..5536ad9872 100644 --- a/Server/mods/deathmatch/logic/net/CSimVehiclePuresyncPacket.h +++ b/Server/mods/deathmatch/logic/net/CSimVehiclePuresyncPacket.h @@ -73,6 +73,7 @@ class CSimVehiclePuresyncPacket : public CSimPacket CVector VehRotationDeg; CVector BothVelocity; CVector VehTurnSpeed; + float VehNitroLevel; float fVehHealth; diff --git a/Server/mods/deathmatch/logic/packets/CVehiclePuresyncPacket.cpp b/Server/mods/deathmatch/logic/packets/CVehiclePuresyncPacket.cpp index 67bc9574be..9dda43c4c1 100644 --- a/Server/mods/deathmatch/logic/packets/CVehiclePuresyncPacket.cpp +++ b/Server/mods/deathmatch/logic/packets/CVehiclePuresyncPacket.cpp @@ -451,6 +451,15 @@ bool CVehiclePuresyncPacket::Read(NetBitStreamInterface& BitStream) pSourcePlayer->GetPad()->NewControllerState(ControllerState); + if (BitStream.Can(eBitStreamVersion::IsVehicleNitroActivated_Serverside)) + { + float vehicleNitro; + if (!BitStream.Read(vehicleNitro)) + return false; + + pVehicle->SetNitroLevel(vehicleNitro); + } + // Success return true; } @@ -676,6 +685,11 @@ bool CVehiclePuresyncPacket::Write(NetBitStreamInterface& BitStream) const BitStream.Write(&damage); } + if (BitStream.Can(eBitStreamVersion::IsVehicleNitroActivated_Serverside)) + { + BitStream.Write(pVehicle->GetNitroLevel()); + } + // Success return true; } diff --git a/Shared/sdk/net/bitstream.h b/Shared/sdk/net/bitstream.h index c29f739ff1..768db59ed1 100644 --- a/Shared/sdk/net/bitstream.h +++ b/Shared/sdk/net/bitstream.h @@ -572,6 +572,10 @@ enum class eBitStreamVersion : unsigned short // 2024-09-04 RespawnObject_Serverside, + // Add "isVehicleNitroActivated" to serverside + // 2024-09-18 + IsVehicleNitroActivated_Serverside, + // 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,