format
Some checks failed
Some checks failed
This commit is contained in:
@@ -25,7 +25,12 @@ static func is_valid_grid_position(pos: Vector2i, grid_size: Vector2i) -> bool:
|
||||
##
|
||||
## Returns:
|
||||
## bool: True if position is valid, False if out of bounds
|
||||
return pos.x >= 0 and pos.y >= 0 and pos.x < grid_size.x and pos.y < grid_size.y
|
||||
return (
|
||||
pos.x >= 0
|
||||
and pos.y >= 0
|
||||
and pos.x < grid_size.x
|
||||
and pos.y < grid_size.y
|
||||
)
|
||||
|
||||
|
||||
static func validate_grid_integrity(grid: Array, grid_size: Vector2i) -> bool:
|
||||
@@ -46,7 +51,8 @@ static func validate_grid_integrity(grid: Array, grid_size: Vector2i) -> bool:
|
||||
|
||||
if grid.size() != grid_size.y:
|
||||
DebugManager.log_error(
|
||||
"Grid height mismatch: %d vs %d" % [grid.size(), grid_size.y], "Match3"
|
||||
"Grid height mismatch: %d vs %d" % [grid.size(), grid_size.y],
|
||||
"Match3"
|
||||
)
|
||||
return false
|
||||
|
||||
@@ -57,20 +63,28 @@ static func validate_grid_integrity(grid: Array, grid_size: Vector2i) -> bool:
|
||||
|
||||
if grid[y].size() != grid_size.x:
|
||||
DebugManager.log_error(
|
||||
"Grid row %d width mismatch: %d vs %d" % [y, grid[y].size(), grid_size.x], "Match3"
|
||||
(
|
||||
"Grid row %d width mismatch: %d vs %d"
|
||||
% [y, grid[y].size(), grid_size.x]
|
||||
),
|
||||
"Match3"
|
||||
)
|
||||
return false
|
||||
|
||||
return true
|
||||
|
||||
|
||||
static func safe_grid_access(grid: Array, pos: Vector2i, grid_size: Vector2i) -> Node2D:
|
||||
static func safe_grid_access(
|
||||
grid: Array, pos: Vector2i, grid_size: Vector2i
|
||||
) -> Node2D:
|
||||
# Safe grid access with comprehensive bounds checking
|
||||
if not is_valid_grid_position(pos, grid_size):
|
||||
return null
|
||||
|
||||
if pos.y >= grid.size() or pos.x >= grid[pos.y].size():
|
||||
DebugManager.log_warn("Grid bounds exceeded: (%d,%d)" % [pos.x, pos.y], "Match3")
|
||||
DebugManager.log_warn(
|
||||
"Grid bounds exceeded: (%d,%d)" % [pos.x, pos.y], "Match3"
|
||||
)
|
||||
return null
|
||||
|
||||
var tile = grid[pos.y][pos.x]
|
||||
|
||||
Reference in New Issue
Block a user