set_bool - 1Fr3aK2/Cub3d GitHub Wiki

📝 set_bool

This function initializes all elements of a temporary boolean map (temp_map) to false based on the dimensions of the main map (map) in the t_map structure.

⚙️ Parameters

Parameter Type Description
map t_map* A pointer to the map structure containing both the main map and the temporary boolean map.

🔁 Returns

Return value Description
void This function does not return a value. It modifies temp_map in place.

📖 Description

The set_bool function iterates through the 2D array map->map and sets all corresponding positions in map->temp_map to false. This is typically used to initialize or reset the temporary map before performing operations such as pathfinding or checking visited positions.

  • The function first checks if the input map is NULL. If so, it returns immediately.
  • It uses nested loops to traverse each row and column of map->map.
  • For each valid cell in map->map, the corresponding cell in temp_map is set to false.

💡 Example Usage

t_map map;
// Assume map.map and map.temp_map have been properly initialized

set_bool(&map); // Sets all values in temp_map to false

// After calling set_bool, map.temp_map[i][j] == false for all valid i, j