-
Notifications
You must be signed in to change notification settings - Fork 0
/
check.c
46 lines (42 loc) · 1.61 KB
/
check.c
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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* check.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: snicolet <snicolet@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/03/22 13:36:52 by snicolet #+# #+# */
/* Updated: 2016/03/31 23:33:50 by snicolet ### ########.fr */
/* */
/* ************************************************************************** */
#include "wolf.h"
/*
** returns:
** 0 = empty cell
** 1 = basic wall
** 2 = other walls
** 3 = invisible wall
** 4 = map external border
*/
int check_obstacle(t_context *c, int x, int y, t_mode mode)
{
char p;
if ((y < 0) || (c->map.lines <= (unsigned int)y))
return (MAP_GENERATED);
else if ((x < 0) || (c->map.b[y].size <= x))
return (MAP_GENERATED);
p = c->map.b[y].data[x];
if ((p == ' ') || (p == MAP_SPAWN) || (p == '0'))
return (0);
if (p == MAP_INVISIBLE_WALL)
{
if (c->flags & FLAG_SHOWINVISIBLE)
return (MAP_WALL_STD);
return ((mode == CHECK_WALK) ? 1 : 0);
}
if (p == MAP_SECRET_WALL)
return ((mode == CHECK_WALK) ? 0 : MAP_SECRET_WALL);
if ((p == MAP_GIRL) && (mode == CHECK_WALK))
return (0);
return (p);
}