mirror of
https://codeberg.org/ACME-Corporation/cub3d.git
synced 2025-12-06 01:48:08 +01:00
style: remove maputils header from central includes folder
This commit is contained in:
parent
8ec3f2e11c
commit
7000634228
15 changed files with 181 additions and 95 deletions
13
Makefile
13
Makefile
|
|
@ -1,15 +1,18 @@
|
|||
CC=cc
|
||||
SANITIZERS=-fsanitize=address,undefined -fno-omit-frame-pointer
|
||||
CFLAGS=-Wall -Wextra -Werror -g $(SANITIZERS) -I mlx
|
||||
SOURCEFILES=src/main.c \
|
||||
src/map/map_checker.c \
|
||||
SOURCEFILES=\
|
||||
src/draw/draw_map.c \
|
||||
src/draw/drawutils.c \
|
||||
src/main.c \
|
||||
src/map/checkers.c \
|
||||
src/map/forbidden_characters.c \
|
||||
src/map/populate_map.c \
|
||||
src/map/setters.c \
|
||||
src/utils/frees.c \
|
||||
src/map/forbidden_characters.c \
|
||||
src/utils/hooks.c \
|
||||
src/draw/drawutils.c \
|
||||
src/draw/draw_map.c
|
||||
src/map/map_checker.c \
|
||||
|
||||
OBJECTS=$(patsubst src/%.c,objects/%.o,$(SOURCEFILES))
|
||||
OBJDIR=objects
|
||||
NAME=cub3d
|
||||
|
|
|
|||
|
|
@ -1,47 +0,0 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* maputils.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: tchampio <tchampio@student.42lehavre.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/06/21 19:34:43 by tchampio #+# #+# */
|
||||
/* Updated: 2025/07/15 10:32:24 by tchampio ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef MAPUTILS_H
|
||||
# define MAPUTILS_H
|
||||
|
||||
# include <stdbool.h>
|
||||
# include "structs.h"
|
||||
|
||||
// TODO: mettre ca dans un autre fichier
|
||||
# define RESET "\033[0m"
|
||||
# define RED "\033[31m"
|
||||
# define GREEN "\033[32m"
|
||||
# define YELLOW "\033[33m"
|
||||
# define BLUE "\033[34m"
|
||||
# define MAGENTA "\033[35m"
|
||||
# define CYAN "\033[36m"
|
||||
# define BOLD "\033[1m"
|
||||
|
||||
bool check_cubfile(char *filename, t_mapdata *map);
|
||||
bool check_filename(t_mapdata *map, char *file);
|
||||
void populate_maps(t_mapdata *map, int fd);
|
||||
bool check_walls(t_mapdata *map);
|
||||
bool check_bare_minimum(t_mapdata *map);
|
||||
bool has_forbidden_characters(char *line);
|
||||
void print_mapdata(const t_mapdata *data);
|
||||
unsigned long set_color(const char *s, t_mapdata *map);
|
||||
bool set_textures(char *line, t_mapdata *map);
|
||||
bool add_textures(int fd, t_mapdata *map);
|
||||
void free_tab_length(char **tab, int length);
|
||||
int copy_old_map(t_mapdata *map, char **newmap,
|
||||
char **newmapflood, int length);
|
||||
void add_map_line(const char *line, t_mapdata *map);
|
||||
void print_map(char **map);
|
||||
bool check_cubfile(char *file, t_mapdata *map);
|
||||
void free_map(t_mapdata *map);
|
||||
|
||||
#endif
|
||||
|
|
@ -6,15 +6,15 @@
|
|||
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/07/17 14:14:30 by kcolin #+# #+# */
|
||||
/* Updated: 2025/07/17 14:24:45 by kcolin ### ########.fr */
|
||||
/* Updated: 2025/07/17 14:35:52 by kcolin ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../libft/includes/libft.h"
|
||||
#include "../includes/structs.h"
|
||||
#include "../mlx/mlx.h"
|
||||
#include "../includes/maputils.h"
|
||||
#include "../includes/cub3d_consts.h"
|
||||
#include "map/map_checker.h"
|
||||
#include "draw/draw_map.h"
|
||||
#include "utils/hooks.h"
|
||||
#include <stdbool.h>
|
||||
|
|
|
|||
|
|
@ -6,12 +6,13 @@
|
|||
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/07/17 14:15:26 by kcolin #+# #+# */
|
||||
/* Updated: 2025/07/17 14:15:26 by kcolin ### ########.fr */
|
||||
/* Updated: 2025/07/17 14:45:47 by kcolin ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../../includes/maputils.h"
|
||||
#include "../../libft/includes/libft.h"
|
||||
#include "../../includes/structs.h"
|
||||
#include "forbidden_characters.h"
|
||||
|
||||
bool check_filename(t_mapdata *map, char *file)
|
||||
{
|
||||
|
|
@ -36,21 +37,6 @@ bool check_filename(t_mapdata *map, char *file)
|
|||
return (true);
|
||||
}
|
||||
|
||||
void populate_maps(t_mapdata *map, int fd)
|
||||
{
|
||||
char *line;
|
||||
|
||||
line = get_next_line(fd);
|
||||
while (line)
|
||||
{
|
||||
if (line[0] != '\n')
|
||||
add_map_line(line, map);
|
||||
free(line);
|
||||
line = get_next_line(fd);
|
||||
}
|
||||
free(line);
|
||||
}
|
||||
|
||||
bool check_walls(t_mapdata *map)
|
||||
{
|
||||
int i;
|
||||
|
|
|
|||
23
src/map/checkers.h
Normal file
23
src/map/checkers.h
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* checkers.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/07/17 14:39:41 by kcolin #+# #+# */
|
||||
/* Updated: 2025/07/17 14:41:45 by kcolin ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef CHECKERS_H
|
||||
# define CHECKERS_H
|
||||
|
||||
# include "../../includes/structs.h"
|
||||
|
||||
bool check_filename(t_mapdata *map, char *file);
|
||||
void populate_maps(t_mapdata *map, int fd);
|
||||
bool check_walls(t_mapdata *map);
|
||||
bool check_bare_minimum(t_mapdata *map);
|
||||
|
||||
#endif // CHECKERS_H
|
||||
|
|
@ -6,12 +6,13 @@
|
|||
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/07/17 14:18:13 by kcolin #+# #+# */
|
||||
/* Updated: 2025/07/17 14:18:18 by kcolin ### ########.fr */
|
||||
/* Updated: 2025/07/17 14:47:34 by kcolin ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../../libft/includes/libft.h"
|
||||
#include "../../includes/maputils.h"
|
||||
|
||||
// TODO: use a #define for allowedchars, to prevent needless repetition
|
||||
|
||||
#ifdef BONUS
|
||||
|
||||
|
|
|
|||
20
src/map/forbidden_characters.h
Normal file
20
src/map/forbidden_characters.h
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* forbidden_characters.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/07/17 14:44:57 by kcolin #+# #+# */
|
||||
/* Updated: 2025/07/17 14:56:50 by kcolin ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef FORBIDDEN_CHARACTERS_H
|
||||
# define FORBIDDEN_CHARACTERS_H
|
||||
|
||||
# include <stdbool.h>
|
||||
|
||||
bool has_forbidden_characters(char *line);
|
||||
|
||||
#endif // FORBIDDEN_CHARACTERS_H
|
||||
|
|
@ -6,15 +6,18 @@
|
|||
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/06/06 17:54:42 by tchampio #+# #+# */
|
||||
/* Updated: 2025/07/17 14:17:06 by kcolin ### ########.fr */
|
||||
/* Updated: 2025/07/17 14:47:16 by kcolin ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../../includes/maputils.h"
|
||||
#include "../../libft/includes/libft.h"
|
||||
#include "../../includes/structs.h"
|
||||
#include "../utils/colors.h"
|
||||
#include "checkers.h"
|
||||
#include "setters.h"
|
||||
#include <fcntl.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include "../../libft/includes/libft.h"
|
||||
|
||||
void print_mapdata(const t_mapdata *data)
|
||||
{
|
||||
|
|
@ -38,21 +41,6 @@ void print_mapdata(const t_mapdata *data)
|
|||
ft_printf(CYAN "=================\n" RESET);
|
||||
}
|
||||
|
||||
void free_tab_length(char **tab, int length)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (!tab)
|
||||
return ;
|
||||
i = 0;
|
||||
while (i < length)
|
||||
{
|
||||
free(tab[i]);
|
||||
++i;
|
||||
}
|
||||
free(tab);
|
||||
}
|
||||
|
||||
void flood_fill(t_mapdata *map, int x, int y)
|
||||
{
|
||||
if (map->mapflood[y][x] == '1')
|
||||
|
|
|
|||
20
src/map/map_checker.h
Normal file
20
src/map/map_checker.h
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* map_checker.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/07/17 14:34:38 by kcolin #+# #+# */
|
||||
/* Updated: 2025/07/17 14:35:09 by kcolin ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef MAP_CHECKER_H
|
||||
# define MAP_CHECKER_H
|
||||
|
||||
# include "../../includes/structs.h"
|
||||
|
||||
bool check_cubfile(char *file, t_mapdata *map);
|
||||
|
||||
#endif // MAP_CHECKER_H
|
||||
30
src/map/populate_map.c
Normal file
30
src/map/populate_map.c
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* populate_map.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/07/17 14:44:02 by kcolin #+# #+# */
|
||||
/* Updated: 2025/07/17 14:52:01 by kcolin ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../../includes/structs.h"
|
||||
#include "../../libft/includes/libft.h"
|
||||
#include "setters.h"
|
||||
|
||||
void populate_maps(t_mapdata *map, int fd)
|
||||
{
|
||||
char *line;
|
||||
|
||||
line = get_next_line(fd);
|
||||
while (line)
|
||||
{
|
||||
if (line[0] != '\n')
|
||||
add_map_line(line, map);
|
||||
free(line);
|
||||
line = get_next_line(fd);
|
||||
}
|
||||
free(line);
|
||||
}
|
||||
|
|
@ -6,11 +6,10 @@
|
|||
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/06/21 19:35:43 by tchampio #+# #+# */
|
||||
/* Updated: 2025/07/17 14:27:56 by kcolin ### ########.fr */
|
||||
/* Updated: 2025/07/17 14:46:29 by kcolin ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../../includes/maputils.h"
|
||||
#include "../../libft/includes/libft.h"
|
||||
#include "../utils/frees.h"
|
||||
|
||||
|
|
|
|||
21
src/map/setters.h
Normal file
21
src/map/setters.h
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* setters.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/07/17 14:40:32 by kcolin #+# #+# */
|
||||
/* Updated: 2025/07/17 14:42:15 by kcolin ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef SETTERS_H
|
||||
# define SETTERS_H
|
||||
|
||||
# include "../../includes/structs.h"
|
||||
|
||||
bool add_textures(int fd, t_mapdata *map);
|
||||
void add_map_line(const char *line, t_mapdata *map);
|
||||
|
||||
#endif // SETTERS_H
|
||||
25
src/utils/colors.h
Normal file
25
src/utils/colors.h
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* colors.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/07/17 14:36:52 by kcolin #+# #+# */
|
||||
/* Updated: 2025/07/17 14:37:29 by kcolin ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef COLORS_H
|
||||
# define COLORS_H
|
||||
|
||||
# define RESET "\033[0m"
|
||||
# define RED "\033[31m"
|
||||
# define GREEN "\033[32m"
|
||||
# define YELLOW "\033[33m"
|
||||
# define BLUE "\033[34m"
|
||||
# define MAGENTA "\033[35m"
|
||||
# define CYAN "\033[36m"
|
||||
# define BOLD "\033[1m"
|
||||
|
||||
#endif // COLORS_H
|
||||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/07/17 13:59:27 by kcolin #+# #+# */
|
||||
/* Updated: 2025/07/17 14:27:07 by kcolin ### ########.fr */
|
||||
/* Updated: 2025/07/17 14:47:25 by kcolin ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -30,6 +30,21 @@ void free_tab(char **tab)
|
|||
free(tab);
|
||||
}
|
||||
|
||||
void free_tab_length(char **tab, int length)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (!tab)
|
||||
return ;
|
||||
i = 0;
|
||||
while (i < length)
|
||||
{
|
||||
free(tab[i]);
|
||||
++i;
|
||||
}
|
||||
free(tab);
|
||||
}
|
||||
|
||||
void free_map(t_mapdata *map)
|
||||
{
|
||||
free_tab(map->map);
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/07/17 14:27:11 by kcolin #+# #+# */
|
||||
/* Updated: 2025/07/17 14:28:47 by kcolin ### ########.fr */
|
||||
/* Updated: 2025/07/17 14:47:27 by kcolin ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -17,5 +17,7 @@
|
|||
|
||||
void gnl_exhaust(int fd);
|
||||
int destroy(t_cub3d_data *data);
|
||||
void free_tab(char **tab);
|
||||
void free_tab_length(char **tab, int length);
|
||||
|
||||
#endif // FREES_H
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue