mirror of
https://codeberg.org/ACME-Corporation/cub3d.git
synced 2025-12-06 01:48:08 +01:00
started to create verification
This commit is contained in:
parent
6669bad8fe
commit
506386e190
1 changed files with 36 additions and 4 deletions
40
src/main.c
40
src/main.c
|
|
@ -3,15 +3,19 @@
|
||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* main.c :+: :+: :+: */
|
/* main.c :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: freddy </var/spool/mail/freddy> +#+ +:+ +#+ */
|
/* By: tchampio <tchampio@student.42lehavre. +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/05/05 16:59:32 by freddy #+# #+# */
|
/* Created: 2025/05/06 13:16:11 by tchampio #+# #+# */
|
||||||
/* Updated: 2025/05/06 09:54:39 by freddy ### ########.fr */
|
/* Updated: 2025/05/06 13:16:18 by tchampio ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "../includes/libft.h"
|
#include "../includes/libft.h"
|
||||||
#include "../includes/mlx.h"
|
#include "../includes/mlx.h"
|
||||||
|
#include "../includes/filecheck.h"
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
|
||||||
typedef struct s_mlx_data
|
typedef struct s_mlx_data
|
||||||
{
|
{
|
||||||
|
|
@ -22,6 +26,13 @@ typedef struct s_mlx_data
|
||||||
int endian;
|
int endian;
|
||||||
} t_mlx_data;
|
} t_mlx_data;
|
||||||
|
|
||||||
|
typedef struct s_mapdata
|
||||||
|
{
|
||||||
|
char *filename;
|
||||||
|
bool isvalid;
|
||||||
|
char error[1024];
|
||||||
|
} t_mapdata;
|
||||||
|
|
||||||
void my_mlx_pixel_put(t_mlx_data *data, int x, int y, int color)
|
void my_mlx_pixel_put(t_mlx_data *data, int x, int y, int color)
|
||||||
{
|
{
|
||||||
char *dst;
|
char *dst;
|
||||||
|
|
@ -30,15 +41,36 @@ void my_mlx_pixel_put(t_mlx_data *data, int x, int y, int color)
|
||||||
*(unsigned int*)dst = color;
|
*(unsigned int*)dst = color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool check_filename(char *file)
|
||||||
|
{
|
||||||
|
(void)file;
|
||||||
|
return (false);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool check_cubfile(char *file, t_mapdata *map)
|
||||||
|
{
|
||||||
|
int fd;
|
||||||
|
|
||||||
|
fd = open(file, O_RDONLY);
|
||||||
|
if (fd < 0)
|
||||||
|
return (ft_strlcpy(map->error, "Can't open file", 16), false);
|
||||||
|
if (!check_filename(file))
|
||||||
|
return (ft_strlcpy(map->error, "File is not a .cub file", 25), false);
|
||||||
|
close(fd);
|
||||||
|
return (true);
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
void *mlx;
|
void *mlx;
|
||||||
void *mlx_win;
|
void *mlx_win;
|
||||||
t_mlx_data data;
|
t_mlx_data data;
|
||||||
|
t_mapdata map;
|
||||||
|
|
||||||
if (argc < 2)
|
if (argc < 2)
|
||||||
return (ft_printf("Error: Missing cub3d filename\n"), 1);
|
return (ft_printf("Error: Missing cub3d filename\n"), 1);
|
||||||
(void)argv;
|
if (!check_cubfile(argv[1], &map))
|
||||||
|
return (ft_printf("Error: Wrong map file. Reason: %s\n", map.error), 1);
|
||||||
mlx = mlx_init();
|
mlx = mlx_init();
|
||||||
mlx_win = mlx_new_window(mlx, 800, 600, "Cub3d");
|
mlx_win = mlx_new_window(mlx, 800, 600, "Cub3d");
|
||||||
data.img = mlx_new_image(mlx, 800, 600);
|
data.img = mlx_new_image(mlx, 800, 600);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue