📄 aujarddlg.cpp
字号:
pTableItem->m_bDroprate = ItemTableSet.m_Droprate;
pTableItem->m_bStrB = ItemTableSet.m_StrB;
pTableItem->m_bStaB = ItemTableSet.m_StaB;
pTableItem->m_bDexB = ItemTableSet.m_DexB;
pTableItem->m_bIntelB = ItemTableSet.m_IntelB;
pTableItem->m_bChaB = ItemTableSet.m_ChaB;
pTableItem->m_MaxHpB = ItemTableSet.m_MaxHpB;
pTableItem->m_MaxMpB = ItemTableSet.m_MaxMpB;
pTableItem->m_bFireR = ItemTableSet.m_FireR;
pTableItem->m_bColdR = ItemTableSet.m_ColdR;
pTableItem->m_bLightningR = ItemTableSet.m_LightningR;
pTableItem->m_bMagicR = ItemTableSet.m_MagicR;
pTableItem->m_bPoisonR = ItemTableSet.m_PoisonR;
pTableItem->m_bCurseR = ItemTableSet.m_CurseR;
if( !m_ItemtableArray.PutData(pTableItem->m_iNum, pTableItem) ) {
TRACE("ItemTable PutData Fail - %d\n", pTableItem->m_iNum );
delete pTableItem;
pTableItem = NULL;
}
ItemTableSet.MoveNext();
}
return TRUE;
}
void CAujardDlg::SelectCharacter(char *pBuf)
{
int index = 0, uid = -1, send_index = 0, idlen1 = 0, idlen2 = 0, t_uid = -1, count = 0, packetindex = 0;
BYTE bInit = 0x01;
char send_buff[256], accountid[MAX_ID_SIZE+1], userid[MAX_ID_SIZE+1];
memset( send_buff, NULL, 256 );
memset( userid, NULL, MAX_ID_SIZE+1 );
memset( accountid, NULL, MAX_ID_SIZE+1 );
_USER_DATA* pUser = NULL;
uid = GetShort( pBuf, index );
idlen1 = GetShort( pBuf, index );
GetString( accountid, pBuf, idlen1, index );
idlen2 = GetShort( pBuf, index );
GetString( userid, pBuf, idlen2, index );
bInit = GetByte( pBuf, index );
packetindex = GetDWORD( pBuf, index );
CTime t = CTime::GetCurrentTime();
char logstr[256]; memset( logstr, 0x00, 256 );
sprintf( logstr, "SelectCharacter : acname=%s, name=%s, index=%d, pid : %d, front : %d\r\n", accountid, userid, packetindex, _getpid(), m_LoggerRecvQueue.GetFrontPointer() );
WriteLogFile( logstr );
//m_LogFile.Write(logstr, strlen(logstr));
m_iRecvPacketCount++; // packet count
if( uid < 0 || uid >= MAX_USER )
goto fail_return;
if( !strlen( accountid ) )
goto fail_return;
if( !strlen( userid ) )
goto fail_return;
if( GetUserPtr( userid, t_uid ) ) {
SetShort( send_buff, t_uid, send_index );
SetShort( send_buff, idlen1, send_index );
SetString( send_buff, accountid, idlen1, send_index );
SetShort( send_buff, idlen2, send_index );
SetString( send_buff, userid, idlen2, send_index );
UserLogOut( send_buff );
return;
}
if( !m_DBAgent.LoadUserData( userid, uid ) )
goto fail_return;
if( !m_DBAgent.LoadWarehouseData( accountid, uid ) )
goto fail_return;
pUser = (_USER_DATA*)m_DBAgent.m_UserDataArray[uid];
if( !pUser ) goto fail_return;
strcpy( pUser->m_Accountid, accountid );
SetByte( send_buff, WIZ_SEL_CHAR, send_index );
SetShort( send_buff, uid, send_index );
SetByte( send_buff, 0x01, send_index );
SetByte( send_buff, bInit, send_index );
m_iPacketCount++; // packet count
do {
if( m_LoggerSendQueue.PutData( send_buff, send_index ) == 1 ) {
m_iSendPacketCount++;
break;
}
else
count++;
} while( count < 50 );
if( count >= 50 )
m_OutputList.AddString("Sel char Packet Drop!!!");
return;
fail_return:
send_index = 0;
SetByte( send_buff, WIZ_SEL_CHAR, send_index );
SetShort( send_buff, uid, send_index );
SetByte( send_buff, 0x00, send_index );
m_LoggerSendQueue.PutData( send_buff, send_index );
}
void CAujardDlg::UserLogOut(char *pBuf)
{
int index = 0, uid = -1, idlen1 = 0, idlen2 = 0, send_index = 0, count = 0;
int retval_1 = 0, retval_2 = 0, retval_3 = 1;
char userid[MAX_ID_SIZE+1], accountid[MAX_ID_SIZE+1];
memset( userid, NULL, MAX_ID_SIZE+1 );
memset( accountid, NULL, MAX_ID_SIZE+1 );
char send_buff[256];
memset( send_buff, NULL, 256 );
char logstr[256]; memset( logstr, 0x00, 256 );
_USER_DATA* pUser = NULL;
uid = GetShort( pBuf, index );
idlen1 = GetShort( pBuf, index );
GetString( accountid, pBuf, idlen1, index );
idlen2 = GetShort( pBuf, index );
GetString( userid, pBuf, idlen2, index );
if( uid < 0 || uid >= MAX_USER )
return;
if( !strlen( userid ) )
return;
pUser = (_USER_DATA*)m_DBAgent.m_UserDataArray[uid];
if( !pUser ) return;
retval_2 = m_DBAgent.UpdateUser( userid, uid, UPDATE_LOGOUT );
Sleep(10);
retval_1 = m_DBAgent.UpdateWarehouseData( accountid, uid, UPDATE_LOGOUT );
if( pUser->m_bLogout != 2 ) // zone change logout
retval_3 = m_DBAgent.AccountLogout( accountid );
CTime t = CTime::GetCurrentTime();
sprintf( logstr, "Logout : %s, %s (W:%d,U:%d)\r\n", accountid, userid, retval_1, retval_2 );
WriteLogFile( logstr );
//m_LogFile.Write(logstr, strlen(logstr));
if( retval_2 == 0 || retval_3 != 1 ) {
sprintf( logstr, "Invalid Logout : %s, %s (W:%d,U:%d,A:%d) \r\n", accountid, userid, retval_1, retval_2, retval_3 );
WriteLogFile( logstr );
//m_LogFile.Write(logstr, strlen(logstr));
}
if( retval_1 == FALSE || retval_2 == FALSE )
do {
retval_2 = m_DBAgent.UpdateUser( userid, uid, UPDATE_LOGOUT );
Sleep(10);
retval_1 = m_DBAgent.UpdateWarehouseData( accountid, uid, UPDATE_LOGOUT );
if( retval_1 == TRUE && retval_2 == TRUE )
break;
count++;
} while( count < 10 );
if( count >= 10 ) {
sprintf( logstr, "Logout Save Error: %s, %s (W:%d,U:%d) \r\n", accountid, userid, retval_1, retval_2 );
WriteLogFile( logstr );
//m_LogFile.Write(logstr, strlen(logstr));
}
count = 0;
do {
if( retval_1 = m_DBAgent.CheckUserData( accountid, userid, 1, pUser->m_dwTime, pUser->m_iBank) )
break;
m_DBAgent.UpdateWarehouseData( accountid, uid, UPDATE_LOGOUT ); // retry
count++;
Sleep(10);
} while( count < 10 );
if( count >= 10 ) {
sprintf( logstr, "WarehouseData Logout Check Error: %s, %s (W:%d) \r\n", accountid, userid, retval_1);
WriteLogFile( logstr );
//m_LogFile.Write(logstr, strlen(logstr));
}
count = 0;
do {
if( retval_1 = m_DBAgent.CheckUserData( accountid, userid, 2, pUser->m_dwTime, pUser->m_iExp) )
break;
m_DBAgent.UpdateUser( userid, uid, UPDATE_LOGOUT ); // retry
count++;
Sleep(10);
} while( count < 10 );
if( count >= 10 ) {
sprintf( logstr, "UserDataLogout Check Error: %s, %s (W:%d) \r\n", accountid, userid, retval_1);
WriteLogFile( logstr );
//m_LogFile.Write(logstr, strlen(logstr));
}
m_DBAgent.MUserInit( uid );
SetByte( send_buff, WIZ_LOGOUT, send_index );
SetShort( send_buff, uid, send_index );
count = 0;
do {
if( m_LoggerSendQueue.PutData( send_buff, send_index ) == 1 )
break;
else
count++;
} while( count < 50 );
if( count >= 50 )
m_OutputList.AddString("Logout Packet Drop!!!");
}
void CAujardDlg::AccountLogIn(char *pBuf)
{
int index = 0, uid = -1, idlen = 0, pwdlen = 0, send_index = 0, count = 0;
int nation = -1;
char accountid[MAX_ID_SIZE+1];
memset( accountid, NULL, MAX_ID_SIZE+1 );
char password[MAX_PW_SIZE + 1];
memset( password, NULL, MAX_PW_SIZE+1 );
char send_buff[256];
memset( send_buff, NULL, 256 );
uid = GetShort( pBuf, index );
idlen = GetShort( pBuf, index );
GetString( accountid, pBuf, idlen, index );
pwdlen = GetShort( pBuf, index );
GetString( password, pBuf, pwdlen, index );
nation = m_DBAgent.AccountLogInReq( accountid, password);
SetByte( send_buff, WIZ_LOGIN, send_index );
SetShort( send_buff, uid, send_index );
SetByte( send_buff, nation, send_index );
do {
if( m_LoggerSendQueue.PutData( send_buff, send_index ) == 1 )
break;
else
count++;
} while( count < 50 );
if( count >= 50 )
m_OutputList.AddString("Login Packet Drop!!!");
}
void CAujardDlg::SelectNation(char *pBuf)
{
int index = 0, uid = -1, idlen = 0, send_index = 0, count = 0;
int nation = -1;
BYTE result;
char accountid[MAX_ID_SIZE+1], password[13];
memset( accountid, NULL, MAX_ID_SIZE+1 ); memset( password, NULL, 13 );
char send_buff[256];
memset( send_buff, NULL, 256 );
uid = GetShort( pBuf, index );
idlen = GetShort( pBuf, index );
GetString( accountid, pBuf, idlen, index );
nation = GetByte( pBuf, index );
result = m_DBAgent.NationSelect( accountid, nation );
SetByte( send_buff, WIZ_SEL_NATION, send_index );
SetShort( send_buff, uid, send_index );
if( result )
SetByte( send_buff, nation, send_index );
else
SetByte( send_buff, 0x00, send_index );
do {
if( m_LoggerSendQueue.PutData( send_buff, send_index ) == 1 )
break;
else
count++;
} while( count < 50 );
if( count >= 50 )
m_OutputList.AddString("Sel Nation Packet Drop!!!");
}
void CAujardDlg::CreateNewChar(char *pBuf)
{
int index = 0, uid = -1, idlen = 0, charidlen = 0, send_index = 0, result = 0, count = 0;
int charindex = 0, race = 0, Class = 0, hair = 0, face = 0, str = 0, sta = 0, dex = 0, intel = 0, cha = 0;
char accountid[MAX_ID_SIZE+1], charid[MAX_ID_SIZE+1];
memset( accountid, NULL, MAX_ID_SIZE+1 );
memset( charid, NULL, MAX_ID_SIZE+1 );
char send_buff[256];
memset( send_buff, NULL, 256);
uid = GetShort( pBuf, index );
idlen = GetShort( pBuf, index );
GetString( accountid, pBuf, idlen, index );
charindex = GetByte( pBuf, index );
charidlen = GetShort( pBuf, index );
GetString( charid, pBuf, charidlen, index );
race = GetByte( pBuf, index );
Class = GetShort( pBuf, index );
face = GetByte( pBuf, index );
hair = GetByte( pBuf, index );
str = GetByte( pBuf, index );
sta = GetByte( pBuf, index );
dex = GetByte( pBuf, index );
intel = GetByte( pBuf, index );
cha = GetByte( pBuf, index );
result = m_DBAgent.CreateNewChar( accountid, charindex, charid, race, Class, hair, face, str, sta, dex, intel, cha );
SetByte( send_buff, WIZ_NEW_CHAR, send_index );
SetShort( send_buff, uid, send_index );
SetByte( send_buff, result, send_index );
do {
if( m_LoggerSendQueue.PutData( send_buff, send_index ) == 1 )
break;
else
count++;
} while( count < 50 );
if( count >= 50 )
m_OutputList.AddString("New Char Packet Drop!!!");
}
void CAujardDlg::DeleteChar(char *pBuf)
{
int index = 0, uid = -1, idlen = 0, charidlen = 0, send_index = 0, result = 0, count = 0;
int charindex = 0, soclen = 0;
char accountid[MAX_ID_SIZE+1], charid[MAX_ID_SIZE+1], socno[15];
memset( accountid, NULL, MAX_ID_SIZE+1 );
memset( charid, NULL, MAX_ID_SIZE+1 );
memset( socno, NULL, 15 );
char send_buff[256];
memset( send_buff, NULL, 256);
uid = GetShort( pBuf, index );
idlen = GetShort( pBuf, index );
GetString( accountid, pBuf, idlen, index );
charindex = GetByte( pBuf, index );
charidlen = GetShort( pBuf, index );
GetString( charid, pBuf, charidlen, index );
soclen = GetShort( pBuf, index );
GetString( socno, pBuf, soclen, index );
result = m_DBAgent.DeleteChar( charindex, accountid, charid, socno );
TRACE("*** DeleteChar == charid=%s, socno=%s ***\n", charid, socno);
SetByte( send_buff, WIZ_DEL_CHAR, send_index );
SetShort( send_buff, uid, send_index );
SetByte( send_buff, result, send_index );
if( result > 0 )
SetByte( send_buff, charindex, send_index );
else
SetByte( send_buff, 0xFF, send_index );
do {
if( m_LoggerSendQueue.PutData( send_buff, send_index ) == 1 )
break;
else
count++;
} while( count < 50 );
if( count >= 50 )
m_OutputList.AddString("Del Char Packet Drop!!!");
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -