Zappy - Year end project 2
This is a project that Epitech asked us to create in order to allow us to reveiw the notions of the current year.
Loading...
Searching...
No Matches
Data Structures | Typedefs | Enumerations | Functions
server_handler.h File Reference
#include <sys/select.h>
#include "arg_parse.h"
Include dependency graph for server_handler.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  ressources_s
 A structure to count ressources in the game. More...
 
struct  cli_s
 A structure to store every client/player data. More...
 
struct  map_s
 A structure to store every tiles content (Must be an 2D array) More...
 
struct  team_s
 A structure to store every team data. More...
 
struct  game_data_s
 A structure to store the game data. More...
 
struct  server_handler_s
 A structure to store server general data. More...
 

Typedefs

typedef enum ressources_type_s ressources_type_t
 
typedef enum direction_s direction_t
 
typedef struct ressources_s ressources_t
 A structure to count ressources in the game.
 
typedef struct cli_s cli_t
 A structure to store every client/player data.
 
typedef struct map_s map_t
 A structure to store every tiles content (Must be an 2D array)
 
typedef struct team_s team_t
 A structure to store every team data.
 
typedef struct game_data_s game_data_t
 A structure to store the game data.
 
typedef struct server_handler_s server_handler_t
 A structure to store server general data.
 

Enumerations

enum  ressources_type_s {
  FOOD , LINEMATE , DERAUMERE , SIBUR ,
  MENDIANE , PHIRAS , THYSTAME
}
 
enum  direction_s {
  UNDEFINED , LEFT , RIGHT , UP ,
  DOWN
}
 

Functions

int init_game_data (server_handler_t *server, struct arg_s **arguments)
 The function to initialize every game data.
 
int server_initialization (server_handler_t *server, struct arg_s **arguments)
 The function to initialize every server data.
 
void server_loop (server_handler_t *server)
 The server loop where communication client/server can be done.
 
void command_handling (server_handler_t *server, const int fd)
 Handle client message/command.
 

Typedef Documentation

◆ cli_t

typedef struct cli_s cli_t

A structure to store every client/player data.

Parameters
fdThe file descriptor of the client
is_connectedIs he connected to the server
team_nameThe team where he is
client_numHis numero in the team
levelHis level in the game
posHis position in the map (0 = x, 1 = y)
ressourcesHis inventory
time_lifeHis time life
directionHis direction (LEFT, RIGHT, UP, DOWN)

◆ direction_t

typedef enum direction_s direction_t

◆ game_data_t

typedef struct game_data_s game_data_t

A structure to store the game data.

Parameters
map_sizeThe size of the map (x = 0, y = 1)
frequenceThe frequence passed in parameter
ressources_quantityThe max number, a ressource can have in the map
total_ressourcesAll the ressources in the map
teamsEvery team data
clientsEvery client data
mapMap content

◆ map_t

typedef struct map_s map_t

A structure to store every tiles content (Must be an 2D array)

Parameters
player_nbThe number of player in a tile
ressourcesThe number of ressourcees in a tile

◆ ressources_t

typedef struct ressources_s ressources_t

A structure to count ressources in the game.

Parameters
food_nb
linemate_nb
deraumere_nb
sibur_nb
mendiane_nb
phiras_nb
thystame_nb

◆ ressources_type_t

◆ server_handler_t

A structure to store server general data.

Parameters
socketThe socket of the server for the connexion
current_fdEvery fd storage
ready_fdUsable fd for select function
game_dataThe game data
fd_queueThe queue to wait a fd to give his team name

◆ team_t

typedef struct team_s team_t

A structure to store every team data.

Parameters
team_nameThe name of the team
client_totalThe total number of client it has
clint_num_listThe list of every client number (Refer to "client_num" in cli_t structure)

Enumeration Type Documentation

◆ direction_s

Enumerator
UNDEFINED 
LEFT 
RIGHT 
UP 
DOWN 

Definition at line 36 of file server_handler.h.

◆ ressources_type_s

Enumerator
FOOD 
LINEMATE 
DERAUMERE 
SIBUR 
MENDIANE 
PHIRAS 
THYSTAME 

Definition at line 25 of file server_handler.h.

Function Documentation

◆ command_handling()

void command_handling ( server_handler_t * server,
const int fd )

Handle client message/command.

Parameters
serverThe general server structure
fdThe file descriptor where the message come from

Definition at line 108 of file command_handling.c.

◆ init_game_data()

int init_game_data ( server_handler_t * server,
struct arg_s ** arguments )

The function to initialize every game data.

Parameters
serverThe general server structure
argumentsAll parsed arguments passed as program parameter
Returns
(0) if datas are initialized successfully, (-1) if not

Definition at line 156 of file game_data_initialization.c.

◆ server_initialization()

int server_initialization ( server_handler_t * server,
struct arg_s ** arguments )

The function to initialize every server data.

Parameters
serverThe general server structure
argumentsAll parsed arguments passed as program parameter
Returns
(0) if datas are initialized successfully, (-1) if not

Definition at line 47 of file server_initialization.c.

◆ server_loop()

void server_loop ( server_handler_t * server)

The server loop where communication client/server can be done.

Parameters
serverThe general server structure

Definition at line 67 of file server_loop.c.