From bfa1f4e6e61152ba3ff555d1508f43f0a5ab2754 Mon Sep 17 00:00:00 2001 From: JozanLeClerc Date: Wed, 11 Mar 2020 09:50:36 +0100 Subject: Secured collision segv --- src/ft_key_loop.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src/ft_key_loop.c') diff --git a/src/ft_key_loop.c b/src/ft_key_loop.c index d3e871b..c68b228 100644 --- a/src/ft_key_loop.c +++ b/src/ft_key_loop.c @@ -26,7 +26,7 @@ static uint64_t return (pl->pos_x - (pl->dir_y * FT_COLL_MULT)); else if (key == 3) return (pl->pos_x - (pl->dir_x * (FT_COLL_MULT / 2))); - return (1); + return ((uint64_t)pl->pos_x); } static uint64_t @@ -40,9 +40,10 @@ static uint64_t return (pl->pos_y - (pl->dir_x * FT_COLL_MULT)); else if (key == 3) return (pl->pos_y + (pl->dir_y * (FT_COLL_MULT / 2))); - return (1); + return ((uint64_t)pl->pos_y); } +#include static void ft_collision(float old_y, float old_x, int32_t key, t_cub *cl) { @@ -75,8 +76,12 @@ int ft_collision(old_y, old_x, cl->key_input[i], cl); if (cl->mlist.isnlvl) { - if (ft_warp_level(cl) < 0) - return (ft_exit(FT_RET_FAILED_STRUCTS, cl)); + if ((uint32_t)cl->plist.pos_x == cl->mlist.nlx && + (uint32_t)cl->plist.pos_y == cl->mlist.nly) + { + return ((ft_warp_level(cl) < 0) ? + (ft_exit(FT_RET_FAILED_STRUCTS, cl)) : (0)); + } } i++; } -- cgit v1.2.3