diff options
-rw-r--r-- | Makefile | 3 | ||||
-rw-r--r-- | inc/cub3d.h | 2 | ||||
-rw-r--r-- | src/ft_check_missing.c | 128 | ||||
-rw-r--r-- | src/ft_check_missing_defines.c | 67 | ||||
-rw-r--r-- | src/ft_check_missing_sfx.c | 56 |
5 files changed, 143 insertions, 113 deletions
@@ -115,6 +115,8 @@ SRCS_NAME += ft_draw_weapons_extra.c SRCS_NAME += ft_draw_handweap.c SRCS_NAME += ft_switch_weapons.c SRCS_NAME += ft_init_weaps.c +SRCS_NAME += ft_check_missing_defines.c +SRCS_NAME += ft_check_missing_sfx.c #--------------------------------------------------------------------------------------------------# SRCS = $(addprefix ${SRCS_DIR},${SRCS_NAME}) #--------------------------------------------------------------------------------------------------# @@ -155,7 +157,6 @@ CFLAGS += -Wall CFLAGS += -Wextra CFLAGS += -Werror CFLAGS += -pedantic -CFLAGS += -march=ivybridge -O2 -pipe #--------------------------------------------------------------------------------------------------# ifdef DEBUG CFLAGS += ${DBG} diff --git a/inc/cub3d.h b/inc/cub3d.h index 5f36a2e..81cb3d0 100644 --- a/inc/cub3d.h +++ b/inc/cub3d.h @@ -135,6 +135,8 @@ int ft_get_map_core(int fd, t_cub *clist); void ft_get_topsp(char c, t_cub *clist); void ft_check_map_surrounds(t_map *ml, t_cub *cl); int ft_check_missing(t_cub *clist); +int ft_check_missing_tex_defines(t_cub *clist); +int ft_check_missing_sfx(t_cub *clist); int ft_missing_error(const char *err, t_cub *clist); int ft_map_error(const char *errmsg, t_cub *clist); size_t ft_get_line_len(char *line); diff --git a/src/ft_check_missing.c b/src/ft_check_missing.c index fb2da64..2b49d2e 100644 --- a/src/ft_check_missing.c +++ b/src/ft_check_missing.c @@ -12,49 +12,18 @@ #include <libft.h> #include <cub3d.h> -#include <unistd.h> static int - ft_check_missing_sfx(t_cub *clist) -{ - 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_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 || - 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 || - 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 || - ft_check_ext(FT_SFX_TRAP_PATH, ".wav") < 0) - return (ft_missing_error(FT_ERR_MISS_SFX_TRAP, clist)); - if (ft_check_not_found(FT_SFX_HEAL_PATH) < 0 || - ft_check_ext(FT_SFX_HEAL_PATH, ".wav") < 0) - return (ft_missing_error(FT_ERR_MISS_SFX_HEAL, clist)); - if (ft_check_not_found(FT_SFX_W_ONE_LOAD_PATH) < 0 || - ft_check_ext(FT_SFX_W_ONE_LOAD_PATH, ".wav") < 0) - return (ft_missing_error(FT_ERR_MISS_SFX_W_ONE_LOAD, clist)); - if (ft_check_not_found(FT_SFX_W_ONE_FIRE_PATH) < 0 || - ft_check_ext(FT_SFX_W_ONE_FIRE_PATH, ".wav") < 0) - return (ft_missing_error(FT_ERR_MISS_SFX_W_ONE_FIRE, clist)); - if (ft_check_not_found(FT_SFX_W_TWO_LOAD_PATH) < 0 || - ft_check_ext(FT_SFX_W_TWO_LOAD_PATH, ".wav") < 0) - return (ft_missing_error(FT_ERR_MISS_SFX_W_TWO_LOAD, clist)); - if (ft_check_not_found(FT_SFX_W_TWO_FIRE_PATH) < 0 || - ft_check_ext(FT_SFX_W_TWO_FIRE_PATH, ".wav") < 0) - return (ft_missing_error(FT_ERR_MISS_SFX_W_TWO_FIRE, clist)); - return (0); -} - -static int - ft_check_missing_sprites(t_cub *clist) + ft_check_missing_bonus(t_cub *clist) { int8_t i; + if (clist->mlist.isnlvl && !clist->mlist.nl_tex_path[0]) + return (ft_missing_error(FT_ERR_MISS_NLVL, clist)); + else if (clist->mlist.isnlvl && !clist->mlist.nlevel_path[0]) + return (ft_missing_error(FT_ERR_MISS_NLVL_PATH, clist)); + if (clist->mlist.istraps && !clist->mlist.traps_path[0]) + return (ft_missing_error(FT_ERR_MISS_TRAP, clist)); if (ft_check_not_found(FT_WEAPON_ONE_SPR_PATH) < 0 || ft_check_ext(FT_WEAPON_ONE_SPR_PATH, ".xpm") < 0) return (ft_missing_error(FT_ERR_MISS_W_ONE_SPR, clist)); @@ -71,79 +40,6 @@ static int return (ft_missing_error(FT_ERR_MISS_SPRITE, clist)); i++; } - return (ft_check_missing_sfx(clist)); -} - -static int - ft_check_missing_tex_defines(t_cub *clist) -{ - if (ft_check_not_found(FT_DEATH_SCREEN_PATH) < 0 || - ft_check_ext(FT_DEATH_SCREEN_PATH, ".xpm") < 0) - return (ft_missing_error(FT_ERR_MISS_DEATH_SCREEN, clist)); - if (ft_check_not_found(FT_HUD_BACK_PATH) < 0 || - ft_check_ext(FT_HUD_BACK_PATH, ".xpm") < 0) - return (ft_missing_error(FT_ERR_MISS_HUD_BACK, clist)); - if (ft_check_not_found(FT_WEAPON_ONE_PATH) < 0 || - ft_check_ext(FT_WEAPON_ONE_PATH, ".xpm") < 0) - return (ft_missing_error(FT_ERR_MISS_W_ONE, clist)); - if (ft_check_not_found(FT_WEAPON_TWO_PATH) < 0 || - ft_check_ext(FT_WEAPON_TWO_PATH, ".xpm") < 0) - return (ft_missing_error(FT_ERR_MISS_W_TWO, clist)); - if (ft_check_not_found(FT_WEAPON_ONE_FIRE_PATH) < 0 || - ft_check_ext(FT_WEAPON_ONE_FIRE_PATH, ".xpm") < 0) - return (ft_missing_error(FT_ERR_MISS_W_ONE_FIRE, clist)); - if (ft_check_not_found(FT_WEAPON_TWO_FIRE_PATH) < 0 || - ft_check_ext(FT_WEAPON_TWO_FIRE_PATH, ".xpm") < 0) - return (ft_missing_error(FT_ERR_MISS_W_TWO_FIRE, clist)); - if (ft_check_not_found(FT_ZER_PATH) < 0 || - ft_check_ext(FT_ZER_PATH, ".xpm") < 0 || - ft_check_not_found(FT_ONE_PATH) < 0 || - ft_check_ext(FT_ONE_PATH, ".xpm") < 0 || - ft_check_not_found(FT_TWO_PATH) < 0 || - ft_check_ext(FT_TWO_PATH, ".xpm") < 0 || - ft_check_not_found(FT_THR_PATH) < 0 || - ft_check_ext(FT_THR_PATH, ".xpm") < 0 || - ft_check_not_found(FT_FOU_PATH) < 0 || - ft_check_ext(FT_FOU_PATH, ".xpm") < 0 || - ft_check_not_found(FT_FIV_PATH) < 0 || - ft_check_ext(FT_FIV_PATH, ".xpm") < 0 || - ft_check_not_found(FT_SIX_PATH) < 0 || - ft_check_ext(FT_SIX_PATH, ".xpm") < 0 || - ft_check_not_found(FT_SEV_PATH) < 0 || - ft_check_ext(FT_SEV_PATH, ".xpm") < 0 || - ft_check_not_found(FT_EIG_PATH) < 0 || - ft_check_ext(FT_EIG_PATH, ".xpm") < 0 || - ft_check_not_found(FT_NIN_PATH) < 0 || - ft_check_ext(FT_NIN_PATH, ".xpm") < 0 || - ft_check_not_found(FT_PER_PATH) < 0 || - ft_check_ext(FT_PER_PATH, ".xpm") < 0) - return (ft_missing_error(FT_ERR_MISS_NUMBER, clist)); - return (ft_check_missing_sprites(clist)); -} - -static int - ft_check_missing_norme(t_cub *clist) -{ - if (!clist->mlist.isftex) - { - if (clist->f_rgb.r == -1 || clist->f_rgb.g == -1 - || clist->f_rgb.b == -1) - return (ft_missing_error(FT_ERR_MISS_FLOOR_C, clist)); - } - if (!clist->mlist.isctex) - { - if (clist->c_rgb.r == -1 || clist->c_rgb.g == -1 - || clist->c_rgb.b == -1) - return (ft_missing_error(FT_ERR_MISS_CEIL_C, clist)); - } - if (clist->plist.pos_x == 0 || clist->plist.pos_y == 0) - return (ft_missing_error(FT_ERR_MISS_PLAYER_SPAWN, clist)); - else if (clist->mlist.isnlvl && !clist->mlist.nl_tex_path[0]) - return (ft_missing_error(FT_ERR_MISS_NLVL, clist)); - else if (clist->mlist.isnlvl && !clist->mlist.nlevel_path[0]) - return (ft_missing_error(FT_ERR_MISS_NLVL_PATH, clist)); - if (clist->mlist.istraps && !clist->mlist.traps_path[0]) - return (ft_missing_error(FT_ERR_MISS_TRAP, clist)); return (ft_check_missing_tex_defines(clist)); } @@ -162,5 +58,13 @@ int return (ft_missing_error(FT_ERR_MISS_SPRITE, clist)); else if (clist->wlist.x_size == 0 || clist->wlist.y_size == 0) return (ft_missing_error(FT_ERR_MISS_RESOLUTION, clist)); - return (ft_check_missing_norme(clist)); + if (clist->plist.pos_x == 0 || clist->plist.pos_y == 0) + return (ft_missing_error(FT_ERR_MISS_PLAYER_SPAWN, clist)); + if (!clist->mlist.isftex && (clist->f_rgb.r == -1 || clist->f_rgb.g == -1 + || clist->f_rgb.b == -1)) + return (ft_missing_error(FT_ERR_MISS_FLOOR_C, clist)); + if (!clist->mlist.isctex && (clist->c_rgb.r == -1 || clist->c_rgb.g == -1 + || clist->c_rgb.b == -1)) + return (ft_missing_error(FT_ERR_MISS_CEIL_C, clist)); + return (ft_check_missing_bonus(clist)); } diff --git a/src/ft_check_missing_defines.c b/src/ft_check_missing_defines.c new file mode 100644 index 0000000..2e365b8 --- /dev/null +++ b/src/ft_check_missing_defines.c @@ -0,0 +1,67 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_check_missing_defines.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: rbousset <marvin@42.fr> +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/02/14 17:28:42 by rbousset #+# #+# */ +/* Updated: 2020/02/14 17:28:42 by rbousset ### ########lyon.fr */ +/* */ +/* ************************************************************************** */ + +#include <libft.h> +#include <cub3d.h> + +static int + ft_check_missing_number_defines(t_cub *clist) +{ + if (ft_check_not_found(FT_ZER_PATH) < 0 || + ft_check_ext(FT_ZER_PATH, ".xpm") < 0 || + ft_check_not_found(FT_ONE_PATH) < 0 || + ft_check_ext(FT_ONE_PATH, ".xpm") < 0 || + ft_check_not_found(FT_TWO_PATH) < 0 || + ft_check_ext(FT_TWO_PATH, ".xpm") < 0 || + ft_check_not_found(FT_THR_PATH) < 0 || + ft_check_ext(FT_THR_PATH, ".xpm") < 0 || + ft_check_not_found(FT_FOU_PATH) < 0 || + ft_check_ext(FT_FOU_PATH, ".xpm") < 0 || + ft_check_not_found(FT_FIV_PATH) < 0 || + ft_check_ext(FT_FIV_PATH, ".xpm") < 0 || + ft_check_not_found(FT_SIX_PATH) < 0 || + ft_check_ext(FT_SIX_PATH, ".xpm") < 0 || + ft_check_not_found(FT_SEV_PATH) < 0 || + ft_check_ext(FT_SEV_PATH, ".xpm") < 0 || + ft_check_not_found(FT_EIG_PATH) < 0 || + ft_check_ext(FT_EIG_PATH, ".xpm") < 0 || + ft_check_not_found(FT_NIN_PATH) < 0 || + ft_check_ext(FT_NIN_PATH, ".xpm") < 0 || + ft_check_not_found(FT_PER_PATH) < 0 || + ft_check_ext(FT_PER_PATH, ".xpm") < 0) + return (ft_missing_error(FT_ERR_MISS_NUMBER, clist)); + return (ft_check_missing_sfx(clist)); +} + +int + ft_check_missing_tex_defines(t_cub *clist) +{ + if (ft_check_not_found(FT_DEATH_SCREEN_PATH) < 0 || + ft_check_ext(FT_DEATH_SCREEN_PATH, ".xpm") < 0) + return (ft_missing_error(FT_ERR_MISS_DEATH_SCREEN, clist)); + if (ft_check_not_found(FT_HUD_BACK_PATH) < 0 || + ft_check_ext(FT_HUD_BACK_PATH, ".xpm") < 0) + return (ft_missing_error(FT_ERR_MISS_HUD_BACK, clist)); + if (ft_check_not_found(FT_WEAPON_ONE_PATH) < 0 || + ft_check_ext(FT_WEAPON_ONE_PATH, ".xpm") < 0) + return (ft_missing_error(FT_ERR_MISS_W_ONE, clist)); + if (ft_check_not_found(FT_WEAPON_TWO_PATH) < 0 || + ft_check_ext(FT_WEAPON_TWO_PATH, ".xpm") < 0) + return (ft_missing_error(FT_ERR_MISS_W_TWO, clist)); + if (ft_check_not_found(FT_WEAPON_ONE_FIRE_PATH) < 0 || + ft_check_ext(FT_WEAPON_ONE_FIRE_PATH, ".xpm") < 0) + return (ft_missing_error(FT_ERR_MISS_W_ONE_FIRE, clist)); + if (ft_check_not_found(FT_WEAPON_TWO_FIRE_PATH) < 0 || + ft_check_ext(FT_WEAPON_TWO_FIRE_PATH, ".xpm") < 0) + return (ft_missing_error(FT_ERR_MISS_W_TWO_FIRE, clist)); + return (ft_check_missing_number_defines(clist)); +} diff --git a/src/ft_check_missing_sfx.c b/src/ft_check_missing_sfx.c new file mode 100644 index 0000000..f8a32b1 --- /dev/null +++ b/src/ft_check_missing_sfx.c @@ -0,0 +1,56 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_check_missing_sfx.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: rbousset <marvin@42.fr> +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/02/14 17:28:42 by rbousset #+# #+# */ +/* Updated: 2020/02/14 17:28:42 by rbousset ### ########lyon.fr */ +/* */ +/* ************************************************************************** */ + +#include <libft.h> +#include <cub3d.h> + +static int + ft_check_missing_weapon_sfx(t_cub *clist) +{ + if (ft_check_not_found(FT_SFX_W_ONE_LOAD_PATH) < 0 || + ft_check_ext(FT_SFX_W_ONE_LOAD_PATH, ".wav") < 0) + return (ft_missing_error(FT_ERR_MISS_SFX_W_ONE_LOAD, clist)); + if (ft_check_not_found(FT_SFX_W_ONE_FIRE_PATH) < 0 || + ft_check_ext(FT_SFX_W_ONE_FIRE_PATH, ".wav") < 0) + return (ft_missing_error(FT_ERR_MISS_SFX_W_ONE_FIRE, clist)); + if (ft_check_not_found(FT_SFX_W_TWO_LOAD_PATH) < 0 || + ft_check_ext(FT_SFX_W_TWO_LOAD_PATH, ".wav") < 0) + return (ft_missing_error(FT_ERR_MISS_SFX_W_TWO_LOAD, clist)); + if (ft_check_not_found(FT_SFX_W_TWO_FIRE_PATH) < 0 || + ft_check_ext(FT_SFX_W_TWO_FIRE_PATH, ".wav") < 0) + return (ft_missing_error(FT_ERR_MISS_SFX_W_TWO_FIRE, clist)); + return (0); +} + +int + ft_check_missing_sfx(t_cub *clist) +{ + 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_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 || + 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 || + 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 || + ft_check_ext(FT_SFX_TRAP_PATH, ".wav") < 0) + return (ft_missing_error(FT_ERR_MISS_SFX_TRAP, clist)); + if (ft_check_not_found(FT_SFX_HEAL_PATH) < 0 || + ft_check_ext(FT_SFX_HEAL_PATH, ".wav") < 0) + return (ft_missing_error(FT_ERR_MISS_SFX_HEAL, clist)); + return (ft_check_missing_weapon_sfx(clist)); +} |