From 52b462fffd314df03fd645aa94aa824879e8a2d1 Mon Sep 17 00:00:00 2001 From: notmatthewbeshay <92357869+NotMachow@users.noreply.github.com> Date: Tue, 10 Mar 2026 01:00:49 +1100 Subject: [PATCH] Remove DWORD texture pack IDs from server prelogin state --- Minecraft.Client/MinecraftServer.h | 6 ++++-- Minecraft.World/Network/Packets/PreLoginPacket.cpp | 12 ++++++++---- Minecraft.World/Network/Packets/PreLoginPacket.h | 7 ++++--- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/Minecraft.Client/MinecraftServer.h b/Minecraft.Client/MinecraftServer.h index ced9a6c9e..07be02ac7 100644 --- a/Minecraft.Client/MinecraftServer.h +++ b/Minecraft.Client/MinecraftServer.h @@ -1,4 +1,6 @@ #pragma once +#include + #include "Input/ConsoleInputSource.h" #include "../Minecraft.World/Util/ArrayWithLength.h" #include "../Minecraft.World/Util/SharedConstants.h" @@ -34,7 +36,7 @@ typedef struct _NetworkGameInitData LoadSaveDataThreadParam *saveData; DWORD settings; LevelGenerationOptions *levelGen; - DWORD texturePackId; + std::uint32_t texturePackId; bool findSeed; unsigned int xzSize; unsigned char hellScale; @@ -118,7 +120,7 @@ public: DWORD m_ugcPlayersVersion; // This value is used to store the texture pack id for the currently loaded world - DWORD m_texturePackId; + std::uint32_t m_texturePackId; public: MinecraftServer(); diff --git a/Minecraft.World/Network/Packets/PreLoginPacket.cpp b/Minecraft.World/Network/Packets/PreLoginPacket.cpp index 2cc287ec0..8c51cd463 100644 --- a/Minecraft.World/Network/Packets/PreLoginPacket.cpp +++ b/Minecraft.World/Network/Packets/PreLoginPacket.cpp @@ -1,4 +1,6 @@ #include "../../Platform/stdafx.h" +#include +#include #include #include "PacketListener.h" #include "PreLoginPacket.h" @@ -32,7 +34,7 @@ PreLoginPacket::PreLoginPacket(std::wstring userName) m_netcodeVersion = 0; } -PreLoginPacket::PreLoginPacket(std::wstring userName, PlayerUID *playerXuids, DWORD playerCount, BYTE friendsOnlyBits, DWORD ugcPlayersVersion,char *pszUniqueSaveName, DWORD serverSettings, BYTE hostIndex, DWORD texturePackId) +PreLoginPacket::PreLoginPacket(std::wstring userName, PlayerUID *playerXuids, DWORD playerCount, BYTE friendsOnlyBits, DWORD ugcPlayersVersion,char *pszUniqueSaveName, DWORD serverSettings, BYTE hostIndex, std::uint32_t texturePackId) { this->loginKey = userName; m_playerXuids = playerXuids; @@ -75,8 +77,8 @@ void PreLoginPacket::read(DataInputStream *dis) //throws IOException m_serverSettings = dis->readInt(); m_hostIndex = dis->readByte(); - INT texturePackId = dis->readInt(); - m_texturePackId = *(DWORD *)&texturePackId; + std::int32_t texturePackId = dis->readInt(); + std::memcpy(&m_texturePackId, &texturePackId, sizeof(m_texturePackId)); // Set the name of the map so we can check it for players banned lists app.SetUniqueMapName((char *)m_szUniqueSaveName); @@ -103,7 +105,9 @@ void PreLoginPacket::write(DataOutputStream *dos) //throws IOException } dos->writeInt(m_serverSettings); dos->writeByte(m_hostIndex); - dos->writeInt(m_texturePackId); + std::int32_t texturePackId = 0; + std::memcpy(&texturePackId, &m_texturePackId, sizeof(texturePackId)); + dos->writeInt(texturePackId); } void PreLoginPacket::handle(PacketListener *listener) diff --git a/Minecraft.World/Network/Packets/PreLoginPacket.h b/Minecraft.World/Network/Packets/PreLoginPacket.h index c6839b2b6..ea3c34758 100644 --- a/Minecraft.World/Network/Packets/PreLoginPacket.h +++ b/Minecraft.World/Network/Packets/PreLoginPacket.h @@ -1,5 +1,6 @@ #pragma once +#include #include "Packet.h" @@ -18,14 +19,14 @@ public: BYTE m_szUniqueSaveName[m_iSaveNameLen]; // added for checking if the level is in the ban list DWORD m_serverSettings; // A bitfield of server settings constructed with the MAKE_SERVER_SETTINGS macro BYTE m_hostIndex; // Rather than sending the xuid of the host again, send an index into the m_playerXuids array - DWORD m_texturePackId; + std::uint32_t m_texturePackId; SHORT m_netcodeVersion; std::wstring loginKey; PreLoginPacket(); PreLoginPacket(std::wstring userName); - PreLoginPacket(std::wstring userName, PlayerUID *playerXuids, DWORD playerCount, BYTE friendsOnlyBits, DWORD ugcPlayersVersion,char *pszUniqueSaveName, DWORD serverSettings, BYTE hostIndex, DWORD texturePackId); + PreLoginPacket(std::wstring userName, PlayerUID *playerXuids, DWORD playerCount, BYTE friendsOnlyBits, DWORD ugcPlayersVersion,char *pszUniqueSaveName, DWORD serverSettings, BYTE hostIndex, std::uint32_t texturePackId); ~PreLoginPacket(); virtual void read(DataInputStream *dis); @@ -36,4 +37,4 @@ public: public: static std::shared_ptr create() { return std::shared_ptr(new PreLoginPacket()); } virtual int getId() { return 2; } -}; \ No newline at end of file +};