From db250cd1a6fad417cba88599a370b8c23712427b Mon Sep 17 00:00:00 2001 From: Aaron Veden Date: Mon, 8 May 2023 21:09:13 -0700 Subject: [PATCH] FACTO-340: Fixed tile passability check using water-layer instead of player-layer --- changelog.txt | 1 + libs/MapUtils.lua | 42 +++++++++++++++++++++++------------------- libs/Upgrade.lua | 25 +++++++++++++++++++------ 3 files changed, 43 insertions(+), 25 deletions(-) diff --git a/changelog.txt b/changelog.txt index 9c01ca8..facae83 100644 --- a/changelog.txt +++ b/changelog.txt @@ -3,6 +3,7 @@ Version: 3.3.3 Bugfixes: - Added check for invalid entity upgrade - Added wander command to squads if they timeout for executing a command to fix enemy units getting stuck + - Changed tile algorithm to use player-layer instead of water-layer for determining if a chunk is passable --------------------------------------------------------------------------------------------------- Version: 3.3.2 diff --git a/libs/MapUtils.lua b/libs/MapUtils.lua index 21a40ae..2366d3d 100644 --- a/libs/MapUtils.lua +++ b/libs/MapUtils.lua @@ -188,6 +188,27 @@ function MapUtils.isExcludedSurface(surfaceName) sFind(surfaceName, "bpsb%-lab%-") end +function MapUtils.queueChunks(surface, chunks, flush, tick) + for chunk in chunks do + if surface.is_chunk_generated(chunk) then + MapUtils.queueGeneratedChunk( + { + surface = surface, + tick = tick, + area = { + left_top = { + x = chunk.x * 32, + y = chunk.y * 32 + } + } + } + ) + end + end + + Universe.flushPendingChunks = flush +end + function MapUtils.prepMap(surface) if Universe.maps[surface.index] then return Universe.maps[surface.index] @@ -219,27 +240,10 @@ function MapUtils.prepMap(surface) } Universe.maps[map.id] = map + local tick = game.tick -- queue all current chunks that wont be generated during play - local tick = game.tick - for chunk in surface.get_chunks() do - if surface.is_chunk_generated(chunk) then - MapUtils.queueGeneratedChunk( - { - surface = surface, - tick = tick, - area = { - left_top = { - x = chunk.x * 32, - y = chunk.y * 32 - } - } - } - ) - end - end - - Universe.flushPendingChunks = true + MapUtils.queueChunks(surface, surface.get_chunks(), true, tick) return map end diff --git a/libs/Upgrade.lua b/libs/Upgrade.lua index 39b8460..756da2d 100644 --- a/libs/Upgrade.lua +++ b/libs/Upgrade.lua @@ -19,6 +19,7 @@ local Upgrade = {} -- imports local Constants = require("libs/Constants") +local MapUtils = require("libs/MapUtils") -- @@ -190,7 +191,7 @@ local function addCommandSet() {0,0} } Universe.isFilteredTilesQuery = { - collision_mask="water-tile", + collision_mask="player-layer", area=isSharedChunkArea } Universe.isFilteredEntitiesChunkNeutral = { @@ -225,7 +226,7 @@ local function addCommandSet() {0,0} } Universe.cpsFilteredTilesQuery = { - collision_mask="water-tile", + collision_mask="player-layer", area=cpsSharedChunkArea } Universe.cpsFilteredEntitiesChunkNeutral = { @@ -252,7 +253,7 @@ local function addCommandSet() {0,0} } Universe.msrcFilteredTilesQuery = { - collision_mask="water-tile", + collision_mask="player-layer", area=msrcSharedChunkArea } Universe.msrcFilteredEntitiesChunkNeutral = { @@ -280,7 +281,7 @@ local function addCommandSet() } Universe.spFilteredTilesPathQuery = { area=spSharedAreaChunk, - collision_mask="water-tile", + collision_mask="player-layer", limit = 1 } @@ -532,8 +533,8 @@ function Upgrade.addUniverseProperties() global.universePropertyVersion = 2 Universe.hiveDataIterator = nil end - if global.universePropertyVersion < 3 then - global.universePropertyVersion = 3 + if global.universePropertyVersion < 4 then + global.universePropertyVersion = 4 addCommandSet() end end @@ -628,6 +629,18 @@ function Upgrade.attempt() Universe.hiveIterator = nil Universe.hiveDataIterator = nil end + if global.gameVersion < 4 then + global.gameVersion = 4 + + local tick = game.tick + + for _, map in pairs(Universe.maps) do + local surface = map.surface + if surface.valid then + MapUtils.queueChunks(surface, surface.get_chunks(), true, tick) + end + end + end end function Upgrade.init(universe)