From 38e83283fcf3d8dafa5520adcdc2ec2fad1fab65 Mon Sep 17 00:00:00 2001 From: Aaron Veden Date: Sun, 5 Dec 2021 14:39:50 -0800 Subject: [PATCH] added logic to reset pending upgrade table --- libs/ChunkProcessor.lua | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/libs/ChunkProcessor.lua b/libs/ChunkProcessor.lua index 0ed4847..b5b0c95 100644 --- a/libs/ChunkProcessor.lua +++ b/libs/ChunkProcessor.lua @@ -144,16 +144,20 @@ function chunkProcessor.processPendingUpgrades(map, tick) else entityData = map.pendingUpgrades[entityId] end - if entityId then + if not entityId then + map.pendingUpgradeIterator = nil + if table_size(map.pendingUpgrades) == 0 then + map.pendingUpgrades = {} + end + else local entity = entityData.entity if entity.valid then map.pendingUpgradeIterator = next(map.pendingUpgrades, entityId) map.pendingUpgrades[entityId] = nil - local universe = map.universe - local query = universe.upgradeEntityQuery + local surface = entity.surface + local query = map.universe.upgradeEntityQuery query.position = entityData.position or entity.position query.name = entityData.name - local surface = entity.surface unregisterEnemyBaseStructure(map, entity) entity.destroy() local createdEntity = surface.create_entity(query)