| Line |
Branch |
Exec |
Source |
| 1 |
|
|
/* |
| 2 |
|
|
** EPITECH PROJECT, 2024 |
| 3 |
|
|
** zappy |
| 4 |
|
|
** File description: |
| 5 |
|
|
** right.c |
| 6 |
|
|
*/ |
| 7 |
|
|
|
| 8 |
|
|
#include "server.h" |
| 9 |
|
|
|
| 10 |
|
|
static const struct { |
| 11 |
|
|
int current_orientation; |
| 12 |
|
|
int next_orientation; |
| 13 |
|
|
} next_orientation_table[] = { |
| 14 |
|
|
{NORTH, EAST}, |
| 15 |
|
|
{EAST, SOUTH}, |
| 16 |
|
|
{SOUTH, WEST}, |
| 17 |
|
|
{WEST, NORTH}, |
| 18 |
|
|
}; |
| 19 |
|
|
|
| 20 |
|
6 |
void right(client_t *c, server_t *server) |
| 21 |
|
|
{ |
| 22 |
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
|
13 |
for (int i = 0; i < 4; i++) { |
| 23 |
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 7 times.
|
13 |
if (next_orientation_table[i].current_orientation == c->orientation) { |
| 24 |
|
6 |
c->orientation = next_orientation_table[i].next_orientation; |
| 25 |
|
6 |
break; |
| 26 |
|
|
} |
| 27 |
|
|
} |
| 28 |
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
|
6 |
if (c->tclient[NB_REQUESTS_HANDLEABLE - 1].available_request == false) { |
| 29 |
|
6 |
message_to_graphicals(server, "ppo %d %d %d %d\n", |
| 30 |
|
6 |
c->id, c->x, c->y, c->orientation); |
| 31 |
|
6 |
handle_response(&c->payload, "ok\n"); |
| 32 |
|
|
} else { |
| 33 |
|
✗ |
handle_response(&c->payload, "ko\n"); |
| 34 |
|
|
} |
| 35 |
|
6 |
client_time_handler(c, RIGHT); |
| 36 |
|
6 |
} |
| 37 |
|
|
|