aboutsummaryrefslogtreecommitdiff
path: root/parse/parse_check.c
diff options
context:
space:
mode:
authorCharles <sircharlesaze@gmail.com>2020-01-11 12:37:34 +0100
committerCharles <sircharlesaze@gmail.com>2020-01-11 12:37:34 +0100
commitcff05e83256a67b8cb23b16b1e1e6f761ff52f4c (patch)
tree33eb6eae520a085d6774205601f13d07dc99aaf9 /parse/parse_check.c
parent0dcba6ff7e68ed13f8e6caadd80b77506b917050 (diff)
downloadcub3d-cff05e83256a67b8cb23b16b1e1e6f761ff52f4c.tar.gz
cub3d-cff05e83256a67b8cb23b16b1e1e6f761ff52f4c.tar.bz2
cub3d-cff05e83256a67b8cb23b16b1e1e6f761ff52f4c.zip
fixing a few segfault, map border checking
Diffstat (limited to 'parse/parse_check.c')
-rw-r--r--parse/parse_check.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/parse/parse_check.c b/parse/parse_check.c
new file mode 100644
index 0000000..7bcfc8b
--- /dev/null
+++ b/parse/parse_check.c
@@ -0,0 +1,44 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* check.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2020/01/11 10:59:15 by cacharle #+# #+# */
+/* Updated: 2020/01/11 11:15:04 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 (state_destroy(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 (state_destroy(state));
+ // maybe not necessary
+ /* 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 (state_destroy(state)); */
+ return (state);
+}