From 2658ed59008608bba1766d466af88e7497f734aa Mon Sep 17 00:00:00 2001 From: dongresource Date: Sun, 2 May 2021 19:51:59 +0200 Subject: [PATCH] Check if the destination chunk exists after leaving the source chunk This fixes a crash if a player does a /refresh in the zeroeth chunk. --- src/Chunking.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Chunking.cpp b/src/Chunking.cpp index d707ce2..1b67645 100644 --- a/src/Chunking.cpp +++ b/src/Chunking.cpp @@ -161,12 +161,13 @@ static void emptyChunk(ChunkPos chunkPos) { void Chunking::updateEntityChunk(const EntityRef& ref, ChunkPos from, ChunkPos to) { Entity* ent = ref.getEntity(); + // move to other chunk's player set + untrackEntity(from, ref); // this will delete the chunk if it's empty + // if the new chunk doesn't exist, make it first if (!chunkExists(to)) newChunk(to); - // move to other chunk's player set - untrackEntity(from, ref); // this will delete the chunk if it's empty trackEntity(to, ref); // calculate viewable chunks from both points