aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJozanLeClerc <bousset.rudy@gmail.com>2020-03-16 19:05:52 +0100
committerJozanLeClerc <bousset.rudy@gmail.com>2020-03-16 19:05:52 +0100
commit192f2260f196914e0db07d4695dc85a859f24e26 (patch)
tree58f343a5dd6161da601bf8ccae05acc0782c2e9b
parentin progress (diff)
download42-cub3d-192f2260f196914e0db07d4695dc85a859f24e26.tar.gz
42-cub3d-192f2260f196914e0db07d4695dc85a859f24e26.tar.bz2
42-cub3d-192f2260f196914e0db07d4695dc85a859f24e26.tar.xz
42-cub3d-192f2260f196914e0db07d4695dc85a859f24e26.tar.zst
42-cub3d-192f2260f196914e0db07d4695dc85a859f24e26.zip
Still searching
-rw-r--r--inc/cub3d.h2
-rw-r--r--src/ft_exit.c1
-rw-r--r--src/ft_get_sprite_spawns.c5
-rw-r--r--src/ft_init_lists.c2
-rw-r--r--src/ft_init_sprites.c15
-rw-r--r--src/ft_warp_level.c7
6 files changed, 14 insertions, 18 deletions
diff --git a/inc/cub3d.h b/inc/cub3d.h
index b524b9a..6ca6f8b 100644
--- a/inc/cub3d.h
+++ b/inc/cub3d.h
@@ -35,7 +35,7 @@ t_bmp_file ft_init_bmp(void);
t_bmp_info ft_init_bmp_info(void);
t_rgb ft_hex_to_og_rgb(uint32_t color);
int8_t ft_init_sfx(t_sfx *sfx);
-t_sprite **ft_init_sprites(void);
+int8_t ft_init_sprites(t_sprite ***sprites);
/*
** ====== HOOKS ======
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);