#include <GameOS\GameOS.hpp>
#include <GameOS\ToolOS.hpp>
#include <string.h>
//
//
//
//
//
//
extern HGOSFONT3D Font_Arial8;
extern HGOSFONT3D font3d;
void __stdcall ExitTestNetworkShell();





static void __stdcall DoGameLogic()
{


}

static void __stdcall UpdateRenderers()
{
	gos_TextSetAttributes( Font_Arial8, 0xffff0000, -16, 0, 1, 0, 0 );
	gos_TextSetPosition( 50,10 );
	gos_TextDraw( "Test Guaranteed" );
	gos_TextSetAttributes( Font_Arial8, 0xffc0c0c0, -8, 0, 1, 0, 0 );
	gos_TextSetPosition( 220,19 );
	gos_TextDraw( "This machine is the server=/color=ffffffff/bold=1%c/color=ffc0c0c0/bold=0, Player name=/color=ffffffff/bold=1%s/color=ffc0c0c0/bold=0", (gos_NetInformation(gos_AmITheServer) ? 'Y' : 'N'), ((char*)gos_NetInformation(gos_PlayerName,(DWORD)gos_NetInformation(gos_PlayerNumber,(DWORD)(gos_NetInformation(gos_MyID))))) );
	gos_TextSetAttributes( Font_Arial8, 0xffffffff, -8, 0, 1, 0, 0 );


}

static void __stdcall TerminateGameEngine()
{
	ExitTestNetworkShell();
	gos_DeleteFont( Font_Arial8 );
}

//
// Decode game specific data (in Test Guaranteed, it's just an ASCII string anyway)
//
char* DecodeData3( void* Data )
{
	if( Data )
	{
		return (char*)Data;
	}
	else
	{
		return "";
	}
}




DWORD InitNetworkGuaranteedPackets()
{
//
// Test game specific data - fill game information with current time / date
//
	strncpy( (char*)Environment.NetGameInfo, gos_FileTimeString( gos_GetTimeDate() ), 15 );
//
// Test game specific data - pointer to a routine to decode data
//
	Environment.DecodeGameInfo=DecodeData3;
//
// Setup environment
//
	Environment.NetworkMaxPlayers = 8;
	Environment.DoGameLogic=DoGameLogic;
	Environment.UpdateRenderers=UpdateRenderers;
	Environment.TerminateGameEngine=TerminateGameEngine;
	Font_Arial8=gos_LoadFont("arial.ttf");
//
// Start pong test
//
	if( !gos_NetStartGame(0) )
	{
		return 1;
	}
	return 0;
}