mirror of
https://github.com/neoStudiosLCE/neoLegacy.git
synced 2026-07-25 04:37:03 +00:00
smartcmd/MinecraftConsoles and itsRevela/MinecraftConsoles network packet compatibility fix:
LoginPacket.cpp: - read(): Extracts hardcore from bit 3 of gameType (gameType & 0x8), then masks it off (gameType & ~0x8) - write(): Encodes hardcore into gameType via gameType | (m_isHardcore ? 0x8 : 0) - Removed the separate readBoolean()/writeBoolean() for m_isHardcore - Removed trailing + sizeof(bool) from getEstimatedSize() RespawnPacket.cpp: - read(): Extracts hardcore from bit 3 of the playerGameType byte, then masks it off before passing to GameType::byId() - write(): Encodes hardcore into the playerGameType byte via getId() | (m_isHardcore ? 0x8 : 0) - Removed the separate readBoolean()/writeBoolean() for m_isHardcore - Reverted getEstimatedSize() from 14+length to 13+length
This commit is contained in:
parent
b28c0026af
commit
514c4cf102
|
|
@ -109,6 +109,8 @@ void LoginPacket::read(DataInputStream *dis) //throws IOException
|
||||||
}
|
}
|
||||||
seed = dis->readLong();
|
seed = dis->readLong();
|
||||||
gameType = dis->readInt();
|
gameType = dis->readInt();
|
||||||
|
m_isHardcore = (gameType & 0x8) != 0;
|
||||||
|
gameType = gameType & ~0x8;
|
||||||
dimension = dis->readByte();
|
dimension = dis->readByte();
|
||||||
mapHeight = dis->readByte();
|
mapHeight = dis->readByte();
|
||||||
maxPlayers = dis->readByte();
|
maxPlayers = dis->readByte();
|
||||||
|
|
@ -130,7 +132,6 @@ void LoginPacket::read(DataInputStream *dis) //throws IOException
|
||||||
m_xzSize = dis->readShort();
|
m_xzSize = dis->readShort();
|
||||||
m_hellScale = dis->read();
|
m_hellScale = dis->read();
|
||||||
#endif
|
#endif
|
||||||
m_isHardcore = dis->readBoolean();
|
|
||||||
app.DebugPrintf("LoginPacket::read - Difficulty = %d\n",difficulty);
|
app.DebugPrintf("LoginPacket::read - Difficulty = %d\n",difficulty);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -148,7 +149,7 @@ void LoginPacket::write(DataOutputStream *dos) //throws IOException
|
||||||
writeUtf(m_pLevelType->getGeneratorName(), dos);
|
writeUtf(m_pLevelType->getGeneratorName(), dos);
|
||||||
}
|
}
|
||||||
dos->writeLong(seed);
|
dos->writeLong(seed);
|
||||||
dos->writeInt(gameType);
|
dos->writeInt(gameType | (m_isHardcore ? 0x8 : 0));
|
||||||
dos->writeByte(dimension);
|
dos->writeByte(dimension);
|
||||||
dos->writeByte(mapHeight);
|
dos->writeByte(mapHeight);
|
||||||
dos->writeByte(maxPlayers);
|
dos->writeByte(maxPlayers);
|
||||||
|
|
@ -168,7 +169,6 @@ void LoginPacket::write(DataOutputStream *dos) //throws IOException
|
||||||
dos->writeShort(m_xzSize);
|
dos->writeShort(m_xzSize);
|
||||||
dos->write(m_hellScale);
|
dos->write(m_hellScale);
|
||||||
#endif
|
#endif
|
||||||
dos->writeBoolean(m_isHardcore);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoginPacket::handle(PacketListener *listener)
|
void LoginPacket::handle(PacketListener *listener)
|
||||||
|
|
@ -184,5 +184,5 @@ int LoginPacket::getEstimatedSize()
|
||||||
length = static_cast<int>(m_pLevelType->getGeneratorName().length());
|
length = static_cast<int>(m_pLevelType->getGeneratorName().length());
|
||||||
}
|
}
|
||||||
|
|
||||||
return static_cast<int>(sizeof(int) + userName.length() + 4 + 6 + sizeof(int64_t) + sizeof(char) + sizeof(int) + (2 * sizeof(PlayerUID)) + 1 + sizeof(char) + sizeof(BYTE) + sizeof(bool) + sizeof(bool) + length + sizeof(unsigned int) + sizeof(bool));
|
return static_cast<int>(sizeof(int) + userName.length() + 4 + 6 + sizeof(int64_t) + sizeof(char) + sizeof(int) + (2 * sizeof(PlayerUID)) + 1 + sizeof(char) + sizeof(BYTE) + sizeof(bool) + sizeof(bool) + length + sizeof(unsigned int));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,9 @@ void RespawnPacket::handle(PacketListener *listener)
|
||||||
void RespawnPacket::read(DataInputStream *dis) //throws IOException
|
void RespawnPacket::read(DataInputStream *dis) //throws IOException
|
||||||
{
|
{
|
||||||
dimension = dis->readByte();
|
dimension = dis->readByte();
|
||||||
playerGameType = GameType::byId(dis->readByte());
|
int rawGameType = dis->readByte();
|
||||||
|
m_isHardcore = (rawGameType & 0x8) != 0;
|
||||||
|
playerGameType = GameType::byId(rawGameType & ~0x8);
|
||||||
mapHeight = dis->readShort();
|
mapHeight = dis->readShort();
|
||||||
wstring typeName = readUtf(dis, 16);
|
wstring typeName = readUtf(dis, 16);
|
||||||
m_pLevelType = LevelType::getLevelType(typeName);
|
m_pLevelType = LevelType::getLevelType(typeName);
|
||||||
|
|
@ -61,7 +63,6 @@ void RespawnPacket::read(DataInputStream *dis) //throws IOException
|
||||||
m_xzSize = dis->readShort();
|
m_xzSize = dis->readShort();
|
||||||
m_hellScale = dis->read();
|
m_hellScale = dis->read();
|
||||||
#endif
|
#endif
|
||||||
m_isHardcore = dis->readBoolean();
|
|
||||||
app.DebugPrintf("RespawnPacket::read - Difficulty = %d\n",difficulty);
|
app.DebugPrintf("RespawnPacket::read - Difficulty = %d\n",difficulty);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -69,7 +70,7 @@ void RespawnPacket::read(DataInputStream *dis) //throws IOException
|
||||||
void RespawnPacket::write(DataOutputStream *dos) //throws IOException
|
void RespawnPacket::write(DataOutputStream *dos) //throws IOException
|
||||||
{
|
{
|
||||||
dos->writeByte(dimension);
|
dos->writeByte(dimension);
|
||||||
dos->writeByte(playerGameType->getId());
|
dos->writeByte(playerGameType->getId() | (m_isHardcore ? 0x8 : 0));
|
||||||
dos->writeShort(mapHeight);
|
dos->writeShort(mapHeight);
|
||||||
if (m_pLevelType == nullptr)
|
if (m_pLevelType == nullptr)
|
||||||
{
|
{
|
||||||
|
|
@ -87,7 +88,6 @@ void RespawnPacket::write(DataOutputStream *dos) //throws IOException
|
||||||
dos->writeShort(m_xzSize);
|
dos->writeShort(m_xzSize);
|
||||||
dos->write(m_hellScale);
|
dos->write(m_hellScale);
|
||||||
#endif
|
#endif
|
||||||
dos->writeBoolean(m_isHardcore);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int RespawnPacket::getEstimatedSize()
|
int RespawnPacket::getEstimatedSize()
|
||||||
|
|
@ -97,5 +97,5 @@ int RespawnPacket::getEstimatedSize()
|
||||||
{
|
{
|
||||||
length = static_cast<int>(m_pLevelType->getGeneratorName().length());
|
length = static_cast<int>(m_pLevelType->getGeneratorName().length());
|
||||||
}
|
}
|
||||||
return 14+length;
|
return 13+length;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue