diff options
Diffstat (limited to '')
-rw-r--r-- | Makefile | 1 | ||||
-rw-r--r-- | inc/cub3d.h | 3 | ||||
-rw-r--r-- | src/ft_init_lists.c | 2 | ||||
-rw-r--r-- | src/ft_parse_map.c | 31 | ||||
-rw-r--r-- | src/ft_select_get.c | 7 |
5 files changed, 37 insertions, 7 deletions
@@ -22,6 +22,7 @@ SRCS_NAME += ft_key_events.c SRCS_NAME += ft_exit.c SRCS_NAME += ft_drawsquare.c SRCS_NAME += ft_parse_map.c +SRCS_NAME += ft_select_get.c SRCS_NAME += ft_get_res.c SRCS_NAME += ft_get_tex.c SRCS_NAME += ft_get_sprite_tex.c diff --git a/inc/cub3d.h b/inc/cub3d.h index 676253a..5a56df1 100644 --- a/inc/cub3d.h +++ b/inc/cub3d.h @@ -45,10 +45,11 @@ typedef struct s_cub t_win *ft_init_win(void); t_cub *ft_init_cub(void); -void ft_parse_map(const char *map_path, t_cub *clist); int ft_key_event(int keycode, void *param); int ft_exit(uint8_t exit_code, t_cub *clist); void ft_drawsquare(int a, int b, int rgb, t_cub *clist); +void ft_parse_map(const char *map_path, t_cub *clist); +int ft_select_get(char **words, t_cub *clist); int ft_get_res(int fd, t_cub *clist); int ft_get_tex(int fd, t_cub *clist); int ft_get_sprite_tex(int fd, t_cub *clist); diff --git a/src/ft_init_lists.c b/src/ft_init_lists.c index 5c14731..1b4ab59 100644 --- a/src/ft_init_lists.c +++ b/src/ft_init_lists.c @@ -38,6 +38,6 @@ t_cub return (NULL); clist->map[1] = 0; clist->map_w = 0; - clist->line_chk = 0; + clist->line_chk = 1; return (clist); } diff --git a/src/ft_parse_map.c b/src/ft_parse_map.c index 1911e5c..c94a91b 100644 --- a/src/ft_parse_map.c +++ b/src/ft_parse_map.c @@ -31,7 +31,7 @@ ft_check_cub(const char *map_path, t_cub *clist) } static void -ft_check_last_line(t_cub *clist) +ft_check_map_last_line(t_cub *clist) { size_t i; size_t j; @@ -48,9 +48,30 @@ ft_check_last_line(t_cub *clist) } } -/* -** I can't close fd -*/ +static int +ft_parse_it(int fd, t_cub *clist) +{ + char *line; + char **words; + + if (get_next_line(fd, &line) <= 0) + { + ft_memdel(line); + return (ft_map_error(clist->line_chk, clist)); + } + if (!line[0]) + { + ft_memdel(line); + return (ft_parse_it(fd, clist)); + } + if (!(words = ft_split(line, ' '))) + { + ft_memdel(line); + return (ft_map_error(clist->line_chk, clist)); + } + ft_memdel(line); + return (ft_select_get(words, clist)); +} void ft_parse_map(const char *map_path, t_cub *clist) @@ -75,7 +96,7 @@ ft_parse_map(const char *map_path, t_cub *clist) ft_check_empty_line(fd, 10, clist); if (ft_get_map(fd, clist) < 0) ft_map_error(11, clist); - ft_check_last_line(clist); + ft_check_map_last_line(clist); ft_print_list(clist); close(fd); } diff --git a/src/ft_select_get.c b/src/ft_select_get.c new file mode 100644 index 0000000..0ddc80a --- /dev/null +++ b/src/ft_select_get.c @@ -0,0 +1,7 @@ +int +ft_select_get(char **words, t_cub *clist) +{ + (void)words; + (void)clist; + return (0); +} |