From d78e358b82d9a83edc07bc68bfc1e2fd238f2a89 Mon Sep 17 00:00:00 2001 From: Theo Champion Date: Wed, 8 Oct 2025 12:54:20 +0200 Subject: [PATCH 1/4] fix: Fixed makefile not building mlx --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index fd902ba..06111ad 100644 --- a/Makefile +++ b/Makefile @@ -55,7 +55,7 @@ all: $(OBJECTS) $(NAME) -include $(DEPS) $(NAME): $(OBJECTS) - if [[ "$$(echo $$LD_LIBRARY_PATH | grep -c minilibx)" == "0" ]]; then $(MAKE) CC=cc -C mlx/; fi + +$(MAKE) CC=cc -C mlx/ +$(MAKE) -C libft/ $(CC) $(CFLAGS) $(IFLAGS) $(OBJECTS) -o $(NAME) -Llibft -Lmlx -lft -lmlx -lz -lXext -lX11 -lm From 5d1f915a77fc35f73b88cea4f066448ead324ced Mon Sep 17 00:00:00 2001 From: Theo Champion Date: Wed, 8 Oct 2025 13:14:58 +0200 Subject: [PATCH 2/4] chore: Moved maps and deleted some --- .../{good_maps => bad_maps}/othermap.cub | 0 ressources/good_maps/big_square.cub | 8 +++--- ressources/good_maps/mixed_textures.cub | 26 ------------------- ressources/good_maps/testmap_bonus.cub | 22 ---------------- ressources/good_maps/testmap_lot_zombies.cub | 22 ---------------- 5 files changed, 4 insertions(+), 74 deletions(-) rename ressources/{good_maps => bad_maps}/othermap.cub (100%) delete mode 100644 ressources/good_maps/mixed_textures.cub delete mode 100644 ressources/good_maps/testmap_bonus.cub delete mode 100644 ressources/good_maps/testmap_lot_zombies.cub diff --git a/ressources/good_maps/othermap.cub b/ressources/bad_maps/othermap.cub similarity index 100% rename from ressources/good_maps/othermap.cub rename to ressources/bad_maps/othermap.cub diff --git a/ressources/good_maps/big_square.cub b/ressources/good_maps/big_square.cub index 030724d..3190c39 100644 --- a/ressources/good_maps/big_square.cub +++ b/ressources/good_maps/big_square.cub @@ -1,7 +1,7 @@ -NO ./path_to_the_north_texture -SO ./path_to_the_south_texture -WE ./path_to_the_west_texture -EA ./path_to_the_east_texture +NO ressources/north.xpm +SO ressources/north.xpm +WE ressources/north.xpm +EA ressources/north.xpm F 220,100,0 C 225,30,0 diff --git a/ressources/good_maps/mixed_textures.cub b/ressources/good_maps/mixed_textures.cub deleted file mode 100644 index ef9de0b..0000000 --- a/ressources/good_maps/mixed_textures.cub +++ /dev/null @@ -1,26 +0,0 @@ -SO ./path_to_the_south_texture - - - -F 220,100,0 -WE ./path_to_the_west_texture - -C 225,30,0 -NO ./path_to_the_north_texture - -EA ./path_to_the_east_texture - - 1111111111111111111111111 - 1000000000110000000000001 - 1011000001110000000000001 - 1001000000000000000000001 -111111111011000001110000000000001 -100000000011000001110111110111111 -11110111111111011100000010001 -11110111111111011101010010001 -11000000110101011100000010001 -10000000000000001100000010001 -10000000000000001101010010001 -11000001110101011111011110N0111 -11110111 1110101 101111010001 -11111111 1111111 111111111111 diff --git a/ressources/good_maps/testmap_bonus.cub b/ressources/good_maps/testmap_bonus.cub deleted file mode 100644 index d30e41e..0000000 --- a/ressources/good_maps/testmap_bonus.cub +++ /dev/null @@ -1,22 +0,0 @@ -NO ./path_to_the_north_texture -SO ./path_to_the_south_texture -WE ./path_to_the_west_texture -EA ./path_to_the_east_texture - -F 220,100,0 -C 225,30,0 - - 1111111111111111111111111 - 100000000011000Z000000001 - 1011000001110000000000001 - 1001000000d00000000000001 -111111111011000001110000000000001 -10000000001100000111011111D111111 -11110111111111011100000010001 -11110111111111011101010010001 -110000001101010111M0000010001 -10000000s00000001100000010001 -10000000000000001101010010001 -11000001110101011111011110N01 -11110111 1110101 101111010001 -11111111 1111111 111111111111 diff --git a/ressources/good_maps/testmap_lot_zombies.cub b/ressources/good_maps/testmap_lot_zombies.cub deleted file mode 100644 index b993710..0000000 --- a/ressources/good_maps/testmap_lot_zombies.cub +++ /dev/null @@ -1,22 +0,0 @@ -NO ressources/north.xpm -SO ressources/south.xpm -WE ressources/west.xpm -EA ressources/east.xpm - -F 220,100,0 -C 225,30,0 - - 1111111111111111111111111 - 1000000000110zzzzzz000001 - 101100000111zzzzzzz000001 - 10D100000000zzzzzzz000001 -11111111101100000111zMzzzzz000001 -100000000011000001110111110111111 -11110111111111011100000010001 -11110111111111011101010010001 -11000000110101011100000010001 -100000000000000011J0000010001 -10000000000000001101010010001 -11Q00001110101011111011110N0111 -11110111 1110101 101111010001 -11111111 1111111 111111111111 From ae66d62f750fb52ead83a09d8f14d462b2f9a2a8 Mon Sep 17 00:00:00 2001 From: Theo Champion Date: Wed, 8 Oct 2025 13:15:17 +0200 Subject: [PATCH 3/4] fix: Fixed bad binary name --- test_badmaps.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test_badmaps.sh b/test_badmaps.sh index 118f5fa..ec1a46c 100755 --- a/test_badmaps.sh +++ b/test_badmaps.sh @@ -2,5 +2,5 @@ for i in ./ressources/bad_maps/*; do printf "testing $i...\n" - ./cub3d $i && printf "$i...\tFAILED (did not detect expected error)\n" || printf "$i...\tPASSED\n" + ./cub3D $i && printf "$i...\tFAILED (did not detect expected error)\n" || printf "$i...\tPASSED\n" done From 6957e843348c5a923d8ea0762c0401641d7ed879 Mon Sep 17 00:00:00 2001 From: Theo Champion Date: Wed, 8 Oct 2025 13:15:32 +0200 Subject: [PATCH 4/4] fix: Fixed undefined behaviors --- src/sprites/sprite_caster.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/sprites/sprite_caster.c b/src/sprites/sprite_caster.c index d327842..edd3648 100644 --- a/src/sprites/sprite_caster.c +++ b/src/sprites/sprite_caster.c @@ -22,6 +22,8 @@ static void calculate_pos_and_transform(t_cub3d_data *data, t_sprite *sprite, int i) { + double tmp; + sprite->sprite_pos_x = data->sprite_list[data->sprite_order[i]]->x - data->player.x; sprite->sprite_pos_y = data->sprite_list[data->sprite_order[i]]->y @@ -33,24 +35,31 @@ static void calculate_pos_and_transform(t_cub3d_data *data, t_sprite *sprite, sprite->transform_y = sprite->inv_det * (-data->player.plane_y * sprite->sprite_pos_x + data->player.plane_x * sprite->sprite_pos_y); - sprite->sprite_screen_x = (int)((WIDTH / 2) + tmp = ((WIDTH / 2) * (1 + sprite->transform_x / sprite->transform_y)); + if (tmp < INFINITY && tmp > -INFINITY) + sprite->sprite_screen_x = (int)tmp; } static void sprite_calculate_pos_and_dist(t_cub3d_data *data, int i) { t_sprite *sprite; + double tmp; sprite = data->sprite_list[i]; calculate_pos_and_transform(data, sprite, i); - sprite->sprite_height = (int)fabs((HEIGHT / sprite->transform_y)); + tmp = fabs((HEIGHT / sprite->transform_y)); + if (tmp < INFINITY && tmp > -INFINITY) + sprite->sprite_height = (int)tmp; sprite->sprite_draw_start_y = -sprite->sprite_height / 2 + HEIGHT / 2; if (sprite->sprite_draw_start_y < 0) sprite->sprite_draw_start_y = 0; sprite->sprite_draw_end_y = sprite->sprite_height / 2 + HEIGHT / 2; if (sprite->sprite_draw_end_y >= HEIGHT) sprite->sprite_draw_end_y = HEIGHT - 1; - sprite->sprite_width = (int)fabs((HEIGHT / sprite->transform_y)); + tmp = fabs((HEIGHT / sprite->transform_y)); + if (tmp < INFINITY && tmp > -INFINITY) + sprite->sprite_width = (int)tmp; sprite->sprite_draw_start_x = -sprite->sprite_width / 2 + sprite->sprite_screen_x; if (sprite->sprite_draw_start_x < 0)