blob: 5fc2674739e9f0faedfee32433427530bcf673f2 (
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
|
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* check.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/01/11 10:59:15 by cacharle #+# #+# */
/* Updated: 2020/02/02 19:42:34 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
#include "cub3d.h"
t_state *parse_check(t_state *state)
{
int i;
int j;
int player_count;
i = -1;
while (++i < state->map_width)
if (state->map[0][i] != CELL_WALL
|| state->map[state->map_height - 1][i] != CELL_WALL)
return (error_put_return_state_destroy(
"validate map without borders", state));
i = -1;
while (++i < state->map_height)
if (state->map[i][0] != CELL_WALL
|| state->map[i][state->map_width - 1] != CELL_WALL)
return (error_put_return_state_destroy(
"validate map without borders", state));
player_count = 0;
i = -1;
while (++i < state->map_height)
{
j = -1;
while (++j < state->map_width)
if (helper_is_player_cell(state->map[i][j]))
player_count++;
}
if (player_count != 1)
return (error_put_return_state_destroy("only one player allowed", state));
return (state);
}
|