void ft_free_tab(t_list **begin_list) { int size; char **tab; int i; size = ft_tab_len(begin_list); tab = ft_init_tab(size); i = 0; while (!ft_backtraking(begin_list, tab)) { while (tab[i]) { free(tab[i++]); } free(tab); size++; tab = ft_init_tab(size); } ft_print_tab(tab); i = 0; while (tab[i]) { free(tab[i++]); } free(tab); }
int ft_intersection(t_obj *obj, t_3d p_beg, t_3d v_ray) { static int init = 0; static t_inter tab_inter[4]; float coef; t_3d tmp; coef = -1; obj->distance = -1; if (init == 0) { ft_init_tab(tab_inter); init = 1; } coef = tab_inter[(int)obj->type].inter(obj, p_beg, v_ray); if (coef == -1) return (0); else { ft_init3d(&obj->p_inter, p_beg.x + v_ray.x * coef, p_beg.y + v_ray.y * coef, p_beg.z + v_ray.z * coef); ft_init3d(&tmp, obj->p_inter.x - p_beg.x, obj->p_inter.y - p_beg.y, obj->p_inter.z - p_beg.z); obj->distance = ft_norme(&tmp); } return (1); }
static void ft_init_game(t_game *game) { int i; i = 0; while (i < MAX_CLI) { ft_bzero(&game->eggs[i], sizeof(t_egg)); ft_bzero(&game->cls[i], sizeof(t_client)); i++; } ft_init_tab(game->tab); game->tab[12].line = ft_strdup("birth"); game->tab[12].t = 600; game->sock = 0; game->port = 4242; game->width = 20; game->height = 20; game->nourr_base = 0; i = 0; while (i < MAX_NB_TEAM) { game->max_cli[i] = 6; i++; } game->time = 100; }
t_bool ft_sudoku_check_block(int grille[9][9], int position) { t_bool check[10]; int i; int j; int min_i; int min_j; ft_init_tab(check); min_i = ((position / 9) - ((position / 9) % 3)); min_j = ((position % 9) - ((position % 9) % 3)); i = min_i; while (i < (min_i + 3)) { j = min_j; while (j < (min_j + 3)) { if (grille[i][j] < 0 || grille[i][j] > 9 || (check[grille[i][j]])) return (FALSE); if (grille[i][j] != 0) check[grille[i][j]] = TRUE; j++; } i++; } return (TRUE); }
void bit_convert(char *buf, t_tetri *tetris) { int tab[3]; int power; I = -1; J = -1; tetris->tetris = (t_tetris2*)malloc(sizeof(t_tetris2) * tetris->nb_tetris); while (buf[++I]) { K = 0; ft_init_tab(TET[++J].tetris, 16); TET[J].carac = 'A' + J; while ((buf[I] != '\n' && buf[I + 1] != '\n') && buf[I--]) { power = 0; while (buf[++I] != '\n') { if (buf[I] == '#') TET[J].tetris[K] += ft_power(2, power); power++; } K++; I++; } bit_reset(TET[J].tetris, 4); } }
t_bool ft_sudoku_check_column(int grille[9][9], int position) { t_bool check[10]; int i; int j; i = 0; j = (position % 9); ft_init_tab(check); while (i < 9) { if (grille[i][j] < 0 || grille[i][j] > 9 || (check[grille[i][j]])) return (FALSE); if (grille[i][j] != 0) check[grille[i][j]] = TRUE; i++; } return (TRUE); }