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

📄 user.cpp

📁 决战帝王1.5武神降临对喜爱决战的玩家共享研究用
💻 CPP
📖 第 1 页 / 共 5 页
字号:

	CString strSource = account;

	// IKING 2001.1.
	USER *pUser = NULL;
	for( int i = 0; i < MAX_USER; i++)
	{
		if(i == m_uid) continue;

		pUser = m_pCom->GetUserUid(i);
		if( pUser == NULL ) continue;

		if( !strSource.CompareNoCase(pUser->m_strAccount))
		{
			if( pUser->m_state != STATE_DISCONNECTED && pUser->m_state != STATE_LOGOUT)
			{
			//	pUser->SendSystemMsg( IDS_USER_DOUBLE_ACCOUNT, SYSTEM_SPECIAL, TO_ME);				
			//	pUser->SoftClose();
				return TRUE;
			}
		}
	}
	//

	return FALSE;
}

///////////////////////////////////////////////////////////////////////////////////
//	Session 俊 Login 沁阑 锭狼 贸府
//
void USER::SessionLoginReq(TCHAR *pBuf)
{
	int			index = 0, nCount;
	TCHAR		strAccount[ACCOUNT_LENGTH+1], strPassword[PASSWORD_LENGTH+1];
	BYTE		result = FAIL, error_code = 0;
	CBufferEx	TempBuf;

	::ZeroMemory(strAccount, sizeof(strAccount));
	::ZeroMemory(strPassword, sizeof(strPassword));

	if(!GetVarString(sizeof(strAccount), strAccount, pBuf, index)) return;
	if(!GetVarString(sizeof(strPassword), strPassword, pBuf, index)) return;
	
	if( IsDoubleAccount( strAccount ) )
	{
		TRACE( "DOUBLE ACCOUNT - %s\n", strAccount );
		error_code = ERR_3;
		goto result_send;
	}

	if(CheckSessionLoginReq(strAccount, strPassword, nCount) == FALSE)
	{
		error_code = UNKNOWN_ERR;
		goto result_send;
	}
	
	if(nCount == 0) result = SUCCESS;
	else error_code = (BYTE)nCount;

result_send:

	TempBuf.Add(SESSION_LOGIN_RESULT);
	TempBuf.Add(result);

	if(result != SUCCESS)
	{
		TempBuf.Add(error_code);
		Send(TempBuf, TempBuf.GetLength());
		SoftClose();
	}
	else Send(TempBuf, TempBuf.GetLength());
}

////////////////////////////////////////////////////////////////////////////////////
//	Session 俊 New Account 甫 父电促.
//
void USER::NewAccountReq(TCHAR *pBuf)
{
	int		index = 0, nRet = -1;
	BYTE	result = FAIL;

	TCHAR	szUserID	[12 + 1];
	TCHAR	szPassword	[12 + 1];
	TCHAR	szRealName	[40 + 1];
	TCHAR	szSocNo		[15 + 1];
	TCHAR	szAddress	[80 + 1];
	TCHAR	szTel		[20 + 1];
	TCHAR	szEmail		[30 + 1];
	TCHAR	szQuiz01	[50 + 1];
	TCHAR	szAnswer01	[50 + 1];

	SQLHSTMT		hstmt;
	SQLRETURN		retcode;
	TCHAR			szSQL[1024];
	BOOL			bQuerySuccess = TRUE;
	CDatabase*		pDB = NULL;
	int				db_index = 0;
	SQLSMALLINT		sRet = 0;
	SQLINTEGER		sRetInd;

	if(!GetVarString(12, szUserID,			pBuf, index)) goto result_send;
	if(!GetVarString(12, szPassword,		pBuf, index)) goto result_send;
	if(!GetVarString(40, szRealName,		pBuf, index)) goto result_send;
	if(!GetVarString(15, szSocNo,			pBuf, index)) goto result_send;
	if(!GetVarString(80, szAddress,			pBuf, index)) goto result_send;
	if(!GetVarString(20, szTel,				pBuf, index)) goto result_send;
	if(!GetVarString(30, szEmail,			pBuf, index)) goto result_send;
	if(!GetVarString(50, szQuiz01,			pBuf, index)) goto result_send;
	if(!GetVarString(50, szAnswer01,		pBuf, index)) goto result_send;	
	
	memset(szSQL, 0x00, 1024);
	_sntprintf(szSQL, sizeof(szSQL), TEXT("{? = call NewAccount (\'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\')}"), 
		szUserID, szPassword, szRealName, szSocNo, szAddress, szTel, szEmail, szQuiz01, szAnswer01);
	
	hstmt = NULL;
	
	pDB = g_DBSession[m_iModSid].GetDB( db_index );
	if( !pDB ) return;

	retcode = SQLAllocHandle( (SQLSMALLINT)SQL_HANDLE_STMT, pDB->m_hdbc, &hstmt );
	if (retcode!=SQL_SUCCESS)
	{
		//g_DBSession[m_iModSid].ReleaseDB(db_index);
		goto result_send;
	}

	retcode = SQLBindParameter(hstmt, 1 ,SQL_PARAM_OUTPUT,SQL_C_SSHORT, SQL_SMALLINT, 0, 0, &sRet, 0, &sRetInd);
	if (retcode!=SQL_SUCCESS) 
	{
		g_DBSession[m_iModSid].ReleaseDB(db_index);
		goto result_send;
	}

	retcode = SQLExecDirect (hstmt, (unsigned char *)szSQL, SQL_NTS);
	if (retcode ==SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO)
	{
		while (TRUE)
		{
			retcode = SQLFetch(hstmt);
			if (retcode !=SQL_SUCCESS && retcode !=SQL_SUCCESS_WITH_INFO)
			{
				break;
			}
		}
	}
	else if (retcode==SQL_ERROR)
	{
		bQuerySuccess = FALSE;
		DisplayErrorMsg(hstmt);
		SQLFreeHandle((SQLSMALLINT)SQL_HANDLE_STMT, hstmt);

		g_DBSession[m_iModSid].ReleaseDB(db_index);
		goto result_send;
	}
	else if (retcode==SQL_NO_DATA)
	{
		bQuerySuccess = FALSE;
	}

	if (hstmt!=NULL) SQLFreeHandle((SQLSMALLINT)SQL_HANDLE_STMT, hstmt);

	if(bQuerySuccess) nRet = sRet;

	g_DBSession[m_iModSid].ReleaseDB(db_index);

result_send:
		
	if(bQuerySuccess == TRUE && nRet == 0) result = SUCCESS;

	index = 0;
	SetByte(m_TempBuf, NEW_ACCOUNT_RESULT, index);
	SetByte(m_TempBuf, result, index);
	Send(m_TempBuf, index);
}

///////////////////////////////////////////////////////////////////////////////////
//	Session 俊辑 牢刘累诀阑 芭摹绊 某腐磐甫 急琶窍扁 困秦 Login
//
void USER::AccountLoginReq(TCHAR *pBuf)
{
/*	if( g_bShutDown ) return;

	int		index = 0;
	BYTE	result = FAIL, error_code = 0;
	int		old_index = 0;
	TCHAR	szTemp[8096];

	TRACE("AccountLoginReq Request...Check");

#ifdef _GETVARSTRING_DEBUG
	char strFn[128];
	sprintf( strFn, "AccountLoginReq1" );
	int	nIDLength = GetVarString(m_strAccount, pBuf, sizeof(BYTE), index, strFn);
#endif
#ifndef _GETVARSTRING_DEBUG
	int	nIDLength = GetVarString(m_strAccount, pBuf, sizeof(BYTE), index);
#endif

	if(nIDLength == 0 || nIDLength > ACCOUNT_LENGTH)
	{
		error_code = 1;
		goto result_send;
	}

	if(IsDoubleAccount(m_strAccount))
	{
		error_code = ERR_2;
		goto result_send;
	}

	if(!LoadCharData(m_strAccount))
	{
		// Load Character Data Fail...
		error_code = UNKNOWN_ERR;
		goto result_send;
	}
	else
	{
		m_state = STATE_CONNECTED;
		result = SUCCESS;
	}

result_send:

	index = 0;
	SetByte(m_TempBuf, ACCOUNT_LOGIN_RESULT, index );
	SetByte(m_TempBuf, result, index );

	old_index = index;
	::CopyMemory(szTemp, m_TempBuf, old_index);

	if(result == SUCCESS)
	{
		SetByte(m_TempBuf, (BYTE)m_nCharNum, index);
	}
	else
	{
		SetByte(m_TempBuf, error_code, index);
		Send( m_TempBuf, index );
		SoftClose();
		return;
	}

	if(m_nCharNum != 0 && result == SUCCESS)
	{
		for(int i = 0; i < 3; i++)
		{
			if(m_strChar[i][0])
			{
				SetByte(m_TempBuf, (BYTE)i, index);
				if(!SendCharInfo(m_strChar[i], m_TempBuf, index))
				{
					result = FAIL;
					error_code = UNKNOWN_ERR;
					index = 0;
					SetByte(m_TempBuf, ACCOUNT_LOGIN_RESULT, index );
					SetByte(m_TempBuf, result, index );
					SetByte(m_TempBuf, error_code, old_index);
					Send(m_TempBuf, old_index);
					SoftClose();
					return;
				}
			}
		}
	}

//	UpdateCurrentUserTable();				// 技记俊 辑滚 IP甫 喀但茄促.

	Send(m_TempBuf, index);
*/
	if( g_bShutDown ) return;

	int		index = 0;
	BYTE	result = FAIL, error_code = 0;
	int		old_index = 0;
	TCHAR	szTemp[8096];

//	TRACE("AccountLoginReq Request...Check");

	int	nIDLength = GetVarString(ACCOUNT_LENGTH + 1, m_strAccount, pBuf, index);

	if(nIDLength == 0 || nIDLength > ACCOUNT_LENGTH)	
	{
		error_code = 1;
		goto result_send;
	}

	if(IsDoubleAccount(m_strAccount))
	{
		error_code = ERR_2;
		goto result_send;
	}

	if(!LoadCharData(m_strAccount))
	{
		// Load Character Data Fail...
		error_code = UNKNOWN_ERR;
		goto result_send;
	}
	else 
	{
		m_state = STATE_CONNECTED;
		result = SUCCESS;
	}

result_send:

	index = 0;
	SetByte(m_TempBuf, ACCOUNT_LOGIN_RESULT, index );
	SetByte(m_TempBuf, result, index );

	old_index = index;
	::CopyMemory(szTemp, m_TempBuf, old_index);

	if(result == SUCCESS)
	{
		SetByte(m_TempBuf, (BYTE)m_nCharNum, index);
	}
	else
	{
		SetByte(m_TempBuf, error_code, index);
		Send( m_TempBuf, index );
		SoftClose();
		return;
	}

	if(m_nCharNum != 0 && result == SUCCESS)
	{
		for(int i = 0; i < 3; i++)
		{
			if(m_strChar[i][0])	
			{
				SetByte(m_TempBuf, (BYTE)i, index);
				if(!SendCharInfo(m_strChar[i], m_TempBuf, index))
				{
					result = FAIL;
					error_code = UNKNOWN_ERR;
					index = 0;
					SetByte(m_TempBuf, ACCOUNT_LOGIN_RESULT, index );
					SetByte(m_TempBuf, result, index );
					SetByte(m_TempBuf, error_code, old_index);
					Send(m_TempBuf, old_index);
					SoftClose();
					return;
				}
			}
		}
	}

//	UpdateCurrentUserTable();				// 技记俊 辑滚 IP甫 喀但茄促.

	Send(m_TempBuf, index);
}

void USER::ZoneLoginReq(TCHAR *pBuf)
{
	int			index = 0;
	TCHAR		szPw[PASSWORD_LENGTH + 1];
	TCHAR		szID[CHAR_NAME_LENGTH+1];
	BYTE		result = FAIL, error_code = 0;
	CPoint		pt(-1, -1);
	CBufferEx	TempBuf;
	int			iMemory = 0;
	int			iMemoryAccountBank = 0;

	TRACE("ZoneLoginReq Request...Check\n");

	int nIDLength, nPwLength, nCharLength;
	int iMyServer = -1;
	USER *pDoubleUser = NULL;

	nIDLength = GetVarString( sizeof( m_strAccount ), m_strAccount, pBuf, index);
	if(nIDLength == 0 || nIDLength > CHAR_NAME_LENGTH)	
	{
		error_code = ERR_1;
		goto result_send;
	}
	nPwLength = GetVarString( sizeof( szPw ), szPw, pBuf, index);
	if(nPwLength == 0 || nPwLength > CHAR_NAME_LENGTH)	
	{
		error_code = ERR_1;
		goto result_send;
	}
	nCharLength = GetVarString( sizeof( szID ), szID, pBuf, index);
	if(nCharLength == 0 || nCharLength > CHAR_NAME_LENGTH)	
	{
		error_code = ERR_1;
		goto result_send;
	}
	
	// IKING 2002.1.
	iMyServer = GetShort(pBuf, index);

	m_iMyServer = iMyServer;

	if( !IsMyDBServer( m_iMyServer ) )
	{
		m_iMyServer = -1;
		error_code = 255;
		goto result_send;
	}
	//

	if(nIDLength == 0 || nIDLength > CHAR_NAME_LENGTH)	
	{
		error_code = ERR_1;
		goto result_send;
	}

	//鞍篮 酒捞叼啊 乐栏搁 角菩 茄促...
	pDoubleUser = GetUser( szID );
	if( pDoubleUser != NULL ) 
	{  
		//double fors test
		error_code = ERR_1;
		goto result_send;
/*		if( pDoubleUser->m_state != STATE_DISCONNECTED && pDoubleUser->m_state != STATE_LOGOUT )
		{
			error_code = ERR_5;
			TempBuf.Add(GAME_START_RESULT);
			TempBuf.Add(FAIL);
			TempBuf.Add(error_code);
			Send(TempBuf, TempBuf.GetLength());

			pDoubleUser->SendSystemMsg( IDS_USER_DOUBLE_CHAR, SYSTEM_SPECIAL, TO_ME);
			pDoubleUser->SoftClose();
			return;
		} */
	}

	g_pMainDlg->BridgeServerUserZoneLogIn( m_uid, m_strAccount, szID );
	return;


	InitUser();
//	InitMemoryDB(m_uid);
	iMemory = CheckMemoryDB( szID );
//	iMemory = 0;		// 酒第 鞍篮 巴档 绝菌绊, 拌沥 鞍篮 巴档 绝菌促.
//						// 酒第,篮青,烹芒 葛滴 DB俊辑 啊廉客具 茄促.

//	iMemory = 1;		// 酒第尔 拌沥捞 鞍篮 巴篮 乐菌绊, 拌沥父 鞍绊 酒第啊 促弗巴篮 绝菌促.
//						// 酒第,篮青,烹芒 葛滴 MemoryDB俊辑 啊廉吭促. DB俊辑 啊廉坷瘤 臼绰促.

//	iMemory = 1;		// 酒第尔 拌沥捞 鞍篮 巴捞 乐菌绊, 拌沥父 鞍绊 酒第啊 促弗巴档 乐菌促.
//						// 酒第,篮青,烹芒 葛滴 MemoryDB俊辑 啊廉吭促. DB俊辑 啊廉坷瘤 臼绰促.

//	iMemory = 2;		// 酒第尔 拌沥捞 鞍篮 巴篮 绝菌绊, 拌沥父 鞍篮 巴捞 乐菌促.
//						// 酒第,篮青,烹芒 葛滴 DB俊辑 啊廉客具 茄促. (唱吝俊 烹芒父 MemoryDB俊辑 啊廉坷绰 风凭阑 持阑巴捞促.)

	if( iMemory == 0 || iMemory == 2 )
	{
		if( !LoadUserData( szID ) )
		{
			error_code = ERR_2;
			goto result_send;
		}
	}

	/*
	if( !IsZoneInThisServer(m_curz) )
	{
		ChangeServer(m_curz);
		
		ReInitMemoryDB();

		SoftClose();
		return;
	}
	*/

	m_state = STATE_CONNECTED;

	// zone, zoneindex肺 谅钎 函券...
//	ZoneChangeInfoSet(m_curz, m_curx, m_cury);

	pt = FindNearAvailablePoint_S(m_curx, m_cury);	// DB俊 历厘等 谅钎啊 框流老 荐 乐绰 谅钎牢瘤 魄窜
	if(pt.x == -1 || pt.y == -1) 
	{
		error_code = ERR_4;
		goto result_send;
	}

//	CheckUserLevel();					// 公丰眉氰饭骇牢 25饭骇阑 逞菌阑 版快 

	m_curx = pt.x; m_cury = pt.y;
	SetUid(m_curx, m_cury, m_uid + USER_BAND );		// 蜡历 困摹沥焊 悸泼
	m_presx = -1;
	m_presy = -1;

	pt = ConvertToClient(m_curx, m_cury);

	GetMagicItemSetting();							// 泅犁 酒捞袍吝 概流 加己, 饭骇函悼阑 悼利 函荐俊 馆康茄促.

	m_UserFlag = TRUE;

	result = SUCCESS;

	m_ConnectionSuccessTick = 0;


	InitMemoryDB(m_uid);

	if( iMemory == 0 || iMemory == 2 )
	{
		if( !LoadUserBank() )
		{
			error_code = ERR_2;
			result = FAIL;
			goto result_send;
		}
		if( !LoadAccountBank() )
		{
			error_code = ERR_2;
			result = FAIL;
			goto result_send;
		}
	}

	// 粮 眉牢瘤 犬牢棺 函荐 檬扁拳...
	m_strZoneIP = "";
	m_nZonePort	= -1;

	SetPsiAbnormalStatus();

result_send:
	TempBuf.Add(GAME_START_RESULT);
	TempBuf.Add(result);

	if(result != SUCCESS)
	{
		ReInitMemoryDB();

		TempBuf.Add(error_code);
		Send(TempBuf, TempBuf.GetLength());
		return;
	}

⌨️ 快捷键说明

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