diff options
-rw-r--r-- | Makefile | 1 | ||||
-rw-r--r-- | inc/cub3d.h | 1 | ||||
-rw-r--r-- | inc/cub3d_defines.h | 9 | ||||
-rw-r--r-- | inc/cub3d_structs.h | 6 | ||||
-rw-r--r-- | src/ft_get_traps.c | 42 | ||||
-rw-r--r-- | src/ft_init_funptr.c | 4 | ||||
-rw-r--r-- | src/ft_select_get.c | 2 |
7 files changed, 56 insertions, 9 deletions
@@ -42,6 +42,7 @@ 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 +SRCS_NAME += ft_get_traps.c SRCS_NAME += ft_set_minimap_scale.c SRCS_NAME += ft_check_missing.c SRCS_NAME += ft_check_not_found.c diff --git a/inc/cub3d.h b/inc/cub3d.h index e351fa9..bb30122 100644 --- a/inc/cub3d.h +++ b/inc/cub3d.h @@ -102,6 +102,7 @@ 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_traps(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_defines.h b/inc/cub3d_defines.h index edc3dec..6453e73 100644 --- a/inc/cub3d_defines.h +++ b/inc/cub3d_defines.h @@ -114,11 +114,11 @@ enum ** ====== CHARSET ====== */ -# define FT_CHRST_VALID_PARSE "RNSEWFCLM" -# define FT_CHRST_MAP_ENTRY "012NSEWL " +# define FT_CHRST_VALID_PARSE "RNSEWFCLMT" +# define FT_CHRST_MAP_ENTRY "012NSEWLT " # define FT_CHRST_SPAWN "NSEW" -# define FT_CHRST_MAP_NON_WALL "02NESWL" -# define FT_CHRST_COLLISION "12 " +# define FT_CHRST_MAP_NON_WALL "02NESWLT" +# define FT_CHRST_COLLISION "12T " # define FT_CHRST_DETECT "1L" /* @@ -166,6 +166,7 @@ enum # define FT_ERR_RD_NL_TEX "could not find next level texture file" # define FT_ERR_RD_NL_MAP "could not find next level map file" # define FT_ERR_RD_MUSIC "could not find music file" +# define FT_ERR_RD_TRAP "could not find trap texture file" # define FT_ERR_WR_BMP "could not export to bmp" /* diff --git a/inc/cub3d_structs.h b/inc/cub3d_structs.h index 9f48975..89e531a 100644 --- a/inc/cub3d_structs.h +++ b/inc/cub3d_structs.h @@ -214,8 +214,8 @@ typedef struct s_cub int32_t key_input[5]; pid_t mpid; int (*key_ptr[6])(struct s_cub*); - int8_t (*get_ptr[13])(char**, struct s_cub*); - char ref[14][3]; + int8_t (*get_ptr[14])(char**, struct s_cub*); + char ref[15][3]; struct s_win wlist; struct s_player plist; struct s_map mlist; @@ -225,7 +225,7 @@ typedef struct s_cub struct s_rgb c_rgb; struct s_img tlist[16]; struct s_sprite sprites[4096]; - struct s_sprite traps[4096]; + struct s_sprite traps[512]; } t_cub; # endif diff --git a/src/ft_get_traps.c b/src/ft_get_traps.c new file mode 100644 index 0000000..cdc05de --- /dev/null +++ b/src/ft_get_traps.c @@ -0,0 +1,42 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_get_tex_nl.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: rbousset <marvin@42.fr> +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/02/28 18:24:52 by rbousset #+# #+# */ +/* Updated: 2020/02/28 18:24:56 by rbousset ### ########lyon.fr */ +/* */ +/* ************************************************************************** */ + +#include <libft.h> +#include <cub3d.h> +#include <stdint.h> + +int8_t + ft_get_traps(char **words, t_cub *clist) +{ + if (!(*words) || !(*(words + 1)) || (*(words + 2))) + { + ft_sprintf(clist->errmsg, "%s", FT_ERR_ARGS); + return (-1); + } + if (ft_check_ext(*(words + 1), ".xpm") < 0) + { + ft_sprintf(clist->errmsg, "%s", FT_ERR_NOT_A_XPM); + return (-1); + } + ft_memdel((void**)&clist->mlist.traps_path); + if (!(clist->mlist.traps_path = ft_strdup(*(words + 1)))) + { + ft_sprintf(clist->errmsg, "%s", FT_ERR_ALLOCATE); + return (-1); + } + if (ft_check_not_found(clist->mlist.traps_path) < 0) + { + ft_sprintf(clist->errmsg, FT_ERR_RD_TRAP); + return (-1); + } + return (0); +} diff --git a/src/ft_init_funptr.c b/src/ft_init_funptr.c index 6bfa3f7..c74b2c8 100644 --- a/src/ft_init_funptr.c +++ b/src/ft_init_funptr.c @@ -29,7 +29,8 @@ void ft_sprintf(clist->ref[10], "MU"); ft_sprintf(clist->ref[11], "SH"); ft_sprintf(clist->ref[12], "SB"); - ft_bzero(clist->ref[13], 3); + ft_sprintf(clist->ref[13], "T"); + ft_bzero(clist->ref[14], 3); } void @@ -54,4 +55,5 @@ void clist->get_ptr[10] = ft_get_music; clist->get_ptr[11] = ft_get_darkness; clist->get_ptr[12] = ft_get_skybox; + clist->get_ptr[14] = ft_get_traps; } diff --git a/src/ft_select_get.c b/src/ft_select_get.c index fe6bb3e..2a95309 100644 --- a/src/ft_select_get.c +++ b/src/ft_select_get.c @@ -66,7 +66,7 @@ static int8_t ret = 0; while (ft_strncmp(words[0], clist->ref[ret], 3) && clist->ref[ret][0]) ret++; - if (ret == 13) + if (ret == 14) ret = FT_PARSE_END_RET; ret = ft_check_exists(ret, clist); ret = ft_check_exists_two(ret, clist); |