1
0
mirror of https://github.com/veden/Rampant.git synced 2025-01-28 03:29:34 +02:00

perform a cleanup of tables and iterators when chunk becomes impassable

This commit is contained in:
Aaron Veden 2021-12-14 22:03:29 -08:00
parent d9c733cb54
commit db337c4a92
No known key found for this signature in database
GPG Key ID: FF5990B1C6DD3F84
4 changed files with 78 additions and 10 deletions

View File

@ -5,7 +5,8 @@ Date: 23. 11. 2021
- RealSimplyData fixed missing map parameter in onUnitGroupCreated (Thanks illiander42 for reporting)
Bugfixes:
- 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)
---------------------------------------------------------------------------------------------------

View File

@ -7,11 +7,13 @@ local chunkProcessor = {}
local chunkUtils = require("ChunkUtils")
local queryUtils = require("QueryUtils")
local mapUtils = require("MapUtils")
-- constants
-- imported functions
local removeChunkFromMap = mapUtils.removeChunkFromMap
local setPositionInQuery = queryUtils.setPositionInQuery
local registerEnemyBaseStructure = chunkUtils.registerEnemyBaseStructure
local unregisterEnemyBaseStructure = chunkUtils.unregisterEnemyBaseStructure
@ -102,8 +104,7 @@ function chunkProcessor.processPendingChunks(universe, tick, flush)
local chunk = initialScan(oldChunk, map, tick)
if (chunk == -1) then
removeProcessQueueChunk(map.processQueue, oldChunk)
universe.chunkIdToChunk[oldChunk.id] = nil
map[x][y] = nil
removeChunkFromMap(map, x, y, oldChunk.id)
end
else
local initialChunk = createChunk(map, x, y)
@ -117,8 +118,8 @@ function chunkProcessor.processPendingChunks(universe, tick, flush)
chunk
)
else
universe.chunkIdToChunk[initialChunk.id] = nil
map[x][y] = nil
universe.chunkIdToChunk[initialChunk.id] = nil
end
end
@ -195,8 +196,7 @@ function chunkProcessor.processScanChunks(universe)
if (chunkPassScan(chunk, map) == -1) then
removeProcessQueueChunk(map.processQueue, chunk)
map[chunk.x][chunk.y] = nil
map.universe.chunkIdToChunk[chunk.id] = nil
removeChunkFromMap(map, chunk.x, chunk.y, chunk.id)
end
end
end

View File

@ -426,17 +426,17 @@ function mapProcessor.processVengence(universe)
end
else
universe.deployVengenceIterator = next(vengenceQueue, chunkId)
vengenceQueue[chunkId] = nil
local map = vengencePack.map
if not map.surface.valid then
vengenceQueue[chunkId] = nil
return
end
local chunk = getChunkById(vengencePack.map, chunkId)
if universe.enabledMigration and (universe.random() < 0.075) then
formVengenceSettler(map, getChunkById(vengencePack.map, chunkId))
formVengenceSettler(map, chunk)
else
formVengenceSquad(map, getChunkById(vengencePack.map, chunkId))
formVengenceSquad(map, chunk)
end
vengenceQueue[chunkId] = nil
end
end

View File

@ -76,6 +76,73 @@ function mapUtils.nextMap(universe)
until mapIterator == universe.mapIterator
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
\|/