From d0410440008c3868673e1e7fbf45d74c095b28a8 Mon Sep 17 00:00:00 2001 From: notmatthewbeshay <92357869+NotMachow@users.noreply.github.com> Date: Tue, 10 Mar 2026 07:31:09 +1100 Subject: [PATCH] Remove BYTE from network player IDs --- Minecraft.Client/Network/PlayerList.cpp | 8 ++++---- Minecraft.Client/Network/PlayerList.h | 9 +++++---- Minecraft.World/Network/Packets/KickPlayerPacket.cpp | 4 ++-- Minecraft.World/Network/Packets/KickPlayerPacket.h | 7 ++++--- Minecraft.World/Network/Packets/PlayerInfoPacket.cpp | 4 ++-- Minecraft.World/Network/Packets/PlayerInfoPacket.h | 7 ++++--- Minecraft.World/Network/Socket.h | 5 +++-- 7 files changed, 24 insertions(+), 20 deletions(-) diff --git a/Minecraft.Client/Network/PlayerList.cpp b/Minecraft.Client/Network/PlayerList.cpp index c26079a16..e56efca60 100644 --- a/Minecraft.Client/Network/PlayerList.cpp +++ b/Minecraft.Client/Network/PlayerList.cpp @@ -847,7 +847,7 @@ void PlayerList::tick() EnterCriticalSection(&m_closePlayersCS); while(!m_smallIdsToClose.empty()) { - BYTE smallId = m_smallIdsToClose.front(); + std::uint8_t smallId = m_smallIdsToClose.front(); m_smallIdsToClose.pop_front(); std::shared_ptr player = nullptr; @@ -873,7 +873,7 @@ void PlayerList::tick() EnterCriticalSection(&m_kickPlayersCS); while(!m_smallIdsToKick.empty()) { - BYTE smallId = m_smallIdsToKick.front(); + std::uint8_t smallId = m_smallIdsToKick.front(); m_smallIdsToKick.pop_front(); INetworkPlayer *selectedPlayer = g_NetworkManager.GetPlayerBySmallId(smallId); if( selectedPlayer != NULL ) @@ -1416,14 +1416,14 @@ bool PlayerList::canReceiveAllPackets(std::shared_ptr player) return false; } -void PlayerList::kickPlayerByShortId(BYTE networkSmallId) +void PlayerList::kickPlayerByShortId(std::uint8_t networkSmallId) { EnterCriticalSection(&m_kickPlayersCS); m_smallIdsToKick.push_back(networkSmallId); LeaveCriticalSection(&m_kickPlayersCS); } -void PlayerList::closePlayerConnectionBySmallId(BYTE networkSmallId) +void PlayerList::closePlayerConnectionBySmallId(std::uint8_t networkSmallId) { EnterCriticalSection(&m_closePlayersCS); m_smallIdsToClose.push_back(networkSmallId); diff --git a/Minecraft.Client/Network/PlayerList.h b/Minecraft.Client/Network/PlayerList.h index 1c5bebfc5..50a00ea91 100644 --- a/Minecraft.Client/Network/PlayerList.h +++ b/Minecraft.Client/Network/PlayerList.h @@ -1,4 +1,5 @@ #pragma once +#include #include #include "../../Minecraft.World/Util/ArrayWithLength.h" @@ -30,9 +31,9 @@ private: // 4J Added std::vector m_bannedXuids; - std::deque m_smallIdsToKick; + std::deque m_smallIdsToKick; CRITICAL_SECTION m_kickPlayersCS; - std::deque m_smallIdsToClose; + std::deque m_smallIdsToClose; CRITICAL_SECTION m_closePlayersCS; /* 4J - removed Set bans = new HashSet(); @@ -119,8 +120,8 @@ public: void setAllowCheatsForAllPlayers(bool allowCommands); // 4J Added - void kickPlayerByShortId(BYTE networkSmallId); - void closePlayerConnectionBySmallId(BYTE networkSmallId); + void kickPlayerByShortId(std::uint8_t networkSmallId); + void closePlayerConnectionBySmallId(std::uint8_t networkSmallId); bool isXuidBanned(PlayerUID xuid); // AP added for Vita so the range can be increased once the level starts void setViewDistance(int newViewDistance); diff --git a/Minecraft.World/Network/Packets/KickPlayerPacket.cpp b/Minecraft.World/Network/Packets/KickPlayerPacket.cpp index 502fd6b86..fcbdce6bc 100644 --- a/Minecraft.World/Network/Packets/KickPlayerPacket.cpp +++ b/Minecraft.World/Network/Packets/KickPlayerPacket.cpp @@ -11,7 +11,7 @@ KickPlayerPacket::KickPlayerPacket() m_networkSmallId = 0; } -KickPlayerPacket::KickPlayerPacket(BYTE networkSmallId) +KickPlayerPacket::KickPlayerPacket(std::uint8_t networkSmallId) { m_networkSmallId = networkSmallId; } @@ -23,7 +23,7 @@ void KickPlayerPacket::handle(PacketListener *listener) void KickPlayerPacket::read(DataInputStream *dis) //throws IOException { - m_networkSmallId = (int)dis->readByte(); + m_networkSmallId = static_cast(dis->readByte()); } void KickPlayerPacket::write(DataOutputStream *dos) //throws IOException diff --git a/Minecraft.World/Network/Packets/KickPlayerPacket.h b/Minecraft.World/Network/Packets/KickPlayerPacket.h index 37e4655c5..30c04b4c6 100644 --- a/Minecraft.World/Network/Packets/KickPlayerPacket.h +++ b/Minecraft.World/Network/Packets/KickPlayerPacket.h @@ -1,15 +1,16 @@ #pragma once +#include #include "Packet.h" class KickPlayerPacket : public Packet, public std::enable_shared_from_this { public: - BYTE m_networkSmallId; + std::uint8_t m_networkSmallId; KickPlayerPacket(); - KickPlayerPacket(BYTE networkSmallId); + KickPlayerPacket(std::uint8_t networkSmallId); virtual void handle(PacketListener *listener); virtual void read(DataInputStream *dis); @@ -19,4 +20,4 @@ public: public: static std::shared_ptr create() { return std::shared_ptr(new KickPlayerPacket()); } virtual int getId() { return 159; } -}; \ No newline at end of file +}; diff --git a/Minecraft.World/Network/Packets/PlayerInfoPacket.cpp b/Minecraft.World/Network/Packets/PlayerInfoPacket.cpp index 4b9056386..020c9e739 100644 --- a/Minecraft.World/Network/Packets/PlayerInfoPacket.cpp +++ b/Minecraft.World/Network/Packets/PlayerInfoPacket.cpp @@ -19,7 +19,7 @@ PlayerInfoPacket::PlayerInfoPacket() m_entityId = -1; } -PlayerInfoPacket::PlayerInfoPacket(BYTE networkSmallId, short playerColourIndex, unsigned int playerPrivileges) +PlayerInfoPacket::PlayerInfoPacket(std::uint8_t networkSmallId, short playerColourIndex, unsigned int playerPrivileges) { m_networkSmallId = networkSmallId; m_playerColourIndex = playerColourIndex; @@ -38,7 +38,7 @@ PlayerInfoPacket::PlayerInfoPacket(std::shared_ptr player) void PlayerInfoPacket::read(DataInputStream *dis) { - m_networkSmallId = dis->readByte(); + m_networkSmallId = static_cast(dis->readByte()); m_playerColourIndex = dis->readShort(); m_playerPrivileges = dis->readInt(); m_entityId = dis->readInt(); diff --git a/Minecraft.World/Network/Packets/PlayerInfoPacket.h b/Minecraft.World/Network/Packets/PlayerInfoPacket.h index fd4c83451..0c98036df 100644 --- a/Minecraft.World/Network/Packets/PlayerInfoPacket.h +++ b/Minecraft.World/Network/Packets/PlayerInfoPacket.h @@ -1,4 +1,5 @@ #pragma once +#include #include "Packet.h" @@ -11,14 +12,14 @@ class PlayerInfoPacket : public Packet, public std::enable_shared_from_this player); virtual void read(DataInputStream *dis); @@ -29,4 +30,4 @@ class PlayerInfoPacket : public Packet, public std::enable_shared_from_this create() { return std::shared_ptr(new PlayerInfoPacket()); } virtual int getId() { return 201; } -}; \ No newline at end of file +}; diff --git a/Minecraft.World/Network/Socket.h b/Minecraft.World/Network/Socket.h index 659967e1a..082274c23 100644 --- a/Minecraft.World/Network/Socket.h +++ b/Minecraft.World/Network/Socket.h @@ -1,4 +1,5 @@ #pragma once +#include #ifndef __linux__ #include #include @@ -109,7 +110,7 @@ private: // Host only connection class static ServerConnection *s_serverConnection; - BYTE networkPlayerSmallId; + std::uint8_t networkPlayerSmallId; public: C4JThread::Event* m_socketClosedEvent; @@ -133,5 +134,5 @@ public: bool isLocal() { return m_hostLocal; } bool isClosing() { return m_endClosed[SOCKET_CLIENT_END] || m_endClosed[SOCKET_SERVER_END]; } - BYTE getSmallId() { return networkPlayerSmallId; } + std::uint8_t getSmallId() { return networkPlayerSmallId; } };