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