diff options
Diffstat (limited to 'src/ft_warp_level.c')
-rw-r--r-- | src/ft_warp_level.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/ft_warp_level.c b/src/ft_warp_level.c new file mode 100644 index 0000000..03302bd --- /dev/null +++ b/src/ft_warp_level.c @@ -0,0 +1,40 @@ +#include <libft.h> +#include <cub3d.h> +#include <stdlib.h> +#include <stdint.h> + +static void + ft_del_map(t_map *ml) +{ + ft_memdel((void**)&ml->no_tex_path); + ft_memdel((void**)&ml->so_tex_path); + ft_memdel((void**)&ml->ea_tex_path); + ft_memdel((void**)&ml->we_tex_path); + ft_memdel((void**)&ml->sprite_path); + ft_memdel((void**)&ml->nl_tex_path); + ft_memdel((void**)&ml->nlevel_path); + ft_memdel((void**)&ml->mapl); + ft_free_words(ml->map); + ft_memdel((void**)&ml); +} + +int8_t + ft_warp_level(t_cub *cl) +{ + char *next_path; + + if ((uint32_t)cl->plist->pos_x == cl->mlist->nlx + && (uint32_t)cl->plist->pos_y == cl->mlist->nly) + { + if (!(next_path = (char *)malloc + ((ft_strlen(cl->mlist->nlevel_path) + 1) * sizeof(char)))) + return (-1); + ft_sprintf(next_path, "%s", cl->mlist->nlevel_path); + ft_del_map(cl->mlist); + if (!(cl->mlist = ft_init_map())) + return (-1); + ft_parse_map(next_path, cl); + ft_memdel((void**)&next_path); + } + return (0); +} |