#ifndef __SOCCERCLIENT_H__
#define __SOCCERCLIENT_H__

/* Unix version of soccer client		*/
/* updated 8/8/03						*/
/* Dan Maynes-Aminzade <monzy@mit.edu>	*/

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <termios.h> 

#define	REMOTE_PORT		25618
#define LOCAL_PORT		25619

#define NUM_PLAYERS 5

#pragma pack( push, 1 )

typedef struct Player {
	float x,y;
	float vx,vy;
	float kick;
} PLAYER;
typedef struct Ball {
	float x,y;
	float vx,vy;
} BALL;
typedef struct Datagram {
	long team;
	long paused;
	long score[2];
	BALL ball;
	PLAYER team0[NUM_PLAYERS];
	PLAYER team1[NUM_PLAYERS];
} DATAGRAM;

#pragma pack( pop )

inline float ntohf(float nf) {
	float *pnf = &nf;
	long *pnl = (long*) pnf;
	long nl = *pnl;
	long l = ntohl(nl);
	long *pl = &l;
	float *pf = (float*) pl;
	float f = *pf;
	return f;
}

inline float htonf(float f) {
	float *pf = &f;
	long *pl = (long*) pf;
	long l = *pl;
	long nl = htonl(l);
	long *pnl = &nl;
	float *pnf = (float*) pnl;
	float nf = *pnf;
	return nf;
}

#endif

struct termios original_t, new_t; 
void setup_terminal();
void restore_terminal();
