36 lines
1.3 KiB
C
36 lines
1.3 KiB
C
/* ************************************************************************** */
|
|
/* */
|
|
/* :::::::: */
|
|
/* errors.c :+: :+: */
|
|
/* +:+ */
|
|
/* By: qmennen <qmennen@student.codam.nl> +#+ */
|
|
/* +#+ */
|
|
/* Created: 2025/04/15 15:40:14 by qmennen #+# #+# */
|
|
/* Updated: 2025/05/07 11:34:57 by whaffman ######## odam.nl */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
#include "MLX42.h"
|
|
#include "cub3d.h"
|
|
|
|
const char *last_error(void)
|
|
{
|
|
if (mlx_errno > 0)
|
|
return (mlx_strerror(mlx_errno));
|
|
else if (errno > 0)
|
|
return (strerror(errno));
|
|
else
|
|
return (NULL);
|
|
}
|
|
|
|
void game_error(t_game *game, const char *msg)
|
|
{
|
|
const char *last_err = last_error();
|
|
|
|
if (msg == NULL && last_err)
|
|
printf(RED"%s\n"RESET, last_err);
|
|
else
|
|
printf(RED"%s\n"RESET, msg);
|
|
game_terminate(game);
|
|
}
|