diff options
-rw-r--r-- | inc/cub3d_defines.h | 6 | ||||
-rw-r--r-- | src/ft_parse_map.c | 10 | ||||
-rw-r--r-- | src/ft_select_get.c | 16 |
3 files changed, 20 insertions, 12 deletions
diff --git a/inc/cub3d_defines.h b/inc/cub3d_defines.h index 30d497e..71c7baf 100644 --- a/inc/cub3d_defines.h +++ b/inc/cub3d_defines.h @@ -182,4 +182,10 @@ enum # define FT_ERR_MISS_CEIL_C "ceiling color" # define FT_ERR_MISS_PLAYER_SPAWN "player spawn" +/* +** ====== OTHER ====== +*/ + +# define FT_PARSE_END_RET 25 + # endif diff --git a/src/ft_parse_map.c b/src/ft_parse_map.c index 9c688fe..a93cca3 100644 --- a/src/ft_parse_map.c +++ b/src/ft_parse_map.c @@ -64,12 +64,14 @@ static int8_t return (ft_parse_it(fd, clist)); } if (ft_ischarset("1 ", line[0])) - return ((ft_get_map_first_line(line, clist) < 0) ? (-1) : (12)); + return ((ft_get_map_first_line(line, clist) < 0) ? + (-1) : (FT_PARSE_END_RET)); if (!ft_ischarset(FT_CHRST_VALID_PARSE, line[0]) || !(words = ft_split(line, ' '))) return (ft_error_here(FT_ERR_ILL_ENTRY, line, clist)); - if ((ret = ft_select_get(words, clist)) == 12) - return ((ft_get_map_first_line(line, clist) < 0) ? (-1) : (12)); + if ((ret = ft_select_get(words, clist)) == FT_PARSE_END_RET) + return ((ft_get_map_first_line(line, clist) < 0) ? + (-1) : (FT_PARSE_END_RET)); ft_memdel((void**)&line); return (ret); } @@ -97,7 +99,7 @@ void ft_error(FT_RET_NO_MAP, FT_ERR_NO_MAP, clist); ft_save_name(map_path, clist); ret = 1; - while (ret != 25 && ret >= 0) + while (ret != FT_PARSE_END_RET && ret >= 0) ret = ft_parse_it(fd, clist); (ret == -2) ? (ft_map_error(FT_ERR_ALR_SET, clist)) : 0; (ret == -1) ? (ft_map_error(clist->errmsg, clist)) : 0; diff --git a/src/ft_select_get.c b/src/ft_select_get.c index 96ed6e7..f4673c0 100644 --- a/src/ft_select_get.c +++ b/src/ft_select_get.c @@ -18,8 +18,8 @@ static int8_t ft_check_exists(const int8_t ret, t_cub *clist) { - if (ret == 25) - return (25); + if (ret == FT_PARSE_END_RET) + return (FT_PARSE_END_RET); if (ret == 0 && clist->currlvl == 0 && (clist->wlist.x_size != 0 || clist->wlist.y_size != 0)) return (-1); @@ -45,8 +45,8 @@ static int8_t static int8_t ft_check_exists_two(const int8_t ret, t_cub *clist) { - if (ret == 25) - return (25); + if (ret == FT_PARSE_END_RET) + return (FT_PARSE_END_RET); if (ret == 8 && (clist->mlist.nlevel_path[0])) return (-1); if (ret == 9 && (clist->mlist.nl_tex_path[0])) @@ -75,12 +75,12 @@ static int8_t ft_sprintf(ref[10], "MU"); ft_bzero(ref[11], 3); if (words[0][0] == ' ' || words[0][0] == '1') - return (12); + return (FT_PARSE_END_RET); ret = 0; while (ft_strncmp(words[0], ref[ret], 3) && ref[ret][0]) ret++; if (ret == 11) - ret = 25; + ret = FT_PARSE_END_RET; ret = ft_check_exists(ret, clist); ret = ft_check_exists_two(ret, clist); return (ret); @@ -91,10 +91,10 @@ int8_t { int8_t id; - if ((id = ft_get_id(words, clist)) == 25) + if ((id = ft_get_id(words, clist)) == FT_PARSE_END_RET) { ft_free_words(words); - return (25); + return (FT_PARSE_END_RET); } if (id < 0 || clist->get_ptr[id](words, clist) < 0) { |