diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaWorldDefs.cpp b/Client/mods/deathmatch/logic/luadefs/CLuaWorldDefs.cpp index 13084cd7a7..ef8c72c912 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaWorldDefs.cpp +++ b/Client/mods/deathmatch/logic/luadefs/CLuaWorldDefs.cpp @@ -1278,7 +1278,7 @@ bool CLuaWorldDefs::SetWorldSpecialPropertyEnabled(const WorldSpecialProperty pr if (auto stream = g_pNet->AllocateNetBitStream()) { - stream->WriteString(EnumToString(property)); + stream->Write(static_cast(property)); stream->WriteBit(enabled); g_pNet->SendPacket(PACKET_ID_PLAYER_WORLD_SPECIAL_PROPERTY, stream, PACKET_PRIORITY_HIGH, PACKET_RELIABILITY_RELIABLE_ORDERED); g_pNet->DeallocateNetBitStream(stream); diff --git a/Server/mods/deathmatch/logic/CGame.cpp b/Server/mods/deathmatch/logic/CGame.cpp index 9081b6bcef..376ef9d19f 100644 --- a/Server/mods/deathmatch/logic/CGame.cpp +++ b/Server/mods/deathmatch/logic/CGame.cpp @@ -4173,16 +4173,16 @@ void CGame::Packet_PlayerResourceStart(CPlayerResourceStartPacket& Packet) void CGame::Packet_PlayerWorldSpecialProperty(CPlayerWorldSpecialPropertyPacket& packet) noexcept { CPlayer* player = packet.GetSourcePlayer(); - if (!player) return; - const std::string& property = packet.GetProperty(); - const bool enabled = packet.IsEnabled(); + const auto propertyId = static_cast(packet.GetPropertyId()); + if (!EnumValueValid(propertyId)) + return; CLuaArguments arguments; - arguments.PushString(property); - arguments.PushBoolean(enabled); + arguments.PushString(EnumToString(propertyId)); + arguments.PushBoolean(packet.IsEnabled()); player->CallEvent("onPlayerChangesWorldSpecialProperty", arguments, nullptr); } diff --git a/Server/mods/deathmatch/logic/packets/CPlayerWorldSpecialPropertyPacket.cpp b/Server/mods/deathmatch/logic/packets/CPlayerWorldSpecialPropertyPacket.cpp index 59c3ec4c7b..532aeb8503 100644 --- a/Server/mods/deathmatch/logic/packets/CPlayerWorldSpecialPropertyPacket.cpp +++ b/Server/mods/deathmatch/logic/packets/CPlayerWorldSpecialPropertyPacket.cpp @@ -13,8 +13,5 @@ bool CPlayerWorldSpecialPropertyPacket::Read(NetBitStreamInterface& stream) noexcept { - stream.ReadString(m_property); - stream.ReadBit(m_enabled); - - return true; + return stream.Read(m_propertyId) && stream.ReadBit(m_enabled); } diff --git a/Server/mods/deathmatch/logic/packets/CPlayerWorldSpecialPropertyPacket.h b/Server/mods/deathmatch/logic/packets/CPlayerWorldSpecialPropertyPacket.h index cb6dd9e2f1..5ec8b390e6 100644 --- a/Server/mods/deathmatch/logic/packets/CPlayerWorldSpecialPropertyPacket.h +++ b/Server/mods/deathmatch/logic/packets/CPlayerWorldSpecialPropertyPacket.h @@ -25,10 +25,10 @@ class CPlayerWorldSpecialPropertyPacket final : public CPacket bool Read(NetBitStreamInterface& stream) noexcept; - std::string GetProperty() const noexcept { return m_property; } - bool IsEnabled() const noexcept { return m_enabled; } + std::uint8_t GetPropertyId() const noexcept { return m_propertyId; } + bool IsEnabled() const noexcept { return m_enabled; } private: - std::string m_property; - bool m_enabled; + std::uint8_t m_propertyId; + bool m_enabled; }; diff --git a/Shared/mods/deathmatch/logic/Enums.h b/Shared/mods/deathmatch/logic/Enums.h index 884bb559f5..d2f0b93756 100644 --- a/Shared/mods/deathmatch/logic/Enums.h +++ b/Shared/mods/deathmatch/logic/Enums.h @@ -75,7 +75,7 @@ DECLARE_ENUM_CLASS(HmacAlgorithm); DECLARE_ENUM_CLASS(ZLibFormat); DECLARE_ENUM_CLASS(ZLibStrategy); -enum class WorldSpecialProperty +enum class WorldSpecialProperty : std::uint8_t { HOVERCARS, AIRCARS,