📄 aujarddlg.cpp
字号:
void CAujardDlg::AllCharInfoReq(char *pBuf)
{
int index = 0, uid = 0, idlen = 0, send_index = 0, buff_index = 0, count = 0;
char accountid[MAX_ID_SIZE+1];
memset( accountid, NULL, MAX_ID_SIZE+1 );
char send_buff[1024], buff[1024];
memset( send_buff, NULL, 1024 );
memset( buff, NULL, 1024 );
char charid1[MAX_ID_SIZE+1], charid2[MAX_ID_SIZE+1], charid3[MAX_ID_SIZE+1], charid4[MAX_ID_SIZE+1], charid5[MAX_ID_SIZE+1];
memset( charid1, NULL, MAX_ID_SIZE+1 ); memset( charid2, NULL, MAX_ID_SIZE+1 ); memset( charid3, NULL, MAX_ID_SIZE+1 ); memset( charid4, NULL, MAX_ID_SIZE+1 ); memset( charid5, NULL, MAX_ID_SIZE+1 );
uid = GetShort( pBuf, index );
idlen = GetShort( pBuf, index );
GetString( accountid, pBuf, idlen, index );
SetByte( buff, 0x01, buff_index ); // result
m_DBAgent.GetAllCharID( accountid, charid1, charid2, charid3, charid4, charid5 );
m_DBAgent.LoadCharInfo( charid1, buff, buff_index );
m_DBAgent.LoadCharInfo( charid2, buff, buff_index );
m_DBAgent.LoadCharInfo( charid3, buff, buff_index );
SetByte( send_buff, WIZ_ALLCHAR_INFO_REQ, send_index );
SetShort( send_buff, uid, send_index );
SetShort( send_buff, buff_index, send_index );
SetString( send_buff, 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("All Char Packet Drop!!!");
}
BOOL CAujardDlg::PreTranslateMessage(MSG* pMsg)
{
if( pMsg->message == WM_KEYDOWN ) {
if( pMsg->wParam == VK_RETURN || pMsg->wParam == VK_ESCAPE )
return TRUE;
}
return CDialog::PreTranslateMessage(pMsg);
}
void CAujardDlg::OnOK()
{
if( AfxMessageBox("柳楼 场尘鳖夸?", MB_YESNO) == IDYES )
CDialog::OnOK();
}
void CAujardDlg::OnTimer(UINT nIDEvent)
{
HANDLE hProcess = NULL;
switch( nIDEvent ) {
case PROCESS_CHECK:
hProcess = OpenProcess( PROCESS_ALL_ACCESS | PROCESS_VM_READ, FALSE, m_LoggerSendQueue.GetProcessId() );
if( hProcess == NULL )
AllSaveRoutine();
break;
case CONCURRENT_CHECK:
#ifdef __SAMMA
ConCurrentUserCount();
#endif
break;
case SERIAL_TIME:
g_increase_serial = 50001;
break;
case PACKET_CHECK:
WritePacketLog();
// SaveUserData();
break;
}
CDialog::OnTimer(nIDEvent);
}
void CAujardDlg::AllSaveRoutine()
{
_USER_DATA* pUser = NULL;
int t_count = 0, retval_1 = 0, retval_2 = 0, count = 0;
bool bsaved = false;
CString msgstr;
char logstr[256]; memset( logstr, 0x00, 256 );
CTime cur = CTime::GetCurrentTime();
TRACE("Dead Time : %d斥 %d岿 %d老 %d矫 %d盒\n", cur.GetYear(), cur.GetMonth(), cur.GetDay(), cur.GetHour(), cur.GetMinute());
t_count = m_DBAgent.m_UserDataArray.size();
for( int i=0; i<t_count; i++ ) {
pUser = (_USER_DATA*)m_DBAgent.m_UserDataArray[i];
if( !pUser )
continue;
if( strlen(pUser->m_id) == 0 )
continue;
m_DBAgent.AccountLogout( pUser->m_Accountid );
Sleep(100);
m_DBAgent.UpdateWarehouseData( pUser->m_Accountid, i, UPDATE_ALL_SAVE );
Sleep(100);
if( m_DBAgent.UpdateUser( pUser->m_id, i, UPDATE_ALL_SAVE ) ) {
TRACE("GameServer Dead!! - %s Saved\n", pUser->m_id );
Sleep(100);
count = 0;
do {
if( retval_1 = m_DBAgent.CheckUserData( pUser->m_Accountid, pUser->m_id, 1, pUser->m_dwTime, pUser->m_iBank) )
break;
m_DBAgent.UpdateWarehouseData( pUser->m_Accountid, i, UPDATE_ALL_SAVE ); // retry
count++;
Sleep(10);
} while( count < 10 );
if( count >= 10 ) {
sprintf( logstr, "WarehouseData All Save Check Error: %s, %s (W:%d) \r\n", pUser->m_Accountid, pUser->m_id, retval_1 );
WriteLogFile( logstr );
//m_LogFile.Write(logstr, strlen(logstr));
TRACE(logstr);
}
count = 0;
do {
if( retval_1 = m_DBAgent.CheckUserData( pUser->m_Accountid, pUser->m_id, 2, pUser->m_dwTime, pUser->m_iExp) )
break;
m_DBAgent.UpdateUser( pUser->m_id, i, UPDATE_ALL_SAVE ); // retry
count++;
Sleep(10);
} while( count < 10 );
if( count >= 10 ) {
sprintf( logstr, "UserDataSave All Save Check Error: %s, %s (W:%d,U:%d) \r\n", pUser->m_Accountid, pUser->m_id, retval_1, retval_2 );
WriteLogFile( logstr );
//m_LogFile.Write(logstr, strlen(logstr));
TRACE(logstr);
}
m_DBAgent.MUserInit(i);
bsaved = true;
}
else
TRACE("GameServer Dead!! - %s Not Saved\n", pUser->m_id );
Sleep(100);
}
if( bsaved ) {
msgstr.Format("All Data Saved:%d斥%d岿%d老%d矫%d盒", cur.GetYear(), cur.GetMonth(), cur.GetDay(), cur.GetHour(), cur.GetMinute());
m_OutputList.AddString(msgstr);
}
}
void CAujardDlg::ConCurrentUserCount()
{
int t_count = 0;
_USER_DATA* pUser = NULL;
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 )
continue;
t_count++;
}
TRACE("*** ConCurrentUserCount : server=%d, zone=%d, usercount=%d ***\n", m_nServerNo, m_nZoneNo, t_count);
m_DBAgent.UpdateConCurrentUserCount( m_nServerNo, m_nZoneNo, t_count );
}
void CAujardDlg::UserDataSave(char *pBuf)
{
int index = 0, uid = -1, idlen1 = 0, idlen2 = 0, retval_1 = 0, retval_2 = 0, count = 0;
_USER_DATA* pUser = NULL;
char logstr[256]; memset( logstr, 0x00, 256 );
char accountid[MAX_ID_SIZE+1];
char userid[MAX_ID_SIZE+1];
memset( accountid, NULL, MAX_ID_SIZE+1 );
memset( userid, NULL, MAX_ID_SIZE+1 );
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( accountid ) )
return;
if( !strlen( userid ) )
return;
if( uid < 0 || uid >= MAX_USER ) return;
pUser = (_USER_DATA*)m_DBAgent.m_UserDataArray[uid];
if( !pUser ) return;
retval_2 = m_DBAgent.UpdateUser( userid, uid, UPDATE_PACKET_SAVE );
Sleep(10);
retval_1 = m_DBAgent.UpdateWarehouseData( accountid, uid, UPDATE_PACKET_SAVE );
if( retval_1 == FALSE || retval_2 == FALSE )
do {
retval_2 = m_DBAgent.UpdateUser( userid, uid, UPDATE_PACKET_SAVE );
Sleep(10);
retval_1 = m_DBAgent.UpdateWarehouseData( accountid, uid, UPDATE_PACKET_SAVE );
if( retval_1 == TRUE && retval_2 == TRUE )
break;
count++;
} while( count < 10 );
if( count >= 10 ) {
sprintf( logstr, "UserData 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;
Sleep(10);
count++;
} while( count < 10 );
if( count >= 10 ) {
sprintf( logstr, "WarehouseDataSave 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;
Sleep(10);
count++;
} while( count < 10 );
if( count >= 10 ) {
sprintf( logstr, "UserDataSave Check Error: %s, %s (W:%d) \r\n", accountid, userid, retval_1 );
WriteLogFile( logstr );
//m_LogFile.Write(logstr, strlen(logstr));
}
// sprintf( logstr, "UserDataSave Packet Receive: %s, %s (W:%d,U:%d) \r\n", accountid, userid, retval_1, retval_2 );
// m_LogFile.Write(logstr, strlen(logstr));
// TRACE(logstr);
return;
}
_USER_DATA* CAujardDlg::GetUserPtr(const char *struserid, int &uid)
{
_USER_DATA* pUser = NULL;
for( int i=0; i<MAX_USER; i++ ) {
pUser = (_USER_DATA*)m_DBAgent.m_UserDataArray[i];
if( !pUser )
continue;
if( strnicmp( struserid, pUser->m_id, MAX_ID_SIZE ) == 0 ) {
uid = i;
return pUser;
}
}
return NULL;
}
void CAujardDlg::KnightsPacket(char *pBuf)
{
int index = 0, nation = 0;
BYTE command = GetByte( pBuf, index );
switch( command ) {
case KNIGHTS_CREATE:
CreateKnights( pBuf+index );
break;
case KNIGHTS_JOIN:
JoinKnights( pBuf+index );
break;
case KNIGHTS_WITHDRAW:
WithdrawKnights( pBuf+index );
break;
case KNIGHTS_REMOVE:
case KNIGHTS_ADMIT:
case KNIGHTS_REJECT:
case KNIGHTS_CHIEF:
case KNIGHTS_VICECHIEF:
case KNIGHTS_OFFICER:
case KNIGHTS_PUNISH:
ModifyKnightsMember( pBuf+index, command );
break;
case KNIGHTS_DESTROY:
DestroyKnights( pBuf+index );
break;
case KNIGHTS_MEMBER_REQ:
AllKnightsMember( pBuf+index );
break;
case KNIGHTS_STASH:
break;
case KNIGHTS_LIST_REQ:
KnightsList( pBuf+index );
break;
case KNIGHTS_ALLLIST_REQ:
nation = GetByte( pBuf, index );
m_DBAgent.LoadKnightsAllList( nation );
break;
}
}
void CAujardDlg::CreateKnights(char *pBuf)
{
int index = 0, send_index = 0, namelen = 0, idlen = 0, knightindex = 0, uid = -1, nation = 0, result = 0, community = 0, count = 0;
char knightsname[MAX_ID_SIZE+1]; memset( knightsname, 0x00, MAX_ID_SIZE+1 );
char chiefname[MAX_ID_SIZE+1]; memset( chiefname, 0x00, MAX_ID_SIZE+1 );
char send_buff[256]; memset( send_buff, 0x00, 256 );
uid = GetShort( pBuf, index );
community = GetByte( pBuf, index );
knightindex = GetShort( pBuf, index );
nation = GetByte( pBuf, index );
namelen = GetShort( pBuf, index );
GetString( knightsname, pBuf, namelen, index );
idlen = GetShort( pBuf, index );
GetString( chiefname, pBuf, idlen, index );
if( uid < 0 || uid >= MAX_USER ) return;
result = m_DBAgent.CreateKnights( knightindex, nation, knightsname, chiefname, community );
TRACE("CreateKnights - nid=%d, index=%d, result=%d \n", uid, knightindex, result);
SetByte( send_buff, KNIGHTS_CREATE, send_index );
SetShort( send_buff, uid, send_index );
SetByte( send_buff, result, send_index );
SetByte( send_buff, community, send_index );
SetShort( send_buff, knightindex, send_index );
SetByte( send_buff, nation, send_index );
SetShort( send_buff, namelen, send_index );
SetString( send_buff, knightsname, namelen, send_index );
SetShort( send_buff, idlen, send_index );
SetString( send_buff, chiefname, idlen, send_index );
do {
if( m_LoggerSendQueue.PutData( send_buff, send_index ) == 1 )
break;
else
count++;
} while( count < 50 );
if( count >= 50 )
m_OutputList.AddString("Create Knight Packet Drop!!!");
}
void CAujardDlg::JoinKnights(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];
if( !pUser ) return;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -