diff options
Diffstat (limited to 'src/include/game.h')
-rw-r--r-- | src/include/game.h | 67 |
1 files changed, 3 insertions, 64 deletions
diff --git a/src/include/game.h b/src/include/game.h index 6bb1583..bcd902f 100644 --- a/src/include/game.h +++ b/src/include/game.h @@ -1,86 +1,25 @@ #ifndef GAME_H #define GAME_H -#define DEFAULT_LISTEN_PORT 9999 #define TICK_DURATION_MS 30 #define LEVEL_WIDTH 1664*2 #define LEVEL_HEIGHT 160*2 -#include "SDL/SDL_net.h" +#include "SDL/SDL.h" -typedef int tick_t; -typedef unsigned int id_t; -typedef struct { - unsigned int x,y; -} pos_t; - -enum eventType_t { eReady, eTimeSync, eLemAction }; +#include "data_types.h" -typedef struct { - unsigned int dead : 1; - unsigned int side : 1; - unsigned int flotter : 1; - unsigned int climber : 1; - unsigned int remainCount: 4; - unsigned int currRole: 4; - unsigned int animState: 4; - pos_t pos; -} stateLem_t; - enum gameState { gameNew, gameRunning, gameEnded }; typedef struct { enum gameState state; int startTime_ms; int clientCount; - struct _client_t **clients; + struct _client_t **clients; // FIXME: il y a toujours la boucle ? } game_t; -typedef struct _event_t { - id_t playerId; - tick_t eventTick; - tick_t serverTick; - - enum eventType_t type; - - id_t lemId; - unsigned int newRole: 4; - - struct _event_t *prev, *next; -} event_t; - -typedef struct { - event_t *first, *last; - SDL_mutex *lock; -} eventList_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é pour rien -} netGame_t; - - tick_t getGameCurrentTick(Uint32 startTime_ms); -int initNetGame(netGame_t *ng, id_t lemCount); -void freeNetGame(netGame_t *ng); -int sendEvent(TCPsocket sockDest, const event_t *e); -int receiveEvent(client_t *c, event_t *e); void play(int tick); |