mirror of
https://github.com/veden/Rampant.git
synced 2025-01-28 03:29:34 +02:00
optimized processing spawners covered by pollution
This commit is contained in:
parent
2f87808593
commit
d1eeee025f
@ -427,6 +427,7 @@ function upgrade.attempt(universe)
|
||||
universe.groupNumberToSquad = {}
|
||||
universe.pendingUpgrades = {}
|
||||
universe.processActiveNest = {}
|
||||
universe.processActiveNestIterator = nil
|
||||
universe.deployVengenceIterator = nil
|
||||
universe.pendingUpgradeIterator = nil
|
||||
universe.squadIterator = nil
|
||||
@ -499,7 +500,6 @@ function upgrade.prepMap(universe, surface)
|
||||
map.chunkToResource = {}
|
||||
map.chunkToPlayerCount = {}
|
||||
map.playerToChunk = {}
|
||||
map.pendingChunks = {}
|
||||
|
||||
map.chunkToPassScan = {}
|
||||
map.chunkToSquad = {}
|
||||
@ -527,7 +527,6 @@ function upgrade.prepMap(universe, surface)
|
||||
map.chunkScanCounts = {}
|
||||
|
||||
map.chunkRemovals = {}
|
||||
map.tickActiveNest = {}
|
||||
|
||||
map.emptySquadsOnChunk = {}
|
||||
|
||||
|
@ -19,6 +19,7 @@ Date: 23. 11. 2021
|
||||
- Added max number of move commands that touch the same chunk to squads before disbanding or settling based on if migration is enabled
|
||||
- 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
|
||||
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
|
||||
|
@ -241,18 +241,6 @@ function chunkPropertyUtils.setRaidNestActiveness(map, chunk, value)
|
||||
end
|
||||
end
|
||||
|
||||
function chunkPropertyUtils.getNestActiveTick(map, chunk)
|
||||
return map.tickActiveNest[chunk.id] or 0
|
||||
end
|
||||
|
||||
function chunkPropertyUtils.setNestActiveTick(map, chunk, tick)
|
||||
if (tick == 0) then
|
||||
map.tickActiveNest[chunk.id] = nil
|
||||
else
|
||||
map.tickActiveNest[chunk.id] = tick
|
||||
end
|
||||
end
|
||||
|
||||
function chunkPropertyUtils.getNestActiveness(map, chunk)
|
||||
return map.chunkToActiveNest[chunk.id] or 0
|
||||
end
|
||||
|
@ -69,8 +69,6 @@ constants.PLAYER_PHEROMONE_MULTIPLER = 100
|
||||
|
||||
constants.DURATION_ACTIVE_NEST = 60 * constants.TICKS_A_SECOND
|
||||
|
||||
constants.DURATION_ACTIVE_NEST_DIVIDER = 1 / constants.DURATION_ACTIVE_NEST
|
||||
|
||||
-- chunk properties
|
||||
|
||||
constants.CHUNK_SIZE = 32
|
||||
|
@ -17,7 +17,6 @@ local baseUtils = require("BaseUtils")
|
||||
|
||||
-- constants
|
||||
|
||||
local DURATION_ACTIVE_NEST_DIVIDER = constants.DURATION_ACTIVE_NEST_DIVIDER
|
||||
local DURATION_ACTIVE_NEST = constants.DURATION_ACTIVE_NEST
|
||||
|
||||
local PROCESS_QUEUE_SIZE = constants.PROCESS_QUEUE_SIZE
|
||||
@ -76,8 +75,6 @@ local mapScanResourceChunk = chunkUtils.mapScanResourceChunk
|
||||
local getNestCount = chunkPropertyUtils.getNestCount
|
||||
local getEnemyStructureCount = chunkPropertyUtils.getEnemyStructureCount
|
||||
local getNestActiveness = chunkPropertyUtils.getNestActiveness
|
||||
local getNestActiveTick = chunkPropertyUtils.getNestActiveTick
|
||||
local setNestActiveTick = chunkPropertyUtils.setNestActiveTick
|
||||
|
||||
local getRaidNestActiveness = chunkPropertyUtils.getRaidNestActiveness
|
||||
|
||||
@ -179,52 +176,15 @@ function mapProcessor.processStaticMap(map)
|
||||
end
|
||||
|
||||
local function queueNestSpawners(map, chunk, tick)
|
||||
local limitPerActiveChunkTick =
|
||||
(map.activeNests + map.activeRaidNests) * DURATION_ACTIVE_NEST_DIVIDER
|
||||
|
||||
local processActiveNest = map.universe.processActiveNest
|
||||
|
||||
if ((getNestActiveness(map, chunk) > 0) or (getRaidNestActiveness(map, chunk) > 0)) and
|
||||
(getNestActiveTick(map, chunk) == 0)
|
||||
then
|
||||
local nextTick = tick + DURATION_ACTIVE_NEST
|
||||
local slot = processActiveNest[nextTick]
|
||||
if not slot then
|
||||
slot = {}
|
||||
processActiveNest[nextTick] = slot
|
||||
slot[#slot+1] = {
|
||||
chunk = chunk,
|
||||
map = map
|
||||
}
|
||||
else
|
||||
if (#slot > limitPerActiveChunkTick) then
|
||||
while (#slot > limitPerActiveChunkTick) do
|
||||
nextTick = nextTick + 1
|
||||
slot = processActiveNest[nextTick]
|
||||
if not slot then
|
||||
slot = {}
|
||||
processActiveNest[nextTick] = slot
|
||||
slot[#slot+1] = {
|
||||
chunk = chunk,
|
||||
map = map
|
||||
}
|
||||
break
|
||||
elseif (#slot < limitPerActiveChunkTick) then
|
||||
slot[#slot+1] = {
|
||||
chunk = chunk,
|
||||
map = map
|
||||
}
|
||||
break
|
||||
end
|
||||
end
|
||||
else
|
||||
slot[#slot+1] = {
|
||||
chunk = chunk,
|
||||
map = map
|
||||
}
|
||||
end
|
||||
end
|
||||
setNestActiveTick(map, chunk, tick)
|
||||
local chunkId = chunk.id
|
||||
if not processActiveNest[chunkId] then
|
||||
processActiveNest[chunkId] = {
|
||||
map = map,
|
||||
chunk = chunk,
|
||||
tick = tick + DURATION_ACTIVE_NEST
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
@ -452,26 +412,25 @@ end
|
||||
|
||||
function mapProcessor.processActiveNests(universe, tick)
|
||||
local processActiveNest = universe.processActiveNest
|
||||
local slot = processActiveNest[tick]
|
||||
if slot then
|
||||
for i=1,#slot do
|
||||
local chunkPack = slot[i]
|
||||
local chunk = chunkPack.chunk
|
||||
local chunkId = universe.processActiveNestIterator
|
||||
local chunkPack
|
||||
if not chunkId then
|
||||
chunkId, chunkPack = next(processActiveNest, nil)
|
||||
else
|
||||
chunkPack = processActiveNest[chunkId]
|
||||
end
|
||||
if not chunkId then
|
||||
universe.processActiveNestIterator = nil
|
||||
else
|
||||
universe.processActiveNestIterator = next(processActiveNest, chunkId)
|
||||
if chunkPack.tick < tick then
|
||||
local map = chunkPack.map
|
||||
if (getNestActiveness(map, chunk) > 0) or (getRaidNestActiveness(map, chunk) > 0) then
|
||||
processNestActiveness(map, chunk)
|
||||
local nextTick = tick + DURATION_ACTIVE_NEST
|
||||
local nextSlot = processActiveNest[nextTick]
|
||||
if not nextSlot then
|
||||
nextSlot = {}
|
||||
processActiveNest[nextTick] = nextSlot
|
||||
end
|
||||
nextSlot[#nextSlot+1] = chunk
|
||||
else
|
||||
setNestActiveTick(map, chunk, 0)
|
||||
local chunk = chunkPack.chunk
|
||||
processNestActiveness(map, chunk)
|
||||
if (getNestActiveness(map, chunk) == 0) and (getRaidNestActiveness(map, chunk) == 0) then
|
||||
processActiveNest[chunkId] = nil
|
||||
end
|
||||
end
|
||||
processActiveNest[tick] = nil
|
||||
end
|
||||
end
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user