v1 of parsing finished
This commit is contained in:
parent
d586acba8f
commit
8211ff19ea
9 changed files with 121 additions and 37 deletions
|
|
@ -6,7 +6,7 @@
|
|||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/10/31 11:09:00 by rparodi #+# #+# */
|
||||
/* Updated: 2024/11/18 11:31:05 by bgoulard ### ########.fr */
|
||||
/* Updated: 2024/11/27 12:00:34 by bgoulard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -37,10 +37,10 @@ void c3_perror(t_info *info)
|
|||
{
|
||||
if (info->last_error == NO_ERROR)
|
||||
return ;
|
||||
print_error(g_error_message[info->last_error]);
|
||||
print_error(g_error_message[info->last_error], info->errno_state);
|
||||
}
|
||||
|
||||
void print_error(const char *msg)
|
||||
void print_error(const char *msg, int state)
|
||||
{
|
||||
ft_putstr_fd(BOLD_RED, STDERR_FILENO);
|
||||
ft_putstr_fd("Error:\n", STDERR_FILENO);
|
||||
|
|
@ -48,5 +48,13 @@ void print_error(const char *msg)
|
|||
ft_putstr_fd(RED, STDERR_FILENO);
|
||||
ft_putstr_fd(msg, STDERR_FILENO);
|
||||
ft_putstr_fd(RESET, STDERR_FILENO);
|
||||
if (state != 0)
|
||||
{
|
||||
ft_putstr_fd(YELLOW, STDERR_FILENO);
|
||||
ft_putstr_fd(" due to:\n", STDERR_FILENO);
|
||||
ft_putstr_fd(BOLD_YELLOW, STDERR_FILENO);
|
||||
ft_putstr_fd(ft_strerror(state), STDERR_FILENO);
|
||||
ft_putstr_fd(RESET, STDERR_FILENO);
|
||||
}
|
||||
ft_putstr_fd(".\n", STDERR_FILENO);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/10/30 16:30:03 by rparodi #+# #+# */
|
||||
/* Updated: 2024/11/18 14:17:27 by bgoulard ### ########.fr */
|
||||
/* Updated: 2024/11/27 11:51:42 by bgoulard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -57,7 +57,8 @@ void check_err(t_info *info)
|
|||
return (info->last_error = ERROR_EXTENSION_FILE, (void)0);
|
||||
info->map.fd = open(info->cli_ctx.file, O_RDONLY);
|
||||
if (info->map.fd == -1)
|
||||
return (info->last_error = ERROR_OPEN_FILE, (void)0);
|
||||
return (info->errno_state = errno,
|
||||
info->last_error = ERROR_OPEN_FILE, (void)0);
|
||||
}
|
||||
|
||||
void run_cub3d(t_info *info)
|
||||
|
|
@ -69,15 +70,14 @@ void run_cub3d(t_info *info)
|
|||
dump_info(info);
|
||||
if (info->last_error != NO_ERROR)
|
||||
return ;
|
||||
if (info->cli_ctx.no_graphics)
|
||||
printf("no graphics mode\n");
|
||||
// todo: here
|
||||
// - validity check
|
||||
printf("launching mlx\n");
|
||||
mlx_loop(info->mlx_ptr);
|
||||
// - game loop : already loops over the mlx_ptr
|
||||
// -> get events if key pressed move player + run math to re-draw screen
|
||||
// - mlx cleanup : already called in parent function deprecated to call here
|
||||
// -> previous 'segfault' were due to someone calling cleaup instead of
|
||||
// mlx_loop_end
|
||||
}
|
||||
|
||||
/// @brief main function of the cub3d executable
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: bgoulard <bgoulard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/11/09 01:14:09 by bgoulard #+# #+# */
|
||||
/* Updated: 2024/11/15 09:03:03 by bgoulard ### ########.fr */
|
||||
/* Updated: 2024/11/27 11:35:08 by bgoulard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -25,6 +25,7 @@ int c3_options(t_info *info, int argc, char *argv[])
|
|||
{"debug", 'd', c3_set_debug, 0},
|
||||
{"save", 's', c3_set_save, 0},
|
||||
{"help", 'h', c3_print_help, 0},
|
||||
{"parse-only", 'p', c3_set_parse_excl, 0},
|
||||
// add more options here put the implementation in options_impl.c
|
||||
// if you want custom option see ft_args_types.h for more info
|
||||
// code example in it.
|
||||
|
|
|
|||
|
|
@ -6,13 +6,21 @@
|
|||
/* By: bgoulard <bgoulard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/11/09 01:12:16 by bgoulard #+# #+# */
|
||||
/* Updated: 2024/11/15 09:08:34 by bgoulard ### ########.fr */
|
||||
/* Updated: 2024/11/27 11:35:14 by bgoulard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "cub3d_struct.h"
|
||||
#include "ft_string.h"
|
||||
|
||||
void c3_set_parse_excl(void *usr_control_struct)
|
||||
{
|
||||
t_cli *cli_ctx;
|
||||
|
||||
cli_ctx = (t_cli *)usr_control_struct;
|
||||
cli_ctx->no_graphics = true;
|
||||
}
|
||||
|
||||
void c3_set_file(void *usr_control_struct, const char *arg)
|
||||
{
|
||||
t_cli *cli_ctx;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue