mirror of
https://github.com/veden/Rampant.git
synced 2025-09-16 09:16:43 +02:00
FACTO-248: Fixed pheromone process inner and outer chunks
This commit is contained in:
@@ -119,77 +119,39 @@ local next = next
|
|||||||
pheromone dissipate at a faster rate.
|
pheromone dissipate at a faster rate.
|
||||||
--]]
|
--]]
|
||||||
function mapProcessor.processMap(map, tick)
|
function mapProcessor.processMap(map, tick)
|
||||||
local outgoingWave = map.outgoingScanWave
|
|
||||||
local processQueue = map.processQueue
|
local processQueue = map.processQueue
|
||||||
local processQueueLength = #processQueue
|
local processQueueLength = #processQueue
|
||||||
local index = mMin(map.processIndex, processQueueLength)
|
|
||||||
|
|
||||||
local step
|
|
||||||
local endIndex
|
|
||||||
if outgoingWave then
|
|
||||||
step = 1
|
|
||||||
endIndex = mMin(index + PROCESS_QUEUE_SIZE, processQueueLength)
|
|
||||||
else
|
|
||||||
step = -1
|
|
||||||
endIndex = mMax(index - PROCESS_QUEUE_SIZE, 1)
|
|
||||||
end
|
|
||||||
|
|
||||||
if (processQueueLength == 0) then
|
if (processQueueLength == 0) then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
for x=index,endIndex,step do
|
local startIndex = mMin(map.processIndex, processQueueLength)
|
||||||
local chunk = processQueue[x]
|
local step
|
||||||
if chunk[CHUNK_TICK] ~= tick then
|
local endIndex
|
||||||
chunk[CHUNK_TICK] = tick
|
if map.outgoingScanWave then
|
||||||
processPheromone(map, chunk)
|
step = 1
|
||||||
|
endIndex = mMin(startIndex + PROCESS_QUEUE_SIZE, processQueueLength)
|
||||||
|
if (endIndex == processQueueLength) then
|
||||||
|
map.outgoingScanWave = false
|
||||||
|
map.processIndex = processQueueLength
|
||||||
|
else
|
||||||
|
map.processIndex = endIndex + 1
|
||||||
|
end
|
||||||
|
else
|
||||||
|
step = -1
|
||||||
|
endIndex = mMax(startIndex - PROCESS_QUEUE_SIZE, 1)
|
||||||
|
if (endIndex == 1) then
|
||||||
|
map.outgoingScanWave = true
|
||||||
|
map.processIndex = 1
|
||||||
|
else
|
||||||
|
map.processIndex = endIndex - 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
map.universe.processedChunks = map.universe.processedChunks + ((startIndex - endIndex) * step)
|
||||||
|
|
||||||
if (endIndex == processQueueLength) then
|
for x=startIndex,endIndex,step do
|
||||||
map.outgoingScanWave = false
|
processPheromone(map, processQueue[x], tick)
|
||||||
elseif (endIndex == 1) then
|
|
||||||
map.outgoingScanWave = true
|
|
||||||
elseif outgoingWave then
|
|
||||||
map.processIndex = endIndex + 1
|
|
||||||
else
|
|
||||||
map.processIndex = endIndex - 1
|
|
||||||
end
|
|
||||||
map.universe.processedChunks = map.universe.processedChunks + PROCESS_QUEUE_SIZE
|
|
||||||
end
|
|
||||||
|
|
||||||
function mapProcessor.processStaticMap(map)
|
|
||||||
local outgoingWave = map.outgoingStaticScanWave
|
|
||||||
local processQueue = map.processQueue
|
|
||||||
local processQueueLength = #processQueue
|
|
||||||
local index = mMin(map.processStaticIndex, processQueueLength)
|
|
||||||
|
|
||||||
local step
|
|
||||||
local endIndex
|
|
||||||
if outgoingWave then
|
|
||||||
step = 1
|
|
||||||
endIndex = mMin(index + PROCESS_STATIC_QUEUE_SIZE, processQueueLength)
|
|
||||||
else
|
|
||||||
step = -1
|
|
||||||
endIndex = mMax(index - PROCESS_STATIC_QUEUE_SIZE, 1)
|
|
||||||
end
|
|
||||||
|
|
||||||
if (processQueueLength == 0) then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
for x=index,endIndex,step do
|
|
||||||
processStaticPheromone(map, processQueue[x])
|
|
||||||
end
|
|
||||||
|
|
||||||
if (endIndex == processQueueLength) then
|
|
||||||
map.outgoingStaticScanWave = false
|
|
||||||
elseif (endIndex == 1) then
|
|
||||||
map.outgoingStaticScanWave = true
|
|
||||||
elseif outgoingWave then
|
|
||||||
map.processStaticIndex = endIndex + 1
|
|
||||||
else
|
|
||||||
map.processStaticIndex = endIndex - 1
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -258,9 +220,8 @@ function mapProcessor.processPlayers(players, universe, tick)
|
|||||||
for y=playerChunk.y - PROCESS_PLAYER_BOUND, playerChunk.y + PROCESS_PLAYER_BOUND, 32 do
|
for y=playerChunk.y - PROCESS_PLAYER_BOUND, playerChunk.y + PROCESS_PLAYER_BOUND, 32 do
|
||||||
local chunk = getChunkByXY(map, x, y)
|
local chunk = getChunkByXY(map, x, y)
|
||||||
|
|
||||||
if (chunk ~= -1) and (chunk[CHUNK_TICK] ~= tick) then
|
if (chunk ~= -1) then
|
||||||
chunk[CHUNK_TICK] = tick
|
processPheromone(map, chunk, tick, true)
|
||||||
processPheromone(map, chunk, true)
|
|
||||||
|
|
||||||
if (getNestCount(map, chunk) > 0) then
|
if (getNestCount(map, chunk) > 0) then
|
||||||
processNestActiveness(map, chunk)
|
processNestActiveness(map, chunk)
|
||||||
|
@@ -27,6 +27,8 @@ local chunkPropertyUtils = require("ChunkPropertyUtils")
|
|||||||
|
|
||||||
-- constants
|
-- constants
|
||||||
|
|
||||||
|
local CHUNK_TICK = constants.CHUNK_TICK
|
||||||
|
|
||||||
local ENEMY_PHEROMONE_MULTIPLER = constants.ENEMY_PHEROMONE_MULTIPLER
|
local ENEMY_PHEROMONE_MULTIPLER = constants.ENEMY_PHEROMONE_MULTIPLER
|
||||||
local VICTORY_SCENT_MULTIPLER = constants.VICTORY_SCENT_MULTIPLER
|
local VICTORY_SCENT_MULTIPLER = constants.VICTORY_SCENT_MULTIPLER
|
||||||
local VICTORY_SCENT_BOUND = constants.VICTORY_SCENT_BOUND
|
local VICTORY_SCENT_BOUND = constants.VICTORY_SCENT_BOUND
|
||||||
@@ -128,7 +130,12 @@ function pheromoneUtils.deathScent(map, chunk, structure)
|
|||||||
addPermanentDeathGenerator(map, chunk, amount)
|
addPermanentDeathGenerator(map, chunk, amount)
|
||||||
end
|
end
|
||||||
|
|
||||||
function pheromoneUtils.processPheromone(map, chunk, player)
|
function pheromoneUtils.processPheromone(map, chunk, tick, player)
|
||||||
|
if chunk[CHUNK_TICK] > tick then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
chunk[CHUNK_TICK] = tick
|
||||||
|
|
||||||
local chunkPlayer = chunk[PLAYER_PHEROMONE]
|
local chunkPlayer = chunk[PLAYER_PHEROMONE]
|
||||||
local chunkBase = -MAGIC_MAXIMUM_NUMBER
|
local chunkBase = -MAGIC_MAXIMUM_NUMBER
|
||||||
local chunkDeath = getCombinedDeathGenerator(map, chunk)
|
local chunkDeath = getCombinedDeathGenerator(map, chunk)
|
||||||
|
Reference in New Issue
Block a user