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