From e820bd7a581075f5b45ec8118046e8c467d83f4a Mon Sep 17 00:00:00 2001 From: klmp200 Date: Mon, 18 Jun 2018 15:56:22 +0200 Subject: [PATCH] =?UTF-8?q?Et=20voil=C3=A0,=20c'est=20propre=20comme=20?= =?UTF-8?q?=C3=A7a=20:D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Building/Building.c | 2 +- Elevator/Elevator.c | 6 +++--- Elevator/Elevator.h | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Building/Building.c b/Building/Building.c index b15f4ac..85c1351 100644 --- a/Building/Building.c +++ b/Building/Building.c @@ -144,7 +144,7 @@ int get_inside_elevator_Building(THIS(Building), int current_floor, ElevatorPass if (this->elevators[i]->can_get_inside(this->elevators[i], current_floor)){ /* pour faire taire le compilateur le temps que je revienne sur cette fonction */ if (elevator_passenger.type == VISITOR) - this->elevators[i]->add_passenger(this->elevators[i], elevator_passenger.passenger.visitor->get_id(elevator_passenger.passenger.visitor)); + this->elevators[i]->add_passenger(this->elevators[i], elevator_passenger); /* Il faut faire des trucs ici */ pthread_mutex_unlock(this->mutex_func_get_inside_elevator); return i; diff --git a/Elevator/Elevator.c b/Elevator/Elevator.c index 3ff7288..6080c70 100644 --- a/Elevator/Elevator.c +++ b/Elevator/Elevator.c @@ -28,11 +28,11 @@ void _free__Elevator(THIS(Elevator)){ free(this); } -void add_passenger_Elevator(THIS(Elevator), int passenger_id){ +void add_passenger_Elevator(THIS(Elevator), ElevatorPassenger passenger){ pthread_mutex_lock(&this->mutex_passenger); - this->passengers->insert_tail(this->passengers, ((void *)&passenger_id), sizeof(int)); + this->passengers->insert_tail(this->passengers, ((void *)&passenger), sizeof(ElevatorPassenger)); printf("Le passager avec l'id %d est entre dans l'ascenseur %s\nIl y a maintenant %d passagers dans l'ascenseur %s\n", - passenger_id, this->name, this->passengers->get_size(this->passengers), this->name); + passenger.passenger.visitor->get_id(passenger.passenger.visitor), this->name, this->passengers->get_size(this->passengers), this->name); if (this->passengers->get_size(this->passengers) >= MAX_ELEVATOR_CAPACITY) this->set_state(this, SLEEPING); pthread_mutex_unlock(&this->mutex_passenger); diff --git a/Elevator/Elevator.h b/Elevator/Elevator.h index 98b9ccb..24a52b1 100644 --- a/Elevator/Elevator.h +++ b/Elevator/Elevator.h @@ -31,7 +31,7 @@ typedef struct o_Elevator { SYNCHRONIZE PUBLIC void (*repair)(_THIS(Elevator)); SYNCHRONIZE PUBLIC int (*get_number_of_passengers)(_THIS(Elevator)); - SYNCHRONIZE PUBLIC void (*add_passenger)(_THIS(Elevator), int passenger_id); + SYNCHRONIZE PUBLIC void (*add_passenger)(_THIS(Elevator), ElevatorPassenger passenger); SYNCHRONIZE PUBLIC ELEVATOR_STATE (*get_state)(_THIS(Elevator)); SYNCHRONIZE PUBLIC int (*get_floor)(_THIS(Elevator)); SYNCHRONIZE PUBLIC int (*can_get_inside)(_THIS(Elevator), int floor);