aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--inc/cub3d.h1
-rw-r--r--inc/cub3d_defines.h2
-rw-r--r--map/map_three.cub1
-rw-r--r--src/ft_get_darkness.c30
-rw-r--r--src/ft_init_map.c1
-rw-r--r--src/ft_select_get.c2
6 files changed, 36 insertions, 1 deletions
diff --git a/inc/cub3d.h b/inc/cub3d.h
index f851f5e..39df1ea 100644
--- a/inc/cub3d.h
+++ b/inc/cub3d.h
@@ -93,6 +93,7 @@ int8_t ft_get_f_color(char **words, t_cub *clist);
int8_t ft_get_f_tex(char **words, t_cub *clist);
int8_t ft_get_c_color(char **words, t_cub *clist);
int8_t ft_get_c_tex(char **words, t_cub *clist);
+int8_t ft_get_darkness(char **words, t_cub *clist);
int8_t ft_get_path_nl(char **words, t_cub *clist);
int8_t ft_get_tex_nl(char **words, t_cub *clist);
int8_t ft_get_music(char **words, t_cub *clist);
diff --git a/inc/cub3d_defines.h b/inc/cub3d_defines.h
index 71c7baf..01b4ec9 100644
--- a/inc/cub3d_defines.h
+++ b/inc/cub3d_defines.h
@@ -138,6 +138,8 @@ enum
# define FT_ERR_ARGS "too many or to few arguments"
# define FT_ERR_RES_SMALL "resolution is too small, 50x50 minimum pls"
# define FT_ERR_RES_ALPHA "resolution should be digits only"
+# define FT_ERR_SH_ALPHA "shadow amount should be digits only"
+# define FT_ERR_SH_RANGE "shadow should be set between 0 - 10"
# define FT_ERR_NOT_A_CUB "given map is not a .cub"
# define FT_ERR_NOT_A_XPM "given texture is not a .xpm"
# define FT_ERR_NOT_A_WAV "given sound file is not a .wav"
diff --git a/map/map_three.cub b/map/map_three.cub
index 019f61e..9601c42 100644
--- a/map/map_three.cub
+++ b/map/map_three.cub
@@ -6,6 +6,7 @@ EA ./media/img/hey.xpm
WE ./media/img/left_arrow.xpm
S ./media/img/segfot.xpm
+SH 0
C 50,100,200
F 50,190,124
diff --git a/src/ft_get_darkness.c b/src/ft_get_darkness.c
index e9c3966..7f1bc00 100644
--- a/src/ft_get_darkness.c
+++ b/src/ft_get_darkness.c
@@ -10,10 +10,40 @@
/* */
/* ************************************************************************** */
+#include <libft.h>
#include <cub3d.h>
+static int8_t
+ ft_checkdigit(const char *word, t_cub *clist)
+{
+ size_t i;
+
+ i = 0;
+ while (ft_isdigit(word[i]))
+ i++;
+ if (i != ft_strlen(word))
+ {
+ ft_sprintf(clist->errmsg, FT_ERR_SH_ALPHA);
+ return (-1);
+ }
+ return (0);
+}
+
int8_t
ft_get_darkness(char **words, t_cub *clist)
{
+ if (!(*words) || !words[1] || words[2])
+ {
+ ft_sprintf(clist->errmsg, FT_ERR_ARGS);
+ return (-1);
+ }
+ if (ft_checkdigit(words[1], clist))
+ return (-1);
+ if (ft_atoi(words[1]) < 0 || ft_atoi(words[1]) > 10)
+ {
+ ft_sprintf(clist->errmsg, FT_ERR_SH_RANGE);
+ return (-1);
+ }
+ clist->mlist.darklvl = ft_atoi(words[1]);
return (0);
}
diff --git a/src/ft_init_map.c b/src/ft_init_map.c
index 3daa3b7..68a3b6d 100644
--- a/src/ft_init_map.c
+++ b/src/ft_init_map.c
@@ -58,6 +58,7 @@ int8_t
mlist->isctex = 0;
mlist->isnlvl = 0;
mlist->ismusic = 0;
+ mlist->darklvl = 0;
mlist->scale = 0;
mlist->nlx = 0;
mlist->nly = 0;
diff --git a/src/ft_select_get.c b/src/ft_select_get.c
index 64ba14b..2ed439c 100644
--- a/src/ft_select_get.c
+++ b/src/ft_select_get.c
@@ -80,7 +80,7 @@ static int8_t
ret = 0;
while (ft_strncmp(words[0], ref[ret], 3) && ref[ret][0])
ret++;
- if (ret == 11)
+ if (ret == 12)
ret = FT_PARSE_END_RET;
ret = ft_check_exists(ret, clist);
ret = ft_check_exists_two(ret, clist);