| Line | 
                Branch | 
                Exec | 
                Source | 
            
            
                | 1 | 
                
                 | 
                 | 
                /* | 
            
            
                | 2 | 
                
                 | 
                 | 
                ** EPITECH PROJECT, 2024 | 
            
            
                | 3 | 
                
                 | 
                 | 
                ** zappy | 
            
            
                | 4 | 
                
                 | 
                 | 
                ** File description: | 
            
            
                | 5 | 
                
                 | 
                 | 
                ** forward.c | 
            
            
                | 6 | 
                
                 | 
                 | 
                */ | 
            
            
                | 7 | 
                
                 | 
                 | 
                 | 
            
            
                | 8 | 
                
                 | 
                 | 
                #include "server.h" | 
            
            
                | 9 | 
                
                 | 
                 | 
                 | 
            
            
                | 10 | 
                
                 | 
                5 | 
                void forward(client_t *c, server_t *server) | 
            
            
                | 11 | 
                
                 | 
                 | 
                { | 
            
            
                | 12 | 
                
                 | 
                5 | 
                    int width = server->proprieties.width; | 
            
            
                | 13 | 
                
                 | 
                5 | 
                    int height = server->proprieties.height; | 
            
            
                | 14 | 
                
                 | 
                5 | 
                    int direction = c->orientation; | 
            
            
                | 15 | 
                
                 | 
                5 | 
                    int dx[] = {0, 1, 0, -1}; | 
            
            
                | 16 | 
                
                 | 
                5 | 
                    int dy[] = {-1, 0, 1, 0}; | 
            
            
                | 17 | 
                
                 | 
                 | 
                 | 
            
            
                | 18 | 
                
                 | 
                5 | 
                    c->x = (c->x + dx[direction - 1] + width) % width; | 
            
            
                | 19 | 
                
                 | 
                5 | 
                    c->y = (c->y + dy[direction - 1] + height) % height; | 
            
            
                | 20 | 
                
                    
                        1/2
                        
                            ✗ Branch 0 not taken. 
                            ✓ Branch 1 taken 5 times. 
                         
                     
                 | 
                5 | 
                    if (c->x < 0) | 
            
            
                | 21 | 
                
                 | 
                ✗ | 
                        c->x += width; | 
            
            
                | 22 | 
                
                    
                        1/2
                        
                            ✗ Branch 0 not taken. 
                            ✓ Branch 1 taken 5 times. 
                         
                     
                 | 
                5 | 
                    if (c->y < 0) | 
            
            
                | 23 | 
                
                 | 
                ✗ | 
                        c->y += height; | 
            
            
                | 24 | 
                
                    
                        1/2
                        
                            ✓ Branch 0 taken 5 times. 
                            ✗ Branch 1 not taken. 
                         
                     
                 | 
                5 | 
                    if (c->tclient[NB_REQUESTS_HANDLEABLE - 1].available_request == false) { | 
            
            
                | 25 | 
                
                 | 
                5 | 
                        message_to_graphicals(server, "ppo %d %d %d %d\n", | 
            
            
                | 26 | 
                
                 | 
                5 | 
                        c->id, c->x, c->y, c->orientation); | 
            
            
                | 27 | 
                
                 | 
                5 | 
                        c->payload = strdup("ok\n"); | 
            
            
                | 28 | 
                
                 | 
                 | 
                    } else | 
            
            
                | 29 | 
                
                 | 
                ✗ | 
                        c->payload = strdup("ko\n"); | 
            
            
                | 30 | 
                
                 | 
                5 | 
                    client_time_handler(c, FORWARD); | 
            
            
                | 31 | 
                
                 | 
                5 | 
                } | 
            
            
                | 32 | 
                
                 | 
                 | 
                 |