First shot on structures, First shot on option
option:
Added options for help, debug, save, file using bgoulard lib
structures:
Moved cub3d.h structures to cub3d_struct.h
Added color, dpoint, ipoint, tile, cli, error
Modified t_map, t_player to use previously mentioned struct :
ipoint, dpoint, tyle
This commit is contained in:
parent
be6038dcc8
commit
8ee1c5f85a
14 changed files with 580 additions and 79 deletions
|
|
@ -6,25 +6,45 @@
|
|||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/10/31 11:09:00 by rparodi #+# #+# */
|
||||
/* Updated: 2024/10/31 12:01:18 by rparodi ### ########.fr */
|
||||
/* Updated: 2024/11/09 01:43:06 by bgoulard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "ft_string.h"
|
||||
|
||||
#include "cub3d.h"
|
||||
#include "message_error.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
/**
|
||||
* @brief Print the message error with red color !
|
||||
*
|
||||
* @param msg The detailled message
|
||||
*/
|
||||
void print_error(char *msg)
|
||||
const char *g_error_message[] = {
|
||||
"no error",
|
||||
"unknown error",
|
||||
|
||||
"could not open file",
|
||||
"could not read file",
|
||||
"bad file extension",
|
||||
"invalid file name",
|
||||
"missing file",
|
||||
"malloc error",
|
||||
"parse error",
|
||||
"cli error",
|
||||
"mlx error",
|
||||
};
|
||||
|
||||
void c3_perror(t_info *info)
|
||||
{
|
||||
write(2, BOLD_RED, strlen(BOLD_RED));
|
||||
write(2, "Error:\n", strlen("Error:\n"));
|
||||
write(2, RESET, strlen(RESET));
|
||||
write(2, RED, strlen(RED));
|
||||
write(2, msg, strlen(msg));
|
||||
write(2, RESET, strlen(RESET));
|
||||
if (info->last_error == NO_ERROR)
|
||||
return ;
|
||||
print_error(g_error_message[info->last_error]);
|
||||
}
|
||||
|
||||
void print_error(const char *msg)
|
||||
{
|
||||
ft_putstr_fd(BOLD_RED, STDERR_FILENO);
|
||||
ft_putstr_fd("Error:\n", STDERR_FILENO);
|
||||
ft_putstr_fd(RESET, STDERR_FILENO);
|
||||
ft_putstr_fd(RED, STDERR_FILENO);
|
||||
ft_putstr_fd(msg, STDERR_FILENO);
|
||||
ft_putstr_fd(RESET, STDERR_FILENO);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue