diff --git a/Minecraft.Client/ServerChunkCache.cpp b/Minecraft.Client/ServerChunkCache.cpp index 1fcaf384..2b2d7a42 100644 --- a/Minecraft.Client/ServerChunkCache.cpp +++ b/Minecraft.Client/ServerChunkCache.cpp @@ -927,6 +927,7 @@ bool ServerChunkCache::tick() int ix = chunk->x + XZOFFSET; int iz = chunk->z + XZOFFSET; int idx = ix * XZSIZE + iz; + delete m_unloadedCache[idx]; m_unloadedCache[idx] = chunk; cache[idx] = nullptr; } diff --git a/Minecraft.Client/Windows64/Network/WinsockNetLayer.cpp b/Minecraft.Client/Windows64/Network/WinsockNetLayer.cpp index 96b35187..130ab531 100644 --- a/Minecraft.Client/Windows64/Network/WinsockNetLayer.cpp +++ b/Minecraft.Client/Windows64/Network/WinsockNetLayer.cpp @@ -455,6 +455,12 @@ bool WinsockNetLayer::JoinGame(const char* ip, int port) { return false; } + + // Clear the recv timeout now that the handshake is complete. + // The recv thread should block indefinitely waiting for data. + DWORD noTimeout = 0; + setsockopt(s_hostConnectionSocket, SOL_SOCKET, SO_RCVTIMEO, (const char*)&noTimeout, sizeof(noTimeout)); + s_localSmallId = assignedSmallId; // Save the host IP and port so JoinSplitScreen can connect to the same host diff --git a/README.md b/README.md index 5251a736..d450e35e 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,12 @@ This project is based on source code of Minecraft Legacy Console Edition v1.6.05 ## Latest: +Chunk unloading and connection stability fixes: +- Fixed a regression where chunks outside the player's immediate vicinity would fail to load on dedicated servers, leaving giant missing areas. The server's chunk drop function was immediately removing chunks from the cache instead of queuing them for the existing save/unload pipeline, which meant chunks were never saved, never moved to the recovery cache, and their entities (item frames, paintings, etc.) were never removed from the level before being reloaded, causing entity duplication +- Fixed the server's `dropAll()` and autosave chunk cleanup iterating the loaded chunk list while simultaneously modifying it (undefined behavior that could corrupt chunk tracking or stall the server) +- Removed an overly aggressive `dropAll()` call that wiped the entire chunk cache whenever render distance decreased, instead of only removing the out-of-range chunks +- Fixed a client-side connection bug where a 5-second socket recv timeout (used during the initial server handshake) was never cleared after connecting. This meant any brief server pause longer than 5 seconds (e.g. autosave, chunk I/O) would cause the client to interpret the silence as a lost connection and disconnect + Dedicated server biome diversity fix: - The dedicated server previously used a completely random seed with no biome diversity checks, unlike the client which validates seeds to guarantee varied biomes. This could result in server worlds with large regions dominated by only one or two biome types (e.g. all taiga/snowy) - On top of that, the client's seed validation was hardcoded to only check a 54-chunk (Classic) area, so even validated seeds had no diversity guarantee beyond that. This made the problem especially noticeable on Large worlds or worlds expanded from Classic to Large