#pragma once

#define UNICODE

#include <winsock2.h>
#include <windows.h>
#include "resource.h"

#include <math.h>
#include <float.h>

#define WindowX 320
#define WindowY 240
#define NUM_PLAYERS 5
#define BALL_RADIUS 0.8
#define PLAYER_RADIUS 1.5

#define	REMOTE_PORT		25618
#define LOCAL_PORT		25619
#define	WM_SOCKETREAD	(WM_APP + 100)

#define CURRENT_TEAM 0

#include <gdiplus.h>
using namespace Gdiplus;

#include <atlbase.h>
extern CComModule _Module;
#include <atlwin.h>

#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;
}
