aboutsummaryrefslogtreecommitdiffstats
path: root/src/ft_check_missing.c
blob: b223e6fc00dcc081ce64e99117b5824c9c50f787 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   ft_check_missing.c                                 :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: joelecle <marvin@42.fr>                    +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2020/02/14 17:28:42 by joelecle          #+#    #+#             */
/*   Updated: 2020/02/14 17:28:42 by joelecle         ###   ########lyon.fr   */
/*                                                                            */
/* ************************************************************************** */

#include <libft.h>
#include <cub3d.h>

static int
	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));
	if (ft_check_not_found(FT_WEAPON_TWO_SPR_PATH) < 0 ||
		ft_check_ext(FT_WEAPON_TWO_SPR_PATH, ".xpm") < 0)
		return (ft_missing_error(FT_ERR_MISS_W_TWO_SPR, clist));
	i = 0;
	while ((i + 2) <= clist->mlist.topsp)
	{
		if (!clist->mlist.sprite_path[i][0])
			return (ft_missing_error(FT_ERR_MISS_SPRITE, clist));
		i++;
	}
	return (ft_check_missing_tex_defines(clist));
}

int
	ft_check_missing(t_cub *clist)
{
	if (!clist->mlist.no_tex_path[0])
		return (ft_missing_error(FT_ERR_MISS_NORTH, clist));
	else if (!clist->mlist.so_tex_path[0])
		return (ft_missing_error(FT_ERR_MISS_SOUTH, clist));
	else if (!clist->mlist.ea_tex_path[0])
		return (ft_missing_error(FT_ERR_MISS_EAST, clist));
	else if (!clist->mlist.we_tex_path[0])
		return (ft_missing_error(FT_ERR_MISS_WEST, clist));
	else if (!clist->mlist.sprite_path[0][0])
		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));
	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));
}