1
0
mirror of https://github.com/veden/Rampant.git synced 2025-03-17 20:58:35 +02:00

chunk passing scanning happens regardless of active map

This commit is contained in:
Aaron Veden 2021-12-09 22:38:50 -08:00
parent e9681f1644
commit 76dbc8363e
No known key found for this signature in database
GPG Key ID: FF5990B1C6DD3F84
5 changed files with 31 additions and 19 deletions

View File

@ -468,6 +468,8 @@ function upgrade.attempt(universe)
universe.chunkToRetreats = {}
universe.chunkToRallyIterator = nil
universe.chunkToRallys = {}
universe.chunkToPassScan = {}
universe.chunkToPassScanIterator = nil
game.print("Rampant - Version 2.0.0")
end
@ -531,14 +533,12 @@ function upgrade.prepMap(universe, surface)
map.chunkToPlayerCount = {}
map.playerToChunk = {}
map.chunkToPassScan = {}
map.chunkToSquad = {}
map.chunkToPassable = {}
map.chunkToPathRating = {}
map.chunkToDeathGenerator = {}
map.chunkToPassScanIterator = nil
map.recycleBaseIterator = nil
map.chunkScanCounts = {}

View File

@ -31,6 +31,7 @@ Date: 23. 11. 2021
- Attack waves are processed regardless of current active map
- Surfaces are allocated but don't begin processing until the first enemy structure or unit group is found
- Map cleanup is now processed regardless of current active map
- Chunk pass scanning is now processed regardless of current active map
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

View File

@ -538,7 +538,12 @@ local function processSurfaceTile(map, position, chunks, tick)
local chunk = getChunkByPosition(map, position)
if (chunk ~= -1) then
map.chunkToPassScan[chunk.id] = chunk
if not map.universe.chunkToPassScan[chunk.id] then
map.universe.chunkToPassScan[chunk.id] = {
map=map,
chunk=chunk
}
end
else
local x,y = positionToChunkXY(position)
local addMe = true
@ -961,9 +966,7 @@ script.on_event(defines.events.on_tick,
processNests(universe, tick)
elseif (pick == 7) then
processPendingChunks(universe, tick)
if map then
processScanChunks(map)
end
processScanChunks(universe)
end
processActiveNests(universe, tick)

View File

@ -178,26 +178,31 @@ function chunkProcessor.processPendingUpgrades(universe, tick)
end
function chunkProcessor.processScanChunks(map)
local chunkId = map.chunkToPassScanIterator
local chunk
function chunkProcessor.processScanChunks(universe)
local chunkId = universe.chunkToPassScanIterator
local chunkPack
if not chunkId then
chunkId, chunk = next(map.chunkToPassScan, nil)
chunkId, chunkPack = next(universe.chunkToPassScan, nil)
else
chunk = map.chunkToPassScan[chunkId]
chunkPack = universe.chunkToPassScan[chunkId]
end
if not chunkId then
map.chunkToPassScanIterator = nil
if (table_size(map.chunkToPassScan) == 0) then
universe.chunkToPassScanIterator = nil
if (table_size(universe.chunkToPassScan) == 0) then
-- this is needed as the next command remembers the max length a table has been
map.chunkToPassScan = {}
universe.chunkToPassScan = {}
end
else
map.chunkToPassScanIterator = next(map.chunkToPassScan, chunkId)
map.chunkToPassScan[chunkId] = nil
universe.chunkToPassScanIterator = next(universe.chunkToPassScan, chunkId)
universe.chunkToPassScan[chunkId] = nil
local map = chunkPack.map
if not map.surface.valid then
return
end
local chunk = chunkPack.chunk
local area = map.universe.area
local area = universe.area
local topOffset = area[1]
local bottomOffset = area[2]
topOffset[1] = chunk.x

View File

@ -350,8 +350,11 @@ function chunkUtils.entityForPassScan(map, entity)
for i=1,#overlapArray do
local chunk = overlapArray[i]
if (chunk ~= -1) then
map.chunkToPassScan[chunk.id] = chunk
if (chunk ~= -1) and not map.universe.chunkToPassScan[chunk.id] then
map.universe.chunkToPassScan[chunk.id] = {
map = map,
chunk = chunk
}
end
end
end