1
0
mirror of https://github.com/veden/Rampant.git synced 2024-12-26 20:54:12 +02:00

FACTO-257: Removed unneeded iterators

This commit is contained in:
Aaron Veden 2023-03-11 18:14:42 -08:00
parent 1b2d7da3ea
commit a7cdf98ce2
No known key found for this signature in database
GPG Key ID: FF5990B1C6DD3F84
9 changed files with 193 additions and 347 deletions

View File

@ -61,6 +61,7 @@ Version: 3.2.0
- Centralized base points manipulation and chat messaging (Dagothur) - Centralized base points manipulation and chat messaging (Dagothur)
- Base point deductions for unit losses are now batched in 20 to reduce chat spam when using the print AI points to chat options (Dagothur) - Base point deductions for unit losses are now batched in 20 to reduce chat spam when using the print AI points to chat options (Dagothur)
- Reduced corpse and particle variation to optimize increased entity times due to high entity counts - Reduced corpse and particle variation to optimize increased entity times due to high entity counts
- Removed unneeded iterators
- Moved map properties directly into chunk object - Moved map properties directly into chunk object
--------------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------------

View File

@ -576,12 +576,7 @@ local function processSurfaceTile(map, position, chunks, tick)
local chunk = getChunkByPosition(map, position) local chunk = getChunkByPosition(map, position)
if (chunk ~= -1) then if (chunk ~= -1) then
if not map.Universe.chunkToPassScan[chunk.id] then Universe.chunkToPassScan[chunk.id] = chunk
map.Universe.chunkToPassScan[chunk.id] = {
map=map,
chunk=chunk
}
end
else else
local x,y = positionToChunkXY(position) local x,y = positionToChunkXY(position)
local addMe = true local addMe = true
@ -1015,11 +1010,9 @@ local function onBuilderArrived(event)
game.print(map.surface.name.." Settled: [gps=" .. builder.position.x .. "," .. builder.position.y .."]") game.print(map.surface.name.." Settled: [gps=" .. builder.position.x .. "," .. builder.position.y .."]")
end end
if Universe.enabledPurpleSettlerCloud then if Universe.enabledPurpleSettlerCloud then
local len = Universe.settlePurpleCloud.len + 1 Universe.eventId = Universe.eventId + 1
Universe.settlePurpleCloud.len = len Universe.settlePurpleCloud[Universe.eventId] = {
Universe.settlePurpleCloud[len] = {
map = map, map = map,
position = builder.position,
group = builder, group = builder,
tick = event.tick + SETTLE_CLOUD_WARMUP tick = event.tick + SETTLE_CLOUD_WARMUP
} }

View File

@ -193,16 +193,7 @@ function aiAttackWave.rallyUnits(chunk, tick, base)
if (x ~= cX) and (y ~= cY) then if (x ~= cX) and (y ~= cY) then
local rallyChunk = getChunkByXY(map, x, y) local rallyChunk = getChunkByXY(map, x, y)
if (rallyChunk ~= -1) and rallyChunk.nestCount then if (rallyChunk ~= -1) and rallyChunk.nestCount then
local pack = vengenceQueue[rallyChunk.id] vengenceQueue[rallyChunk.id] = rallyChunk
if not pack then
pack = {
v = 0,
map = map,
base = base
}
vengenceQueue[rallyChunk.id] = pack
end
pack.v = pack.v + 1
end end
end end
end end

View File

@ -65,198 +65,171 @@ local tInsert = table.insert
function ChunkProcessor.processPendingChunks(tick, flush) function ChunkProcessor.processPendingChunks(tick, flush)
local pendingChunks = Universe.pendingChunks local pendingChunks = Universe.pendingChunks
local eventId = Universe.chunkProcessorIterator local eventId, event = next(pendingChunks, nil)
local event
if not eventId then if not eventId then
eventId, event = next(pendingChunks, nil) if (tableSize(pendingChunks) == 0) then
else -- this is needed as the next command remembers the max length a table has been
event = pendingChunks[eventId] Universe.pendingChunks = {}
end
return
end end
local endCount = 1 local endCount = 1
if flush then if flush then
endCount = table_size(pendingChunks) endCount = tableSize(pendingChunks)
eventId, event = next(pendingChunks, nil)
end end
for _=1,endCount do for _=1,endCount do
if not eventId then if not flush and (event.tick > tick) then
Universe.chunkProcessorIterator = nil return
if (table_size(pendingChunks) == 0) then end
-- this is needed as the next command remembers the max length a table has been local newEventId, newEvent = next(pendingChunks, eventId)
Universe.pendingChunks = {} pendingChunks[eventId] = nil
local map = event.map
if not map.surface.valid then
return
end
local topLeft = event.area.left_top
local x = topLeft.x
local y = topLeft.y
if not map[x] then
map[x] = {}
end
if map[x][y] then
local oldChunk = map[x][y]
local chunk = initialScan(oldChunk, map, tick)
if (chunk == -1) then
removeChunkFromMap(map, oldChunk)
end end
break
else else
if not flush and (event.tick > tick) then local initialChunk = createChunk(map, x, y)
Universe.chunkProcessorIterator = eventId map[x][y] = initialChunk
return Universe.chunkIdToChunk[initialChunk.id] = initialChunk
end local chunk = initialScan(initialChunk, map, tick)
local newEventId, newEvent = next(pendingChunks, eventId) if (chunk ~= -1) then
pendingChunks[eventId] = nil tInsert(
local map = event.map map.processQueue,
if not map.surface.valid then findInsertionPoint(map.processQueue, chunk),
Universe.chunkProcessorIterator = newEventId chunk
return )
end
local topLeft = event.area.left_top
local x = topLeft.x
local y = topLeft.y
if not map[x] then
map[x] = {}
end
if map[x][y] then
local oldChunk = map[x][y]
local chunk = initialScan(oldChunk, map, tick)
if (chunk == -1) then
removeChunkFromMap(map, oldChunk)
end
else else
local initialChunk = createChunk(map, x, y) map[x][y] = nil
map[x][y] = initialChunk Universe.chunkIdToChunk[initialChunk.id] = nil
Universe.chunkIdToChunk[initialChunk.id] = initialChunk
local chunk = initialScan(initialChunk, map, tick)
if (chunk ~= -1) then
tInsert(
map.processQueue,
findInsertionPoint(map.processQueue, chunk),
chunk
)
else
map[x][y] = nil
Universe.chunkIdToChunk[initialChunk.id] = nil
end
end end
end
eventId = newEventId eventId = newEventId
event = newEvent event = newEvent
if not eventId then
return
end end
end end
Universe.chunkProcessorIterator = eventId
end end
function ChunkProcessor.processPendingUpgrades(tick) function ChunkProcessor.processPendingUpgrades(tick)
local entityId = Universe.pendingUpgradeIterator local entityId, entityData = next(Universe.pendingUpgrades, nil)
local entityData
if not entityId then if not entityId then
entityId, entityData = next(Universe.pendingUpgrades, nil) if tableSize(Universe.pendingUpgrades) == 0 then
else
entityData = Universe.pendingUpgrades[entityId]
end
if not entityId then
Universe.pendingUpgradeIterator = nil
if table_size(Universe.pendingUpgrades) == 0 then
Universe.pendingUpgrades = {} Universe.pendingUpgrades = {}
end end
else return
local entity = entityData.entity end
if entity.valid then local entity = entityData.entity
Universe.pendingUpgradeIterator = next(Universe.pendingUpgrades, entityId) if not entity.valid then
if entityData.delayTLL and tick < entityData.delayTLL then Universe.pendingUpgrades[entityId] = nil
return end
end if entityData.delayTLL and tick < entityData.delayTLL then
Universe.pendingUpgrades[entityId] = nil return
local base = entityData.base end
local map = base.map Universe.pendingUpgrades[entityId] = nil
local baseAlignment = base.alignment local base = entityData.base
local position = entityData.position or entity.position local map = base.map
local baseAlignment = base.alignment
local position = entityData.position or entity.position
local pickedBaseAlignment local pickedBaseAlignment
if baseAlignment[2] then if baseAlignment[2] then
if Universe.random() < 0.75 then if Universe.random() < 0.75 then
pickedBaseAlignment = baseAlignment[2] pickedBaseAlignment = baseAlignment[2]
else
pickedBaseAlignment = baseAlignment[1]
end
else
pickedBaseAlignment = baseAlignment[1]
end
local currentEvo = entity.prototype.build_base_evolution_requirement or 0
local distance = mMin(1, euclideanDistancePoints(position.x, position.y, 0, 0) * BASE_DISTANCE_TO_EVO_INDEX)
local evoIndex = mMax(distance, Universe.evolutionLevel)
local name = findEntityUpgrade(pickedBaseAlignment,
currentEvo,
evoIndex,
entity,
map,
entityData.evolve)
local entityName = entity.name
if not name and PROXY_ENTITY_LOOKUP[entityName] then
entity.destroy()
return
elseif (name == entityName) or not name then
return
end
local surface = entity.surface
local query = Universe.ppuUpgradeEntityQuery
query.name = name
unregisterEnemyBaseStructure(map, entity, nil, true)
entity.destroy()
local foundPosition = surface.find_non_colliding_position(BUILDING_SPACE_LOOKUP[name],
position,
2,
1,
true)
setPositionInQuery(query, foundPosition or position)
local createdEntity = surface.create_entity({
name = query.name,
position = query.position
})
if createdEntity and createdEntity.valid then
if entityData.register then
registerEnemyBaseStructure(map, createdEntity, base, tick, true)
end
if not entityData.evolve and Universe.printBaseUpgrades then
surface.print("["..base.id.."]:"..surface.name.." Upgrading ".. entityName .. " to " .. name .. " [gps=".. position.x ..",".. position.y .."]")
end
if remote.interfaces["kr-creep"] then
remote.call("kr-creep", "spawn_creep_at_position", surface, foundPosition or position, false, createdEntity.name)
end
end
else else
Universe.pendingUpgradeIterator = next(Universe.pendingUpgrades, entityId) pickedBaseAlignment = baseAlignment[1]
Universe.pendingUpgrades[entityId] = nil end
else
pickedBaseAlignment = baseAlignment[1]
end
local currentEvo = entity.prototype.build_base_evolution_requirement or 0
local distance = mMin(1, euclideanDistancePoints(position.x, position.y, 0, 0) * BASE_DISTANCE_TO_EVO_INDEX)
local evoIndex = mMax(distance, Universe.evolutionLevel)
local name = findEntityUpgrade(pickedBaseAlignment,
currentEvo,
evoIndex,
entity,
map,
entityData.evolve)
local entityName = entity.name
if not name and PROXY_ENTITY_LOOKUP[entityName] then
entity.destroy()
return
elseif (name == entityName) or not name then
return
end
local surface = entity.surface
local query = Universe.ppuUpgradeEntityQuery
query.name = name
unregisterEnemyBaseStructure(map, entity, nil, true)
entity.destroy()
local foundPosition = surface.find_non_colliding_position(BUILDING_SPACE_LOOKUP[name],
position,
2,
1,
true)
setPositionInQuery(query, foundPosition or position)
local createdEntity = surface.create_entity({
name = query.name,
position = query.position
})
if createdEntity and createdEntity.valid then
if entityData.register then
registerEnemyBaseStructure(map, createdEntity, base, tick, true)
end
if not entityData.evolve and Universe.printBaseUpgrades then
surface.print("["..base.id.."]:"..surface.name.." Upgrading ".. entityName .. " to " .. name .. " [gps=".. position.x ..",".. position.y .."]")
end
if remote.interfaces["kr-creep"] then
remote.call("kr-creep", "spawn_creep_at_position", surface, foundPosition or position, false, createdEntity.name)
end end
end end
end end
function ChunkProcessor.processScanChunks() function ChunkProcessor.processScanChunks()
local chunkId = Universe.chunkToPassScanIterator local chunkId, chunk = next(Universe.chunkToPassScan, nil)
local chunkPack
if not chunkId then if not chunkId then
chunkId, chunkPack = next(Universe.chunkToPassScan, nil) if (tableSize(Universe.chunkToPassScan) == 0) then
else
chunkPack = Universe.chunkToPassScan[chunkId]
end
if not chunkId 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 -- this is needed as the next command remembers the max length a table has been
Universe.chunkToPassScan = {} Universe.chunkToPassScan = {}
end end
else return
Universe.chunkToPassScanIterator = next(Universe.chunkToPassScan, chunkId) end
Universe.chunkToPassScan[chunkId] = nil
local map = chunkPack.map
if not map.surface.valid then
return
end
local chunk = chunkPack.chunk
if (chunkPassScan(chunk, map) == -1) then Universe.chunkToPassScan[chunkId] = nil
removeChunkFromMap(map, chunk) local map = chunk.map
end if not map.surface.valid then
return
end
if (chunkPassScan(chunk, map) == -1) then
removeChunkFromMap(map, chunk)
end end
end end

View File

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

View File

@ -207,16 +207,7 @@ function MapProcessor.processPlayers(players, tick)
processNestActiveness(chunk, tick) processNestActiveness(chunk, tick)
if vengence then if vengence then
local pack = Universe.vengenceQueue[chunk.id] Universe.vengenceQueue[chunk.id] = chunk
if not pack then
pack = {
v = 0,
map = map,
base = base
}
Universe.vengenceQueue[chunk.id] = pack
end
pack.v = pack.v + 1
end end
end end
end end
@ -228,21 +219,13 @@ function MapProcessor.processPlayers(players, tick)
end end
end end
local function processCleanUp(chunks, iterator, tick, duration) local function processCleanUp(chunks, tick, duration)
local chunkId = Universe[iterator] local chunkId, eventTick = next(chunks, nil)
local eventTick
if not chunkId then if not chunkId then
chunkId, eventTick = next(chunks, nil) return
else
eventTick = chunks[chunkId]
end end
if not chunkId then if (tick - eventTick) > duration then
Universe[iterator] = nil chunks[chunkId] = nil
else
Universe[iterator] = next(chunks, chunkId)
if (tick - eventTick) > duration then
chunks[chunkId] = nil
end
end end
end end
@ -252,11 +235,11 @@ function MapProcessor.cleanUpMapTables(tick)
local drained = Universe.chunkToDrained local drained = Universe.chunkToDrained
for _=1,CLEANUP_QUEUE_SIZE do for _=1,CLEANUP_QUEUE_SIZE do
processCleanUp(retreats, "chunkToRetreatIterator", tick, COOLDOWN_RETREAT) processCleanUp(retreats, tick, COOLDOWN_RETREAT)
processCleanUp(rallys, "chunkToRallyIterator", tick, COOLDOWN_RALLY) processCleanUp(rallys, tick, COOLDOWN_RALLY)
processCleanUp(drained, "chunkToDrainedIterator", tick, COOLDOWN_DRAIN) processCleanUp(drained, tick, COOLDOWN_DRAIN)
end end
end end
@ -292,10 +275,6 @@ function MapProcessor.scanPlayerMap(map, tick)
end end
function MapProcessor.scanEnemyMap(map, tick) function MapProcessor.scanEnemyMap(map, tick)
if (map.nextProcessMap == tick) or (map.nextPlayerScan == tick) or (map.nextChunkProcess == tick) then
return
end
local index = map.scanEnemyIndex local index = map.scanEnemyIndex
local processQueue = map.processQueue local processQueue = map.processQueue
@ -319,11 +298,6 @@ function MapProcessor.scanEnemyMap(map, tick)
end end
function MapProcessor.scanResourceMap(map, tick) function MapProcessor.scanResourceMap(map, tick)
if (map.nextProcessMap == tick) or (map.nextPlayerScan == tick) or
(map.nextEnemyScan == tick) or (map.nextChunkProcess == tick)
then
return
end
local index = map.scanResourceIndex local index = map.scanResourceIndex
local processQueue = map.processQueue local processQueue = map.processQueue
@ -348,32 +322,24 @@ end
function MapProcessor.processVengence() function MapProcessor.processVengence()
local vengenceQueue = Universe.vengenceQueue local vengenceQueue = Universe.vengenceQueue
local chunkId = Universe.deployVengenceIterator local chunkId, chunk = next(vengenceQueue, nil)
local vengencePack
if not chunkId then if not chunkId then
chunkId, vengencePack = next(vengenceQueue, nil)
else
vengencePack = vengenceQueue[chunkId]
end
if not chunkId then
Universe.deployVengenceIterator = nil
if (tableSize(vengenceQueue) == 0) then if (tableSize(vengenceQueue) == 0) then
Universe.vengenceQueue = {} Universe.vengenceQueue = {}
end end
return
end
vengenceQueue[chunkId] = nil
local map = chunk.map
if not map.surface.valid then
return
end
local base = chunk.base
if canMigrate(map, base) and (Universe.random() < 0.075) then
formVengenceSettler(chunk, base)
else else
Universe.deployVengenceIterator = next(vengenceQueue, chunkId) formVengenceSquad(chunk, base)
vengenceQueue[chunkId] = nil
local map = vengencePack.map
if not map.surface.valid then
return
end
local chunk = getChunkById(chunkId)
local base = vengencePack.base
if canMigrate(map, base) and (Universe.random() < 0.075) then
formVengenceSettler(map, chunk, base)
else
formVengenceSquad(map, chunk, base)
end
end end
end end
@ -448,10 +414,10 @@ local function processSpawnersBody(iterator, chunks)
local migrate = canMigrate(map, base) local migrate = canMigrate(map, base)
local attack = canAttack(map, base) local attack = canAttack(map, base)
if migrate then if migrate then
formSettlers(map, chunk, base) formSettlers(chunk, base)
end end
if attack then if attack then
formSquads(map, chunk, base) formSquads(chunk, base)
end end
end end
end end
@ -466,16 +432,14 @@ function MapProcessor.processAttackWaves()
end end
function MapProcessor.processClouds(tick) function MapProcessor.processClouds(tick)
local len = Universe.settlePurpleCloud.len local eventId, builderPack = next(Universe.settlePurpleCloud, nil)
local builderPack = Universe.settlePurpleCloud[len]
if builderPack and (builderPack.tick <= tick) then if builderPack and (builderPack.tick <= tick) then
Universe.settlePurpleCloud[len] = nil Universe.settlePurpleCloud[eventId] = nil
Universe.settlePurpleCloud.len = len - 1
local map = builderPack.map local map = builderPack.map
if builderPack.group.valid and map.surface.valid then if builderPack.group.valid and map.surface.valid then
setPositionInQuery( setPositionInQuery(
Universe.obaCreateBuildCloudQuery, Universe.obaCreateBuildCloudQuery,
builderPack.position builderPack.group.position
) )
map.surface.create_entity(Universe.obaCreateBuildCloudQuery) map.surface.create_entity(Universe.obaCreateBuildCloudQuery)
end end

View File

@ -82,10 +82,10 @@ function MapUtils.queueGeneratedChunk(event)
return return
end end
event.tick = (event.tick or game.tick) + 20 event.tick = (event.tick or game.tick) + 20
Universe.eventId = Universe.eventId + 1
event.id = Universe.eventId event.id = Universe.eventId
event.map = map event.map = map
Universe.pendingChunks[event.id] = event Universe.pendingChunks[event.id] = event
Universe.eventId = Universe.eventId + 1
end end
function MapUtils.nextMap() function MapUtils.nextMap()
@ -155,6 +155,9 @@ function MapUtils.removeChunkFromMap(map, chunk)
Universe.chunkToRallys[chunkId] = nil Universe.chunkToRallys[chunkId] = nil
Universe.chunkToPassScan[chunkId] = nil Universe.chunkToPassScan[chunkId] = nil
Universe.chunkToNests[chunkId] = nil Universe.chunkToNests[chunkId] = nil
Universe.chunkToTurrets[chunkId] = nil
Universe.chunkToUtilities[chunkId] = nil
Universe.chunkToHives[chunkId] = nil
Universe.vengenceQueue[chunkId] = nil Universe.vengenceQueue[chunkId] = nil
Universe.processActiveNest[chunkId] = nil Universe.processActiveNest[chunkId] = nil
Universe.chunkToVictory[chunkId] = nil Universe.chunkToVictory[chunkId] = nil
@ -163,44 +166,13 @@ function MapUtils.removeChunkFromMap(map, chunk)
base.chunkCount = base.chunkCount - 1 base.chunkCount = base.chunkCount - 1
map.chunkToBase[chunkId] = nil map.chunkToBase[chunkId] = nil
end end
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 if Universe.processActiveNestIterator == chunkId then
Universe.processActiveNestIterator = nil Universe.processActiveNestIterator = nil
end end
if Universe.victoryScentIterator == chunkId then
Universe.victoryScentIterator = nil
end
if Universe.processNestIterator == chunkId then if Universe.processNestIterator == chunkId then
Universe.processNestIterator = nil Universe.processNestIterator = nil
end 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 if Universe.processActiveSpawnerIterator == chunkId then
Universe.processActiveSpawnerIterator = nil Universe.processActiveSpawnerIterator = nil
end end
@ -210,9 +182,6 @@ function MapUtils.removeChunkFromMap(map, chunk)
if Universe.processMigrationIterator == chunkId then if Universe.processMigrationIterator == chunkId then
Universe.processMigrationIterator = nil Universe.processMigrationIterator = nil
end end
if Universe.deployVengenceIterator == chunkId then
Universe.deployVengenceIterator = nil
end
end end
--[[ --[[

View File

@ -78,50 +78,43 @@ local mMax = math.max
-- module code -- module code
function PheromoneUtils.victoryScent(map, chunk, entityType) function PheromoneUtils.victoryScent(chunk, entityType)
local value = VICTORY_SCENT[entityType] local value = VICTORY_SCENT[entityType]
if value then if value then
addVictoryGenerator(map, chunk, value) addVictoryGenerator(chunk, value)
end end
end end
function PheromoneUtils.disperseVictoryScent() function PheromoneUtils.disperseVictoryScent()
local chunkId = Universe.victoryScentIterator
local chunkToVictory = Universe.chunkToVictory local chunkToVictory = Universe.chunkToVictory
local pheromonePack local chunkId, pheromonePack = next(chunkToVictory, nil)
if not chunkId then if not chunkId then
chunkId, pheromonePack = next(chunkToVictory, nil) return
else
pheromonePack = chunkToVictory[chunkId]
end end
if not chunkId then
Universe.victoryScentIterator = nil chunkToVictory[chunkId] = nil
else local chunk = pheromonePack.chunk
Universe.victoryScentIterator = next(chunkToVictory, chunkId) local map = chunk.map
chunkToVictory[chunkId] = nil if not map.surface.valid then
local map = pheromonePack.map return
if not map.surface.valid then end
return local chunkX = chunk.x
end local chunkY = chunk.y
local chunk = getChunkById(chunkId) local i = 1
local chunkX = chunk.x for x=chunkX - VICTORY_SCENT_BOUND, chunkX + VICTORY_SCENT_BOUND,32 do
local chunkY = chunk.y for y = chunkY - VICTORY_SCENT_BOUND, chunkY + VICTORY_SCENT_BOUND,32 do
local i = 1 local c = getChunkByXY(map, x, y)
for x=chunkX - VICTORY_SCENT_BOUND, chunkX + VICTORY_SCENT_BOUND,32 do if (c ~= -1) then
for y = chunkY - VICTORY_SCENT_BOUND, chunkY + VICTORY_SCENT_BOUND,32 do local amount = pheromonePack.v * VICTORY_SCENT_MULTIPLER[i]
local c = getChunkByXY(map, x, y) addDeathGenerator(c, amount)
if (c ~= -1) then addPermanentDeathGenerator(c, amount)
local amount = pheromonePack.v * VICTORY_SCENT_MULTIPLER[i]
addDeathGenerator(c, amount)
addPermanentDeathGenerator(c, amount)
end
i = i + 1
end end
i = i + 1
end end
end end
end end
function PheromoneUtils.deathScent(map, chunk, structure) function PheromoneUtils.deathScent(chunk, structure)
local amount = -DEATH_PHEROMONE_GENERATOR_AMOUNT local amount = -DEATH_PHEROMONE_GENERATOR_AMOUNT
if structure then if structure then
amount = -TEN_DEATH_PHEROMONE_GENERATOR_AMOUNT amount = -TEN_DEATH_PHEROMONE_GENERATOR_AMOUNT

View File

@ -518,9 +518,6 @@ function Upgrade.addUniverseProperties()
Universe.pendingChunks = {} Universe.pendingChunks = {}
Universe.processActiveNest = {} Universe.processActiveNest = {}
Universe.processActiveNestIterator = nil Universe.processActiveNestIterator = nil
Universe.deployVengenceIterator = nil
Universe.pendingUpgradeIterator = nil
Universe.victoryScentIterator = nil
Universe.squadIterator = nil Universe.squadIterator = nil
Universe.processMapAIIterator = nil Universe.processMapAIIterator = nil
Universe.processNestIterator = nil Universe.processNestIterator = nil
@ -535,16 +532,12 @@ function Upgrade.addUniverseProperties()
Universe.processActiveSpawnerIterator = nil Universe.processActiveSpawnerIterator = nil
Universe.processActiveRaidSpawnerIterator = nil Universe.processActiveRaidSpawnerIterator = nil
Universe.processMigrationIterator = nil Universe.processMigrationIterator = nil
Universe.chunkToDrainedIterator = nil
Universe.chunkToActiveNest = {} Universe.chunkToActiveNest = {}
Universe.chunkToActiveRaidNest = {} Universe.chunkToActiveRaidNest = {}
Universe.chunkToDrained = {} Universe.chunkToDrained = {}
Universe.chunkToRetreatIterator = nil
Universe.chunkToRetreats = {} Universe.chunkToRetreats = {}
Universe.chunkToRallyIterator = nil
Universe.chunkToRallys = {} Universe.chunkToRallys = {}
Universe.chunkToPassScan = {} Universe.chunkToPassScan = {}
Universe.chunkToPassScanIterator = nil
Universe.baseId = 0 Universe.baseId = 0
Universe.awake = false Universe.awake = false
@ -573,7 +566,6 @@ function Upgrade.addUniverseProperties()
Universe.pendingUpgrades = {} Universe.pendingUpgrades = {}
Universe.settlePurpleCloud = {} Universe.settlePurpleCloud = {}
Universe.settlePurpleCloud.len = 0
end end
end end
@ -674,45 +666,18 @@ function Upgrade.prepMap(surface)
map.scanPlayerIndex = 1 map.scanPlayerIndex = 1
map.scanResourceIndex = 1 map.scanResourceIndex = 1
map.scanEnemyIndex = 1 map.scanEnemyIndex = 1
map.processStaticIndex = 1
map.outgoingScanWave = true map.outgoingScanWave = true
map.outgoingStaticScanWave = true map.outgoingStaticScanWave = true
map.chunkToBase = {}
map.chunkToTurrets = {}
map.chunkToTraps = {}
map.chunkToUtilities = {}
map.chunkToHives = {}
map.chunkToNestIds = {}
map.chunkToHiveIds = {}
map.chunkToTrapIds = {}
map.chunkToTurretIds = {}
map.chunkToUtilityIds = {}
map.drainPylons = {} map.drainPylons = {}
map.chunkToPlayerBase = {}
map.chunkToResource = {}
map.chunkToPlayerCount = {}
map.playerToChunk = {}
map.chunkToSquad = {} map.chunkToSquad = {}
map.chunkToPassable = {}
map.chunkToPathRating = {}
map.chunkToDeathGenerator = {}
map.chunkToPermanentDeathGenerator = {}
map.chunkToPlayerGenerator = {}
map.chunkScanCounts = {} map.chunkScanCounts = {}
map.emptySquadsOnChunk = {}
map.surface = surface map.surface = surface
map.bases = {} map.bases = {}
map.squads = nil
map.pendingAttack = nil
map.building = nil
-- queue all current chunks that wont be generated during play -- queue all current chunks that wont be generated during play
local tick = game.tick local tick = game.tick