Remove DWORD texture pack IDs from server prelogin state

This commit is contained in:
notmatthewbeshay 2026-03-10 01:00:49 +11:00
parent 91c8698358
commit 52b462fffd
3 changed files with 16 additions and 9 deletions

View file

@ -1,4 +1,6 @@
#pragma once
#include <cstdint>
#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();

View file

@ -1,4 +1,6 @@
#include "../../Platform/stdafx.h"
#include <cstdint>
#include <cstring>
#include <iostream>
#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)

View file

@ -1,5 +1,6 @@
#pragma once
#include <cstdint>
#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<Packet> create() { return std::shared_ptr<Packet>(new PreLoginPacket()); }
virtual int getId() { return 2; }
};
};