Ejemplo n.º 1
0
//--------------------------------------------------------------------------------------//
//		Change guild notice
//--------------------------------------------------------------------------------------//
void CClientSession::SendGuildChangeNotice(CNtlPacket * pPacket, CChatServer * app)
{
	sUT_GUILD_CHANGE_NOTICE_REQ * req = (sUT_GUILD_CHANGE_NOTICE_REQ *)pPacket->GetPacketData();

	app->db->prepare("CALL UpdateGuildNotice (?,?, @wResultCode)");
	app->db->setInt(1, this->GetCharacterId());
	app->db->setString(2, Ntl_WC2MB(req->awchNotice));
	app->db->execute();

	app->db->execute("SELECT @wResultCode");
	app->db->fetch();

	CNtlPacket packet(sizeof(sTU_GUILD_CHANGE_NOTICE_RES));
	sTU_GUILD_CHANGE_NOTICE_RES * res = (sTU_GUILD_CHANGE_NOTICE_RES *)packet.GetPacketData();
	res->wOpCode = TU_GUILD_CHANGE_NOTICE_RES;
	res->wResultCode = app->db->getInt("@wResultCode");
	packet.SetPacketLen( sizeof(sTU_GUILD_CHANGE_NOTICE_RES));
	int rc = g_pApp->Send( this->GetHandle(), &packet);

	if(app->db->getInt("@wResultCode") == 300)
	{
		CNtlPacket packet2(sizeof(sTU_GUILD_CHANGE_NOTICE_NFY));
		sTU_GUILD_CHANGE_NOTICE_NFY * res2 = (sTU_GUILD_CHANGE_NOTICE_NFY *)packet2.GetPacketData();
		res2->wOpCode = TU_GUILD_CHANGE_NOTICE_NFY;
		wcscpy_s(res2->awchCharName, NTL_MAX_SIZE_CHAR_NAME_UNICODE, s2ws(this->GetCharName()).c_str());
		memcpy(res2->awchNotice, req->awchNotice, sizeof(wchar_t)* NTL_MAX_LENGTH_OF_GUILD_NOTICE_UNICODE);
		res2->wNoticeLengthInUnicode = req->wNoticeLengthInUnicode;
		//app->UserBroadcastothers(&packet2, this); // CHANGE THAT IT ONLY BROADCAST TO OTHER GUILD MEMBERS
		packet2.SetPacketLen( sizeof(sTU_GUILD_CHANGE_NOTICE_NFY));
		rc = g_pApp->Send( this->GetHandle(), &packet2);
	}
	
}
Ejemplo n.º 2
0
//--------------------------------------------------------------------------------------//
//		Get the account ID and log in to Char Server									//
//--------------------------------------------------------------------------------------//
void CClientSession::SendCharLogInReq(CNtlPacket * pPacket, CAuthServer * app) 
{
	NTL_PRINT(PRINT_APP, "Client Received Login Request");

	sUA_LOGIN_REQ * req = (sUA_LOGIN_REQ *)pPacket->GetPacketData();

	CNtlPacket packet(sizeof(sAU_LOGIN_RES));
	sAU_LOGIN_RES * res = (sAU_LOGIN_RES *)packet.GetPacketData();


	res->wOpCode = AU_LOGIN_RES;
	memcpy(res->awchUserId, req->awchUserId, NTL_MAX_SIZE_USERID_UNICODE);
	strcpy_s((char*)res->abyAuthKey, NTL_MAX_SIZE_AUTH_KEY, "Dbo");


	app->db->prepare("CALL AuthLogin (? ,?, @acc_id, @result_code)");
	app->db->setString(1, Ntl_WC2MB(req->awchUserId));
	app->db->setString(2, Ntl_WC2MB(req->awchPasswd));
	app->db->execute();
	app->db->execute("SELECT @acc_id, @result_code");
	app->db->fetch(); 

	res->wResultCode = app->db->getInt("@result_code");
	res->accountId = app->db->getInt("@acc_id");

	res->byServerInfoCount = 1;
	strcpy_s(res->aServerInfo[0].szCharacterServerIP, NTL_MAX_LENGTH_OF_IP, IP_SERVER_ALL);
	res->aServerInfo[0].wCharacterServerPortForClient = 20300;
	res->aServerInfo[0].dwLoad = 0;
	res->lastServerFarmId = 0;

	packet.SetPacketLen(sizeof(sAU_LOGIN_RES));
	int rc = g_pApp->Send(this->GetHandle(), &packet);
		if (NTL_SUCCESS != rc)
		{
			NTL_PRINT(PRINT_APP, "Failed to send packet %d(%s)", rc, NtlGetErrorMessage(rc));
		}
		else{
			NTL_PRINT(PRINT_APP, "User %S send to charserver", req->awchUserId);
		 }
}
Ejemplo n.º 3
0
//--------------------------------------------------------------------------------------//
//		Character Rename
//--------------------------------------------------------------------------------------//
void CClientSession::SendCharRenameReq(CNtlPacket * pPacket, CCharServer * app)
{
	sUC_CHARACTER_RENAME_REQ * req = (sUC_CHARACTER_RENAME_REQ*)pPacket->GetPacketData();
	printf("--- CHARACTER RENAME REQUEST --- \n");

	CNtlPacket packet(sizeof(sCU_CHARACTER_RENAME_RES));
	sCU_CHARACTER_RENAME_RES * res = (sCU_CHARACTER_RENAME_RES *)packet.GetPacketData();

	app->db->prepare("CALL ChangeCharname (?,?, @wResultCode)");
	app->db->setString(1, Ntl_WC2MB(req->awchCharName));
	app->db->setInt(2, req->charId);
	app->db->execute();
	app->db->execute("SELECT @wResultCode");
	app->db->fetch(); 

	res->wOpCode = CU_CHARACTER_RENAME_RES;
	res->charId = req->charId;
	res->wResultCode = app->db->getInt("@wResultCode");

	packet.SetPacketLen( sizeof(sCU_CHARACTER_RENAME_RES) );
	int rc = g_pApp->Send( this->GetHandle(), &packet );
}
Ejemplo n.º 4
0
//--------------------------------------------------------------------------------------//
//		Create Character
//--------------------------------------------------------------------------------------//
void CClientSession::SendCharCreateReq(CNtlPacket * pPacket, CCharServer * app)
{
	sUC_CHARACTER_ADD_REQ * req = (sUC_CHARACTER_ADD_REQ*)pPacket->GetPacketData();
	printf("--- CHARACTER ADD REQUEST --- \n");

	app->db->prepare("CALL CharCreate (?,?,?,?,?,?,?,?,?, @charId, @wResultCode)");

	app->db->setString(1, Ntl_WC2MB(req->awchCharName));
	app->db->setInt(2, req->byRace);
	app->db->setInt(3, req->byClass);
	app->db->setInt(4, req->byGender);
	app->db->setInt(5, req->byFace);
	app->db->setInt(6, req->byHair);
	app->db->setInt(7, req->byHairColor);
	app->db->setInt(8, req->bySkinColor);
	app->db->setInt(9, this->accountID);

	app->db->execute();
	app->db->execute("SELECT @charId, @wResultCode");
	app->db->fetch(); 

	cout << "CHAR ID: " << app->db->print("@charId")
	<< " RESULT CODE: " << app->db->print("@wResultCode")
	<< endl;

	CNtlPacket packet(sizeof(sCU_CHARACTER_ADD_RES));
	sCU_CHARACTER_ADD_RES * res = (sCU_CHARACTER_ADD_RES *)packet.GetPacketData();

	res->wOpCode = CU_CHARACTER_ADD_RES;
	res->wResultCode = app->db->getInt("@wResultCode");

	if (res->wResultCode != 200) {

		packet.SetPacketLen( sizeof(sCU_CHARACTER_ADD_RES) );
		int rc = g_pApp->Send( this->GetHandle(), &packet );
		cout << " RESULT CODE: " << res->wResultCode << endl;

	}else{

	res->sPcDataSummary.charId = app->db->getInt("@charId");
	memcpy(res->sPcDataSummary.awchName, req->awchCharName, sizeof(wchar_t)* NTL_MAX_SIZE_CHAR_NAME_UNICODE);
	res->sPcDataSummary.byRace = req->byRace;
	res->sPcDataSummary.byClass = req->byClass;
	res->sPcDataSummary.bIsAdult = false;
	res->sPcDataSummary.byGender = req->byGender;
	res->sPcDataSummary.byFace = req->byFace;
	res->sPcDataSummary.byHair = req->byHair;
	res->sPcDataSummary.byHairColor = req->byHairColor;
	res->sPcDataSummary.bySkinColor = req->bySkinColor;
	res->sPcDataSummary.byLevel = 1;
	res->sPcDataSummary.worldId = 1;
	for (int j = 0; j < NTL_MAX_EQUIP_ITEM_SLOT; j++)
	{
		//Get items which the characters is wearing
		app->db2->prepare("select * from items WHERE place=7 AND pos=? AND owner_id=?");
		app->db2->setInt(1, j);
		app->db2->setInt(2, app->db->getInt("@charId"));
		app->db2->execute();
		app->db2->fetch();
		if (app->db2->rowsCount() == 0)
		{
			res->sPcDataSummary.sItem[j].tblidx = INVALID_TBLIDX;
		}
		else
		{
			res->sPcDataSummary.sItem[j].tblidx = app->db2->getInt("tblidx");
		}

	}

	packet.SetPacketLen( sizeof(sCU_CHARACTER_ADD_RES) );
	int rc = g_pApp->Send( this->GetHandle(), &packet );

	}
}