Skip to content

Commit

Permalink
Merge branch 'main' into callback-quest
Browse files Browse the repository at this point in the history
  • Loading branch information
omarcopires authored Dec 14, 2024
2 parents ff48f7e + 61c1fc0 commit d14b487
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
7 changes: 4 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,10 @@ endif()
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules)

# Configure build options for compatibility with commodity CPUs
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=x86-64 -mtune=generic -mno-avx -mno-sse4")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=x86-64 -mtune=generic -mno-avx -mno-sse4")

if(NOT MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=x86-64 -mtune=generic -mno-avx -mno-sse4")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=x86-64 -mtune=generic -mno-avx -mno-sse4")
endif()

# *****************************************************************************
# Include cmake tools
Expand Down
22 changes: 17 additions & 5 deletions data/libs/systems/zones.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,24 @@ function Zone:randomPosition()
logger.error("Zone:randomPosition() - Zone {} has no positions", self:getName())
return nil
end
local destination = positions[math.random(1, #positions)]
local tile = destination:getTile()
while not tile or not tile:isWalkable(false, false, false, false, true) do
destination = positions[math.random(1, #positions)]
tile = destination:getTile()

local validPositions = {}
for _, position in ipairs(positions) do
local tile = position:getTile()
if tile and tile:isWalkable(false, false, false, false, true) then
table.insert(validPositions, position)
else
logger.debug("Zone:randomPosition() - Position {} is invalid (Tile: {}, Walkable: {})", position, tile or "nil", tile and tile:isWalkable(false, false, false, false, true) or "false")
end
end

if #validPositions == 0 then
logger.error("Zone:randomPosition() - No valid positions in Zone {}", self:getName())
return nil
end

local destination = validPositions[math.random(1, #validPositions)]
logger.debug("Zone:randomPosition() - Selected valid position: {}", destination)
return destination
end

Expand Down

0 comments on commit d14b487

Please sign in to comment.