diff options
Diffstat (limited to '')
-rw-r--r-- | Makefile | 13 | ||||
-rw-r--r-- | inc/cub3d.h | 1 | ||||
-rw-r--r-- | inc/cub3d_structs.h | 3 | ||||
-rw-r--r-- | libft/Makefile | 12 | ||||
-rw-r--r-- | src/ft_exit.c | 1 | ||||
-rw-r--r-- | src/ft_get_skybox.c | 43 | ||||
-rw-r--r-- | src/ft_init_funptr.c | 1 | ||||
-rw-r--r-- | src/ft_init_map.c | 1 | ||||
-rw-r--r-- | src/ft_warp_level.c | 1 |
9 files changed, 71 insertions, 5 deletions
@@ -38,6 +38,7 @@ SRCS_NAME += ft_get_tex_nl.c SRCS_NAME += ft_get_tex_extra.c SRCS_NAME += ft_get_path_nl.c SRCS_NAME += ft_get_nlvl_pos.c +SRCS_NAME += ft_get_skybox.c SRCS_NAME += ft_get_player_spawn.c SRCS_NAME += ft_get_music.c SRCS_NAME += ft_get_darkness.c @@ -101,10 +102,18 @@ endif #==================================================================================================# #------------------------------------------ Compiler ----------------------------------------------# #==================================================================================================# -DEBUG = -glldb +ifeq (${OS}, Darwin) + DEBUG = -glldb +else + DEBUG = -ggdb +endif FSANITIZE = -fsanitize=address #--------------------------------------------------------------------------------------------------# -CC = clang +ifeq (${OS}, Darwin) + CC = clang +else + CC = gcc +endif #--------------------------------------------------------------------------------------------------# CFLAGS = -std=c89 CFLAGS += -Wall diff --git a/inc/cub3d.h b/inc/cub3d.h index f255b00..6201b91 100644 --- a/inc/cub3d.h +++ b/inc/cub3d.h @@ -99,6 +99,7 @@ int8_t ft_get_c_color(char **words, t_cub *clist); int8_t ft_get_c_tex(char **words, t_cub *clist); int8_t ft_get_darkness(char **words, t_cub *clist); int8_t ft_get_path_nl(char **words, t_cub *clist); +int8_t ft_get_skybox(char **words, t_cub *clist); int8_t ft_get_tex_nl(char **words, t_cub *clist); int8_t ft_get_music(char **words, t_cub *clist); size_t ft_get_map_h(char **map); diff --git a/inc/cub3d_structs.h b/inc/cub3d_structs.h index 845ae31..773c783 100644 --- a/inc/cub3d_structs.h +++ b/inc/cub3d_structs.h @@ -167,6 +167,7 @@ typedef struct s_map char *fl_tex_path; char *ce_tex_path; char *nlevel_path; + char *skybox_path; char *music_path; char *music_cmd; char *mapl; @@ -208,7 +209,7 @@ typedef struct s_cub int32_t key_input[5]; pid_t mpid; int (*key_ptr[6])(struct s_cub*); - int8_t (*get_ptr[12])(char**, struct s_cub*); + int8_t (*get_ptr[13])(char**, struct s_cub*); char ref[14][3]; struct s_win wlist; struct s_player plist; diff --git a/libft/Makefile b/libft/Makefile index d2053ee..1f93f13 100644 --- a/libft/Makefile +++ b/libft/Makefile @@ -119,10 +119,18 @@ USER = $(shell w | grep tty7 | awk '{print $$1}') #==============================================================================# #-------------------------------- Compiler ------------------------------------# #==============================================================================# -DEBUG = -glldb +ifeq (${OS}, Darwin) + DEBUG = -glldb +else + DEBUG = -ggdb +endif FSANITIZE = -fsanitize=address #------------------------------------------------------------------------------# -CC = clang +ifeq (${OS}, Darwin) + CC = clang +else + CC = gcc +endif #------------------------------------------------------------------------------# CFLAGS = -std=c89 CFLAGS += -Wall diff --git a/src/ft_exit.c b/src/ft_exit.c index 659d0ec..97c9e02 100644 --- a/src/ft_exit.c +++ b/src/ft_exit.c @@ -32,6 +32,7 @@ static void ft_memdel((void**)&clist->mlist.fl_tex_path); ft_memdel((void**)&clist->mlist.ce_tex_path); ft_memdel((void**)&clist->mlist.nlevel_path); + ft_memdel((void**)&clist->mlist.skybox_path); ft_memdel((void**)&clist->mlist.music_path); ft_memdel((void**)&clist->mlist.music_cmd); ft_memdel((void**)&clist->mlist.mapl); diff --git a/src/ft_get_skybox.c b/src/ft_get_skybox.c new file mode 100644 index 0000000..011bec7 --- /dev/null +++ b/src/ft_get_skybox.c @@ -0,0 +1,43 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_get_skybox.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: rbousset <marvin@42.fr> +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/02/14 17:28:53 by rbousset #+# #+# */ +/* Updated: 2020/02/14 17:28:53 by rbousset ### ########lyon.fr */ +/* */ +/* ************************************************************************** */ + +#include <libft.h> +#include <cub3d.h> +#include <stdint.h> + +int8_t + ft_get_skybox(char **words, t_cub *clist) +{ + if (!(*words) || !(*(words + 1)) || (*(words + 2))) + { + ft_sprintf(clist->errmsg, FT_ERR_ARGS); + return (-1); + } + if (ft_check_ext(*(words + 1), ".xpm") < 0) + { + ft_sprintf(clist->errmsg, FT_ERR_NOT_A_XPM); + return (-1); + } + ft_memdel((void**)&clist->mlist.skybox_path); + if (!(clist->mlist.skybox_path = ft_strdup(*(words + 1)))) + { + ft_sprintf(clist->errmsg, FT_ERR_ALLOCATE); + return (-1); + } + if (ft_check_not_found(clist->mlist.skybox_path) < 0) + { + ft_sprintf(clist->errmsg, FT_ERR_RD_NL_MAP); + return (-1); + } + clist->mlist.isskybox = 1; + return (0); +} diff --git a/src/ft_init_funptr.c b/src/ft_init_funptr.c index 6d668dc..6bfa3f7 100644 --- a/src/ft_init_funptr.c +++ b/src/ft_init_funptr.c @@ -53,4 +53,5 @@ void clist->get_ptr[9] = ft_get_tex_nl; clist->get_ptr[10] = ft_get_music; clist->get_ptr[11] = ft_get_darkness; + clist->get_ptr[12] = ft_get_skybox; } diff --git a/src/ft_init_map.c b/src/ft_init_map.c index f8b91ec..27b4a39 100644 --- a/src/ft_init_map.c +++ b/src/ft_init_map.c @@ -28,6 +28,7 @@ static int8_t !(mlist->fl_tex_path = (char*)ft_calloc(1, sizeof(char))) || !(mlist->ce_tex_path = (char*)ft_calloc(1, sizeof(char))) || !(mlist->nlevel_path = (char*)ft_calloc(1, sizeof(char))) || + !(mlist->skybox_path = (char*)ft_calloc(1, sizeof(char))) || !(mlist->music_path = (char*)ft_calloc(1, sizeof(char))) || !(mlist->music_cmd = (char*)ft_calloc(1, sizeof(char))) || !(mlist->mapl = (char*)ft_calloc(1, sizeof(char))) || diff --git a/src/ft_warp_level.c b/src/ft_warp_level.c index de2103d..0af4ecb 100644 --- a/src/ft_warp_level.c +++ b/src/ft_warp_level.c @@ -33,6 +33,7 @@ static void ft_memdel((void**)&ml->fl_tex_path); ft_memdel((void**)&ml->ce_tex_path); ft_memdel((void**)&ml->nlevel_path); + ft_memdel((void**)&ml->skybox_path); ft_memdel((void**)&ml->music_path); ft_memdel((void**)&ml->music_cmd); ft_memdel((void**)&ml->mapl); |