Fix chunk unloading regression from upstream merge

Commit a24318ee changed drop() to immediately remove chunks from cache,
bypassing the deferred m_toDrop save/unload pipeline. This caused missing
chunks on dedicated servers, iterator invalidation in dropAll() and
ServerLevel::save(), and entity duplication (item frames) from chunks
being reloaded without their entities first being removed from the level.

- ServerChunkCache::drop(): restore m_toDrop queue instead of immediate
  cache removal, so tick() can save/unload/move to unloadedCache safely
- MultiPlayerChunkCache::drop(): restore soft-unload (keep chunk in cache
  with loaded=true) instead of nulling cache and hasData
- PlayerChunkMap::setRadius(): remove dropAll() call when reducing radius,
  the per-chunk removal loop already handles out-of-range chunks
This commit is contained in:
itsRevela
2026-03-25 19:57:35 -05:00
parent 3a8106593f
commit c264262b66
3 changed files with 7 additions and 17 deletions

View File

@@ -91,11 +91,7 @@ void ServerChunkCache::drop(const int x, const int z)
if (chunk != nullptr)
{
const auto it = std::find(m_loadedChunkList.begin(), m_loadedChunkList.end(), chunk);
if (it != m_loadedChunkList.end()) m_loadedChunkList.erase(it);
cache[idx] = nullptr;
chunk->loaded = false;
m_toDrop.push_back(chunk);
}
}