From 64078e5e8456c91f68e9d42b553865e430bf7888 Mon Sep 17 00:00:00 2001 From: Aaron Veden Date: Mon, 27 Dec 2021 09:48:49 -0800 Subject: [PATCH] fixed adding player to chunk crash --- changelog.txt | 1 + libs/ChunkPropertyUtils.lua | 11 ++++++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/changelog.txt b/changelog.txt index 1e8e64f..65f2933 100644 --- a/changelog.txt +++ b/changelog.txt @@ -5,6 +5,7 @@ Date: 17. 12. 2021 - Added RTStasisRealm to surface exclusion list Bugfixes: - Fixed onBuilderArrived if the builder was a unit and not a group (Thanks DBotThePony for reporting) + - Fixed adding player to chunk crash --------------------------------------------------------------------------------------------------- Version: 2.0.3 diff --git a/libs/ChunkPropertyUtils.lua b/libs/ChunkPropertyUtils.lua index a92b9f6..afa17ca 100644 --- a/libs/ChunkPropertyUtils.lua +++ b/libs/ChunkPropertyUtils.lua @@ -451,11 +451,10 @@ function chunkPropertyUtils.decayDeathGenerator(map, chunk) end function chunkPropertyUtils.addPlayerToChunk(map, chunk, name) - local playerChunks = map.playerToChunk local playerCountChunks = map.chunkToPlayerCount - local playerChunk = playerChunks[name] + local playerChunk = map.playerToChunk[name] if not playerChunk then - playerChunks[name] = chunk + map.playerToChunk[name] = chunk local playerCount = playerCountChunks[chunk.id] if not playerCount then playerCountChunks[chunk.id] = 1 @@ -463,9 +462,11 @@ function chunkPropertyUtils.addPlayerToChunk(map, chunk, name) playerCountChunks[chunk.id] = playerCount + 1 end elseif (playerChunk.id ~= chunk.id) then - playerChunks[name] = chunk + map.playerToChunk[name] = chunk local playerCount = playerCountChunks[playerChunk.id] - chunkPropertyUtils.setPlayersOnChunk(map, playerChunk, playerCount - 1) + if playerCount then + chunkPropertyUtils.setPlayersOnChunk(map, playerChunk, playerCount - 1) + end playerCount = playerCountChunks[chunk.id] if not playerCount then playerCountChunks[chunk.id] = 1