1
0
mirror of https://github.com/veden/Rampant.git synced 2024-12-30 21:19:46 +02:00

code cleanup in onDeath event and chunkProcessor

This commit is contained in:
Aaron Veden 2021-12-06 20:46:47 -08:00
parent d68c3c93d6
commit b88e1abd91
No known key found for this signature in database
GPG Key ID: FF5990B1C6DD3F84
2 changed files with 161 additions and 164 deletions

View File

@ -337,7 +337,9 @@ end
local function onDeath(event)
local entity = event.entity
if entity.valid then
if not entity.valid then
return
end
local surface = entity.surface
local map = universe.maps[surface.index]
if not map then
@ -346,9 +348,8 @@ local function onDeath(event)
if (entity.force.name == "neutral") then
if (entity.name == "cliff") then
entityForPassScan(map, entity)
else
return
end
return
end
local entityPosition = entity.position
local chunk = getChunkByPosition(map, entityPosition)
@ -356,7 +357,6 @@ local function onDeath(event)
local tick = event.tick
local entityType = entity.type
if (entity.force.name == "enemy") then
local artilleryBlast = (cause and
((cause.type == "artillery-wagon") or (cause.type == "artillery-turret")))
@ -523,7 +523,6 @@ local function onDeath(event)
accountPlayerEntity(entity, map, false, creditNatives)
end
end
end
end
local function onEnemyBaseBuild(event)

View File

@ -175,11 +175,6 @@ end
function chunkProcessor.processScanChunks(map)
local area = map.universe.area
local topOffset = area[1]
local bottomOffset = area[2]
local chunkId = map.chunkToPassScanIterator
local chunk
if not chunkId then
@ -198,6 +193,9 @@ function chunkProcessor.processScanChunks(map)
map.chunkToPassScanIterator = next(map.chunkToPassScan, chunkId)
map.chunkToPassScan[chunkId] = nil
local area = map.universe.area
local topOffset = area[1]
local bottomOffset = area[2]
topOffset[1] = chunk.x
topOffset[2] = chunk.y
bottomOffset[1] = chunk.x + CHUNK_SIZE