⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 aujarddlg.cpp

📁 骑士游戏部分源代码。
💻 CPP
📖 第 1 页 / 共 4 页
字号:

	result = m_DBAgent.UpdateKnights( KNIGHTS_JOIN, pUser->m_id, knightindex, 0 );
	
	TRACE("JoinKnights - nid=%d, name=%s, index=%d, result=%d \n", uid, pUser->m_id, knightindex, result);

	SetByte( send_buff, KNIGHTS_JOIN, send_index );
	SetShort( send_buff, uid, send_index );
	SetByte( send_buff, result, send_index );
	SetShort( send_buff, knightindex, send_index );

	do {
		if( m_LoggerSendQueue.PutData( send_buff, send_index ) == 1 )
			break;
		else
			count++;
	} while( count < 50 );
	if( count >= 50 )
		m_OutputList.AddString("Join Packet Drop!!!");
}

void CAujardDlg::WithdrawKnights(char *pBuf)
{
	int index = 0, send_index = 0, knightindex = 0, uid = -1, count = 0;
	BYTE result = 0;
	char send_buff[256]; memset( send_buff, 0x00, 256 );
	_USER_DATA* pUser = NULL;

	uid = GetShort( pBuf, index );
	knightindex = GetShort( pBuf, index );

	if( uid < 0 || uid >= MAX_USER ) return;
	pUser = (_USER_DATA*)m_DBAgent.m_UserDataArray[uid];

	result = m_DBAgent.UpdateKnights( KNIGHTS_WITHDRAW, pUser->m_id, knightindex, 0 );
	TRACE("WithDrawKnights - nid=%d, index=%d, result=%d \n", uid, knightindex, result);
	
	SetByte( send_buff, KNIGHTS_WITHDRAW, send_index );
	SetShort( send_buff, uid, send_index );
	SetByte( send_buff, result, send_index );
	SetShort( send_buff, knightindex, send_index );

	do {
		if( m_LoggerSendQueue.PutData( send_buff, send_index ) == 1 )
			break;
		else
			count++;
	} while( count < 50 );
	if( count >= 50 )
		m_OutputList.AddString("Withdraw Packet Drop!!!");
}

void CAujardDlg::ModifyKnightsMember(char *pBuf, BYTE command)
{
	int index = 0, send_index = 0, knightindex = 0, uid = -1, idlen = 0, vicechief = 0, remove_flag = 0, count = 0;
	BYTE result = 0;
	char send_buff[256]; memset( send_buff, 0x00, 256 );
	char userid[MAX_ID_SIZE+1]; memset( userid, 0x00, MAX_ID_SIZE+1 );

	uid = GetShort( pBuf, index );
	knightindex = GetShort( pBuf, index );
	idlen = GetShort( pBuf, index );
	GetString( userid, pBuf, idlen, index );
	remove_flag = GetByte( pBuf, index );

	if( uid < 0 || uid >= MAX_USER ) return;

/*	if( remove_flag == 0 && command == KNIGHTS_REMOVE )	{		// 绝绰 蜡历 眠规矫俊绰 叼厚俊辑父 贸府茄促
		result = m_DBAgent.UpdateKnights( command, userid, knightindex, remove_flag );
		TRACE("ModifyKnights - command=%d, nid=%d, index=%d, result=%d \n", command, uid, knightindex, result);
		return;
	}	*/

	result = m_DBAgent.UpdateKnights( command, userid, knightindex, remove_flag );
	TRACE("ModifyKnights - command=%d, nid=%d, index=%d, result=%d \n", command, uid, knightindex, result);

	//SetByte( send_buff, WIZ_KNIGHTS_PROCESS, send_index );
	SetByte( send_buff, command, send_index );
	SetShort( send_buff, uid, send_index );
	SetByte( send_buff, result, send_index );
	SetShort( send_buff, knightindex, send_index );
	SetShort( send_buff, idlen, send_index );
	SetString( send_buff, userid, idlen, send_index );
	SetByte( send_buff, remove_flag, send_index );

	do {
		if( m_LoggerSendQueue.PutData( send_buff, send_index ) == 1 )
			break;
		else
			count++;
	} while( count < 50 );
	if( count >= 50 )
		m_OutputList.AddString("Modify Packet Drop!!!");
}

void CAujardDlg::DestroyKnights(char *pBuf)
{
	int index = 0, send_index = 0, knightindex = 0, uid = -1, count = 0;
	BYTE result = 0;
	char send_buff[256]; memset( send_buff, 0x00, 256 );

	uid = GetShort( pBuf, index );
	knightindex = GetShort( pBuf, index );
	if( uid < 0 || uid >= MAX_USER ) return;

	result = m_DBAgent.DeleteKnights( knightindex );
	TRACE("DestoryKnights - nid=%d, index=%d, result=%d \n", uid, knightindex, result);

	SetByte( send_buff, KNIGHTS_DESTROY, send_index );
	SetShort( send_buff, uid, send_index );
	SetByte( send_buff, result, send_index );
	SetShort( send_buff, knightindex, send_index );

	do {
		if( m_LoggerSendQueue.PutData( send_buff, send_index ) == 1 )
			break;
		else
			count++;
	} while( count < 50 );
	if( count >= 50 )
		m_OutputList.AddString("Destroy Packet Drop!!!");
}

void CAujardDlg::AllKnightsMember(char *pBuf)
{
	int index = 0, send_index = 0, knightindex = 0, uid = -1, buff_index = 0, page = 0, count = 0, t_count = 0;
	BYTE result = 0;
	char send_buff[2048]; memset( send_buff, 0x00, 2048 );
	char temp_buff[2048]; memset( temp_buff, 0x00, 2048 );

	uid = GetShort( pBuf, index );
	knightindex = GetShort( pBuf, index );
	//page = GetShort( pBuf, index );
	if( uid < 0 || uid >= MAX_USER ) return;
	//if( page < 0 )  return;

	count = m_DBAgent.LoadKnightsAllMembers( knightindex, 0, temp_buff, buff_index );
	//count = m_DBAgent.LoadKnightsAllMembers( knightindex, page*10, temp_buff, buff_index );
	
	SetByte( send_buff, KNIGHTS_MEMBER_REQ, send_index );
	SetShort( send_buff, uid, send_index );
	SetByte( send_buff, 0x00, send_index );		// Success
	SetShort( send_buff, 4+buff_index, send_index );	// total packet size -> short(*3) + buff_index 
	//SetShort( send_buff, page, send_index );
	SetShort( send_buff, count, send_index );
	SetString( send_buff, temp_buff, buff_index, send_index );

	do {
		if( m_LoggerSendQueue.PutData( send_buff, send_index ) == 1 )
			break;
		else
			t_count++;
	} while( t_count < 50 );
	if( t_count >= 50 )
		m_OutputList.AddString("Member Packet Drop!!!");
}

void CAujardDlg::KnightsList( char* pBuf )
{
	int index = 0, send_index = 0, knightindex = 0, uid = -1, buff_index = 0, count = 0, retvalue = 0;
	char send_buff[256]; memset( send_buff, 0x00, 256 );
	char temp_buff[256]; memset( temp_buff, 0x00, 256 );

	uid = GetShort( pBuf, index );
	knightindex = GetShort( pBuf, index );
	if( uid < 0 || uid >= MAX_USER ) return;

	retvalue = m_DBAgent.LoadKnightsInfo( knightindex, temp_buff, buff_index );
	
	SetByte( send_buff, KNIGHTS_LIST_REQ, send_index );
	SetShort( send_buff, uid, send_index );
	SetByte( send_buff, 0x00, send_index );							// Success
	SetString( send_buff, temp_buff, buff_index, send_index );

	do {
		if( m_LoggerSendQueue.PutData( send_buff, send_index ) == 1 )
			break;
		else
			count++;
	} while( count < 50 );
	if( count >= 50 )
		m_OutputList.AddString("KnightsList Packet Drop!!!");
}

void CAujardDlg::SetLogInInfo(char *pBuf)
{
	int index = 0, idlen = 0, serverno = 0, iplen1 = 0, iplen2 = 0, uid = -1, send_index = 0, count = 0, idlen2 = 0;
	BYTE bInit;
	char accountid[MAX_ID_SIZE+1], serverip[20], clientip[20], charid[MAX_ID_SIZE+1];	
	char send_buff[256]; memset( send_buff, 0x00, 256 );
	memset( accountid, NULL, MAX_ID_SIZE+1 );
	memset( charid, NULL, MAX_ID_SIZE+1 );
	memset( serverip, NULL, 20 );
	memset( clientip, NULL, 20 );

	uid = GetShort( pBuf, index );
	idlen = GetShort( pBuf, index );
	GetString( accountid, pBuf, idlen, index );
	idlen2 = GetShort( pBuf, index );
	GetString( charid, pBuf, idlen2, index );
	iplen1 = GetShort( pBuf, index );
	GetString( serverip, pBuf, iplen1, index );
	serverno = GetShort( pBuf, index );
	iplen2 = GetShort( pBuf, index );
	GetString( clientip, pBuf, iplen2, index );
	bInit = GetByte( pBuf, index );

	if( m_DBAgent.SetLogInInfo( accountid, charid, serverip, serverno, clientip, bInit ) == FALSE ) {
		SetByte( send_buff, WIZ_LOGIN_INFO, send_index );
		SetShort( send_buff, uid, send_index );
		SetByte( send_buff, 0x00, send_index );							// FAIL
		do {
			if( m_LoggerSendQueue.PutData( send_buff, send_index ) == 1 )
				break;
			else
				count++;
		} while( count < 50 );
		if( count >= 50 )
			m_OutputList.AddString("Login Info Packet Drop!!!");

		char logstr[256]; memset( logstr, 0x00, 256 );
		sprintf( logstr, "LoginINFO Insert Fail : %s, %s, %d\r\n", accountid, charid, bInit );
		WriteLogFile( logstr );
		//m_LogFile.Write(logstr, strlen(logstr));
	}
}

void CAujardDlg::UserKickOut(char *pBuf)
{
	int index = 0, idlen = 0;
	char accountid[MAX_ID_SIZE+1];
	memset( accountid, NULL, MAX_ID_SIZE+1 );

	idlen = GetShort( pBuf, index );
	GetString( accountid, pBuf, idlen, index );

	m_DBAgent.AccountLogout( accountid );
}

void CAujardDlg::WritePacketLog()
{
	CTime t = CTime::GetCurrentTime();
	char logstr[256]; memset( logstr, 0x00, 256 );
	sprintf( logstr, "* Packet Count : recv=%d, send=%d, realsend=%d , time = %d:%d\r\n", m_iRecvPacketCount, m_iPacketCount, m_iSendPacketCount, t.GetHour(), t.GetMinute() );
	WriteLogFile( logstr );
	//m_LogFile.Write(logstr, strlen(logstr));
}

void CAujardDlg::SaveUserData()
{
	_USER_DATA* pUser = NULL;
	char send_buff[256]; memset( send_buff, 0x00, 256 );
	int send_index = 0;
	
	for( int i=0; i<MAX_USER; i++ ) {
		pUser = (_USER_DATA*)m_DBAgent.m_UserDataArray[i];
		if( !pUser )
			continue;
		if( strlen( pUser->m_id ) > 0 ) {
			if( ::GetTickCount() - pUser->m_dwTime > 360000 ) {
				memset( send_buff, 0x00, 256 ); send_index = 0;
				SetShort( send_buff, i, send_index );
				SetShort( send_buff, strlen(pUser->m_Accountid), send_index );
				SetString( send_buff, pUser->m_Accountid, strlen(pUser->m_Accountid), send_index );
				SetShort( send_buff, strlen(pUser->m_id), send_index );
				SetString( send_buff, pUser->m_id, strlen(pUser->m_id), send_index );
				UserDataSave(send_buff);
				Sleep(100);
			}
		}
	}
}

void CAujardDlg::WriteLogFile( char* pData )
{
	CTime cur = CTime::GetCurrentTime();
	char strLog[1024];	memset(strLog, 0x00, 1024);
	int nDay = cur.GetDay();

	if( m_iLogFileDay != nDay )	{
		if(m_LogFile.m_hFile != CFile::hFileNull) m_LogFile.Close();

		wsprintf(strLog, "AujardLog-%d-%d-%d.txt", cur.GetYear(), cur.GetMonth(), cur.GetDay());
		m_LogFile.Open( strLog, CFile::modeWrite | CFile::modeCreate | CFile::modeNoTruncate | CFile::shareDenyNone );
		m_LogFile.SeekToEnd();
		m_iLogFileDay = nDay;
	}

	wsprintf(strLog, "%d-%d-%d %d:%d, %s\r\n", cur.GetYear(), cur.GetMonth(), cur.GetDay(), cur.GetHour(), cur.GetMinute(), pData);
	int nLen = strlen(strLog);
	if( nLen >= 1024 )	{
		TRACE("### WriteLogFile Fail : length = %d ###\n", nLen);
		return;
	}
	
	m_LogFile.Write(strLog, nLen);
}

void CAujardDlg::BattleEventResult( char* pData )
{
	int nType = 0, nResult = 0, nLen = 0, index = 0;
	char strMaxUserName[MAX_ID_SIZE+1];	memset( strMaxUserName, 0x00, MAX_ID_SIZE+1 );

	nType = GetByte( pData, index );
	nResult = GetByte(pData, index);
	nLen = GetByte(pData, index);
	if( nLen > 0 && nLen < MAX_ID_SIZE+1 )	{
		GetString( strMaxUserName, pData, nLen, index );
		TRACE("--> BattleEventResult : 利惫狼 措厘阑 磷牢 蜡历捞抚篮? %s, len=%d, nation=%d \n", strMaxUserName, nResult, nResult);
		m_DBAgent.UpdateBattleEvent( strMaxUserName, nResult );
	}
}

void CAujardDlg::CouponEvent( char* pData )
{
	int nSid = 0, nEventNum = 0, nLen = 0, nCharLen=0, nCouponLen=0, index = 0, nType = 0, nResult = 0, send_index = 0, count = 0;
	int nItemID = 0, nItemCount = 0, nMessageNum = 0;
	char strAccountName[MAX_ID_SIZE+1];	memset( strAccountName, 0x00, MAX_ID_SIZE+1 );
	char strCharName[MAX_ID_SIZE+1];	memset( strCharName, 0x00, MAX_ID_SIZE+1 );
	char strCouponID[MAX_ID_SIZE+1];	memset( strCouponID, 0x00, MAX_ID_SIZE+1 );
	char send_buff[256]; memset( send_buff, 0x00, 256 );

	nType = GetByte( pData, index );
	if( nType == CHECK_COUPON_EVENT	)	{
		nSid = GetShort( pData, index );
		nLen = GetShort( pData, index);
		GetString( strAccountName, pData, nLen, index );
		nEventNum = GetDWORD( pData, index );
// 厚矾赣臂 措荤巩 >.<
		nMessageNum = GetDWORD( pData, index );
//
		nResult = m_DBAgent.CheckCouponEvent( strAccountName );

		SetByte( send_buff, DB_COUPON_EVENT, send_index );
		SetShort( send_buff, nSid, send_index );
		SetByte( send_buff, nResult, send_index );	
		SetDWORD( send_buff, nEventNum, send_index );
// 厚矾赣臂 措荤巩 >.<
		SetDWORD( send_buff, nMessageNum, send_index ); 
//
		do {
			if( m_LoggerSendQueue.PutData( send_buff, send_index ) == 1 )
				break;
			else
				count++;
		} while( count < 50 );
		if( count >= 50 )
			m_OutputList.AddString("CouponEvent Packet Drop!!!");


	}
	else if( nType == UPDATE_COUPON_EVENT	)	{
		nSid = GetShort( pData, index );
		nLen = GetShort( pData, index);
		GetString( strAccountName, pData, nLen, index );
		nCharLen = GetShort( pData, index);
		GetString( strCharName, pData, nCharLen, index );
		nCouponLen = GetShort( pData, index);
		GetString( strCouponID, pData, nCouponLen, index );
		nItemID = GetDWORD( pData, index );
		nItemCount = GetDWORD( pData, index );

		nResult = m_DBAgent.UpdateCouponEvent( strAccountName, strCharName, strCouponID, nItemID, nItemCount);
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -