aboutsummaryrefslogtreecommitdiffstats
path: root/src/ft_sfx_trap.c
diff options
context:
space:
mode:
authorJozanLeClerc <bousset.rudy@gmail.com>2020-03-13 18:09:55 +0100
committerJozanLeClerc <bousset.rudy@gmail.com>2020-03-13 18:09:55 +0100
commit273459283c98b5f10814fdf74c74c2e6a13f10c0 (patch)
tree6959619028e32cb5452e7ca6b65cccf5a7ca0072 /src/ft_sfx_trap.c
parentNew sfx, clean exit (diff)
download42-cub3d-273459283c98b5f10814fdf74c74c2e6a13f10c0.tar.gz
42-cub3d-273459283c98b5f10814fdf74c74c2e6a13f10c0.tar.bz2
42-cub3d-273459283c98b5f10814fdf74c74c2e6a13f10c0.tar.xz
42-cub3d-273459283c98b5f10814fdf74c74c2e6a13f10c0.tar.zst
42-cub3d-273459283c98b5f10814fdf74c74c2e6a13f10c0.zip
Not ideal
Diffstat (limited to 'src/ft_sfx_trap.c')
-rw-r--r--src/ft_sfx_trap.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/src/ft_sfx_trap.c b/src/ft_sfx_trap.c
index 32fc35a..cf5dafa 100644
--- a/src/ft_sfx_trap.c
+++ b/src/ft_sfx_trap.c
@@ -12,21 +12,22 @@
#include <cub3d.h>
#include <unistd.h>
+#include <stdint.h>
static void
ft_sfx_pain(t_cub *cl)
{
- static uint8_t ref_scr = 0;
+ static uint8_t ref = 0;
- ref_scr += 1;
- if (ref_scr > 201)
- ref_scr = 0;
- if (ref_scr % 2)
+ ref += 1;
+ if (ref > 201)
+ ref = 0;
+ if (ref % 2)
{
- cl->pain_pid = fork();
- if (cl->pain_pid == 0)
+ cl->sfx.pain_pid = fork();
+ if (cl->sfx.pain_pid == 0)
{
- if (ref_scr % 3)
+ if (ref % 3)
execve(*(cl->sfx.pain_one + 0), cl->sfx.pain_one, cl->envp);
else
execve(*(cl->sfx.pain_two + 0), cl->sfx.pain_two, cl->envp);
@@ -37,8 +38,8 @@ static void
void
ft_sfx_trap(t_cub *cl)
{
- cl->trap_pid = fork();
- if (cl->trap_pid == 0)
+ cl->sfx.trap_pid = fork();
+ if (cl->sfx.trap_pid == 0)
execve(*(cl->sfx.trap + 0), cl->sfx.trap, cl->envp);
ft_sfx_pain(cl);
}