diff options
author | JozanLeClerc <bousset.rudy@gmail.com> | 2020-03-13 03:11:12 +0100 |
---|---|---|
committer | JozanLeClerc <bousset.rudy@gmail.com> | 2020-03-13 03:11:12 +0100 |
commit | a90c6f5cafbc47c7380d932d8db7bffd9b8b72bf (patch) | |
tree | 4e7044b92a3e97a338aaf769fe2b55d63e69338b /src | |
parent | Removed beta minilibx make options (diff) | |
download | 42-cub3d-a90c6f5cafbc47c7380d932d8db7bffd9b8b72bf.tar.gz 42-cub3d-a90c6f5cafbc47c7380d932d8db7bffd9b8b72bf.tar.bz2 42-cub3d-a90c6f5cafbc47c7380d932d8db7bffd9b8b72bf.tar.xz 42-cub3d-a90c6f5cafbc47c7380d932d8db7bffd9b8b72bf.tar.zst 42-cub3d-a90c6f5cafbc47c7380d932d8db7bffd9b8b72bf.zip |
sounds
Diffstat (limited to 'src')
-rw-r--r-- | src/ft_check_missing.c | 21 | ||||
-rw-r--r-- | src/ft_get_music.c | 4 | ||||
-rw-r--r-- | src/ft_init_lists.c | 4 | ||||
-rw-r--r-- | src/ft_init_sfx.c | 47 |
4 files changed, 67 insertions, 9 deletions
diff --git a/src/ft_check_missing.c b/src/ft_check_missing.c index 1e89781..f9df88f 100644 --- a/src/ft_check_missing.c +++ b/src/ft_check_missing.c @@ -26,19 +26,26 @@ int static int ft_check_missing_sfx(t_cub *clist) { - if (ft_check_not_found(FT_SFX_DEATH_PATH) < 0) + if (ft_check_not_found(FT_SFX_DEATH_PATH) < 0 || + ft_check_ext(FT_SFX_DEATH_PATH, ".wav") < 0) return (ft_missing_error(FT_ERR_MISS_SFX_DEATH, clist)); - if (ft_check_not_found(FT_SFX_FS_ONE_PATH) < 0) + if (ft_check_not_found(FT_SFX_FS_ONE_PATH) < 0 || + ft_check_ext(FT_SFX_FS_ONE_PATH, ".wav") < 0) return (ft_missing_error(FT_ERR_MISS_SFX_FS_ONE, clist)); - if (ft_check_not_found(FT_SFX_FS_TWO_PATH) < 0) + if (ft_check_not_found(FT_SFX_FS_TWO_PATH) < 0 || + ft_check_ext(FT_SFX_FS_TWO_PATH, ".wav") < 0) return (ft_missing_error(FT_ERR_MISS_SFX_FS_TWO, clist)); - if (ft_check_not_found(FT_SFX_N_LVL_PATH) < 0) + if (ft_check_not_found(FT_SFX_N_LVL_PATH) < 0 || + ft_check_ext(FT_SFX_N_LVL_PATH, ".wav") < 0) return (ft_missing_error(FT_ERR_MISS_SFX_N_LVL, clist)); - if (ft_check_not_found(FT_SFX_SCR_ONE_PATH) < 0) + if (ft_check_not_found(FT_SFX_SCR_ONE_PATH) < 0 || + ft_check_ext(FT_SFX_SCR_ONE_PATH, ".wav") < 0) return (ft_missing_error(FT_ERR_MISS_SFX_SCR_ONE, clist)); - if (ft_check_not_found(FT_SFX_SCR_TWO_PATH) < 0) + if (ft_check_not_found(FT_SFX_SCR_TWO_PATH) < 0 || + ft_check_ext(FT_SFX_SCR_TWO_PATH, ".wav") < 0) return (ft_missing_error(FT_ERR_MISS_SFX_SCR_TWO, clist)); - if (ft_check_not_found(FT_SFX_TRAP_PATH) < 0) + if (ft_check_not_found(FT_SFX_TRAP_PATH) < 0 || + ft_check_ext(FT_SFX_TRAP_PATH, ".wav") < 0) return (ft_missing_error(FT_ERR_MISS_SFX_TRAP, clist)); return (0); } diff --git a/src/ft_get_music.c b/src/ft_get_music.c index 2383e0a..7a8d36f 100644 --- a/src/ft_get_music.c +++ b/src/ft_get_music.c @@ -21,11 +21,11 @@ static int8_t uint8_t len; len = ft_strlen(mlist->music_path); - len += ft_strlen(FT_MUS_CMD) - 2; + len += ft_strlen(FT_SND_CMD) - 2; ft_memdel((void**)&mlist->music_cmd); if (!(mlist->music_cmd = (char *)malloc((len + 1) * sizeof(char)))) return (-1); - ft_sprintf(mlist->music_cmd, FT_MUS_CMD, + ft_sprintf(mlist->music_cmd, FT_SND_CMD, mlist->music_path); ft_free_words(mlist->mcmd_words); if (!(mlist->mcmd_words = ft_split(mlist->music_cmd, ' '))) diff --git a/src/ft_init_lists.c b/src/ft_init_lists.c index d480912..a6484c2 100644 --- a/src/ft_init_lists.c +++ b/src/ft_init_lists.c @@ -78,6 +78,10 @@ static int8_t cl->f_rgb = ft_init_rgb(); cl->c_rgb = ft_init_rgb(); cl->rlist = ft_init_s_ray(); + if (ft_init_sfx(&cl->sfx) < 0) + return (-1); + ft_printf("%s\n", cl->sfx.death[0]); + ft_printf("%s\n", cl->sfx.trap[0]); cl->currlvl = 0; cl->walltexgood = 0; ft_init_funptr(cl); diff --git a/src/ft_init_sfx.c b/src/ft_init_sfx.c new file mode 100644 index 0000000..1452b5c --- /dev/null +++ b/src/ft_init_sfx.c @@ -0,0 +1,47 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_init_lists.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 <mlx.h> +#include <cub3d.h> +#include <stddef.h> +#include <stdlib.h> +#include <stdint.h> + +static int8_t + ft_split_sfx(char ***target, const char *path) +{ + uint8_t len; + char *tmp; + + len = ft_strlen(path); + len += ft_strlen(FT_SND_CMD) - 2; + if (!(tmp = (char *)malloc((len + 1) * sizeof(char)))) + return (-1); + ft_sprintf(tmp, FT_SND_CMD, path); + if (!(*target = ft_split(tmp, ' '))) + { + ft_memdel((void**)&tmp); + return (-1); + } + ft_memdel((void**)&tmp); + return (0); +} + +int8_t + ft_init_sfx(t_sfx *sfx) +{ + if (ft_split_sfx(&sfx->death, FT_SFX_DEATH_PATH) < 0 || + ft_split_sfx(&sfx->trap, FT_SFX_TRAP_PATH) < 0) + return (-1); + return (0); +} |