aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJozanLeClerc <bousset.rudy@gmail.com>2020-03-02 00:33:11 +0100
committerJozanLeClerc <bousset.rudy@gmail.com>2020-03-02 00:33:11 +0100
commitfc61b9019c867c88868da308fd2d0bfce7408c7f (patch)
tree31ca264c2f2cc61613d38a0ffa91e1894e691f53
parentAnother song (diff)
download42-cub3d-fc61b9019c867c88868da308fd2d0bfce7408c7f.tar.gz
42-cub3d-fc61b9019c867c88868da308fd2d0bfce7408c7f.tar.bz2
42-cub3d-fc61b9019c867c88868da308fd2d0bfce7408c7f.tar.xz
42-cub3d-fc61b9019c867c88868da308fd2d0bfce7408c7f.tar.zst
42-cub3d-fc61b9019c867c88868da308fd2d0bfce7408c7f.zip
in progress
-rw-r--r--Makefile2
-rw-r--r--inc/cub3d.h16
-rw-r--r--inc/cub3d_defines.h3
-rw-r--r--inc/cub3d_structs.h2
-rw-r--r--src/ft_get_music.c5
-rw-r--r--src/ft_init_funptr.c25
-rw-r--r--src/ft_select_get.c26
7 files changed, 45 insertions, 34 deletions
diff --git a/Makefile b/Makefile
index 5c57ff6..9aee1f4 100644
--- a/Makefile
+++ b/Makefile
@@ -37,6 +37,7 @@ SRCS_NAME += ft_get_tex_nl.c
SRCS_NAME += ft_get_path_nl.c
SRCS_NAME += ft_get_nlvl_pos.c
SRCS_NAME += ft_get_player_spawn.c
+SRCS_NAME += ft_get_music.c
SRCS_NAME += ft_set_minimap_scale.c
SRCS_NAME += ft_check_missing.c
SRCS_NAME += ft_check_not_found.c
@@ -68,6 +69,7 @@ SRCS_NAME += ft_draw_sprite.c
SRCS_NAME += ft_warp_level.c
SRCS_NAME += ft_save_to_bmp.c
SRCS_NAME += ft_treat_args.c
+SRCS_NAME += ft_init_funptr.c
#--------------------------------------------------------------------------------------------------#
SRCS = $(addprefix ${SRCS_DIR},${SRCS_NAME})
#--------------------------------------------------------------------------------------------------#
diff --git a/inc/cub3d.h b/inc/cub3d.h
index dc363df..3ddf188 100644
--- a/inc/cub3d.h
+++ b/inc/cub3d.h
@@ -21,6 +21,8 @@
/*
** ====== STRUCTS ======
*/
+
+void ft_init_funptr(t_cub *clist);
int8_t ft_init_cub3d(t_cub **clist);
int ft_init_winlx(t_cub *clist);
int ft_init_winptr(t_cub *clist);
@@ -101,6 +103,13 @@ int ft_map_error(const char *errmsg, t_cub *clist);
size_t ft_get_line_len(char *line);
/*
+** ====== ARGS ======
+*/
+
+uint8_t ft_check_map_arg(int argc, const char *argv[]);
+uint8_t ft_use_args(int argc, const char *argv[], t_cub *clist);
+
+/*
** ====== OTHER ======
*/
@@ -114,11 +123,4 @@ int8_t ft_warp_level(t_cub *cl);
int ft_exit(uint8_t exit_code, t_cub *clist);
uint32_t ft_rgb_to_hex(t_rgb rgb);
-/*
-** ====== ARGS ======
-*/
-
-uint8_t ft_check_map_arg(int argc, const char *argv[]);
-uint8_t ft_use_args(int argc, const char *argv[], t_cub *clist);
-
# endif
diff --git a/inc/cub3d_defines.h b/inc/cub3d_defines.h
index e6aa3b3..3f32fe3 100644
--- a/inc/cub3d_defines.h
+++ b/inc/cub3d_defines.h
@@ -109,7 +109,7 @@ enum
# define FT_ERR_RES_ALPHA "resolution should be digits only"
# define FT_ERR_NOT_A_CUB "given map is not a .cub"
# define FT_ERR_NOT_A_XPM "given texture is not a .xpm"
-# define FT_ERR_NOT_A_XPM "given sound file is not a .wav"
+# define FT_ERR_NOT_A_WAV "given sound file is not a .wav"
# define FT_ERR_COLOR_ALPHA "colors should be digits only"
# define FT_ERR_COLOR_MAX "colors should be maximum 255"
# define FT_ERR_COLOR_ARGS "colors should be three numbers with commas"
@@ -128,6 +128,7 @@ enum
# define FT_ERR_RD_SP "could not find sprite texture file"
# 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"
/*
** ====== MISSING ERROR MSG ======
diff --git a/inc/cub3d_structs.h b/inc/cub3d_structs.h
index 5bd5616..2026a27 100644
--- a/inc/cub3d_structs.h
+++ b/inc/cub3d_structs.h
@@ -139,7 +139,7 @@ typedef struct s_cub
char errmsg[64];
int32_t key_input[5];
int (*key_ptr[6])(struct s_cub*);
- int8_t (*get_ptr[11])(char**, t_cub*);
+ int8_t (*get_ptr[11])(char**, struct s_cub*);
struct s_win *wlist;
struct s_player *plist;
struct s_map *mlist;
diff --git a/src/ft_get_music.c b/src/ft_get_music.c
index c9119c9..0b6fede 100644
--- a/src/ft_get_music.c
+++ b/src/ft_get_music.c
@@ -10,6 +10,10 @@
/* */
/* ************************************************************************** */
+#include <libft.h>
+#include <cub3d.h>
+#include <stdint.h>
+
int8_t
ft_get_music(char **words, t_cub *clist)
{
@@ -18,6 +22,7 @@ int8_t
ft_sprintf(clist->errmsg, FT_ERR_ARGS);
return (-1);
}
+ ft_printf("%s", *(words + 1));
if (ft_check_ext(*(words + 1), ".wav") < 0)
{
ft_sprintf(clist->errmsg, FT_ERR_NOT_A_WAV);
diff --git a/src/ft_init_funptr.c b/src/ft_init_funptr.c
index 7721381..1988cb0 100644
--- a/src/ft_init_funptr.c
+++ b/src/ft_init_funptr.c
@@ -10,7 +10,8 @@
/* */
/* ************************************************************************** */
-#include <cub3.d>
+#include <cub3d.h>
+
void
ft_init_funptr(t_cub *clist)
{
@@ -20,15 +21,15 @@ void
clist->key_ptr[3] = ft_d_key;
clist->key_ptr[4] = ft_left_key;
clist->key_ptr[5] = ft_right_key;
- fun_ptr[0] = ft_get_res;
- fun_ptr[1] = ft_get_tex_no;
- fun_ptr[2] = ft_get_tex_so;
- fun_ptr[3] = ft_get_tex_ea;
- fun_ptr[4] = ft_get_tex_we;
- fun_ptr[5] = ft_get_sprite;
- fun_ptr[6] = ft_get_f_color;
- fun_ptr[7] = ft_get_c_color;
- fun_ptr[8] = ft_get_path_nl;
- fun_ptr[9] = ft_get_tex_nl;
- fun_ptr[10] = ft_get_music;
+ clist->get_ptr[0] = ft_get_res;
+ clist->get_ptr[1] = ft_get_tex_no;
+ clist->get_ptr[2] = ft_get_tex_so;
+ clist->get_ptr[3] = ft_get_tex_ea;
+ clist->get_ptr[4] = ft_get_tex_we;
+ clist->get_ptr[5] = ft_get_sprite;
+ clist->get_ptr[6] = ft_get_f_color;
+ clist->get_ptr[7] = ft_get_c_color;
+ clist->get_ptr[8] = ft_get_path_nl;
+ clist->get_ptr[9] = ft_get_tex_nl;
+ clist->get_ptr[10] = ft_get_music;
}
diff --git a/src/ft_select_get.c b/src/ft_select_get.c
index 9d97748..ed569ff 100644
--- a/src/ft_select_get.c
+++ b/src/ft_select_get.c
@@ -62,18 +62,18 @@ static int8_t
int8_t ret;
char ref[12][3];
- ft_memcpy(ref[0], "R\0", 3);
- ft_memcpy(ref[1], "NO", 3);
- ft_memcpy(ref[2], "SO", 3);
- ft_memcpy(ref[3], "EA", 3);
- ft_memcpy(ref[4], "WE", 3);
- ft_memcpy(ref[5], "S\0", 3);
- ft_memcpy(ref[6], "F\0", 3);
- ft_memcpy(ref[7], "C\0", 3);
- ft_memcpy(ref[8], "L\0", 3);
- ft_memcpy(ref[9], "LT", 3);
- ft_memcpy(ref[9], "MU", 3);
- ft_memcpy(ref[11], "", 1);
+ ft_sprintf(ref[0], "R");
+ ft_sprintf(ref[1], "NO");
+ ft_sprintf(ref[2], "SO");
+ ft_sprintf(ref[3], "EA");
+ ft_sprintf(ref[4], "WE");
+ ft_sprintf(ref[5], "S");
+ ft_sprintf(ref[6], "F");
+ ft_sprintf(ref[7], "C");
+ ft_sprintf(ref[8], "L");
+ ft_sprintf(ref[9], "LT");
+ ft_sprintf(ref[10], "MU");
+ ft_sprintf(ref[11], "");
ret = 0;
while (ft_strncmp(words[0], ref[ret], 3) && ref[ret][0])
ret++;
@@ -94,7 +94,7 @@ int8_t
ft_free_words(words);
return (12);
}
- if (id < 0 || (*fun_ptr[id])(words, clist) < 0)
+ if (id < 0 || clist->get_ptr[id](words, clist) < 0)
{
ft_free_words(words);
return ((id < 0) ? (-2) : (-1));