summaryrefslogtreecommitdiff
path: root/src/include/data_network.h
blob: dfc93a0d2b6bb1386ac2a960e678ddfc6924678a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#ifndef DATA_NETWORK_H
#define DATA_NETWORK_H

#include "SDL/SDL_net.h"

#include "data_types.h"
#include "data_lemming.h"
#include "events.h"

#define DEFAULT_LISTEN_PORT 9999

enum gameState { gameNew, gameRunning, gameEnded };

typedef struct {
	enum gameState state;
	int startTime_ms;
	int clientCount;
	struct _client_t **clients; // FIXME: il y a toujours la boucle ?
} game_t;

enum clientState { clientNew, clientReady };

typedef struct _client_t {
	int numClient;
	enum clientState state;
	TCPsocket sockClient;
	eventList_t events;
	SDL_sem *semEventAvailable;
	SDL_sem *semGameStart;
	int lastEventSendTime_ms;
	game_t *game;
	stateLem_t *lems;
} client_t;

typedef struct {
	id_t lemCount;
	eventList_t elist;
	client_t local, net; //TODO : reprendre un peu, bcp de champs dupliqués pour rien
} netGame_t;

#endif /* DATA_NETWORK_H */