1
0
mirror of https://github.com/veden/Rampant.git synced 2024-12-26 20:54:12 +02:00

adding check to global processors for invalid surfaces

This commit is contained in:
Aaron Veden 2021-12-07 22:13:32 -08:00
parent 954b3d6c84
commit 903e4b49d0
No known key found for this signature in database
GPG Key ID: FF5990B1C6DD3F84
3 changed files with 51 additions and 11 deletions

View File

@ -87,7 +87,13 @@ function chunkProcessor.processPendingChunks(universe, tick, flush)
universe.chunkProcessorIterator = eventId
return
end
local newEventId, newEvent = next(pendingChunks, eventId)
pendingChunks[eventId] = nil
local map = event.map
if not map.surface.valid then
return
end
local topLeft = event.area.left_top
local x = topLeft.x
local y = topLeft.y
@ -126,8 +132,6 @@ function chunkProcessor.processPendingChunks(universe, tick, flush)
end
end
local newEventId, newEvent = next(pendingChunks, eventId)
pendingChunks[eventId] = nil
eventId = newEventId
event = newEvent
end

View File

@ -429,6 +429,10 @@ function mapProcessor.processActiveNests(universe, tick)
universe.processActiveNestIterator = next(processActiveNest, chunkId)
if chunkPack.tick < tick then
local map = chunkPack.map
if not map.surface.valid then
processActiveNest[chunkId] = nil
return
end
local chunk = chunkPack.chunk
processNestActiveness(map, chunk)
if (getNestActiveness(map, chunk) == 0) and (getRaidNestActiveness(map, chunk) == 0) then
@ -456,16 +460,33 @@ function mapProcessor.processVengence(universe)
end
else
universe.deployVengenceIterator = next(vengenceQueue, chunkId)
formVengenceSquad(vengencePack.map, getChunkById(vengencePack.map, chunkId))
local map = vengencePack.map
if not map.surface.valid then
vengenceQueue[chunkId] = nil
return
end
formVengenceSquad(map, getChunkById(vengencePack.map, chunkId))
vengenceQueue[chunkId] = nil
end
end
function mapProcessor.processNests(universe, tick)
local chunkId, chunkPack = next(universe.chunkToNests, universe.processNestIterator)
universe.processNestIterator = chunkId
if chunkId then
local chunkId = universe.processNestIterator
local chunkPack
if not chunkId then
chunkId,chunkPack = next(universe.chunkToNests, nil)
else
chunkPack = universe.chunkToNests[chunkId]
end
if not chunkId then
universe.processNestIterator = nil
else
universe.processNestIterator = next(universe.chunkToNests, chunkId)
local map = chunkPack.map
if not map.surface.valid then
universe.chunkToNests[chunkId] = nil
return
end
local chunk = getChunkById(map, chunkId)
processNestActiveness(map, chunk)
queueNestSpawners(map, chunk, tick)
@ -480,10 +501,22 @@ function mapProcessor.processNests(universe, tick)
end
local function processSpawnersBody(universe, iterator, chunks)
local chunkId, chunkPack = next(chunks, universe[iterator])
universe[iterator] = chunkId
if chunkId then
local chunkId = universe[iterator]
local chunkPack
if not chunkId then
chunkId,chunkPack = next(chunks, nil)
else
chunkPack = chunks[chunkId]
end
if not chunkId then
universe[iterator] = nil
else
universe[iterator] = next(chunks, chunkId)
local map = chunkPack.map
if not map.surface.valid then
chunks[chunkId] = nil
return
end
local state = chunkPack.map.state
if state == AI_STATE_PEACEFUL then
return

View File

@ -75,9 +75,12 @@ function pheromoneUtils.disperseVictoryScent(universe)
if not chunkId then
universe.victoryScentIterator = nil
else
local map = pheromonePack.map
map.victoryScentIterator = next(chunkToVictory, chunkId)
universe.victoryScentIterator = next(chunkToVictory, chunkId)
chunkToVictory[chunkId] = nil
local map = pheromonePack.map
if not map.surface.valid then
return
end
local chunk = getChunkById(map, chunkId)
local chunkX = chunk.x
local chunkY = chunk.y