From 1f5d7817fc649ab92c26d0d74104605abf1d4b3c Mon Sep 17 00:00:00 2001 From: qloak Date: Fri, 7 Aug 2026 04:15:00 -0700 Subject: [PATCH] Win64 joining Xbox 360 works again --- .../Common/Network/GameNetworkManager.cpp | 7 +++- .../Network/PlatformNetworkManagerStub.cpp | 2 -- Minecraft.World/AddEntityPacket.cpp | 12 ------- Minecraft.World/AddMobPacket.cpp | 12 ------- Minecraft.World/ChunkTilesUpdatePacket.cpp | 12 ------- Minecraft.World/LoginPacket.cpp | 4 --- Minecraft.World/RespawnPacket.cpp | 4 --- Minecraft.World/TeleportEntityPacket.cpp | 12 ------- Minecraft.World/TileUpdatePacket.cpp | 33 ------------------- 9 files changed, 6 insertions(+), 92 deletions(-) diff --git a/Minecraft.Client/Common/Network/GameNetworkManager.cpp b/Minecraft.Client/Common/Network/GameNetworkManager.cpp index 9bb89f07..e92ea362 100644 --- a/Minecraft.Client/Common/Network/GameNetworkManager.cpp +++ b/Minecraft.Client/Common/Network/GameNetworkManager.cpp @@ -898,6 +898,12 @@ bool CGameNetworkManager::IsNetworkThreadRunning() int CGameNetworkManager::RunNetworkGameThreadProc( void* lpParameter ) { + if( g_NetworkManager.m_bNetworkThreadRunning ) + { + return -1; + } + g_NetworkManager.m_bNetworkThreadRunning = true; + // Share AABB & Vec3 pools with default (main thread) - should be ok as long as we don't tick the main thread whilst this thread is running AABB::UseDefaultThreadStorage(); Vec3::UseDefaultThreadStorage(); @@ -905,7 +911,6 @@ int CGameNetworkManager::RunNetworkGameThreadProc( void* lpParameter ) Tile::CreateNewThreadStorage(); IntCache::CreateNewThreadStorage(); - g_NetworkManager.m_bNetworkThreadRunning = true; bool success = g_NetworkManager._RunNetworkGame(lpParameter); g_NetworkManager.m_bNetworkThreadRunning = false; if( !success) diff --git a/Minecraft.Client/Common/Network/PlatformNetworkManagerStub.cpp b/Minecraft.Client/Common/Network/PlatformNetworkManagerStub.cpp index 896d2249..8767120e 100644 --- a/Minecraft.Client/Common/Network/PlatformNetworkManagerStub.cpp +++ b/Minecraft.Client/Common/Network/PlatformNetworkManagerStub.cpp @@ -419,8 +419,6 @@ int CPlatformNetworkManagerStub::JoinGame(FriendSessionInfo *searchResult, int l NotifyPlayerJoined(&IQNet::m_player[0]); NotifyPlayerJoined(&IQNet::m_player[localSmallId]); - m_pGameNetworkManager->StateChange_AnyToStarting(); - return CGameNetworkManager::JOINGAME_SUCCESS; } diff --git a/Minecraft.World/AddEntityPacket.cpp b/Minecraft.World/AddEntityPacket.cpp index 313c4ca6..138b5de9 100644 --- a/Minecraft.World/AddEntityPacket.cpp +++ b/Minecraft.World/AddEntityPacket.cpp @@ -56,15 +56,9 @@ void AddEntityPacket::read(DataInputStream *dis) // throws IOException TODO 4J { id = dis->readShort(); type = dis->readByte(); -#ifdef _LARGE_WORLDS x = dis->readInt(); y = dis->readInt(); z = dis->readInt(); -#else - x = dis->readShort(); - y = dis->readShort(); - z = dis->readShort(); -#endif yRot = dis->readByte(); xRot = dis->readByte(); data = dis->readInt(); @@ -80,15 +74,9 @@ void AddEntityPacket::write(DataOutputStream *dos) // throws IOException TODO 4J { dos->writeShort(id); dos->writeByte(type); -#ifdef _LARGE_WORLDS dos->writeInt(x); dos->writeInt(y); dos->writeInt(z); -#else - dos->writeShort(x); - dos->writeShort(y); - dos->writeShort(z); -#endif dos->writeByte(yRot); dos->writeByte(xRot); dos->writeInt(data); diff --git a/Minecraft.World/AddMobPacket.cpp b/Minecraft.World/AddMobPacket.cpp index 0843c333..d0d0c89f 100644 --- a/Minecraft.World/AddMobPacket.cpp +++ b/Minecraft.World/AddMobPacket.cpp @@ -68,15 +68,9 @@ void AddMobPacket::read(DataInputStream *dis) //throws IOException { id = dis->readShort(); type = dis->readByte() & 0xff; -#ifdef _LARGE_WORLDS x = dis->readInt(); y = dis->readInt(); z = dis->readInt(); -#else - x = dis->readShort(); - y = dis->readShort(); - z = dis->readShort(); -#endif yRot = dis->readByte(); xRot = dis->readByte(); yHeadRot = dis->readByte(); @@ -92,15 +86,9 @@ void AddMobPacket::write(DataOutputStream *dos) //throws IOException { dos->writeShort(id); dos->writeByte(type & 0xff); -#ifdef _LARGE_WORLDS dos->writeInt(x); dos->writeInt(y); dos->writeInt(z); -#else - dos->writeShort(x); - dos->writeShort(y); - dos->writeShort(z); -#endif dos->writeByte(yRot); dos->writeByte(xRot); dos->writeByte(yHeadRot); diff --git a/Minecraft.World/ChunkTilesUpdatePacket.cpp b/Minecraft.World/ChunkTilesUpdatePacket.cpp index 0072de4d..eab1a65c 100644 --- a/Minecraft.World/ChunkTilesUpdatePacket.cpp +++ b/Minecraft.World/ChunkTilesUpdatePacket.cpp @@ -51,17 +51,10 @@ ChunkTilesUpdatePacket::ChunkTilesUpdatePacket(int xc, int zc, shortArray positi void ChunkTilesUpdatePacket::read(DataInputStream *dis) //throws IOException { // 4J - changed format. See comments in write method. -#ifdef _LARGE_WORLDS xc = dis->readShort(); zc = dis->readShort(); xc = ( xc << 16 ) >> 16; zc = ( zc << 16 ) >> 16; -#else - xc = dis->read(); - zc = dis->read(); - xc = ( xc << 24 ) >> 24; - zc = ( zc << 24 ) >> 24; -#endif int countAndFlags = dis->readByte(); bool dataAllZero = (( countAndFlags & 0x80 ) == 0x80 ); @@ -97,13 +90,8 @@ void ChunkTilesUpdatePacket::read(DataInputStream *dis) //throws IOException void ChunkTilesUpdatePacket::write(DataOutputStream *dos) //throws IOException { // 4J - changed format to reduce size of these packets. -#ifdef _LARGE_WORLDS dos->writeShort(xc); dos->writeShort(zc); -#else - dos->write(xc); - dos->write(zc); -#endif // Determine if we've got any data elements that are non-zero - a large % of these packets set all data to zero, so we don't // bother sending all those zeros in that case. bool dataAllZero = true; diff --git a/Minecraft.World/LoginPacket.cpp b/Minecraft.World/LoginPacket.cpp index 25e53880..caadb5b4 100644 --- a/Minecraft.World/LoginPacket.cpp +++ b/Minecraft.World/LoginPacket.cpp @@ -123,10 +123,8 @@ void LoginPacket::read(DataInputStream *dis) //throws IOException m_isGuest = dis->readBoolean(); m_newSeaLevel = dis->readBoolean(); m_uiGamePrivileges = dis->readInt(); -#ifdef _LARGE_WORLDS m_xzSize = dis->readShort(); m_hellScale = dis->read(); -#endif app.DebugPrintf("LoginPacket::read - Difficulty = %d\n",difficulty); } @@ -160,10 +158,8 @@ void LoginPacket::write(DataOutputStream *dos) //throws IOException dos->writeBoolean(m_isGuest); dos->writeBoolean(m_newSeaLevel); dos->writeInt(m_uiGamePrivileges); -#ifdef _LARGE_WORLDS dos->writeShort(m_xzSize); dos->write(m_hellScale); -#endif } void LoginPacket::handle(PacketListener *listener) diff --git a/Minecraft.World/RespawnPacket.cpp b/Minecraft.World/RespawnPacket.cpp index 0e251f59..7c3e3fcf 100644 --- a/Minecraft.World/RespawnPacket.cpp +++ b/Minecraft.World/RespawnPacket.cpp @@ -55,10 +55,8 @@ void RespawnPacket::read(DataInputStream *dis) //throws IOException difficulty = dis->readByte(); m_newSeaLevel = dis->readBoolean(); m_newEntityId = dis->readShort(); -#ifdef _LARGE_WORLDS m_xzSize = dis->readShort(); m_hellScale = dis->read(); -#endif app.DebugPrintf("RespawnPacket::read - Difficulty = %d\n",difficulty); } @@ -80,10 +78,8 @@ void RespawnPacket::write(DataOutputStream *dos) //throws IOException dos->writeByte(difficulty); dos->writeBoolean(m_newSeaLevel); dos->writeShort(m_newEntityId); -#ifdef _LARGE_WORLDS dos->writeShort(m_xzSize); dos->write(m_hellScale); -#endif } int RespawnPacket::getEstimatedSize() diff --git a/Minecraft.World/TeleportEntityPacket.cpp b/Minecraft.World/TeleportEntityPacket.cpp index 2527a1a5..4325c9ac 100644 --- a/Minecraft.World/TeleportEntityPacket.cpp +++ b/Minecraft.World/TeleportEntityPacket.cpp @@ -40,15 +40,9 @@ TeleportEntityPacket::TeleportEntityPacket(int id, int x, int y, int z, byte yRo void TeleportEntityPacket::read(DataInputStream *dis) //throws IOException { id = dis->readShort(); -#ifdef _LARGE_WORLDS x = dis->readInt(); y = dis->readInt(); z = dis->readInt(); -#else - x = dis->readShort(); - y = dis->readShort(); - z = dis->readShort(); -#endif yRot = dis->readByte(); xRot = dis->readByte(); } @@ -56,15 +50,9 @@ void TeleportEntityPacket::read(DataInputStream *dis) //throws IOException void TeleportEntityPacket::write(DataOutputStream *dos) //throws IOException { dos->writeShort(id); -#ifdef _LARGE_WORLDS dos->writeInt(x); dos->writeInt(y); dos->writeInt(z); -#else - dos->writeShort(x); - dos->writeShort(y); - dos->writeShort(z); -#endif dos->write(yRot); dos->write(xRot); } diff --git a/Minecraft.World/TileUpdatePacket.cpp b/Minecraft.World/TileUpdatePacket.cpp index d19d1e55..a91f0287 100644 --- a/Minecraft.World/TileUpdatePacket.cpp +++ b/Minecraft.World/TileUpdatePacket.cpp @@ -26,7 +26,6 @@ TileUpdatePacket::TileUpdatePacket(int x, int y, int z, Level *level) void TileUpdatePacket::read(DataInputStream *dis) //throws IOException { -#ifdef _LARGE_WORLDS x = dis->readInt(); y = dis->readUnsignedByte(); z = dis->readInt(); @@ -36,26 +35,10 @@ void TileUpdatePacket::read(DataInputStream *dis) //throws IOException BYTE dataLevel = dis->readByte(); data = dataLevel & 0xf; levelIdx = (dataLevel>>4) & 0xf; -#else - // 4J - See comments in write for packing - int xyzdata = dis->readInt(); - x = ( xyzdata >> 22 ) & 0x3ff; - y = ( xyzdata >> 14 ) & 0xff; - z = ( xyzdata >> 4 ) & 0x3ff; - x = ( x << 22 ) >> 22; - z = ( z << 22 ) >> 22; - data = xyzdata & 0xf; - block = (int)dis->readShort() & 0xffff; - //levelIdx = ( xyzdata >> 31 ) & 1; - - // Can't pack this as it's now 2 bits - levelIdx = (int)dis->readByte(); -#endif } void TileUpdatePacket::write(DataOutputStream *dos) //throws IOException { -#ifdef _LARGE_WORLDS dos->writeInt(x); dos->write(y); dos->writeInt(z); @@ -63,18 +46,6 @@ void TileUpdatePacket::write(DataOutputStream *dos) //throws IOException BYTE dataLevel = ((levelIdx & 0xf ) << 4) | (data & 0xf); dos->writeByte(dataLevel); -#else - // 4J - for our fixed size map, we can pack x & z into 10 bits each (-512 -> 511), y into 8 bits (0 to 255) - // block type could really be 7 bits but leaving that as 8 for future ease of expansion. Data only needs to be 4-bits as that is how it - // is ultimately stored - int xyzdata = ( ( x & 0x3ff ) << 22 ) | ( ( y & 0xff ) << 14 ) | ( ( z & 0x3ff ) << 4 ) | ( data & 0xf); - //xyzdata |= levelIdx << 31; - dos->writeInt(xyzdata); - dos->writeShort(block); - - // Can't pack this as it's now 2 bits - dos->write(levelIdx); -#endif } void TileUpdatePacket::handle(PacketListener *listener) @@ -84,9 +55,5 @@ void TileUpdatePacket::handle(PacketListener *listener) int TileUpdatePacket::getEstimatedSize() { -#ifdef _LARGE_WORLDS return 12; -#else - return 5; -#endif }