norminette

This commit is contained in:
Andrei Pago 2023-04-05 18:24:30 +02:00
parent e13c1fec1f
commit 854f581cff
2 changed files with 7 additions and 10 deletions

View File

@ -57,7 +57,7 @@ $(NAME): $(OBJ)
$(OBJ): | $(OBJDIR) $(OBJ): | $(OBJDIR)
$(OBJDIR)/%.o: $(SRCDIR)/%.c $(DEPS) $(OBJDIR)/%.o: $(SRCDIR)/%.c $(DEPS)
# @norminette $< >/dev/null || { printf '\033[101;37m%s\033[m\n' "!Norminette Failed>>>"; norminette $<; printf '\033[101;37m%s\033[m\n' "<<<Norminette Failed!"; exit 1; } @norminette $< >/dev/null || { printf '\033[101;37m%s\033[m\n' "!Norminette Failed>>>"; norminette $<; printf '\033[101;37m%s\033[m\n' "<<<Norminette Failed!"; exit 1; }
$(CC) $(CFLAGS) -c $< -o $@ $(CC) $(CFLAGS) -c $< -o $@
$(OBJDIR): $(OBJDIR):

View File

@ -6,7 +6,7 @@
/* By: apago <apago@student.42.fr> +#+ +:+ +#+ */ /* By: apago <apago@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2023/04/04 21:46:57 by tischmid #+# #+# */ /* Created: 2023/04/04 21:46:57 by tischmid #+# #+# */
/* Updated: 2023/04/05 17:59:44 by apago ### ########.fr */ /* Updated: 2023/04/05 18:24:14 by apago ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -26,10 +26,8 @@ void preprocess_map(t_map *map)
while (idx < map->meta.width * map->meta.height) while (idx < map->meta.width * map->meta.height)
{ {
is_obstacle = map->data[idx] == map->meta.obstacle; is_obstacle = map->data[idx] == map->meta.obstacle;
map->index[idx] = is_obstacle + map->index[idx] = is_obstacle + get_index(map, idx, 0, -1)
get_index(map, idx, 0, -1) + + get_index(map, idx, -1, 0) - get_index(map, idx, -1, -1);
get_index(map, idx, -1, 0) -
get_index(map, idx, -1, -1);
idx++; idx++;
} }
} }
@ -45,10 +43,9 @@ int count_obstacles(t_map *map, int idx, int sq_size)
if (idx + (sq_size - 1) * (map->meta.width + 1) > map->meta.width if (idx + (sq_size - 1) * (map->meta.width + 1) > map->meta.width
* map->meta.height) * map->meta.height)
return (-1); return (-1);
alternat_corner_sum = get_index(map, idx, -1, -1) - alternat_corner_sum = get_index(map, idx, -1, -1) - get_index(map, idx, -1,
get_index(map, idx, -1, sq_size - 1) + sq_size - 1) + get_index(map, idx, sq_size - 1, sq_size - 1)
get_index(map, idx, sq_size - 1, sq_size - 1) - - get_index(map, idx, sq_size - 1, -1);
get_index(map, idx, sq_size - 1, -1);
return (alternat_corner_sum); return (alternat_corner_sum);
} }