📄 recvmsgfromuser.cpp
字号:
// 1) 酒流 立加辆丰 菩哦阑 罐扁 傈俊 焊辰 菩哦牢 版快.
// 2) 辑滚/努扼捞攫飘率 内靛啊 肋给等 版快.
// 3) 沥惑利牢 努扼捞攫飘啊 酒囱 版快.
// 魄窜且 规过捞 绝栏骨肺 菩哦阑 公矫窍绰 规侥栏肺 措贸茄促.
// 绢瞒乔 辑滚啊 辆丰登搁 促 肋赴促.
return;
}
// 价脚磊狼 Identity 备窍扁.
USERINFO *pUserInfo = (USERINFO*)g_pINet->GetUserInfo(dwConnectionIndex);
// 价脚磊狼 Identity绰 公炼扒 沥惑蔼. 弊寇狼 版快 橇肺弊伐狼 滚弊.
_ASSERT( pUserInfo );
g_pUserTable->SetTickForSleptTimeProcess( pUserInfo );
// Invalid User to be Disconnected..
#define IUD_PACKET_WRONG_SIZE_ 10
#define IUD_PACKET_KEY_CODE_ 11
#define IUD_STATUS_USER_NOT_CERTIFIED_ 12
// 扁夯荤捞令 眉农
if( dwLength < sizeof(t_header) )
{
// MyLog( LOG_FATAL, "User(%d) :: Illegal Packet size(smaller than sizeof(t_header)) has received", dwConnectionIndex );
// 荤侩磊啊 痹拜俊 绢边唱绰 菩哦阑 焊陈促.
// 碍力肺 谗绰促.
MyLog( LOG_NORMAL, "** Too Small Packet From User" );
cause = IUD_PACKET_WRONG_SIZE_;
goto DISCONNECT_USER_FOR_ERROR_;
}
// Build Packet Header from string
packet = (t_packet *)pMsg;
// 沥惑利牢 目池记牢瘤 犬牢.
if( pUserInfo->dwStatus == STATUS_USER_NOT_CERTIFIED )
{
if( packet->h.header.type != CMD_ACCESS_LOGIN )
{
cause = IUD_STATUS_USER_NOT_CERTIFIED_;
goto DISCONNECT_USER_FOR_ERROR_;
}
}
else if( !g_pUserTable->IsUserAvailable( pUserInfo ) )
{
// 厚沥惑利牢 目池记.
// 皋矫瘤 贸府甫 窍瘤 臼绰促.
return;
}
//菩哦 虐 叼内爹捞 甸绢哎 磊府
//if(pUserInfo->bAmILogon)
{
if(!RAJADecodePacket(pUserInfo, packet, dwLength))
{
MyLog( LOG_FATAL, "-------------------------", dwConnectionIndex, packet->h.header.type );
MyLog( LOG_FATAL, "CRC Error From Usre", dwConnectionIndex, packet->h.header.type );
char cause[ FILENAME_MAX];
sprintf( cause, "Bad Packet Size %d:%d", packet->h.header.size, dwLength-sizeof(t_header) );
SendHackingUser2DB( pUserInfo, 20008, cause );
g_pUserTable->DisconnectUserBySuggest( pUserInfo, CMD_HACKING_USER );
return;
}
}
// Is it Valid packet?
if( packet->h.header.size != (WORD)(dwLength-sizeof(t_header)) )
{
MyLog( LOG_FATAL, "User(%d) :: Illegal Packet(%d) has received", dwConnectionIndex, packet->h.header.type );
// 荤侩磊啊 痹拜俊 绢边唱绰 菩哦阑 焊陈促. 鞘夸窍搁 咯扁辑 谗绢霖促.
//MyLog( LOG_NORMAL, "Invalid Packet From User(Size is not Valid) - Close It" );
char cause[ FILENAME_MAX];
sprintf( cause, "Bad Packet Size %d:%d", packet->h.header.size, dwLength-sizeof(t_header) );
SendHackingUser2DB( pUserInfo, 20008, cause );
g_pUserTable->DisconnectUserBySuggest( pUserInfo, CMD_HACKING_USER );
return;
}
// Isn't it too big?
if( packet->h.header.size > RAJA_MAX_PACKET_SIZE )
{
MyLog( LOG_FATAL, "User(%d) :: Too Large Packet(%d) Received", dwConnectionIndex, packet->h.header.size);
return;
}
// ----------------------------------------------
// 捞镑俊 扼磊 Agent Server狼 菩哦贸府啊 甸绢埃促.
// ----------------------------------------------
switch( packet->h.header.type )
{
// 流立 贸府且 Packet甸
case CMD_CONNECT_AGENT_SERVER_CONFORM:
{//怕惫 苞陛 罐绰镑
::RecvCMD_CONNECT_AGENT_SERVER_CONFORM(pUserInfo,packet);//
}break;
case CMD_ALL_READY:
{
// FOR DEBUG by chan78 2001/02/21
dwMapChangeCounter--;
LP_SERVER_DATA pTestServer;
pTestServer = g_pServerTable->GetServerData( pUserInfo->dwMapServerConnectionIndex );
if( !pTestServer )
{
if( pUserInfo->dwMapServerConnectionIndex == 0 )
{
// MyLog( LOG_NORMAL, "CMD_ALL_READY (%d) (uID:%d, pUserInfo->dwMapServerConnectionIndex is NULL)", dwMapChangeCounter, pUserInfo->dwID );
}
else
{
// MyLog( LOG_NORMAL, "CMD_ALL_READY (%d) (uID:%d, ---------------FATAL No Server To Redirect)", dwMapChangeCounter, pUserInfo->dwID );
}
}
else
{
//MyLog( LOG_NORMAL, "CMD_ALL_READY (%d) (uID:%d, MapdwID:%d port:%d)", dwMapChangeCounter, pUserInfo->dwID, pUserInfo->dwMapServerConnectionIndex, pTestServer->wPort );
}
}
goto ToMapServer_;
case CMD_PING:
break;
case CMD_NONE:
break;
case CMD_LOST_CONNECTION:
{
//MyLog( LOG_IGNORE, "User connection closed by Client's Request" );
g_pINet->CompulsiveDisconnectUser(dwConnectionIndex);
}
break;
// Added by chan78 at 2000/11/28
// Monitoring Client Related Packets
case CMD_SV_CONNECT_SERVER_COUNT :
{
SendConnectServerCount( dwConnectionIndex );
}
break;
case CMD_SV_GET_CONNECT_SERVER_PORT :
{
SendCurrServerPort( dwConnectionIndex );
}
break;
// Added by chan78 at 2000/12/07
// 010109 KHS
case CMD_SV_SEND_MESSAGE_ALL : // 010110 YGI
{
SendPbs( packet->u.default_msg, packet->h.header.size );
break;
}
//--------------------------------------------
// 沥焊甫 哎秒窍绊 单捞磐甫 函版秦 焊尘 菩哦甸
//--------------------------------------------
case CMD_ACCESS_LOGIN:
{
t_packet to_send;
SOCKADDR_IN* paddr = NULL;
DWORD length = sizeof(t_header)+packet->h.header.size;
::strupr( packet->u.ClientAccessLogin.id );
::memcpy( &pUserInfo->szName, &packet->u.ClientAccessLogin.id, 20 );
pUserInfo->bAmILogon = false;
// IP 嘿洒扁..
::memcpy( &to_send, packet, length );
paddr = g_pINet->GetUserAddress(dwConnectionIndex);
::sprintf( to_send.u.ClientAccessLogin.ip, "%d.%d.%d.%d", paddr->sin_addr.S_un.S_un_b.s_b1
, paddr->sin_addr.S_un.S_un_b.s_b2
, paddr->sin_addr.S_un.S_un_b.s_b3
, paddr->sin_addr.S_un.S_un_b.s_b4 );
to_send.u.ClientAccessLogin.wPort = g_pServerTable->GetOwnServerData()->wPort;
// 菩哦傈价
if( !pUserInfo->dwMapServerConnectionIndex )
{
// Build Packet
sMsg[0] = (BYTE)PTCL_AGENT_TO_DB;
*((DWORD *)(sMsg+1)) = pUserInfo->dwID;
to_send.h.header.size = to_send.h.header.size; // Modified by chan78 at 2000/12/17
::memcpy( sMsg+1+4, to_send.h.data, sizeof(t_header) );
::memcpy( sMsg+1+4+sizeof(t_header), to_send.u.data, to_send.h.header.size );
// 弥檬肺 DB Demon俊 皋矫瘤甫 焊郴绰 何盒.
if( g_pServerTable->GetOwnDBDemonData() && g_pServerTable->GetOwnDBDemonData()->dwConnectionIndex )
{
// 泅犁 AGENT啊 荤侩窍绰 DB DEMON阑 捞 荤侩磊啊 浚飘府甫 焊蜡茄 DB Demon栏肺 汲沥茄促.
pUserInfo->dwDBDemonConnectionIndex = g_pServerTable->GetOwnDBDemonData()->dwConnectionIndex;
if( !g_pServerTable->Send( pUserInfo->dwDBDemonConnectionIndex, (char*)&sMsg, (1+4+sizeof(t_header)+to_send.h.header.size)) )
{
g_pUserTable->DisconnectUserBySuggest( pUserInfo, CMD_CLOSE_CONNECTION_ABNORMAL );
MyLog( LOG_FATAL, "Can't redirect Message to DB Demon -- Close this User");
}
}
else
{
g_pUserTable->DisconnectUserBySuggest( pUserInfo, CMD_CLOSE_CONNECTION_ABNORMAL );
MyLog( LOG_FATAL, "Can't redirect Message to DB Demon -- Close this User");
}
}
}
break;
//-------------------------------------
// DB Demon栏肺 redirection 且 Packet甸
//-------------------------------------
case CMD_SELECTED_CHAR_RESULT_CLIENT_BOTH_DB_DEMON:
case CMD_GLOBAL_CHAT_DATA:
case CMD_IM_GAME_SERVER:
case CMD_CREATE_CHAR:
case CMD_DELETE_CHAR:
case CMD_ISTHERE_CHARNAME:
case CMD_THROW_DICE:
case CMD_CREATE_ABILITY:
case CMD_CHECK_NEW_CHAR:
case CMD_CONNECT_INFO:
case CMD_CHR_ITEM_INFO_0:
case CMD_CHR_ITEM_INFO_1:
case CMD_CHR_ITEM_INFO_2:
case CMD_CHAR_INFO_MAGIC:
case CMD_CHAR_INFO_SKILL:
case CMD_CONNECT_INFO1:
case CMD_SELECT_NATION :
case CMD_RESET_JOB :
ToMapServer_:
// Modified by chan78 at 2000/11/28
// 困俊 秦寸窍绰 目盖靛扼档 dwMapServerConnectionIndex啊 乐栏搁 MapServer肺 焊辰促.
if( !pUserInfo->dwMapServerConnectionIndex )
{
// Build Packet
sMsg[0] = (BYTE)PTCL_AGENT_TO_DB;
*((DWORD *)(sMsg+1)) = pUserInfo->dwID;
memcpy( sMsg+1+4, packet->h.data, sizeof(t_header) );
memcpy( sMsg+1+4+sizeof(t_header), packet->u.data, packet->h.header.size );
// Modified by chan78 at 2001/02/21
if( pUserInfo->dwDBDemonConnectionIndex )
{
if( !g_pServerTable->Send(pUserInfo->dwDBDemonConnectionIndex, sMsg, (1+4+sizeof(t_header)+packet->h.header.size)) )
{
MyLog( LOG_NORMAL, "Can't Redirect Client Packet to DB DEMON -- Close this connection", pUserInfo->dwID );
g_pUserTable->DisconnectUserBySuggest( pUserInfo, CMD_CLOSE_CONNECTION_ABNORMAL );
}
}
else
{
if( !g_pServerTable->SendToDBDemon( sMsg, (1+4+sizeof(t_header)+packet->h.header.size)) )
{
MyLog( LOG_FATAL, "Can't redirect Message to DB Demon -- Close this User");
g_pUserTable->DisconnectUserBySuggest( pUserInfo, CMD_CLOSE_CONNECTION_ABNORMAL );
}
}
break;
}
// ----------------------
// Map Server肺 哎 菩哦甸
// ----------------------
// 捞镑俊辑 MAP Server肺 哎 Packet狼 公搬己阑 八刘秦 吧矾林绰巴捞 亮促.
default :
{
if( DWORD ToServ = pUserInfo->dwMapServerConnectionIndex )
{ // Build Packet
switch( packet->h.header.type )
{
case CMD_ACCESS_JOIN :
{
sMsg[0] = (BYTE)PTCL_AGENT_TO_MAP; // CMD ID
*((DWORD *)(sMsg+1)) = pUserInfo->dwID;
packet->h.header.size = sizeof( ACCESSJOIN );
::memcpy( sMsg+1+4, packet, (sizeof(t_header)+packet->h.header.size) ); // t_packet
::strcpy( packet->u.AccessJoin.ip, pUserInfo->szIP );
}break;
default :
{
sMsg[0] = (BYTE)PTCL_AGENT_TO_MAP; // CMD ID
*((DWORD *)(sMsg+1)) = pUserInfo->dwID;
::memcpy( sMsg+1+4, packet, (sizeof(t_header)+packet->h.header.size) ); // t_packet
}break;
}
if( g_pINet->SendToServer( ToServ, sMsg, (1+4+sizeof(t_header)+packet->h.header.size),FLAG_SEND_NOT_ENCRYPTION ) == false )
{
::MyLog( LOG_FATAL, "User(%d) :: Can't redirect Message to Map Server(%d) :: Illegal Server Index", dwConnectionIndex, ToServ);
}
}
else
{
::MyLog( LOG_FATAL, "Client(%d) has not MapServer Index(%d)", pUserInfo->dwID, ToServ);
} // 努扼捞攫飘俊霸 谗栏扼绰 菩哦阑 焊郴霖促.
}
break;
}
return;
DISCONNECT_USER_FOR_ERROR_:
g_pINet->CompulsiveDisconnectUser(dwConnectionIndex);
return;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -