aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--inc/cub3d.h1
-rw-r--r--inc/cub3d_structs.h1
-rw-r--r--map/lvl_one.cub2
-rw-r--r--src/ft_music.c25
-rw-r--r--src/ft_treat_args.c9
-rw-r--r--src/ft_warp_level.c4
6 files changed, 23 insertions, 19 deletions
diff --git a/inc/cub3d.h b/inc/cub3d.h
index b552b38..6078801 100644
--- a/inc/cub3d.h
+++ b/inc/cub3d.h
@@ -120,6 +120,7 @@ uint8_t ft_use_args(int argc, const char *argv[],
*/
void ft_set_minimap_scale(t_cub *clist);
+void ft_enable_music(t_cub *cl);
void ft_music_fork(char **mcmd_words, char *const envp[]);
void ft_detect(t_cub *cl);
void ft_castray(t_cub *cl);
diff --git a/inc/cub3d_structs.h b/inc/cub3d_structs.h
index d253b7b..d53cdb9 100644
--- a/inc/cub3d_structs.h
+++ b/inc/cub3d_structs.h
@@ -176,6 +176,7 @@ typedef struct s_cub
uint8_t isoldmus;
uint16_t currlvl;
uint16_t i;
+ char *const *envp;
char errmsg[64];
int32_t key_input[5];
pid_t mpid;
diff --git a/map/lvl_one.cub b/map/lvl_one.cub
index c21c879..c6c7cc0 100644
--- a/map/lvl_one.cub
+++ b/map/lvl_one.cub
@@ -1,4 +1,4 @@
-R 900 500
+R 1500 900
NO ./media/img/BRIQUASSE_3.xpm
SO ./media/img/BRIQUASSE_3.xpm
diff --git a/src/ft_music.c b/src/ft_music.c
index a3e2120..0667ecb 100644
--- a/src/ft_music.c
+++ b/src/ft_music.c
@@ -10,20 +10,25 @@
/* */
/* ************************************************************************** */
-#include <libft.h>
-#include <stddef.h>
-#include <stdlib.h>
+#include <cub3d.h>
#include <unistd.h>
void
ft_music_fork(char **mcmd_words, char *const envp[])
{
- /* execve(2) here */
- char *arg[3];
+ if (FT_OS == 1)
+ execve("/usr/bin/afplay", mcmd_words, envp);
+ else
+ execve("/usr/bin/aplay", mcmd_words, envp);
+}
- arg[0] = "/usr/bin/aplay";
- arg[1] = "./media/sound/DEVANT-LES-KAISSONS.wav";
- arg[2] = NULL;
- (void)mcmd_words;
- execve("/usr/bin/aplay", &arg[0], envp);
+void
+ ft_enable_music(t_cub *cl)
+{
+ cl->isoldmus = 1;
+ cl->mpid = fork();
+ if (cl->mpid == 0)
+ {
+ ft_music_fork(cl->mlist.mcmd_words, cl->envp);
+ }
}
diff --git a/src/ft_treat_args.c b/src/ft_treat_args.c
index 79eedae..a47f9f7 100644
--- a/src/ft_treat_args.c
+++ b/src/ft_treat_args.c
@@ -31,18 +31,17 @@ uint8_t
uint8_t
ft_use_args(int argc, const char *argv[], char *const envp[], t_cub *clist)
{
+ clist->envp = envp;
if (argc < 3)
{
if (ft_init_winptr(clist) < 0)
+ {
return (ft_exit(FT_RET_FAILED_MLX, clist));
+ }
ft_draw_scene(clist);
if (clist->mlist.ismusic)
{
- /* create music fork() here */
- clist->isoldmus = 1;
- clist->mpid = fork();
- if (clist->mpid == 0)
- ft_music_fork(clist->mlist.mcmd_words, envp);
+ ft_enable_music(clist);
}
ft_hooks_and_loops(&clist->wlist, clist);
}
diff --git a/src/ft_warp_level.c b/src/ft_warp_level.c
index 2721aca..37789a5 100644
--- a/src/ft_warp_level.c
+++ b/src/ft_warp_level.c
@@ -78,9 +78,7 @@ static void
{
kill(cl->mpid, SIGTERM);
wait(&cl->mpid);
- /* cl->mpid = fork(); */
- /* if (cl->mpid == 0) */
- /* ft_music_fork(cl->mlist.mcmd_words); */
+ ft_enable_music(cl);
}
else if (isoldmus && cl->mlist.ismusic
&& !ft_strncmp(tmp_mup, cl->mlist.music_path, ft_strlen(tmp_mup) + 1))