Line |
Branch |
Exec |
Source |
1 |
|
|
/* |
2 |
|
|
** EPITECH PROJECT, 2024 |
3 |
|
|
** zappy |
4 |
|
|
** File description: |
5 |
|
|
** fork.c |
6 |
|
|
*/ |
7 |
|
|
|
8 |
|
|
#include "client.h" |
9 |
|
|
#include "server.h" |
10 |
|
|
|
11 |
|
✗ |
void fork_z(client_t *c, server_t *server) |
12 |
|
|
{ |
13 |
|
✗ |
eggs_list_t *new_egg = malloc(sizeof(eggs_list_t)); |
14 |
|
✗ |
team_t *team = get_team_by_name(&server->teams, c->team_name); |
15 |
|
|
|
16 |
|
✗ |
if (new_egg == NULL || team == NULL) |
17 |
|
|
return; |
18 |
|
✗ |
new_egg->egg = init_egg(server->proprieties.width, |
19 |
|
|
server->proprieties.height); |
20 |
|
✗ |
if (new_egg->egg == NULL) |
21 |
|
|
return; |
22 |
|
✗ |
TAILQ_INSERT_TAIL(&team->eggs, new_egg, entries); |
23 |
|
✗ |
if (c->tclient[NB_REQUESTS_HANDLEABLE - 1].available_request == false) { |
24 |
|
✗ |
message_to_graphicals(server, "pfk %d\n", c->id); |
25 |
|
✗ |
handle_response(&c->payload, "ok\n"); |
26 |
|
|
} else |
27 |
|
✗ |
handle_response(&c->payload, "ko\n"); |
28 |
|
✗ |
client_time_handler(c, FORK); |
29 |
|
|
} |
30 |
|
|
|