aboutsummaryrefslogtreecommitdiffstats
path: root/src/ft_exit.c
diff options
context:
space:
mode:
authorJozanLeClerc <bousset.rudy@gmail.com>2020-03-22 15:25:01 +0100
committerJozanLeClerc <bousset.rudy@gmail.com>2020-03-22 15:25:01 +0100
commitba7cbd8dbffac2b75ccac01d628ca493426ecf70 (patch)
treef2a09778ada9033522bf36206158c6130eb85365 /src/ft_exit.c
parentNormed so far (diff)
download42-cub3d-ba7cbd8dbffac2b75ccac01d628ca493426ecf70.tar.gz
42-cub3d-ba7cbd8dbffac2b75ccac01d628ca493426ecf70.tar.bz2
42-cub3d-ba7cbd8dbffac2b75ccac01d628ca493426ecf70.tar.xz
42-cub3d-ba7cbd8dbffac2b75ccac01d628ca493426ecf70.tar.zst
42-cub3d-ba7cbd8dbffac2b75ccac01d628ca493426ecf70.zip
Pretty bav
Diffstat (limited to 'src/ft_exit.c')
-rw-r--r--src/ft_exit.c99
1 files changed, 4 insertions, 95 deletions
diff --git a/src/ft_exit.c b/src/ft_exit.c
index 8bf79ce..2af15c7 100644
--- a/src/ft_exit.c
+++ b/src/ft_exit.c
@@ -19,34 +19,8 @@
#include <pthread.h>
static void
- ft_free_some_extras(t_cub *clist)
+ ft_del_last_remains(t_cub *clist)
{
- uint8_t i;
-
- i = 0;
- while (i < 8)
- {
- ft_memdel((void*)&clist->sprites[i]);
- i++;
- }
- ft_memdel((void*)&clist->sprites);
- if (clist->wlist.inited)
- {
- i = 0;
- while (i < 4)
- {
- if (clist->tweap[i].img)
- mlx_destroy_image(clist->wlist.wlx, clist->tweap[i].img);
- i++;
- }
- i = 0;
- while (i < 2)
- {
- if (clist->tlist[i + 18].img)
- mlx_destroy_image(clist->wlist.wlx, clist->tlist[i + 18].img);
- i++;
- }
- }
if (!clist->wlist.inited)
{
ft_memdel((void*)&clist->wlist.winptr);
@@ -56,72 +30,6 @@ static void
}
static void
- ft_free_lists(t_cub *clist)
-{
- uint8_t i;
-
- ft_memdel((void*)&clist->mlist.filename);
- ft_memdel((void*)&clist->mlist.no_tex_path);
- ft_memdel((void*)&clist->mlist.so_tex_path);
- ft_memdel((void*)&clist->mlist.ea_tex_path);
- ft_memdel((void*)&clist->mlist.we_tex_path);
- ft_memdel((void*)&clist->mlist.nl_tex_path);
- ft_memdel((void*)&clist->mlist.fl_tex_path);
- ft_memdel((void*)&clist->mlist.ce_tex_path);
- ft_memdel((void*)&clist->mlist.nlevel_path);
- ft_memdel((void*)&clist->mlist.skybox_path);
- ft_memdel((void*)&clist->mlist.traps_path);
- ft_memdel((void*)&clist->mlist.music_path);
- ft_memdel((void*)&clist->mlist.music_cmd);
- ft_memdel((void*)&clist->mlist.mapl);
- ft_free_words(clist->mlist.map);
- i = -1;
- while (++i < 10)
- ft_memdel((void*)&clist->sfx[i].cmd);
- ft_memdel((void*)&clist->sfx[1].cmd_alt);
- ft_memdel((void*)&clist->sfx[3].cmd_alt);
- ft_free_sprites(clist->mlist.sprite_path);
- i = -1;
- while (++i < 2)
- ft_memdel((void*)&clist->weaps[i]);
- ft_memdel((void*)&clist->weaps);
-}
-
-static void
- ft_del_tex(t_cub *clist)
-{
- int8_t i;
-
- if (clist->tlist[0].img)
- mlx_destroy_image(clist->wlist.wlx, clist->tlist[0].img);
- if (clist->tlist[1].img)
- mlx_destroy_image(clist->wlist.wlx, clist->tlist[1].img);
- if (clist->tlist[2].img)
- mlx_destroy_image(clist->wlist.wlx, clist->tlist[2].img);
- if (clist->tlist[3].img)
- mlx_destroy_image(clist->wlist.wlx, clist->tlist[3].img);
- if (clist->tlist[4].img)
- mlx_destroy_image(clist->wlist.wlx, clist->tlist[4].img);
- if (clist->mlist.isnlvl && clist->tlist[5].img)
- mlx_destroy_image(clist->wlist.wlx, clist->tlist[5].img);
- if (clist->mlist.isftex && clist->tlist[6].img)
- mlx_destroy_image(clist->wlist.wlx, clist->tlist[6].img);
- if (clist->mlist.isctex && clist->tlist[7].img)
- mlx_destroy_image(clist->wlist.wlx, clist->tlist[7].img);
- if (clist->mlist.istraps && clist->tlist[15].img)
- mlx_destroy_image(clist->wlist.wlx, clist->tlist[15].img);
- if (clist->tlist[16].img)
- mlx_destroy_image(clist->wlist.wlx, clist->tlist[16].img);
- if (clist->mlist.isheals && clist->tlist[17].img)
- mlx_destroy_image(clist->wlist.wlx, clist->tlist[17].img);
- i = -1;
- while (++i < 11)
- if (clist->tnum[i].img)
- mlx_destroy_image(clist->wlist.wlx, clist->tnum[i].img);
- ft_del_extra_sprites(clist);
-}
-
-static void
ft_cancel_threads(t_cub *clist)
{
uint8_t i;
@@ -152,8 +60,9 @@ int
mlx_destroy_window(clist->wlist.wlx, clist->wlist.winptr);
}
ft_cancel_threads(clist);
- ft_free_lists(clist);
- ft_free_some_extras(clist);
+ ft_del_map(&clist->mlist);
+ ft_del_lists(clist);
+ ft_del_last_remains(clist);
ft_printf("Exiting program\n");
exit(exit_code);
return (0);