diff options
author | Rudy Bousset <rbousset@z2r5p2.le-101.fr> | 2020-01-29 16:09:52 +0100 |
---|---|---|
committer | Rudy Bousset <rbousset@z2r5p2.le-101.fr> | 2020-01-29 16:09:52 +0100 |
commit | bec06f4323a2cb2c0bc1594df797c529a35d41e2 (patch) | |
tree | e2dbc17ea4f8ab4485c90da51a18e32e28d01267 /src/ft_get_colors.c | |
parent | Good for now, I'll continue later (diff) | |
download | 42-cub3d-bec06f4323a2cb2c0bc1594df797c529a35d41e2.tar.gz 42-cub3d-bec06f4323a2cb2c0bc1594df797c529a35d41e2.tar.bz2 42-cub3d-bec06f4323a2cb2c0bc1594df797c529a35d41e2.tar.xz 42-cub3d-bec06f4323a2cb2c0bc1594df797c529a35d41e2.tar.zst 42-cub3d-bec06f4323a2cb2c0bc1594df797c529a35d41e2.zip |
Got colors
Diffstat (limited to 'src/ft_get_colors.c')
-rw-r--r-- | src/ft_get_colors.c | 43 |
1 files changed, 5 insertions, 38 deletions
diff --git a/src/ft_get_colors.c b/src/ft_get_colors.c index 1b67447..226b427 100644 --- a/src/ft_get_colors.c +++ b/src/ft_get_colors.c @@ -16,11 +16,11 @@ ft_check_digits(const char *word) } int -ft_get_f_color(char *line, char **words, t_cub *clist) +ft_get_f_color(char **words, t_cub *clist) { char **num; - if (!(*words) || ft_strcmp(*words, "F") || !words[1] || words[2]) + if (!(*words) || !words[1] || words[2]) return (-1); if (!(num = ft_split(words[1], ','))) return (-1); @@ -29,7 +29,7 @@ ft_get_f_color(char *line, char **words, t_cub *clist) ft_check_digits(num[2]) || ft_atoi(num[0]) > 255 || ft_atoi(num[1]) > 255 || ft_atoi(num[2]) > 255) { - ft_free_words(num, NULL); + ft_free_words(num); return (-1); } clist->f_color = ft_atoi(num[0]); @@ -37,13 +37,11 @@ ft_get_f_color(char *line, char **words, t_cub *clist) clist->f_color += ft_atoi(num[1]); clist->f_color *= 1000; clist->f_color += ft_atoi(num[2]); - ft_free_words(num, NULL); - ft_free_words(words, line); return (0); } int -ft_get_c_color(char *line, char **words, t_cub *clist) +ft_get_c_color(char **words, t_cub *clist) { char **num; @@ -56,7 +54,7 @@ ft_get_c_color(char *line, char **words, t_cub *clist) ft_check_digits(num[2]) || ft_atoi(num[0]) > 255 || ft_atoi(num[1]) > 255 || ft_atoi(num[2]) > 255) { - ft_free_words(num, NULL); + ft_free_words(num); return (-1); } clist->c_color = ft_atoi(num[0]); @@ -64,36 +62,5 @@ ft_get_c_color(char *line, char **words, t_cub *clist) clist->c_color += ft_atoi(num[1]); clist->c_color *= 1000; clist->c_color += ft_atoi(num[2]); - ft_free_words(num, NULL); - ft_free_words(words, line); - return (0); -} - -int -ft_get_colors(int fd, t_cub *clist) -{ - char *line; - char **words; - - if (get_next_line(fd, &line) <= 0 || !(words = ft_split(line, ' '))) - { - ft_memdel(line); - return (ft_map_error(8, clist)); - } - if (ft_get_f_color(line, words, clist) < 0) - { - ft_free_words(words, line); - return (ft_map_error(8, clist)); - } - if (get_next_line(fd, &line) <= 0 || !(words = ft_split(line, ' '))) - { - ft_memdel(line); - return (ft_map_error(9, clist)); - } - if (ft_get_c_color(line, words, clist) < 0) - { - ft_free_words(words, line); - return (ft_map_error(9, clist)); - } return (0); } |