files cleaned (WORKING)
This commit is contained in:
4
.gitignore
vendored
4
.gitignore
vendored
@@ -5,3 +5,7 @@ objs/
|
|||||||
a\.out\.dSYM/
|
a\.out\.dSYM/
|
||||||
|
|
||||||
a\.out
|
a\.out
|
||||||
|
|
||||||
|
*.swo
|
||||||
|
|
||||||
|
*.swp
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
.test_mask.c.swp
BIN
.test_mask.c.swp
Binary file not shown.
@@ -6,13 +6,13 @@
|
|||||||
/* By: hulamy <hulamy@student.42.fr> +#+ +:+ +#+ */
|
/* By: hulamy <hulamy@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2019/04/14 15:20:53 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 "fillit.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "libft/includes/libft.h"
|
//#include "libft/includes/libft.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** this function prints a 16 bites short
|
** this function prints a 16 bites short
|
||||||
@@ -24,8 +24,8 @@ void print_bits(short line)
|
|||||||
|
|
||||||
mask = 1 << 27;
|
mask = 1 << 27;
|
||||||
while (mask >>= 1)
|
while (mask >>= 1)
|
||||||
(line & mask) ? ft_putnbr(1) : ft_putnbr(0);
|
(line & mask) ? write(1, "1", 1) : write(1, "0", 1);
|
||||||
ft_putchar('\n');
|
write(1, "\n", 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -33,17 +33,19 @@ void print_bits(short line)
|
|||||||
** then it fills it and its reverse into the list
|
** 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;
|
short tmp;
|
||||||
int test;
|
int test;
|
||||||
|
int i;
|
||||||
|
|
||||||
while (*line)
|
i = 0;
|
||||||
|
while (line[i])
|
||||||
{
|
{
|
||||||
list->tetribit <<= 1;
|
list->tetribit <<= 1;
|
||||||
if (*line == '\n')
|
if (line[i] == '\n')
|
||||||
line++;
|
i++;
|
||||||
if (*(line++) == '#')
|
if (line[i++] == '#')
|
||||||
list->tetribit |= 1;
|
list->tetribit |= 1;
|
||||||
}
|
}
|
||||||
tmp = list->tetribit;
|
tmp = list->tetribit;
|
||||||
@@ -128,7 +130,7 @@ void test(unsigned int map[])
|
|||||||
mask = (mask >> 1) | (((1 << (i % 32)) & map[j]) << (31 - (i % 32)));
|
mask = (mask >> 1) | (((1 << (i % 32)) & map[j]) << (31 - (i % 32)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
int main(int ac, char **av)
|
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
|
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);
|
return (0);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|||||||
7
fillit.h
7
fillit.h
@@ -6,7 +6,7 @@
|
|||||||
/* By: vmanzoni <vmanzoni@student.42.fr> +#+ +:+ +#+ */
|
/* By: vmanzoni <vmanzoni@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2019/03/01 13:34:46 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 <stdio.h> // for debug printf
|
#include <stdio.h> // for debug printf
|
||||||
#include <stdbool.h> // to use bool type
|
#include <stdbool.h> // to use bool type
|
||||||
|
|
||||||
# define BUFF_SIZE 1024
|
#include "libft/includes/libft.h"
|
||||||
|
|
||||||
|
//# define BUFF_SIZE 1024
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** STRUCTURE
|
** STRUCTURE
|
||||||
@@ -45,5 +47,6 @@ int check_file_errors(char *file);
|
|||||||
int check_tetri_errors(char *tetri);
|
int check_tetri_errors(char *tetri);
|
||||||
int check_tetri_errors2(char *tetri);
|
int check_tetri_errors2(char *tetri);
|
||||||
int add_to_list(char *square, t_fillist **list);
|
int add_to_list(char *square, t_fillist **list);
|
||||||
|
int fill_list(char *line, t_fillist *list);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
2
main.c
2
main.c
@@ -6,7 +6,7 @@
|
|||||||
/* By: vmanzoni <vmanzoni@student.42.fr> +#+ +:+ +#+ */
|
/* By: vmanzoni <vmanzoni@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2019/02/12 13:20:48 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 */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|||||||
@@ -6,28 +6,12 @@
|
|||||||
/* By: vmanzoni <vmanzoni@student.42.fr> +#+ +:+ +#+ */
|
/* By: vmanzoni <vmanzoni@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2019/04/15 14:48:14 by vmanzoni #+# #+# */
|
/* Created: 2019/04/15 14:48:14 by vmanzoni #+# #+# */
|
||||||
/* Updated: 2019/04/18 16:09:24 by vmanzoni ### ########.fr */
|
/* Updated: 2019/04/22 17:06:51 by vmanzoni ### ########.fr */
|
||||||
/* Updated: 2019/04/19 12:53:40 by hulamy ### ########.fr */
|
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "fillit.h"
|
#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
|
** Function that parse a file and put each tetrimino in a linked list
|
||||||
*/
|
*/
|
||||||
@@ -56,25 +40,9 @@ char **create_square(char *tetri)
|
|||||||
return (square);
|
return (square);
|
||||||
}
|
}
|
||||||
|
|
||||||
short create_tetribit(char *tetri)
|
/*
|
||||||
{
|
** Function that parse a file and put each tetrimino in a linked list
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
void parse_input(char *input)
|
void parse_input(char *input)
|
||||||
{
|
{
|
||||||
@@ -82,24 +50,18 @@ void parse_input(char *input)
|
|||||||
char tetri[20];
|
char tetri[20];
|
||||||
int i;
|
int i;
|
||||||
int j;
|
int j;
|
||||||
short test; //DELETE BEFORE EVAL
|
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
printf("input: %s\n", input);
|
|
||||||
printf("end\n");
|
|
||||||
while (input[i])
|
while (input[i])
|
||||||
{
|
{
|
||||||
j = 0;
|
j = 0;
|
||||||
while (j < 19)
|
while (j < 19)
|
||||||
tetri[j++] = input[i++];
|
tetri[j++] = input[i++];
|
||||||
tetri[19] = '\0';
|
tetri[19] = '\0';
|
||||||
|
printf("%s\n", tetri);
|
||||||
if (check_tetri_errors(tetri))
|
if (check_tetri_errors(tetri))
|
||||||
print_error("Error: Tetrimino not valid.");
|
print_error("Error: Tetrimino not valid.");
|
||||||
test = create_tetribit(tetri);
|
add_to_list(tetri, &list);
|
||||||
printf("\n");
|
|
||||||
print_bits(test);
|
|
||||||
//test = create_square(tetri);
|
|
||||||
//add_to_list(test, &list);
|
|
||||||
while (input[i] == '\n')
|
while (input[i] == '\n')
|
||||||
i++;
|
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
|
** ce qui suit sert juste a afficher le contenu de tous les tetraminos de la liste chainee
|
||||||
** pour debug, a effacer au rendu
|
** pour debug, a effacer au rendu
|
||||||
*/
|
*/
|
||||||
|
/*
|
||||||
while (list && (i = -1))
|
while (list && (i = -1))
|
||||||
{
|
{
|
||||||
while (++i < list->size[1])
|
while (++i < list->size[1])
|
||||||
@@ -114,4 +77,5 @@ void parse_input(char *input)
|
|||||||
printf("\n");
|
printf("\n");
|
||||||
list = list->next;
|
list = list->next;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user