#include "../../mainproc/GameMain.h"
#include "../../netwaker_member/NetWakerClientInc.h"
#include "AccountLogin.h"

//CAccountLogin*						g_pAccountLogin = NULL;

int	LuaFunc_DefaultServerLogin			(lua_State *L);
int	LuaFunc_DisconnectFromServer		(lua_State *L);

// ----------------------------------------------------------------------------
CAccountLogin::CAccountLogin(CInterface* object) : CInterfaceBase(object)
{
	//g_pAccountLogin		= this;
}

// ----------------------------------------------------------------------------
CAccountLogin::~CAccountLogin()
{
	//g_pAccountLogin		= NULL;
}

// ----------------------------------------------------------------------------
void CAccountLogin::RegisterFunc()
{	
	lua_State* L = GetLuaStateLogin();
	if (L)
	{
		lua_register(L, "DefaultServerLogin",		LuaFunc_DefaultServerLogin);
		lua_register(L, "DisconnectFromServer",		LuaFunc_DisconnectFromServer);
	}
}

// ----------------------------------------------------------------------------
int	LuaFunc_DefaultServerLogin(lua_State *L)
{
	const char* name = luaL_checkstring(L, 1);
	const char* password = luaL_checkstring(L, 2);

	CNetCli_Login::Login( g_pGameMain->GetIP(), g_pGameMain->GetPort(), (char*)name, (char*)password);
	return 0;
}

// ----------------------------------------------------------------------------
int	LuaFunc_DisconnectFromServer(lua_State *L)
{
	CNetCli_Login::Logout();
	return 0;
}