From b20294604c5a64a39b3c5f4491b653e4cf2a3c20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matti=20H=C3=A4nninen?= Date: Wed, 5 Aug 2015 01:24:59 +0300 Subject: Fix old style casts and implicit conversions --- src/Protocol/Protocol17x.cpp | 4 ++-- src/Protocol/Protocol18x.cpp | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'src/Protocol') diff --git a/src/Protocol/Protocol17x.cpp b/src/Protocol/Protocol17x.cpp index 003530c67..3ac656d47 100644 --- a/src/Protocol/Protocol17x.cpp +++ b/src/Protocol/Protocol17x.cpp @@ -652,7 +652,7 @@ void cProtocol172::SendKeepAlive(UInt32 a_PingID) } cPacketizer Pkt(*this, 0x00); // Keep Alive packet - Pkt.WriteBEInt32(static_cast(a_PingID)); + Pkt.WriteBEUInt32(a_PingID); } @@ -2144,7 +2144,7 @@ void cProtocol172::HandlePacketEntityAction(cByteBuffer & a_ByteBuffer) void cProtocol172::HandlePacketKeepAlive(cByteBuffer & a_ByteBuffer) { - HANDLE_READ(a_ByteBuffer, ReadBEInt32, Int32, KeepAliveID); + HANDLE_READ(a_ByteBuffer, ReadBEUInt32, UInt32, KeepAliveID); m_Client->HandleKeepAlive(KeepAliveID); } diff --git a/src/Protocol/Protocol18x.cpp b/src/Protocol/Protocol18x.cpp index bd38d25d8..da5c451db 100644 --- a/src/Protocol/Protocol18x.cpp +++ b/src/Protocol/Protocol18x.cpp @@ -649,7 +649,7 @@ void cProtocol180::SendLogin(const cPlayer & a_Player, const cWorld & a_World) Pkt.WriteBEUInt8(static_cast(a_Player.GetEffectiveGameMode()) | (Server->IsHardcore() ? 0x08 : 0)); // Hardcore flag bit 4 Pkt.WriteBEInt8(static_cast(a_World.GetDimension())); Pkt.WriteBEUInt8(2); // TODO: Difficulty (set to Normal) - Pkt.WriteBEUInt8(Clamp(Server->GetMaxPlayers(), 0, 255)); + Pkt.WriteBEUInt8(static_cast(Clamp(Server->GetMaxPlayers(), 0, 255))); Pkt.WriteString("default"); // Level type - wtf? Pkt.WriteBool(false); // Reduced Debug Info - wtf? } @@ -2197,7 +2197,7 @@ void cProtocol180::HandlePacketLoginEncryptionResponse(cByteBuffer & a_ByteBuffe m_Client->Kick("Hacked client"); return; } - if (ntohl(DecryptedNonce[0]) != (unsigned)(uintptr_t)this) // Cannot convert to c++ casts + if (ntohl(DecryptedNonce[0]) != static_cast(reinterpret_cast(this))) { LOGD("Bad nonce value"); m_Client->Kick("Hacked client"); @@ -2247,7 +2247,7 @@ void cProtocol180::HandlePacketLoginStart(cByteBuffer & a_ByteBuffer) Pkt.WriteVarInt32(static_cast(PubKeyDer.size())); Pkt.WriteBuf(PubKeyDer.data(), PubKeyDer.size()); Pkt.WriteVarInt32(4); - Pkt.WriteBEInt32((int)(intptr_t)this); // Using 'this' as the cryptographic nonce, so that we don't have to generate one each time :) Cannot convert to c++ casts + Pkt.WriteBEInt32(static_cast(reinterpret_cast(this))); // Using 'this' as the cryptographic nonce, so that we don't have to generate one each time :) m_Client->SetUsername(Username); return; } @@ -2406,7 +2406,7 @@ void cProtocol180::HandlePacketEntityAction(cByteBuffer & a_ByteBuffer) void cProtocol180::HandlePacketKeepAlive(cByteBuffer & a_ByteBuffer) { HANDLE_READ(a_ByteBuffer, ReadVarInt, UInt32, KeepAliveID); - m_Client->HandleKeepAlive(static_cast(KeepAliveID)); + m_Client->HandleKeepAlive(KeepAliveID); } -- cgit v1.2.3