diff --git a/.gitignore b/.gitignore index e525c97..862bf81 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,7 @@ objs/ a\.out\.dSYM/ a\.out + +*.swo + +*.swp diff --git a/.parse_input.c.swo b/.parse_input.c.swo deleted file mode 100644 index 90e58e0..0000000 Binary files a/.parse_input.c.swo and /dev/null differ diff --git a/.parse_input.c.swp b/.parse_input.c.swp deleted file mode 100644 index b44adaa..0000000 Binary files a/.parse_input.c.swp and /dev/null differ diff --git a/.test_big_map.c.swp b/.test_big_map.c.swp deleted file mode 100644 index e95f62a..0000000 Binary files a/.test_big_map.c.swp and /dev/null differ diff --git a/.test_mask.c.swp b/.test_mask.c.swp deleted file mode 100644 index 6204ff1..0000000 Binary files a/.test_mask.c.swp and /dev/null differ diff --git a/add_to_list.c b/add_to_list.c index 3630c81..048db2a 100644 --- a/add_to_list.c +++ b/add_to_list.c @@ -6,13 +6,13 @@ /* By: hulamy +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/04/14 15:20:53 by hulamy #+# #+# */ -/* Updated: 2019/04/22 15:12:47 by vmanzoni ### ########.fr */ +/* Updated: 2019/04/22 15:58:39 by vmanzoni ### ########.fr */ /* */ /* ************************************************************************** */ #include "fillit.h" #include -#include "libft/includes/libft.h" +//#include "libft/includes/libft.h" /* ** this function prints a 16 bites short @@ -24,8 +24,8 @@ void print_bits(short line) mask = 1 << 27; while (mask >>= 1) - (line & mask) ? ft_putnbr(1) : ft_putnbr(0); - ft_putchar('\n'); + (line & mask) ? write(1, "1", 1) : write(1, "0", 1); + write(1, "\n", 1); } /* @@ -33,17 +33,19 @@ void print_bits(short line) ** then it fills it and its reverse into the list */ -int fill_list(char *line, t_fillist *list) +int fill_list(char line[], t_fillist *list) { short tmp; int test; + int i; - while (*line) + i = 0; + while (line[i]) { list->tetribit <<= 1; - if (*line == '\n') - line++; - if (*(line++) == '#') + if (line[i] == '\n') + i++; + if (line[i++] == '#') list->tetribit |= 1; } tmp = list->tetribit; @@ -128,7 +130,7 @@ void test(unsigned int map[]) mask = (mask >> 1) | (((1 << (i % 32)) & map[j]) << (31 - (i % 32))); } } - +/* int main(int ac, char **av) { static t_fillist *list = NULL; // avant d'appeller add_to_list il faut declarer un pointeur static vers la structure @@ -150,3 +152,4 @@ int main(int ac, char **av) return (0); } +*/ diff --git a/fillit.h b/fillit.h index 94895c2..7a60d6a 100644 --- a/fillit.h +++ b/fillit.h @@ -6,7 +6,7 @@ /* By: vmanzoni +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/03/01 13:34:46 by vmanzoni #+# #+# */ -/* Updated: 2019/04/19 14:52:10 by hulamy ### ########.fr */ +/* Updated: 2019/04/22 15:57:43 by vmanzoni ### ########.fr */ /* */ /* ************************************************************************** */ @@ -20,7 +20,9 @@ #include // for debug printf #include // to use bool type -# define BUFF_SIZE 1024 +#include "libft/includes/libft.h" + +//# define BUFF_SIZE 1024 /* ** STRUCTURE @@ -45,5 +47,6 @@ int check_file_errors(char *file); int check_tetri_errors(char *tetri); int check_tetri_errors2(char *tetri); int add_to_list(char *square, t_fillist **list); +int fill_list(char *line, t_fillist *list); #endif diff --git a/main.c b/main.c index d7dfc4b..47cdfd7 100644 --- a/main.c +++ b/main.c @@ -6,7 +6,7 @@ /* By: vmanzoni +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/02/12 13:20:48 by vmanzoni #+# #+# */ -/* Updated: 2019/04/16 16:41:28 by vmanzoni ### ########.fr */ +/* Updated: 2019/04/22 15:50:16 by vmanzoni ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/parse_input.c b/parse_input.c index 9dbda39..4028264 100644 --- a/parse_input.c +++ b/parse_input.c @@ -6,28 +6,12 @@ /* By: vmanzoni +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/04/15 14:48:14 by vmanzoni #+# #+# */ -/* Updated: 2019/04/18 16:09:24 by vmanzoni ### ########.fr */ -/* Updated: 2019/04/19 12:53:40 by hulamy ### ########.fr */ +/* Updated: 2019/04/22 17:06:51 by vmanzoni ### ########.fr */ /* */ /* ************************************************************************** */ #include "fillit.h" -/* -** !!! DELETE PRINT_BITS BEFORE EVAL !!! -*/ - -void print_bits(short octet) -{ - int i; - - i = 1 << 16; - while (i >>= 1) - (octet & i) ? write(1, "1", 1) : write(1, "0", 1); - printf("\n"); -} - - /* ** Function that parse a file and put each tetrimino in a linked list */ @@ -56,25 +40,9 @@ char **create_square(char *tetri) return (square); } -short create_tetribit(char *tetri) -{ - short tetribit; - int i; - - i = 0; - tetribit = 0; - while (tetri[i]) - { - if (tetri[i] != '\n') // Pour comparer avec le tetri en char - printf("%c", tetri[i]); - if (tetri[i] == '#') - tetribit = tetribit | 1; - else - tetribit <<= 1; - i++; - } - return (tetribit); -} +/* +** Function that parse a file and put each tetrimino in a linked list +*/ void parse_input(char *input) { @@ -82,24 +50,18 @@ void parse_input(char *input) char tetri[20]; int i; int j; - short test; //DELETE BEFORE EVAL i = 0; - printf("input: %s\n", input); - printf("end\n"); while (input[i]) { j = 0; while (j < 19) tetri[j++] = input[i++]; tetri[19] = '\0'; + printf("%s\n", tetri); if (check_tetri_errors(tetri)) print_error("Error: Tetrimino not valid."); - test = create_tetribit(tetri); - printf("\n"); - print_bits(test); - //test = create_square(tetri); - //add_to_list(test, &list); + add_to_list(tetri, &list); while (input[i] == '\n') i++; } @@ -107,6 +69,7 @@ void parse_input(char *input) ** ce qui suit sert juste a afficher le contenu de tous les tetraminos de la liste chainee ** pour debug, a effacer au rendu */ + /* while (list && (i = -1)) { while (++i < list->size[1]) @@ -114,4 +77,5 @@ void parse_input(char *input) printf("\n"); list = list->next; } + */ }