//
//  resolution.c
//  labyrinthe
//
//  Created by léo LELLOUCHE on 11/04/2016.
//  Copyright © 2016 léo LELLOUCHE. All rights reserved.
//

#include "header.h"

void        resolution(t_list *path, char **labyrinthe)
{
    // Etant donné que l'on sauvegarde qu'un seul point sur 2, il faut afficher les points intermediares
    int ligne_suivante;
    int colonne_suivante;
    
    if (labyrinthe[(*path).line][(*path).col] != MUR_EXT)
        labyrinthe[(*path).line][(*path).col] = 'x';
    if ((*path).next != NULL)
    {
        ligne_suivante = ((*path).line + (*(*path).next).line) / 2;
        colonne_suivante = ((*path).col + (*(*path).next).col) / 2;
        if (labyrinthe[ligne_suivante][colonne_suivante] != MUR_EXT)
            labyrinthe[ligne_suivante][colonne_suivante] = 'x';
        resolution((*path).next, labyrinthe);
    }
    else
        print_tab(labyrinthe, 0, 1);
}

void      tmp_path_to_t_list(t_list *old_lst, char **tmp_path, int size_path)
{
    static int  tete_lecture = 2;
    
    lstnew(atoi(tmp_path[tete_lecture + 1]), atoi(tmp_path[tete_lecture]), old_lst);
    tete_lecture = tete_lecture + 2;
    if (tete_lecture < size_path)
        tmp_path_to_t_list(old_lst->next, tmp_path, size_path);
    else
        tete_lecture = 2;
}