// Asura_PC_SteamworksMessages.h
// Thomas Young - 02.03.09
// Copyright (C) 2009 Rebellion, All Rights Reserved.

// F I L E   W R A P P E R ///////////////////////////////////////////////////

#ifdef ASURA_USE_PRAGMA_ONCE
#pragma once
#endif

#ifndef ___ASURA_STEAMWORKSMESSAGES_H___
#define ___ASURA_STEAMWORKSMESSAGES_H___ 1

// I N C L U D E S ///////////////////////////////////////////////////////////

#include "Core/Asura.h"

#ifdef ASURA_PC_SUPPORT_STEAMWORKS

// C O N S T A N T S /////////////////////////////////////////////////////////

static const u_int	uASURA_PC_STEAM_MESSAGE_MAGIC_NO = 0x459D1D37;	// Asura_GetHashID( "Steam Message" )

// C L A S S   D E C L A R A T I O N S ///////////////////////////////////////

#pragma pack ( push )
#pragma pack ( 1 )

// ______________________________ Shared _______________________________

struct Asura_Steam_Msg_Header
{
	u_int	uMagicNumber;
	u_short	usMsgID;

	bool IsValid ( ) const
	{
		return ( uMagicNumber == uASURA_PC_STEAM_MESSAGE_MAGIC_NO );
	}

	void SetType ( const u_short usType )
	{
		// This also makes it 'valid' by setting the magic number field

		uMagicNumber	= uASURA_PC_STEAM_MESSAGE_MAGIC_NO;
		usMsgID			= usType;
	}

	u_short GetType ( ) const
	{
		return usMsgID;
	}

	char* GetMessageBody()
	{
		return ( reinterpret_cast<char*>( this ) + sizeof( *this ) );
	}

	const char* GetMessageBody() const
	{
		return ( reinterpret_cast<const char*>( this ) + sizeof( *this ) );
	}
};

// ______________________ Asura_PC_SteamworksReliableSocket ________________________

struct ASRS_Msg_AuthData
{
	uint64	uSteamID;

	bool	bShouldAuth;
	u_short	usAuthTicketSize;

	char* GetAuthTicketAddress()
	{
		return ( reinterpret_cast<char*>( this ) + sizeof( *this ) );
	}
};


struct ASRS_Msg_ConnectData
{
	u_short	usDataSize;

	char* GetDataAddress()
	{
		return ( reinterpret_cast<char*>( this ) + sizeof( *this ) );
	}
};


struct ASRS_Msg_AcceptReject
{
	bool bAccept;
};


struct ASRS_Msg_Disconnect
{
	u_short uReason;
};


struct ASRS_Msg_External
{
	u_short usMsgExternalID;
	u_short usDataSize;
	u_short	usChecksum;

	char* GetDataAddress()
	{
		return ( reinterpret_cast<char*>( this ) + sizeof( *this ) );
	}
};


// ______________________ Asura_PC_SteamworksClient ________________________

struct ASC_Msg_Voice
{
	u_short usDataSize;
	u_short	usChecksum;	

	char* GetDataAddress()
	{
		return ( reinterpret_cast<char*>( this ) + sizeof( *this ) );
	}

	const char* GetDataAddress() const
	{
		return ( reinterpret_cast<const char*>( this ) + sizeof( *this ) );
	}
};

#pragma pack ( pop )

#endif	// ASURA_PC_SUPPORT_STEAMWORKS
#endif	// ___ASURA_STEAMWORKSMESSAGES_H___

//eof
