mirror of
https://github.com/veden/Rampant.git
synced 2024-12-28 21:08:22 +02:00
pending chunks are processed across all chunks
This commit is contained in:
parent
d1eeee025f
commit
beaeaa6c2e
@ -424,8 +424,10 @@ function upgrade.attempt(universe)
|
||||
universe.random = game.create_random_generator(settings.startup["rampant--enemySeed"].value+game.default_map_gen_settings.seed)
|
||||
game.forces.enemy.kill_all_units()
|
||||
universe.maps = {}
|
||||
universe.chunkIdToChunk = {}
|
||||
universe.groupNumberToSquad = {}
|
||||
universe.pendingUpgrades = {}
|
||||
universe.pendingChunks = {}
|
||||
universe.processActiveNest = {}
|
||||
universe.processActiveNestIterator = nil
|
||||
universe.deployVengenceIterator = nil
|
||||
@ -469,7 +471,6 @@ function upgrade.prepMap(universe, surface)
|
||||
local map = {}
|
||||
universe.maps[surfaceIndex] = map
|
||||
|
||||
map.eventId = 1
|
||||
map.maxAggressiveGroups = 1
|
||||
map.sentAggressiveGroups = 0
|
||||
map.processedChunks = 0
|
||||
@ -506,7 +507,6 @@ function upgrade.prepMap(universe, surface)
|
||||
|
||||
map.chunkToRetreats = {}
|
||||
map.chunkToRallys = {}
|
||||
map.chunkIdToChunk = {}
|
||||
|
||||
map.chunkToPassable = {}
|
||||
map.chunkToPathRating = {}
|
||||
@ -581,7 +581,7 @@ function upgrade.prepMap(universe, surface)
|
||||
end
|
||||
end
|
||||
|
||||
processPendingChunks(map, tick, true)
|
||||
processPendingChunks(universe, tick, true)
|
||||
end
|
||||
|
||||
function upgrade.compareTable(entities, option, new)
|
||||
|
@ -20,6 +20,7 @@ Date: 23. 11. 2021
|
||||
- Enemy structure upgrades now are processed regardless of current active surface
|
||||
- Spawners covered by pollution are now processed regardless of current active surface
|
||||
- Optimized processing spawners covered by pollution
|
||||
- Newly generated chunks are now processed regardless of current active surface
|
||||
Tweaks:
|
||||
- Increase chance to upgrade an enemy structure from 5% to 30%
|
||||
- New enemy regional bases that have two factions now do 75% on one faction and 25% on the faction for building and upgrading enemy structures
|
||||
|
@ -977,7 +977,7 @@ script.on_event(defines.events.on_tick,
|
||||
end
|
||||
|
||||
if (pick == 0) then
|
||||
processPendingChunks(map, tick)
|
||||
processPendingChunks(universe, tick)
|
||||
planning(map, gameRef.forces.enemy.evolution_factor, tick)
|
||||
if universe.NEW_ENEMIES then
|
||||
recycleBases(map)
|
||||
@ -1002,7 +1002,7 @@ script.on_event(defines.events.on_tick,
|
||||
processNests(map, tick)
|
||||
temperamentPlanner(map)
|
||||
elseif (pick == 7) then
|
||||
processPendingChunks(map, tick)
|
||||
processPendingChunks(universe, tick)
|
||||
processScanChunks(map)
|
||||
end
|
||||
|
||||
|
@ -55,17 +55,15 @@ local function removeProcessQueueChunk(processQueue, chunk)
|
||||
end
|
||||
end
|
||||
|
||||
function chunkProcessor.processPendingChunks(map, tick, flush)
|
||||
local processQueue = map.processQueue
|
||||
local pendingChunks = map.pendingChunks
|
||||
|
||||
local area = map.universe.area
|
||||
|
||||
function chunkProcessor.processPendingChunks(universe, tick, flush)
|
||||
local area = universe.area
|
||||
local topOffset = area[1]
|
||||
local bottomOffset = area[2]
|
||||
|
||||
local eventId = map.chunkProcessorIterator
|
||||
local pendingChunks = universe.pendingChunks
|
||||
local eventId = universe.chunkProcessorIterator
|
||||
local event
|
||||
|
||||
if not eventId then
|
||||
eventId, event = next(pendingChunks, nil)
|
||||
else
|
||||
@ -78,17 +76,18 @@ function chunkProcessor.processPendingChunks(map, tick, flush)
|
||||
end
|
||||
for _=1,endCount do
|
||||
if not eventId then
|
||||
map.chunkProcessorIterator = nil
|
||||
universe.chunkProcessorIterator = nil
|
||||
if (table_size(pendingChunks) == 0) then
|
||||
-- this is needed as the next command remembers the max length a table has been
|
||||
map.pendingChunks = {}
|
||||
universe.pendingChunks = {}
|
||||
end
|
||||
break
|
||||
else
|
||||
if not flush and (event.tick > tick) then
|
||||
map.chunkProcessorIterator = eventId
|
||||
universe.chunkProcessorIterator = eventId
|
||||
return
|
||||
end
|
||||
local map = event.map
|
||||
local topLeft = event.area.left_top
|
||||
local x = topLeft.x
|
||||
local y = topLeft.y
|
||||
@ -106,23 +105,23 @@ function chunkProcessor.processPendingChunks(map, tick, flush)
|
||||
local oldChunk = map[x][y]
|
||||
local chunk = initialScan(oldChunk, map, tick)
|
||||
if (chunk == -1) then
|
||||
removeProcessQueueChunk(processQueue, oldChunk)
|
||||
map.chunkIdToChunk[oldChunk.id] = nil
|
||||
removeProcessQueueChunk(map.processQueue, oldChunk)
|
||||
universe.chunkIdToChunk[oldChunk.id] = nil
|
||||
map[x][y] = nil
|
||||
end
|
||||
else
|
||||
local initialChunk = createChunk(map, x, y)
|
||||
map[x][y] = initialChunk
|
||||
map.chunkIdToChunk[initialChunk.id] = initialChunk
|
||||
universe.chunkIdToChunk[initialChunk.id] = initialChunk
|
||||
local chunk = initialScan(initialChunk, map, tick)
|
||||
if (chunk ~= -1) then
|
||||
tInsert(
|
||||
processQueue,
|
||||
findInsertionPoint(processQueue, chunk),
|
||||
map.processQueue,
|
||||
findInsertionPoint(map.processQueue, chunk),
|
||||
chunk
|
||||
)
|
||||
else
|
||||
map.chunkIdToChunk[initialChunk.id] = nil
|
||||
universe.chunkIdToChunk[initialChunk.id] = nil
|
||||
map[x][y] = nil
|
||||
end
|
||||
end
|
||||
@ -133,7 +132,7 @@ function chunkProcessor.processPendingChunks(map, tick, flush)
|
||||
event = newEvent
|
||||
end
|
||||
end
|
||||
map.chunkProcessorIterator = eventId
|
||||
universe.chunkProcessorIterator = eventId
|
||||
end
|
||||
|
||||
function chunkProcessor.processPendingUpgrades(universe, tick)
|
||||
@ -207,7 +206,7 @@ function chunkProcessor.processScanChunks(map)
|
||||
if (chunkPassScan(chunk, map) == -1) then
|
||||
removeProcessQueueChunk(map.processQueue, chunk)
|
||||
map[chunk.x][chunk.y] = nil
|
||||
map.chunkIdToChunk[chunk.id] = nil
|
||||
map.universe.chunkIdToChunk[chunk.id] = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -44,7 +44,7 @@ function mapUtils.getChunkByPosition(map, position)
|
||||
end
|
||||
|
||||
function mapUtils.getChunkById(map, chunkId)
|
||||
return map.chunkIdToChunk[chunkId] or -1
|
||||
return map.universe.chunkIdToChunk[chunkId] or -1
|
||||
end
|
||||
|
||||
function mapUtils.positionToChunkXY(position)
|
||||
@ -59,9 +59,10 @@ function mapUtils.queueGeneratedChunk(universe, event)
|
||||
return
|
||||
end
|
||||
event.tick = (event.tick or game.tick) + 20
|
||||
event.id = map.eventId
|
||||
map.pendingChunks[event.id] = event
|
||||
map.eventId = map.eventId + 1
|
||||
event.id = universe.eventId
|
||||
event.map = map
|
||||
universe.pendingChunks[event.id] = event
|
||||
universe.eventId = universe.eventId + 1
|
||||
end
|
||||
|
||||
--[[
|
||||
|
Loading…
Reference in New Issue
Block a user