diff options
Diffstat (limited to 'src/parse/parse_file.c')
| -rw-r--r-- | src/parse/parse_file.c | 38 |
1 files changed, 36 insertions, 2 deletions
diff --git a/src/parse/parse_file.c b/src/parse/parse_file.c index 443a1b5..8c6ef5e 100644 --- a/src/parse/parse_file.c +++ b/src/parse/parse_file.c @@ -6,7 +6,7 @@ /* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/02/04 03:50:53 by cacharle #+# #+# */ -/* Updated: 2020/02/04 04:28:41 by cacharle ### ########.fr */ +/* Updated: 2020/02/05 01:27:26 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ @@ -49,5 +49,39 @@ char **get_file_lines(char *filename) if (ret == -1) return (NULL); close(fd); - return (trim_file_lines(ft_split(file, '\n'))); + return (trim_file_lines(ft_split_strict(file, '\n'))); +} + +int parse_premap(t_state *state, char **lines) +{ + int i; + + i = -1; + while (lines[++i] != NULL) + { + if (*lines[i] == '\n') + continue ; + if (*lines[i] == '1') + break ; + if (!parse_line(state, lines[i])) + return (-1); + } + return (i); +} + +t_bool create_map_row_char(char c, t_cell *row, int i) +{ + if (c == '0' || c == '1' || c == '2') + row[i] = c - '0'; + else if (c == 'N') + row[i] = CELL_LOOK_NORTH; + else if (c == 'S') + row[i] = CELL_LOOK_SOUTH; + else if (c == 'W') + row[i] = CELL_LOOK_WEST; + else if (c == 'E') + row[i] = CELL_LOOK_EAST; + else + return (FALSE); + return (TRUE); } |
