aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsalad <salad@saladesk.desktop>2020-03-25 16:06:10 +0100
committersalad <salad@saladesk.desktop>2020-03-25 16:06:10 +0100
commit0734c879193ef0cb9aaf7a8e38c198f6661de192 (patch)
tree3332c3b5d5241d0a32b6cd75f58feae88f30cdd2
parentj'aime trier (diff)
download42-cub3d-0734c879193ef0cb9aaf7a8e38c198f6661de192.tar.gz
42-cub3d-0734c879193ef0cb9aaf7a8e38c198f6661de192.tar.bz2
42-cub3d-0734c879193ef0cb9aaf7a8e38c198f6661de192.tar.xz
42-cub3d-0734c879193ef0cb9aaf7a8e38c198f6661de192.tar.zst
42-cub3d-0734c879193ef0cb9aaf7a8e38c198f6661de192.zip
norme, TODO: liks
-rw-r--r--inc/cub3d_structs.h2
-rw-r--r--src/ft_sort_s_t.c39
2 files changed, 18 insertions, 23 deletions
diff --git a/inc/cub3d_structs.h b/inc/cub3d_structs.h
index df3dade..bab7241 100644
--- a/inc/cub3d_structs.h
+++ b/inc/cub3d_structs.h
@@ -199,7 +199,7 @@ typedef struct s_map
uint8_t sprite_var;
uint8_t weapon_var;
int32_t sprite_order[8][4096];
- int32_t st_o[4096];
+ int32_t st_o[8];
int32_t traps_nbr;
int32_t heals_nbr;
int32_t weaps_nbr[3];
diff --git a/src/ft_sort_s_t.c b/src/ft_sort_s_t.c
index eaf866e..c1378c7 100644
--- a/src/ft_sort_s_t.c
+++ b/src/ft_sort_s_t.c
@@ -13,42 +13,37 @@
#include <libft.h>
#include <cub3d.h>
#include <stdint.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <math.h>
-
-/*divine*/
static void
- ft_init_st(uint16_t sprite_var, int32_t st_o[8])
+ ft_init_st(uint16_t sprite_var, int32_t st_o[8])
{
- int8_t i;
+ int8_t i;
- i = -1;
- while (++i < sprite_var)
- st_o[i] = i;
+ i = -1;
+ while (++i < sprite_var)
+ st_o[i] = i;
}
void
- ft_sort_s_t(t_cub *cl, float dist_tab[8][4096])
+ ft_sort_s_t(t_cub *cl, float dist_tab[8][4096])
{
int16_t i;
int32_t tmp;
float *tmp_i;
i = -1;
- if (!(tmp_i = ft_calloc(sizeof(int32_t), 4096)))
- return ;
- ft_init_st(cl->mlist.sprite_var, cl->mlist.st_o);
+ if (!(tmp_i = ft_calloc(sizeof(int32_t), 4096)))
+ return ;
+ ft_init_st(cl->mlist.sprite_var, cl->mlist.st_o);
while (++i < cl->mlist.sprite_var)
if (dist_tab[i][0] < dist_tab[i + 1][0])
- {
- tmp = cl->mlist.st_o[i];
- cl->mlist.st_o[i] = cl->mlist.st_o[i + 1];
- cl->mlist.st_o[i + 1] = tmp;
- ft_memcpy(tmp_i, dist_tab[i], 4096);
- ft_memcpy(dist_tab[i], dist_tab[i + 1], 4096);
- ft_memcpy(dist_tab[i + 1], tmp_i, 4096);
- i = -1;
+ {
+ tmp = cl->mlist.st_o[i];
+ cl->mlist.st_o[i] = cl->mlist.st_o[i + 1];
+ cl->mlist.st_o[i + 1] = tmp;
+ ft_memcpy(tmp_i, dist_tab[i], 4096);
+ ft_memcpy(dist_tab[i], dist_tab[i + 1], 4096);
+ ft_memcpy(dist_tab[i + 1], tmp_i, 4096);
+ i = -1;
}
}