mirror of
https://github.com/veden/Rampant.git
synced 2025-01-28 03:29:34 +02:00
cleanup map is now processes all events regardless of active map
This commit is contained in:
parent
fa996bf96b
commit
1a60d01243
@ -464,6 +464,10 @@ function upgrade.attempt(universe)
|
||||
universe.chunkToActiveNest = {}
|
||||
universe.chunkToActiveRaidNest = {}
|
||||
universe.chunkToDrained = {}
|
||||
universe.chunkToRetreatIterator = nil
|
||||
universe.chunkToRetreats = {}
|
||||
universe.chunkToRallyIterator = nil
|
||||
universe.chunkToRallys = {}
|
||||
|
||||
game.print("Rampant - Version 2.0.0")
|
||||
end
|
||||
@ -504,7 +508,6 @@ function upgrade.prepMap(universe, surface)
|
||||
map.processedChunks = 0
|
||||
map.processQueue = {}
|
||||
map.processIndex = 1
|
||||
map.cleanupIndex = 1
|
||||
map.scanPlayerIndex = 1
|
||||
map.scanResourceIndex = 1
|
||||
map.scanEnemyIndex = 1
|
||||
@ -531,9 +534,6 @@ function upgrade.prepMap(universe, surface)
|
||||
map.chunkToPassScan = {}
|
||||
map.chunkToSquad = {}
|
||||
|
||||
map.chunkToRetreats = {}
|
||||
map.chunkToRallys = {}
|
||||
|
||||
map.chunkToPassable = {}
|
||||
map.chunkToPathRating = {}
|
||||
map.chunkToDeathGenerator = {}
|
||||
|
@ -29,6 +29,7 @@ Date: 23. 11. 2021
|
||||
- Spawners not covered by pollution are now processed regardless of current active map
|
||||
- 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
|
||||
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
|
||||
|
@ -930,8 +930,8 @@ script.on_event(defines.events.on_tick,
|
||||
if universe.NEW_ENEMIES then
|
||||
recycleBases(map)
|
||||
end
|
||||
cleanUpMapTables(map, tick)
|
||||
end
|
||||
cleanUpMapTables(universe, tick)
|
||||
elseif (pick == 1) then
|
||||
processPlayers(gameRef.connected_players, universe, tick)
|
||||
elseif (pick == 2) then
|
||||
|
@ -255,19 +255,45 @@ function chunkPropertyUtils.setDrainedTick(map, chunk, tick)
|
||||
end
|
||||
|
||||
function chunkPropertyUtils.getRetreatTick(map, chunk)
|
||||
return map.chunkToRetreats[chunk.id] or 0
|
||||
local pack = map.universe.chunkToRetreats[chunk.id]
|
||||
if not pack then
|
||||
return 0
|
||||
end
|
||||
return pack.tick
|
||||
end
|
||||
|
||||
function chunkPropertyUtils.getRallyTick(map, chunk)
|
||||
return map.chunkToRallys[chunk.id] or 0
|
||||
local pack = map.universe.chunkToRallys[chunk.id]
|
||||
if not pack then
|
||||
return 0
|
||||
end
|
||||
return pack.tick
|
||||
end
|
||||
|
||||
function chunkPropertyUtils.setRallyTick(map, chunk, tick)
|
||||
map.chunkToRallys[chunk.id] = tick
|
||||
local chunkId = chunk.id
|
||||
local pack = map.universe.chunkToRallys[chunkId]
|
||||
if not pack then
|
||||
pack = {
|
||||
map = map,
|
||||
tick = tick
|
||||
}
|
||||
map.universe.chunkToRallys[chunkId] = pack
|
||||
end
|
||||
pack.tick = tick
|
||||
end
|
||||
|
||||
function chunkPropertyUtils.setRetreatTick(map, chunk, tick)
|
||||
map.chunkToRetreats[chunk.id] = tick
|
||||
local chunkId = chunk.id
|
||||
local pack = map.universe.chunkToRetreats[chunkId]
|
||||
if not pack then
|
||||
pack = {
|
||||
map = map,
|
||||
tick = tick
|
||||
}
|
||||
map.universe.chunkToRetreats[chunkId] = pack
|
||||
end
|
||||
pack.tick = tick
|
||||
end
|
||||
|
||||
function chunkPropertyUtils.setResourceGenerator(map, chunk, resourceGenerator)
|
||||
|
@ -284,43 +284,18 @@ local function processCleanUp(universe, chunks, iterator, tick, duration)
|
||||
end
|
||||
end
|
||||
|
||||
function mapProcessor.cleanUpMapTables(map, tick)
|
||||
local index = map.cleanupIndex
|
||||
function mapProcessor.cleanUpMapTables(universe, tick)
|
||||
local retreats = universe.chunkToRetreats
|
||||
local rallys = universe.chunkToRallys
|
||||
local drained = universe.chunkToDrained
|
||||
|
||||
local universe = map.universe
|
||||
local retreats = map.chunkToRetreats
|
||||
local rallys = map.chunkToRallys
|
||||
local drained = map.universe.chunkToDrained
|
||||
local processQueue = map.processQueue
|
||||
local processQueueLength = #processQueue
|
||||
for _=1,CLEANUP_QUEUE_SIZE do
|
||||
processCleanUp(universe, retreats, "chunkToRetreatIterator", tick, COOLDOWN_RETREAT)
|
||||
|
||||
local endIndex = mMin(index + CLEANUP_QUEUE_SIZE, processQueueLength)
|
||||
|
||||
if (processQueueLength == 0) then
|
||||
return
|
||||
end
|
||||
|
||||
for x=index,endIndex do
|
||||
local chunk = processQueue[x]
|
||||
|
||||
local retreatTick = retreats[chunk]
|
||||
if retreatTick and ((tick - retreatTick) > COOLDOWN_RETREAT) then
|
||||
retreats[chunk] = nil
|
||||
end
|
||||
|
||||
local rallyTick = rallys[chunk]
|
||||
if rallyTick and ((tick - rallyTick) > COOLDOWN_RALLY) then
|
||||
rallys[chunk] = nil
|
||||
end
|
||||
processCleanUp(universe, rallys, "chunkToRallyIterator", tick, COOLDOWN_RALLY)
|
||||
|
||||
processCleanUp(universe, drained, "chunkToDrainedIterator", tick, COOLDOWN_DRAIN)
|
||||
end
|
||||
|
||||
if (endIndex == processQueueLength) then
|
||||
map.cleanupIndex = 1
|
||||
else
|
||||
map.cleanupIndex = endIndex + 1
|
||||
end
|
||||
end
|
||||
|
||||
--[[
|
||||
|
Loading…
x
Reference in New Issue
Block a user