a la norme et sans leaks
This commit is contained in:
@@ -3,12 +3,10 @@
|
||||
|
||||
# include "../libft/includes/libft.h"
|
||||
# include <mlx.h>
|
||||
# include <unistd.h> // for sleep()
|
||||
# include <math.h> // for M_PI
|
||||
# include <stdio.h> // for printf()
|
||||
# include <fcntl.h> // for open
|
||||
|
||||
typedef struct s_fdf
|
||||
typedef struct s_fdf
|
||||
{
|
||||
void *mlx_ptr;
|
||||
void *win_ptr;
|
||||
@@ -40,22 +38,35 @@ typedef struct s_fdf
|
||||
int img_endian;
|
||||
} t_fdf;
|
||||
|
||||
// fdf.c
|
||||
int main(int ac, char **av);
|
||||
void init_fdf(t_fdf *fdf);
|
||||
void init_offset(t_fdf *fdf);
|
||||
void init_server(t_fdf *fdf);
|
||||
int print_keycode(int keycode);
|
||||
int shut_down(t_fdf *fdf);
|
||||
|
||||
// draw.c
|
||||
void draw_image(t_fdf *fdf);
|
||||
void draw_pixel(t_fdf *fdf, int x, int y, int color);
|
||||
void draw_color_pixel(t_fdf *fdf, int new_x, int new_y, int z);
|
||||
int keypress(int keycode, t_fdf *fdf);
|
||||
void keypress_more(int keycode, t_fdf *fdf);
|
||||
void position_state(t_fdf *fdf);
|
||||
int is_color(char *color);
|
||||
int **parse_map(t_fdf *fdf, int fd);
|
||||
int *new_coordinates(t_fdf *fdf, int i, int j);
|
||||
void draw_lines(t_fdf *fdf, int *start, int *end);
|
||||
void draw_grid(t_fdf *fdf, int i, int j);
|
||||
void draw_lines(t_fdf *fdf, int *start, int *end);
|
||||
void draw_color_pixel(t_fdf *fdf, int new_x, int new_y, int z);
|
||||
void draw_pixel(t_fdf *fdf, int x, int y, int color);
|
||||
|
||||
// keypress.c
|
||||
void keypress_more(int keycode, t_fdf *fdf);
|
||||
int keypress(int keycode, t_fdf *fdf);
|
||||
|
||||
// modifs.c
|
||||
int *new_coordinates(t_fdf *fdf, int i, int j);
|
||||
void position_state(t_fdf *fdf);
|
||||
int print_keycode(int keycode);
|
||||
|
||||
// parse.c
|
||||
void z_amplitude(t_fdf*fdf, int i);
|
||||
int **split_to_map(t_fdf *fdf, char *raw);
|
||||
int is_color(char *color);
|
||||
void size_map(t_fdf *fdf, char *raw, int height);
|
||||
int **parse_map(t_fdf *fdf, int fd);
|
||||
|
||||
# define ESCAPE 65307
|
||||
# define UP 65362
|
||||
|
||||
@@ -42,7 +42,7 @@ void init_server(t_fdf *fdf)
|
||||
void init_offset(t_fdf *fdf)
|
||||
{
|
||||
int diagonal;
|
||||
int x;
|
||||
int x;
|
||||
|
||||
x = (fdf->map_width) * (fdf->map_width);
|
||||
x += (fdf->map_height) * (fdf->map_height);
|
||||
@@ -77,7 +77,7 @@ void init_fdf(t_fdf *fdf)
|
||||
draw_image(fdf);
|
||||
}
|
||||
|
||||
int main(int ac, char **av)
|
||||
int main(int ac, char **av)
|
||||
{
|
||||
t_fdf *fdf;
|
||||
int fd;
|
||||
|
||||
@@ -69,4 +69,3 @@ int keypress(int keycode, t_fdf *fdf)
|
||||
draw_image(fdf);
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
@@ -73,4 +73,4 @@ void position_state(t_fdf *fdf)
|
||||
** ft_putchar(' ');
|
||||
** return (0);
|
||||
** }
|
||||
*/
|
||||
*/
|
||||
|
||||
22
srcs/parse.c
22
srcs/parse.c
@@ -14,8 +14,6 @@ int **split_to_map(t_fdf *fdf, char *raw)
|
||||
int j;
|
||||
int **map;
|
||||
|
||||
if (fdf->map_height == 0)
|
||||
shut_down(fdf);
|
||||
map = ft_calloc(fdf->map_height, sizeof(map));
|
||||
if (!map)
|
||||
shut_down(fdf);
|
||||
@@ -50,11 +48,13 @@ int is_color(char *color)
|
||||
return (i);
|
||||
}
|
||||
|
||||
int size_width(char *raw)
|
||||
void size_map(t_fdf *fdf, char *raw, int height)
|
||||
{
|
||||
int i;
|
||||
int j;
|
||||
|
||||
if (height == 0)
|
||||
shut_down(fdf);
|
||||
i = 0;
|
||||
while (raw[i] && raw[i] != '!')
|
||||
{
|
||||
@@ -67,7 +67,10 @@ int size_width(char *raw)
|
||||
i += is_color(raw + i);
|
||||
j++;
|
||||
}
|
||||
return (j);
|
||||
fdf->map_width = j;
|
||||
fdf->map_height = height;
|
||||
fdf->min_z = 0;
|
||||
fdf->max_z = 0;
|
||||
}
|
||||
|
||||
int **parse_map(t_fdf *fdf, int fd)
|
||||
@@ -76,6 +79,7 @@ int **parse_map(t_fdf *fdf, int fd)
|
||||
int ret;
|
||||
char *line;
|
||||
char *raw;
|
||||
int **map;
|
||||
|
||||
height = 0;
|
||||
ret = 1;
|
||||
@@ -91,9 +95,9 @@ int **parse_map(t_fdf *fdf, int fd)
|
||||
raw = ft_strjoinfree(raw, ft_strdup("!"));
|
||||
}
|
||||
}
|
||||
fdf->map_height = height;
|
||||
fdf->map_width = size_width(raw);
|
||||
fdf->min_z = 0;
|
||||
fdf->max_z = 0;
|
||||
return (split_to_map(fdf, raw));
|
||||
size_map(fdf, raw, height);
|
||||
map = split_to_map(fdf, raw);
|
||||
free(line);
|
||||
free(raw);
|
||||
return (map);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user