mirror of
https://github.com/veden/Rampant.git
synced 2025-09-16 09:16:43 +02:00
perform a cleanup of tables and iterators when chunk becomes impassable
This commit is contained in:
@@ -5,7 +5,8 @@ Date: 23. 11. 2021
|
|||||||
- RealSimplyData fixed missing map parameter in onUnitGroupCreated (Thanks illiander42 for reporting)
|
- RealSimplyData fixed missing map parameter in onUnitGroupCreated (Thanks illiander42 for reporting)
|
||||||
Bugfixes:
|
Bugfixes:
|
||||||
- Fixed chunkPassScanning not checking for enemy structures when determining passability
|
- Fixed chunkPassScanning not checking for enemy structures when determining passability
|
||||||
- Potential bugfix for evolutionTable being nil, still need a save to verify
|
- Fixed chunks that become impassable not being properly removed from all tables and iterators (Thanks ZwerOxotnik for reporting)
|
||||||
|
- Potential bugfix for evolutionTable being nil, still need a save to verify (Thanks ZwerOxotnik for reporting)
|
||||||
- Corrected Krastorio2 position parameter wanting xy pair. (Krastorio2 1.1.6 that is currently published at the time of this update is broken still, see thread https://mods.factorio.com/mod/Rampant/discussion/5f44980455e55634147d01f4)
|
- Corrected Krastorio2 position parameter wanting xy pair. (Krastorio2 1.1.6 that is currently published at the time of this update is broken still, see thread https://mods.factorio.com/mod/Rampant/discussion/5f44980455e55634147d01f4)
|
||||||
|
|
||||||
---------------------------------------------------------------------------------------------------
|
---------------------------------------------------------------------------------------------------
|
||||||
|
@@ -7,11 +7,13 @@ local chunkProcessor = {}
|
|||||||
|
|
||||||
local chunkUtils = require("ChunkUtils")
|
local chunkUtils = require("ChunkUtils")
|
||||||
local queryUtils = require("QueryUtils")
|
local queryUtils = require("QueryUtils")
|
||||||
|
local mapUtils = require("MapUtils")
|
||||||
|
|
||||||
-- constants
|
-- constants
|
||||||
|
|
||||||
-- imported functions
|
-- imported functions
|
||||||
|
|
||||||
|
local removeChunkFromMap = mapUtils.removeChunkFromMap
|
||||||
local setPositionInQuery = queryUtils.setPositionInQuery
|
local setPositionInQuery = queryUtils.setPositionInQuery
|
||||||
local registerEnemyBaseStructure = chunkUtils.registerEnemyBaseStructure
|
local registerEnemyBaseStructure = chunkUtils.registerEnemyBaseStructure
|
||||||
local unregisterEnemyBaseStructure = chunkUtils.unregisterEnemyBaseStructure
|
local unregisterEnemyBaseStructure = chunkUtils.unregisterEnemyBaseStructure
|
||||||
@@ -102,8 +104,7 @@ function chunkProcessor.processPendingChunks(universe, tick, flush)
|
|||||||
local chunk = initialScan(oldChunk, map, tick)
|
local chunk = initialScan(oldChunk, map, tick)
|
||||||
if (chunk == -1) then
|
if (chunk == -1) then
|
||||||
removeProcessQueueChunk(map.processQueue, oldChunk)
|
removeProcessQueueChunk(map.processQueue, oldChunk)
|
||||||
universe.chunkIdToChunk[oldChunk.id] = nil
|
removeChunkFromMap(map, x, y, oldChunk.id)
|
||||||
map[x][y] = nil
|
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
local initialChunk = createChunk(map, x, y)
|
local initialChunk = createChunk(map, x, y)
|
||||||
@@ -117,8 +118,8 @@ function chunkProcessor.processPendingChunks(universe, tick, flush)
|
|||||||
chunk
|
chunk
|
||||||
)
|
)
|
||||||
else
|
else
|
||||||
universe.chunkIdToChunk[initialChunk.id] = nil
|
|
||||||
map[x][y] = nil
|
map[x][y] = nil
|
||||||
|
universe.chunkIdToChunk[initialChunk.id] = nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -195,8 +196,7 @@ function chunkProcessor.processScanChunks(universe)
|
|||||||
|
|
||||||
if (chunkPassScan(chunk, map) == -1) then
|
if (chunkPassScan(chunk, map) == -1) then
|
||||||
removeProcessQueueChunk(map.processQueue, chunk)
|
removeProcessQueueChunk(map.processQueue, chunk)
|
||||||
map[chunk.x][chunk.y] = nil
|
removeChunkFromMap(map, chunk.x, chunk.y, chunk.id)
|
||||||
map.universe.chunkIdToChunk[chunk.id] = nil
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@@ -426,17 +426,17 @@ function mapProcessor.processVengence(universe)
|
|||||||
end
|
end
|
||||||
else
|
else
|
||||||
universe.deployVengenceIterator = next(vengenceQueue, chunkId)
|
universe.deployVengenceIterator = next(vengenceQueue, chunkId)
|
||||||
|
vengenceQueue[chunkId] = nil
|
||||||
local map = vengencePack.map
|
local map = vengencePack.map
|
||||||
if not map.surface.valid then
|
if not map.surface.valid then
|
||||||
vengenceQueue[chunkId] = nil
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
local chunk = getChunkById(vengencePack.map, chunkId)
|
||||||
if universe.enabledMigration and (universe.random() < 0.075) then
|
if universe.enabledMigration and (universe.random() < 0.075) then
|
||||||
formVengenceSettler(map, getChunkById(vengencePack.map, chunkId))
|
formVengenceSettler(map, chunk)
|
||||||
else
|
else
|
||||||
formVengenceSquad(map, getChunkById(vengencePack.map, chunkId))
|
formVengenceSquad(map, chunk)
|
||||||
end
|
end
|
||||||
vengenceQueue[chunkId] = nil
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@@ -76,6 +76,73 @@ function mapUtils.nextMap(universe)
|
|||||||
until mapIterator == universe.mapIterator
|
until mapIterator == universe.mapIterator
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function mapUtils.removeChunkFromMap(map, x, y, chunkId)
|
||||||
|
local universe = map.universe
|
||||||
|
map[x][y] = nil
|
||||||
|
universe.chunkIdToChunk[chunkId] = nil
|
||||||
|
universe.chunkToActiveNest[chunkId] = nil
|
||||||
|
universe.chunkToActiveRaidNest[chunkId] = nil
|
||||||
|
universe.chunkToDrained[chunkId] = nil
|
||||||
|
universe.chunkToRetreats[chunkId] = nil
|
||||||
|
universe.chunkToRallys[chunkId] = nil
|
||||||
|
universe.chunkToPassScan[chunkId] = nil
|
||||||
|
universe.chunkToNests[chunkId] = nil
|
||||||
|
universe.vengenceQueue[chunkId] = nil
|
||||||
|
universe.processActiveNest[chunkId] = nil
|
||||||
|
universe.chunkToVictory[chunkId] = nil
|
||||||
|
map.chunkToBase[chunkId] = nil
|
||||||
|
map.chunkToTurrets[chunkId] = nil
|
||||||
|
map.chunkToTraps[chunkId] = nil
|
||||||
|
map.chunkToUtilities[chunkId] = nil
|
||||||
|
map.chunkToHives[chunkId] = nil
|
||||||
|
map.chunkToNestIds[chunkId] = nil
|
||||||
|
map.chunkToHiveIds[chunkId] = nil
|
||||||
|
map.chunkToTrapIds[chunkId] = nil
|
||||||
|
map.chunkToTurretIds[chunkId] = nil
|
||||||
|
map.chunkToUtilityIds[chunkId] = nil
|
||||||
|
map.chunkToPlayerBase[chunkId] = nil
|
||||||
|
map.chunkToResource[chunkId] = nil
|
||||||
|
map.chunkToPlayerCount[chunkId] = nil
|
||||||
|
map.chunkToSquad[chunkId] = nil
|
||||||
|
map.chunkToPassable[chunkId] = nil
|
||||||
|
map.chunkToPathRating[chunkId] = nil
|
||||||
|
map.chunkToDeathGenerator[chunkId] = nil
|
||||||
|
|
||||||
|
if universe.processActiveNestIterator == chunkId then
|
||||||
|
universe.processActiveNestIterator = nil
|
||||||
|
end
|
||||||
|
if universe.victoryScentIterator == chunkId then
|
||||||
|
universe.victoryScentIterator = nil
|
||||||
|
end
|
||||||
|
if universe.processNestIterator == chunkId then
|
||||||
|
universe.processNestIterator = nil
|
||||||
|
end
|
||||||
|
if universe.chunkToDrainedIterator == chunkId then
|
||||||
|
universe.chunkToDrainedIterator = nil
|
||||||
|
end
|
||||||
|
if universe.chunkToRetreatIterator == chunkId then
|
||||||
|
universe.chunkToRetreatIterator = nil
|
||||||
|
end
|
||||||
|
if universe.chunkToRallyIterator == chunkId then
|
||||||
|
universe.chunkToRallyIterator = nil
|
||||||
|
end
|
||||||
|
if universe.chunkToPassScanIterator == chunkId then
|
||||||
|
universe.chunkToPassScanIterator = nil
|
||||||
|
end
|
||||||
|
if universe.processActiveSpawnerIterator == chunkId then
|
||||||
|
universe.processActiveSpawnerIterator = nil
|
||||||
|
end
|
||||||
|
if universe.processActiveRaidSpawnerIterator == chunkId then
|
||||||
|
universe.processActiveRaidSpawnerIterator = nil
|
||||||
|
end
|
||||||
|
if universe.processMigrationIterator == chunkId then
|
||||||
|
universe.processMigrationIterator = nil
|
||||||
|
end
|
||||||
|
if universe.deployVengenceIterator == chunkId then
|
||||||
|
universe.deployVengenceIterator = nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
--[[
|
--[[
|
||||||
1 2 3
|
1 2 3
|
||||||
\|/
|
\|/
|
||||||
|
Reference in New Issue
Block a user