aboutsummaryrefslogtreecommitdiffstats
path: root/src/ft_warp_level.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ft_warp_level.c')
-rw-r--r--src/ft_warp_level.c34
1 files changed, 13 insertions, 21 deletions
diff --git a/src/ft_warp_level.c b/src/ft_warp_level.c
index 8fb5415..88ab45d 100644
--- a/src/ft_warp_level.c
+++ b/src/ft_warp_level.c
@@ -12,11 +12,9 @@
#include <libft.h>
#include <cub3d.h>
-#include <mlx.h>
#include <stddef.h>
#include <stdlib.h>
#include <stdint.h>
-#include <unistd.h>
#include <signal.h>
#include <pthread.h>
@@ -39,24 +37,23 @@ static void
cl->plist.handles_weapon = tmp_handles;
}
-static void
- ft_del_some(t_cub *cl)
+static int8_t
+ ft_reinit_some(t_cub *cl)
{
- int8_t i;
-
ft_player_keepings(cl);
cl->f_rgb = ft_init_rgb();
cl->c_rgb = ft_init_rgb();
cl->rlist = ft_init_s_ray();
ft_del_tex(cl);
- i = -1;
- while (++i < 8)
- ft_memdel((void*)&cl->sprites[i]);
- ft_memdel((void*)&cl->sprites);
- i = -1;
- while (++i < 2)
- ft_memdel((void*)&cl->weaps[i]);
- ft_memdel((void*)&cl->weaps);
+ ft_del_map(&cl->mlist);
+ ft_del_sprites_lists(cl);
+ if (ft_init_sprites(&cl->sprites) < 0)
+ return (-1);
+ if (ft_init_weaps(&cl->weaps) < 0)
+ return (-1);
+ if (ft_init_map(&cl->mlist) < 0)
+ return (-1);
+ return (0);
}
static void
@@ -92,13 +89,7 @@ int8_t
ft_sprintf(next_path, "%s", path);
if ((isoldmus = cl->mlist.ismusic))
tmp_mup = ft_strdup(cl->mlist.music_path);
- ft_del_some(cl);
- ft_del_map(&cl->mlist);
- if (ft_init_sprites(&cl->sprites) < 0)
- return (-1);
- if (ft_init_weaps(&cl->weaps) < 0)
- return (-1);
- if (ft_init_map(&cl->mlist) < 0)
+ if (ft_reinit_some(cl) < 0)
return (-1);
ft_parse_map(next_path, cl);
ft_treat_music(isoldmus, tmp_mup, cl);
@@ -107,6 +98,7 @@ int8_t
ft_memdel((void*)&tmp_mup);
ft_wall_tex_init(cl);
ft_weap_tex_init(cl);
+ ft_num_tex_init(cl);
ft_memdel((void*)&next_path);
return (0);
}