//////////////////////////////////////////////////////////////////////////////
//
// Asura_SteamworksConfig.h
//
// Copyright (c) 2008 Rebellion. All rights reserved.
//
//////////////////////////////////////////////////////////////////////////////

// B E G I N   F I L E   W R A P P E R ///////////////////////////////////////

#include "Core/Asura.h"

#ifdef ASURA_PC_SUPPORT_STEAMWORKS

// This file's header.
#include "Network/Steamworks/Asura_PC_SteamworksConfig.h"

#include "Network/Asura_Platform_NetSocket.h"
#include "Network/Steamworks/Asura_PC_NetSocketSteamworks.h"

bool Asura_PC_SteamworksConfig::s_bWasConfigured = false;
bool Asura_PC_SteamworksConfig::s_bIsServer = false;
Asura_NetAddress Asura_PC_SteamworksConfig::s_xAddress; 
u_short Asura_PC_SteamworksConfig::s_usPort = 0;


bool Asura_PC_SteamworksConfig::SetServer(const char* szConfig)
{
	bool bResult = Asura_PC_NetSocketSteamworks::GetAddressFromString(szConfig, &s_xAddress, &s_usPort);
	if (bResult)
	{
		s_bIsServer = true;
		s_bWasConfigured = true;
	}
	return bResult;
}

bool Asura_PC_SteamworksConfig::SetClient(const char* szConfig)
{
	bool bResult = Asura_PC_NetSocketSteamworks::GetAddressFromString(szConfig, &s_xAddress, &s_usPort);
	if (bResult)
	{
		s_bIsServer = false;
		s_bWasConfigured = true;
	}
	return bResult;
}


bool Asura_PC_SteamworksConfig::IsServer()
{
	Asura_Assert(s_bWasConfigured, "Steamworks was not configured");
	return s_bIsServer;
}

bool Asura_PC_SteamworksConfig::IsConfigured()
{
	return s_bWasConfigured;
}

Asura_NetAddress Asura_PC_SteamworksConfig::GetAddress()
{
	Asura_Assert(s_bWasConfigured, "Steamworks was not configured");
	return s_xAddress;
}

u_short Asura_PC_SteamworksConfig::GetPort()
{
	Asura_Assert(s_bWasConfigured, "Steamworks was not configured");
	return s_usPort;
}

void Asura_PC_SteamworksConfig::ClearConfig()
{
	s_bWasConfigured = false;
}


#endif // ASURA_PC_SUPPORT_STEAMWORKS

