mirror of
https://github.com/4jcraft/4jcraft.git
synced 2026-08-20 09:57:10 +00:00
Remove Win32 types from prelogin packets
This commit is contained in:
parent
d041044000
commit
3aeb023869
|
|
@ -1,4 +1,5 @@
|
||||||
#include "../Platform/stdafx.h"
|
#include "../Platform/stdafx.h"
|
||||||
|
#include <cstdint>
|
||||||
#include "PendingConnection.h"
|
#include "PendingConnection.h"
|
||||||
#include "PlayerConnection.h"
|
#include "PlayerConnection.h"
|
||||||
#include "ServerConnection.h"
|
#include "ServerConnection.h"
|
||||||
|
|
@ -94,9 +95,9 @@ void PendingConnection::sendPreLoginResponse()
|
||||||
{
|
{
|
||||||
// 4J Stu - Calculate the players with UGC privileges set
|
// 4J Stu - Calculate the players with UGC privileges set
|
||||||
PlayerUID *ugcXuids = new PlayerUID[MINECRAFT_NET_MAX_PLAYERS];
|
PlayerUID *ugcXuids = new PlayerUID[MINECRAFT_NET_MAX_PLAYERS];
|
||||||
DWORD ugcXuidCount = 0;
|
std::uint8_t ugcXuidCount = 0;
|
||||||
DWORD hostIndex = 0;
|
std::uint8_t hostIndex = 0;
|
||||||
BYTE ugcFriendsOnlyBits = 0;
|
std::uint8_t ugcFriendsOnlyBits = 0;
|
||||||
char szUniqueMapName[14];
|
char szUniqueMapName[14];
|
||||||
|
|
||||||
StorageManager.GetSaveUniqueFilename(szUniqueMapName);
|
StorageManager.GetSaveUniqueFilename(szUniqueMapName);
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ PreLoginPacket::PreLoginPacket(std::wstring userName)
|
||||||
m_netcodeVersion = 0;
|
m_netcodeVersion = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
PreLoginPacket::PreLoginPacket(std::wstring userName, PlayerUID *playerXuids, DWORD playerCount, BYTE friendsOnlyBits, DWORD ugcPlayersVersion,char *pszUniqueSaveName, DWORD serverSettings, BYTE hostIndex, std::uint32_t texturePackId)
|
PreLoginPacket::PreLoginPacket(std::wstring userName, PlayerUID *playerXuids, std::uint8_t playerCount, std::uint8_t friendsOnlyBits, std::uint32_t ugcPlayersVersion, const char *pszUniqueSaveName, std::uint32_t serverSettings, std::uint8_t hostIndex, std::uint32_t texturePackId)
|
||||||
{
|
{
|
||||||
this->loginKey = userName;
|
this->loginKey = userName;
|
||||||
m_playerXuids = playerXuids;
|
m_playerXuids = playerXuids;
|
||||||
|
|
@ -59,23 +59,25 @@ void PreLoginPacket::read(DataInputStream *dis) //throws IOException
|
||||||
|
|
||||||
loginKey = readUtf(dis, 32);
|
loginKey = readUtf(dis, 32);
|
||||||
|
|
||||||
m_friendsOnlyBits = dis->readByte();
|
m_friendsOnlyBits = static_cast<std::uint8_t>(dis->readByte());
|
||||||
m_ugcPlayersVersion = dis->readInt();
|
std::int32_t ugcPlayersVersion = dis->readInt();
|
||||||
m_dwPlayerCount = dis->readByte();
|
std::memcpy(&m_ugcPlayersVersion, &ugcPlayersVersion, sizeof(m_ugcPlayersVersion));
|
||||||
|
m_dwPlayerCount = static_cast<std::uint8_t>(dis->readByte());
|
||||||
if( m_dwPlayerCount > 0 )
|
if( m_dwPlayerCount > 0 )
|
||||||
{
|
{
|
||||||
m_playerXuids = new PlayerUID[m_dwPlayerCount];
|
m_playerXuids = new PlayerUID[m_dwPlayerCount];
|
||||||
for(DWORD i = 0; i < m_dwPlayerCount; ++i)
|
for(std::uint32_t i = 0; i < m_dwPlayerCount; ++i)
|
||||||
{
|
{
|
||||||
m_playerXuids[i] = dis->readPlayerUID();
|
m_playerXuids[i] = dis->readPlayerUID();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(DWORD i = 0; i < m_iSaveNameLen; ++i)
|
for(int i = 0; i < m_iSaveNameLen; ++i)
|
||||||
{
|
{
|
||||||
m_szUniqueSaveName[i]=dis->readByte();
|
m_szUniqueSaveName[i] = static_cast<char>(dis->readByte());
|
||||||
}
|
}
|
||||||
m_serverSettings = dis->readInt();
|
std::int32_t serverSettings = dis->readInt();
|
||||||
m_hostIndex = dis->readByte();
|
std::memcpy(&m_serverSettings, &serverSettings, sizeof(m_serverSettings));
|
||||||
|
m_hostIndex = static_cast<std::uint8_t>(dis->readByte());
|
||||||
|
|
||||||
std::int32_t texturePackId = dis->readInt();
|
std::int32_t texturePackId = dis->readInt();
|
||||||
std::memcpy(&m_texturePackId, &texturePackId, sizeof(m_texturePackId));
|
std::memcpy(&m_texturePackId, &texturePackId, sizeof(m_texturePackId));
|
||||||
|
|
@ -91,19 +93,23 @@ void PreLoginPacket::write(DataOutputStream *dos) //throws IOException
|
||||||
writeUtf(loginKey, dos);
|
writeUtf(loginKey, dos);
|
||||||
|
|
||||||
dos->writeByte(m_friendsOnlyBits);
|
dos->writeByte(m_friendsOnlyBits);
|
||||||
dos->writeInt(m_ugcPlayersVersion);
|
std::int32_t ugcPlayersVersion = 0;
|
||||||
|
std::memcpy(&ugcPlayersVersion, &m_ugcPlayersVersion, sizeof(m_ugcPlayersVersion));
|
||||||
|
dos->writeInt(ugcPlayersVersion);
|
||||||
dos->writeByte((uint8_t)m_dwPlayerCount);
|
dos->writeByte((uint8_t)m_dwPlayerCount);
|
||||||
for(DWORD i = 0; i < m_dwPlayerCount; ++i)
|
for(std::uint32_t i = 0; i < m_dwPlayerCount; ++i)
|
||||||
{
|
{
|
||||||
dos->writePlayerUID( m_playerXuids[i] );
|
dos->writePlayerUID( m_playerXuids[i] );
|
||||||
}
|
}
|
||||||
|
|
||||||
app.DebugPrintf("*** PreLoginPacket::write - %s\n",m_szUniqueSaveName);
|
app.DebugPrintf("*** PreLoginPacket::write - %s\n",m_szUniqueSaveName);
|
||||||
for(DWORD i = 0; i < m_iSaveNameLen; ++i)
|
for(int i = 0; i < m_iSaveNameLen; ++i)
|
||||||
{
|
{
|
||||||
dos->writeByte(m_szUniqueSaveName[i]);
|
dos->writeByte(static_cast<std::uint8_t>(m_szUniqueSaveName[i]));
|
||||||
}
|
}
|
||||||
dos->writeInt(m_serverSettings);
|
std::int32_t serverSettings = 0;
|
||||||
|
std::memcpy(&serverSettings, &m_serverSettings, sizeof(m_serverSettings));
|
||||||
|
dos->writeInt(serverSettings);
|
||||||
dos->writeByte(m_hostIndex);
|
dos->writeByte(m_hostIndex);
|
||||||
std::int32_t texturePackId = 0;
|
std::int32_t texturePackId = 0;
|
||||||
std::memcpy(&texturePackId, &m_texturePackId, sizeof(texturePackId));
|
std::memcpy(&texturePackId, &m_texturePackId, sizeof(texturePackId));
|
||||||
|
|
|
||||||
|
|
@ -13,20 +13,20 @@ public:
|
||||||
// join, and so that we can inform the server if we have that privilege set. Anyone with UGC turned off completely
|
// join, and so that we can inform the server if we have that privilege set. Anyone with UGC turned off completely
|
||||||
// can't play the game online at all, so we only need to specify players with friends only set
|
// can't play the game online at all, so we only need to specify players with friends only set
|
||||||
PlayerUID *m_playerXuids;
|
PlayerUID *m_playerXuids;
|
||||||
DWORD m_dwPlayerCount;
|
std::uint8_t m_dwPlayerCount;
|
||||||
BYTE m_friendsOnlyBits;
|
std::uint8_t m_friendsOnlyBits;
|
||||||
DWORD m_ugcPlayersVersion;
|
std::uint32_t m_ugcPlayersVersion;
|
||||||
BYTE m_szUniqueSaveName[m_iSaveNameLen]; // added for checking if the level is in the ban list
|
char 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
|
std::uint32_t 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
|
std::uint8_t m_hostIndex; // Rather than sending the xuid of the host again, send an index into the m_playerXuids array
|
||||||
std::uint32_t m_texturePackId;
|
std::uint32_t m_texturePackId;
|
||||||
SHORT m_netcodeVersion;
|
std::int16_t m_netcodeVersion;
|
||||||
|
|
||||||
std::wstring loginKey;
|
std::wstring loginKey;
|
||||||
|
|
||||||
PreLoginPacket();
|
PreLoginPacket();
|
||||||
PreLoginPacket(std::wstring userName);
|
PreLoginPacket(std::wstring userName);
|
||||||
PreLoginPacket(std::wstring userName, PlayerUID *playerXuids, DWORD playerCount, BYTE friendsOnlyBits, DWORD ugcPlayersVersion,char *pszUniqueSaveName, DWORD serverSettings, BYTE hostIndex, std::uint32_t texturePackId);
|
PreLoginPacket(std::wstring userName, PlayerUID *playerXuids, std::uint8_t playerCount, std::uint8_t friendsOnlyBits, std::uint32_t ugcPlayersVersion, const char *pszUniqueSaveName, std::uint32_t serverSettings, std::uint8_t hostIndex, std::uint32_t texturePackId);
|
||||||
~PreLoginPacket();
|
~PreLoginPacket();
|
||||||
|
|
||||||
virtual void read(DataInputStream *dis);
|
virtual void read(DataInputStream *dis);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue