diff options
author | Rudy Bousset <rbousset@z2r5p2.le-101.fr> | 2020-02-28 18:55:45 +0100 |
---|---|---|
committer | Rudy Bousset <rbousset@z2r5p2.le-101.fr> | 2020-02-28 18:55:45 +0100 |
commit | cbb47afbbcc9b42f3094df620bbc0ef02aa7f3d2 (patch) | |
tree | 1e0aa232748e071c10779ed7dbf641178d85664e /src | |
parent | In progress (diff) | |
download | 42-cub3d-cbb47afbbcc9b42f3094df620bbc0ef02aa7f3d2.tar.gz 42-cub3d-cbb47afbbcc9b42f3094df620bbc0ef02aa7f3d2.tar.bz2 42-cub3d-cbb47afbbcc9b42f3094df620bbc0ef02aa7f3d2.tar.xz 42-cub3d-cbb47afbbcc9b42f3094df620bbc0ef02aa7f3d2.tar.zst 42-cub3d-cbb47afbbcc9b42f3094df620bbc0ef02aa7f3d2.zip |
Parsed
Diffstat (limited to 'src')
-rw-r--r-- | src/ft_check_map_line.c | 9 | ||||
-rw-r--r-- | src/ft_get_nlvl_pos.c | 26 | ||||
-rw-r--r-- | src/ft_get_path_nl.c | 1 | ||||
-rw-r--r-- | src/ft_get_tex_nl.c | 1 | ||||
-rw-r--r-- | src/ft_init_map.c | 3 | ||||
-rw-r--r-- | src/ft_parse_map.c | 3 | ||||
-rw-r--r-- | src/ft_select_get.c | 24 |
7 files changed, 61 insertions, 6 deletions
diff --git a/src/ft_check_map_line.c b/src/ft_check_map_line.c index 017d63a..184e489 100644 --- a/src/ft_check_map_line.c +++ b/src/ft_check_map_line.c @@ -18,7 +18,7 @@ static int8_t ft_first_checks(char *line, size_t i, t_cub *clist) { - if (!ft_ischarset("012NSEW ", line[i])) + if (!ft_ischarset("012NSEWL ", line[i])) { ft_sprintf(clist->errmsg, "%s", FT_ERR_ILL_MAP); return (-1); @@ -30,6 +30,13 @@ static int8_t ft_sprintf(clist->errmsg, "%s", FT_ERR_MULT_SPAWN); return (-1); } + if (line[i] == 'L') + clist->mlist->isnlvl += 1; + if (clist->mlist->isnlvl > 1) + { + ft_sprintf(clist->errmsg, "%s", FT_ERR_MULT_NLVL); + return (-1); + } return (0); } diff --git a/src/ft_get_nlvl_pos.c b/src/ft_get_nlvl_pos.c new file mode 100644 index 0000000..069b226 --- /dev/null +++ b/src/ft_get_nlvl_pos.c @@ -0,0 +1,26 @@ +#include <cub3d.h> + +void + ft_get_nlvl_pos(t_map *ml) +{ + size_t x; + size_t y; + + x = 1; + y = 1; + while (ml->map[y]) + { + while (ml->map[y][x]) + { + if (ml->map[y][x] == 'L') + { + ml->nlx = x; + ml->nly = y; + return ; + } + x++; + } + x = 1; + y++; + } +} diff --git a/src/ft_get_path_nl.c b/src/ft_get_path_nl.c index 0b5e987..7227f63 100644 --- a/src/ft_get_path_nl.c +++ b/src/ft_get_path_nl.c @@ -10,6 +10,7 @@ /* */ /* ************************************************************************** */ +#include <libft.h> #include <cub3d.h> #include <stdint.h> diff --git a/src/ft_get_tex_nl.c b/src/ft_get_tex_nl.c index e1ee5ce..77a309a 100644 --- a/src/ft_get_tex_nl.c +++ b/src/ft_get_tex_nl.c @@ -10,6 +10,7 @@ /* */ /* ************************************************************************** */ +#include <libft.h> #include <cub3d.h> #include <stdint.h> diff --git a/src/ft_init_map.c b/src/ft_init_map.c index 0eb2ab2..eac9366 100644 --- a/src/ft_init_map.c +++ b/src/ft_init_map.c @@ -23,6 +23,7 @@ static int8_t !(mlist->ea_tex_path = (char*)ft_calloc(1, sizeof(char))) || !(mlist->we_tex_path = (char*)ft_calloc(1, sizeof(char))) || !(mlist->sprite_path = (char*)ft_calloc(1, sizeof(char))) || + !(mlist->nl_tex_path = (char*)ft_calloc(1, sizeof(char))) || !(mlist->nlevel_path = (char*)ft_calloc(1, sizeof(char))) || !(mlist->mapl = (char*)ft_calloc(1, sizeof(char))) || !(mlist->map = (char**)ft_calloc(2, sizeof(char*))) || @@ -50,5 +51,7 @@ t_map mlist->isspawn = 0; mlist->isnlvl = 0; mlist->scale = 0; + mlist->nlx = 0; + mlist->nly = 0; return (mlist); } diff --git a/src/ft_parse_map.c b/src/ft_parse_map.c index 0dfb779..2b5265d 100644 --- a/src/ft_parse_map.c +++ b/src/ft_parse_map.c @@ -61,7 +61,7 @@ static int8_t ft_memdel((void**)&line); return (ft_parse_it(fd, clist)); } - if (!ft_ischarset("RNSEWFC1\0", line[0]) + if (!ft_ischarset("RNSEWFCL1\0", line[0]) || !(words = ft_split(line, ' '))) return (ft_error_here(FT_ERR_ILL_ENTRY, line, clist)); if ((ret = ft_select_get(words, clist)) == 12) @@ -98,6 +98,7 @@ void ft_map_error(clist->errmsg, clist); ft_check_map_last_line(clist); ft_get_player_spawn(clist->plist, clist); + ft_get_nlvl_pos(clist->mlist); ft_check_missing(clist); ft_set_minimap_scale(clist); close(fd); diff --git a/src/ft_select_get.c b/src/ft_select_get.c index b5df1bc..4ec1a45 100644 --- a/src/ft_select_get.c +++ b/src/ft_select_get.c @@ -42,10 +42,22 @@ static int8_t } static int8_t + ft_check_exists_two(const int8_t ret, t_cub *clist) +{ + if (ret == 12) + return (12); + if (ret == 8 && (clist->mlist->nlevel_path[0])) + return (-1); + if (ret == 9 && (clist->mlist->nl_tex_path[0])) + return (-1); + return (ret); +} + +static int8_t ft_get_id(char **words, t_cub *clist) { int8_t ret; - char ref[9][3]; + char ref[11][3]; ft_memcpy(ref[0], "R\0", 3); ft_memcpy(ref[1], "NO", 3); @@ -55,13 +67,17 @@ static int8_t ft_memcpy(ref[5], "S\0", 3); ft_memcpy(ref[6], "F\0", 3); ft_memcpy(ref[7], "C\0", 3); - ft_memcpy(ref[8], "", 1); + ft_memcpy(ref[8], "L\0", 3); + ft_memcpy(ref[9], "LT\0", 3); + ft_memcpy(ref[10], "", 1); ret = 0; while (ft_strncmp(words[0], ref[ret], 3) && ref[ret][0]) ret++; - if (ret == 8) + if (ret == 10) ret = 12; - return (ret = ft_check_exists(ret, clist)); + ret = ft_check_exists(ret, clist); + ret = ft_check_exists_two(ret, clist); + return (ret); } int8_t |