diff options
| author | Léo Lam <leo@leolam.fr> | 2022-01-03 01:26:59 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-01-03 01:26:59 +0100 |
| commit | 5953c55075338f1d2b5d71f5ad8b883888ef11f1 (patch) | |
| tree | 97dd6166bb5e8aed19873d3512b90fa74dfb4850 /Source/Core/InputCommon/ControllerInterface | |
| parent | f6883a08830158e5ae768b633d69bb504c9e7e3c (diff) | |
| parent | 3d5b46615cfc6d238075a9a1666c29f6f54decbe (diff) | |
Merge pull request #10271 from Pokechu22/hash.h-merge
Merge CRC32.h into Hash.h and remove MD5.h
Diffstat (limited to 'Source/Core/InputCommon/ControllerInterface')
| -rw-r--r-- | Source/Core/InputCommon/ControllerInterface/DualShockUDPClient/DualShockUDPProto.h | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/Source/Core/InputCommon/ControllerInterface/DualShockUDPClient/DualShockUDPProto.h b/Source/Core/InputCommon/ControllerInterface/DualShockUDPClient/DualShockUDPProto.h index a397431e3d..aca2176e6d 100644 --- a/Source/Core/InputCommon/ControllerInterface/DualShockUDPClient/DualShockUDPProto.h +++ b/Source/Core/InputCommon/ControllerInterface/DualShockUDPClient/DualShockUDPProto.h @@ -7,9 +7,8 @@ #include <cstring> #include <optional> -#include <zlib.h> - #include "Common/CommonTypes.h" +#include "Common/Hash.h" namespace ciface::DualShockUDPClient::Proto { @@ -217,11 +216,6 @@ struct FromClient }; } // namespace MessageType -static inline u32 CRC32(const void* buffer, unsigned length) -{ - return crc32(crc32(0L, Z_NULL, 0), static_cast<const Bytef*>(buffer), length); -} - template <typename MsgType> struct Message { @@ -236,7 +230,11 @@ struct Message m_message.message_type = MsgType::TYPE; } - void Finish() { m_message.header.crc32 = CRC32(&m_message, sizeof(m_message)); } + void Finish() + { + m_message.header.crc32 = + Common::ComputeCRC32(reinterpret_cast<const u8*>(&m_message), sizeof(m_message)); + } template <class ToMsgType> std::optional<ToMsgType> CheckAndCastTo() @@ -244,7 +242,8 @@ struct Message const u32 crc32_in_header = m_message.header.crc32; // zero out the crc32 in the packet once we got it since that's whats needed for calculation m_message.header.crc32 = 0; - const u32 crc32_calculated = CRC32(&m_message, sizeof(ToMsgType)); + const u32 crc32_calculated = + Common::ComputeCRC32(reinterpret_cast<const u8*>(&m_message), sizeof(ToMsgType)); if (crc32_in_header != crc32_calculated) { NOTICE_LOG_FMT( |
