diff options
Diffstat (limited to 'src/ft_check_map_line.c')
-rw-r--r-- | src/ft_check_map_line.c | 35 |
1 files changed, 16 insertions, 19 deletions
diff --git a/src/ft_check_map_line.c b/src/ft_check_map_line.c index 1009aa3..7fa68b7 100644 --- a/src/ft_check_map_line.c +++ b/src/ft_check_map_line.c @@ -18,18 +18,23 @@ static int8_t ft_first_checks(char *line, size_t i, t_cub *clist) { - if (!ft_ischarset("012NSEW ", line[i])) + if (!ft_ischarset(FT_CHRST_MAP_ENTRY, line[i])) { - ft_strlcpy(clist->errmsg, FT_ERR_ILL_MAP, - ft_strlen(FT_ERR_ILL_MAP) + 1); + ft_sprintf(clist->errmsg, FT_ERR_ILL_MAP); return (-1); } - if (ft_ischarset("NSEW", line[i])) - clist->mlist->isspawn += 1; - if (clist->mlist->isspawn > 1) + if (ft_ischarset(FT_CHRST_SPAWN, line[i])) + clist->mlist.isspawn += 1; + if (clist->mlist.isspawn > 1) { - ft_strlcpy(clist->errmsg, FT_ERR_MULT_SPAWN, - ft_strlen(FT_ERR_MULT_SPAWN) + 1); + ft_sprintf(clist->errmsg, FT_ERR_MULT_SPAWN); + return (-1); + } + if (line[i] == 'L') + clist->mlist.isnlvl += 1; + if (clist->mlist.isnlvl > 1) + { + ft_sprintf(clist->errmsg, FT_ERR_MULT_NLVL); return (-1); } return (0); @@ -40,8 +45,7 @@ static int8_t { if (!ft_ischarset("1 ", line[i])) { - ft_strlcpy(clist->errmsg, FT_ERR_ILL_MAP, - ft_strlen(FT_ERR_ILL_MAP) + 1); + ft_sprintf(clist->errmsg, FT_ERR_MAP_WALLS); return (-1); } return (0); @@ -67,10 +71,9 @@ size_t static int8_t ft_check_side_walls(char *line, size_t i, t_cub *clist) { - if (line[0] != '1' || line[i - 1] != '1') + if ((line[0] != ' ' && line[0] != '1') || line[i - 1] != '1') { - ft_strlcpy(clist->errmsg, FT_ERR_ILL_ENTRY, - ft_strlen(FT_ERR_ILL_ENTRY) + 1); + ft_sprintf(clist->errmsg, FT_ERR_MAP_WALLS); return (-1); } return (0); @@ -97,11 +100,5 @@ int8_t } if (ft_check_side_walls(line, i, clist) < 0) return (-1); - if (ft_get_line_len(line) != clist->mlist->map_w) - { - ft_strlcpy(clist->errmsg, FT_ERR_MAP_LEN, - ft_strlen(FT_ERR_MAP_LEN) + 1); - return (-1); - } return (0); } |