From 0dcba6ff7e68ed13f8e6caadd80b77506b917050 Mon Sep 17 00:00:00 2001 From: Charles Date: Sat, 11 Jan 2020 10:38:41 +0100 Subject: Hardcore refactoring --- parse/parse_color.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 parse/parse_color.c (limited to 'parse/parse_color.c') 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 +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* 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); +} -- cgit