/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_init_lists.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: rbousset +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/02/14 17:28:53 by rbousset #+# #+# */ /* Updated: 2020/02/14 17:28:53 by rbousset ### ########lyon.fr */ /* */ /* ************************************************************************** */ #include #include #include #include #include #include #include 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->footstep_one, FT_SFX_FS_ONE_PATH) < 0 || ft_split_sfx(&sfx->footstep_two, FT_SFX_FS_TWO_PATH) < 0 || ft_split_sfx(&sfx->new_lvl, FT_SFX_N_LVL_PATH) < 0 || ft_split_sfx(&sfx->pain_one, FT_SFX_SCR_ONE_PATH) < 0 || ft_split_sfx(&sfx->pain_two, FT_SFX_SCR_TWO_PATH) < 0 || ft_split_sfx(&sfx->trap, FT_SFX_TRAP_PATH) < 0) return (-1); return (0); }