diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/ft_exit.c | 1 | ||||
-rw-r--r-- | src/ft_get_sprite_spawns.c | 5 | ||||
-rw-r--r-- | src/ft_init_lists.c | 2 | ||||
-rw-r--r-- | src/ft_init_sprites.c | 15 | ||||
-rw-r--r-- | src/ft_warp_level.c | 7 |
5 files changed, 13 insertions, 17 deletions
diff --git a/src/ft_exit.c b/src/ft_exit.c index 4551e2f..6b1fb5e 100644 --- a/src/ft_exit.c +++ b/src/ft_exit.c @@ -120,7 +120,6 @@ int if (FT_OS == 1) mlx_destroy_image(clist->wlist.wlx, clist->img.img); mlx_destroy_window(clist->wlist.wlx, clist->wlist.winptr); - clist->wlist.winptr = NULL; } ft_kill_forks(clist); ft_free_lists(clist); diff --git a/src/ft_get_sprite_spawns.c b/src/ft_get_sprite_spawns.c index 3a44f56..da883b2 100644 --- a/src/ft_get_sprite_spawns.c +++ b/src/ft_get_sprite_spawns.c @@ -19,7 +19,7 @@ void ft_get_next_sprite(t_cub *clist, int s_n, char c, size_t x) { size_t y; - uint8_t i; + int16_t i; y = 0; i = 0; @@ -37,7 +37,8 @@ void } x = 0; } - if (clist->sprites[s_n][i - 1].s_pos_x != 0) + if (clist->sprites[s_n][(i - 1 < 0) ? (0) : (i - 1)].s_pos_x != 0 + && s_n + 1 < 7) { ft_get_next_sprite(clist, s_n + 1, c + 1, 0); } diff --git a/src/ft_init_lists.c b/src/ft_init_lists.c index fa862ae..1b12b7e 100644 --- a/src/ft_init_lists.c +++ b/src/ft_init_lists.c @@ -84,7 +84,7 @@ static int8_t cl->walltexgood = 0; ft_init_funptr(cl); ft_init_ref(cl); - if (!(cl->sprites = ft_init_sprites())) + if (ft_init_sprites(&cl->sprites) < 0) return (-1); return (0); } diff --git a/src/ft_init_sprites.c b/src/ft_init_sprites.c index f39a692..4fc9aed 100644 --- a/src/ft_init_sprites.c +++ b/src/ft_init_sprites.c @@ -16,20 +16,19 @@ #include <stdlib.h> #include <stdint.h> -t_sprite - **ft_init_sprites(void) +int8_t + ft_init_sprites(t_sprite ***sprites) { - t_sprite **sprites; uint8_t i; - if (!(sprites = (t_sprite**)ft_calloc(8, sizeof(t_sprite*)))) - return (NULL); + if (!(*sprites = (t_sprite**)ft_calloc(8, sizeof(t_sprite*)))) + return (-1); i = 0; while (i < 8) { - if (!(sprites[i] = (t_sprite*)ft_calloc(4096, sizeof(t_sprite)))) - return (NULL); + if (!(*((*sprites) + i) = (t_sprite*)ft_calloc(4096, sizeof(t_sprite)))) + return (-1); i++; } - return (sprites); + return (0); } diff --git a/src/ft_warp_level.c b/src/ft_warp_level.c index 7259275..130b33a 100644 --- a/src/ft_warp_level.c +++ b/src/ft_warp_level.c @@ -45,7 +45,7 @@ static void static void ft_del_some(t_cub *cl) { - uint8_t i; + int8_t i; cl->plist = ft_init_player(); cl->f_rgb = ft_init_rgb(); @@ -53,10 +53,7 @@ static void cl->rlist = ft_init_s_ray(); i = -1; while (++i < 5) - { mlx_destroy_image(cl->wlist.wlx, cl->tlist[i].img); - cl->tlist[i].ptr = NULL; - } if (cl->mlist.isnlvl && cl->tlist[5].img) mlx_destroy_image(cl->wlist.wlx, cl->tlist[5].img); if (cl->mlist.isftex && cl->tlist[6].img) @@ -107,7 +104,7 @@ int8_t tmp_mup = ft_strdup(cl->mlist.music_path); ft_del_some(cl); ft_del_map(&cl->mlist); - if (!(cl->sprites = ft_init_sprites())) + if (ft_init_sprites(&cl->sprites) < 0) return (-1); if (ft_init_map(&cl->mlist) < 0) return (-1); |