diff options
| author | Charles <sircharlesaze@gmail.com> | 2020-01-11 10:38:41 +0100 |
|---|---|---|
| committer | Charles <sircharlesaze@gmail.com> | 2020-01-11 10:39:37 +0100 |
| commit | 0dcba6ff7e68ed13f8e6caadd80b77506b917050 (patch) | |
| tree | 16e1393115941b87ca50f04f1e37511f3f7bbdb5 /parse/parse_color.c | |
| parent | 988e058680280e25d345b17d840c3c6d40e30a76 (diff) | |
| download | cub3d-0dcba6ff7e68ed13f8e6caadd80b77506b917050.tar.gz cub3d-0dcba6ff7e68ed13f8e6caadd80b77506b917050.tar.bz2 cub3d-0dcba6ff7e68ed13f8e6caadd80b77506b917050.zip | |
Hardcore refactoring
Diffstat (limited to 'parse/parse_color.c')
| -rw-r--r-- | parse/parse_color.c | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/parse/parse_color.c b/parse/parse_color.c new file mode 100644 index 0000000..f602706 --- /dev/null +++ b/parse/parse_color.c @@ -0,0 +1,55 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* parse_color.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/01/11 09:52:34 by cacharle #+# #+# */ +/* Updated: 2020/01/11 10:14:29 by cacharle ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "cub3d.h" + +t_bool parse_ceilling_color(t_state *state, char *line) +{ + int tmp; + + line++; + if ((tmp = ft_atoi(line)) > 255 || tmp < 0) + return (FALSE); + state->ceilling_color.rgb.r = (t_byte)tmp; + if ((line = ft_strchr(line, ',') + 1) == NULL) + return (FALSE); + if ((tmp = ft_atoi(line)) > 255 || tmp < 0) + return (FALSE); + state->ceilling_color.rgb.g = (t_byte)tmp; + if ((line = ft_strchr(line, ',') + 1) == NULL) + return (FALSE); + if ((tmp = ft_atoi(line)) > 255 || tmp < 0) + return (FALSE); + state->ceilling_color.rgb.b = (t_byte)tmp; + return (TRUE); +} + +t_bool parse_floor_color(t_state *state, char *line) +{ + int tmp; + + line++; + if ((tmp = ft_atoi(line)) > 255 || tmp < 0) + return (FALSE); + state->floor_color.rgb.r = (t_byte)tmp; + if ((line = ft_strchr(line, ',') + 1) == NULL) + return (FALSE); + if ((tmp = ft_atoi(line)) > 255 || tmp < 0) + return (FALSE); + state->floor_color.rgb.g = (t_byte)tmp; + if ((line = ft_strchr(line, ',') + 1) == NULL) + return (FALSE); + if ((tmp = ft_atoi(line)) > 255 || tmp < 0) + return (FALSE); + state->floor_color.rgb.b = (t_byte)tmp; + return (TRUE); +} |
