📄 recvmsg.cpp
字号:
memcpy( connections[dwNewCN].mapname, MapName, NM_LENGTH );
strcpy( connections[dwNewCN].chrlst.MapName, MapName );
strcpy( connections[dwNewCN].ip_address, packet->u.change_map_protocol.ip );
// Build Packet For DB Demon
// DB狼 'LoginTable'狼 MapName阑 官槽促.
tp.h.header.type = CMD_ACCESS_JOIN_KEIN;
tp.u.gs_req_insert_userid.server_id = dwNewCN;
memcpy( tp.u.gs_req_insert_userid.id, packet->u.change_map_protocol.id, ID_LENGTH );
memcpy( tp.u.gs_req_insert_userid.pw, packet->u.change_map_protocol.password, PW_LENGTH );
memcpy( tp.u.gs_req_insert_userid.name, packet->u.change_map_protocol.name, NM_LENGTH );
memcpy( tp.u.gs_req_insert_userid.mapname, packet->u.change_map_protocol.mapname, NM_LENGTH );
tp.h.header.size = sizeof( t_gs_req_insert_userid );
QueuePacket( connections, DB_DEMON, &tp, 1 ); // LogIn Server肺 焊辰促.
// Now Reading...
NewRecvChangeMapData1( &packet->u.change_map_protocol.mapdata1, dwNewCN );
NewRecvChangeMapData2( &packet->u.change_map_protocol.mapdata2, dwNewCN );
NewRecvChangeMapData3( &packet->u.change_map_protocol.mapdata3, dwNewCN );
NewRecvChangeMapData4( &packet->u.change_map_protocol.mapdata4, dwNewCN );
NewRecvChangeMapData5( &packet->u.change_map_protocol.mapdata5, dwNewCN );
NewRecvChangeMapData6( &packet->u.change_map_protocol.mapdata6, dwNewCN );
NewRecvChangeMapData7( &packet->u.change_map_protocol.mapdata7, dwNewCN );
NewRecvChangeMapData8( &packet->u.change_map_protocol.mapdata8, dwNewCN );
NewRecvChangeMapData9( &packet->u.change_map_protocol.mapdata9, dwNewCN );
//----------------- 辑滚肺 何磐 罐瘤 臼绰 Data甫 沥府. 001218 KHS
LPCHARLIST tch = &connections[dwNewCN].chrlst;
tch->SetServerID(dwNewCN); // CSD-HK-030829
tch->startposition = 0;
tch->updatable = 1; // CSD-TW-030620
tch->timetoupdate = g_curr_time;
tch->Race = HUMAN;
tch->cur_skillno = 0;
for( int i = 0 ; i < 1000 ; i ++) if( tch->Item[i] == 0) break;
tch->ItemMax = i;
//----------------------------------------------------
// Answer(success)
szMsg[0] = (BYTE)PTCL_MAP_TO_MAP;
spacket->h.header.type = CMD_MAP_CHANGE_ACCEPTED;
spacket->h.header.size = sizeof( t_map_change_result );
spacket->h.header.crc = 0;
spacket->u.map_change_result.wAgentServerID = packet->u.change_map_protocol.wAgentServerID;
spacket->u.map_change_result.dwIDForAgent = connections[dwNewCN].dwIDForAgent ;
spacket->u.map_change_result.TargetServerCn = dwNewCN;
spacket->u.map_change_result.FromServerCn = packet->u.change_map_protocol.FromServerCn;
//021030 YGI---------------------------------------
spacket->u.kein.new_map_change_result.u.data2.active = 0;
if( g_EventMgr.IsActive( g_EventMgr.ET_EVENT_OBJECT ) )
{
CEventObject *pData = (CEventObject*)g_EventMgr.GetActiveEvent( g_EventMgr.ET_EVENT_OBJECT );
spacket->u.kein.new_map_change_result.u.data2.active = pData->ACTIVE_NUMBER_;
strcpy( spacket->u.kein.new_map_change_result.u.data2.object_toi, pData->m_szObjectTOI );
strcpy( spacket->u.kein.new_map_change_result.u.data2.object_b, pData->m_szObjectB );
spacket->h.header.size += sizeof( k_event_object );
}
if( g_EventMgr.IsActive( g_EventMgr.ET_EVENT_SOUND ) )
{
CEventSound *pData = (CEventSound *)g_EventMgr.GetActiveEvent( g_EventMgr.ET_EVENT_SOUND );
if( spacket->u.kein.new_map_change_result.u.data3.active )
{
spacket->h.header.size = sizeof( k_new_server_change_map );
spacket->u.kein.new_map_change_result.u.data2.active |= pData->ACTIVE_NUMBER_;
spacket->u.kein.new_map_change_result.u.data2.sound_no = pData->m_nSoundNo;
}
else
{
spacket->u.kein.new_map_change_result.u.data3.active = pData->ACTIVE_NUMBER_;
spacket->u.kein.new_map_change_result.u.data3.sound_no = pData->m_nSoundNo;
spacket->h.header.size += sizeof( k_event_sound );
}
}
//----------------------------------------------------
// tch->server_id = dwNewCN;
if( !g_pServerTable->Send(dwConnectionIndex, szMsg, 1+sizeof(t_header)+spacket->h.header.size) )
{
MyLog( LOG_FATAL, "PTCL_MAP_TO_MAP :: Can't Answer to MapServer(ConnectionIndex:%d)", dwConnectionIndex );
break;
}
}
}
break;
//021030 YGI
case CMD_MAP_CHANGE_ACCEPTED:
{ //< CSD-HK-030829
t_packet *rpacket = (t_packet*)(pMsg+1);
int size = dwLength-1-sizeof(t_header);
if( size > sizeof(k_new_server_change_map) )
{
MyLog( LOG_FATAL, "CMD_MAP_CHANGE_ACCEPTED :: Invalid Packet Size(%d != %d)", size, sizeof(k_new_server_change_map) );
//break;
}
rpacket->u.data[size] = 0;
//------------------
if( connections[rpacket->u.map_change_result.FromServerCn].server_change_map.port == 0 )
{
MyLog( LOG_FATAL, "CMD_MAP_CHANGE_ACCEPTED :: connection[%d] is not found!", rpacket->u.map_change_result.FromServerCn );
break;
}
// Make Packet.
spacket->h.header.type = CMD_CHANGE_MAP;
spacket->h.header.size = sizeof(t_server_change_map);
connections[rpacket->u.map_change_result.FromServerCn].server_change_map.server_id = (short int)rpacket->u.map_change_result.TargetServerCn;
memcpy( &spacket->u.server_change_map, &connections[rpacket->u.map_change_result.FromServerCn].server_change_map, sizeof(server_change_map) );
if( rpacket->u.kein.new_map_change_result.u.data2.active & CEventObject::ACTIVE_NUMBER_ )
{
spacket->u.kein.new_server_change_map.u.data2 = rpacket->u.kein.new_map_change_result.u.data2;
spacket->h.header.size += sizeof(k_event_object);
if( rpacket->u.kein.new_map_change_result.u.data2.active & CEventSound::ACTIVE_NUMBER_ )
{
spacket->h.header.size = sizeof(k_new_server_change_map);
}
}
else if( rpacket->u.kein.new_map_change_result.u.data2.active & CEventSound::ACTIVE_NUMBER_ )
{
spacket->u.kein.new_server_change_map.u.data3 = rpacket->u.kein.new_map_change_result.u.data3;
spacket->h.header.size += sizeof(k_event_sound);
}
// Send It.
QueuePacket(connections, rpacket->u.map_change_result.FromServerCn, spacket, 1);
break;
} //> CSD-HK-030829
case CMD_MAP_CHANGE_DENIED:
{
t_packet *rpacket = (t_packet*)(pMsg+1);
if( dwLength-1 != (sizeof(t_header)+sizeof(t_map_change_result)) )
{
MyLog( LOG_FATAL, "CMD_MAP_CHANGE_DENIED :: Invalid Packet Size(%d != %d)", dwLength-1, sizeof(t_header)+sizeof(t_map_change_result) );
break;
}
if( connections[rpacket->u.map_change_result.FromServerCn].server_change_map.port == 0 )
{
MyLog( LOG_FATAL, "CMD_MAP_CHANGE_DENIED :: connection[%d] is not found!", rpacket->u.map_change_result.FromServerCn );
break;
}
// 趣矫 MapChange 菩哦捞 坷啊绰吝 唱啊滚副荐档 乐促...
// 鉴埃捞骨肺 啊瓷己篮 概快 撤瘤父.
if( connections[rpacket->u.map_change_result.FromServerCn].dwAgentConnectionIndex == 0 )
break;
// Added by chan78 at 2000/11/27
LPCHARLIST ch;
ch = &connections[rpacket->u.map_change_result.FromServerCn].chrlst;
// 目池记 蔼 汗备
connections[rpacket->u.map_change_result.FromServerCn].state = CONNECT_JOIN;
memcpy( connections[rpacket->u.map_change_result.FromServerCn].mapname, MapName, NM_LENGTH);
// 归诀秦初疽带 蔼栏肺 登倒府扁.
ch->MoveGox = ch->MapChange_MoveGox;
ch->MoveGoy = ch->MapChange_MoveGoy;
ch->X = ch->MapChange_X;
ch->Y = ch->MapChange_Y;
ch->MoveSx = ch->MapChange_MoveSx;
ch->MoveSy = ch->MapChange_MoveSy;
ch->MoveLength = ch->MapChange_MoveLength;
ch->MovePathCount = ch->MapChange_MovePathCount;
// MAP 函版 牡浇
CallClient( rpacket->u.map_change_result.FromServerCn, CMD_CHANGE_MAP_FAIL);
}
break;
// 001206 KHS 惫啊傈包访
case CMD_SEALSTONE_STATUS :
{
t_packet *rpacket = (t_packet*)(pMsg+1);
RecvSealStoneStatus( rpacket );
break;
}
case CMD_STEALSTONE_BREAKABLE:
{ //< CSD-CN-031213
t_packet *rpacket = (t_packet*)(pMsg+1);
g_pUserManager->SendPacket(rpacket);
SealStoneBreakable = CMD_STEALSTONE_BREAKABLE;
g_LocalWarBegin=rpacket->u.LocalWar.CommonDataC.Data; // 011215 LTS
// MyLog(0,"Local War Status : %d",g_LocalWarBegin);
break;
} //> CSD-CN-031213
case CMD_STEALSTONE_NON_BREAKABLE_PEACE:
{ //< CSD-CN-031213
t_packet *rpacket = (t_packet*)(pMsg+1);
g_pUserManager->SendPacket(rpacket);
SealStoneBreakable = CMD_STEALSTONE_NON_BREAKABLE_PEACE;
g_LocalWarBegin=rpacket->u.LocalWar.CommonDataC.Data; // 011215 LTS
// MyLog(0,"Local War Status : %d",g_LocalWarBegin);
break;
} //> CSD-CN-031213
case CMD_STEALSTONE_NON_BREAKABLE:
{ //< CSD-CN-031213
t_packet *rpacket = (t_packet*)(pMsg+1);
g_pUserManager->SendPacket(rpacket);
SealStoneBreakable = CMD_STEALSTONE_NON_BREAKABLE;
g_LocalWarBegin=rpacket->u.LocalWar.CommonDataC.Data; // 011215 LTS
// MyLog(0,"Local War Status : %d",g_LocalWarBegin);
break;
} //> CSD-CN-031213
default:
{
t_packet *rpacket = (t_packet*)(pMsg+1);
HandleCommand( CN_FROM_OTHER_MAPSERVER_MSG, rpacket );
// MyLog( LOG_FATAL, "PTCL_MAP_TO_MAP :: Invalid Packet(%d) has received!", packet->h.header.type );
break;
}
}
}
break;
case PTCL_BROADCAST_TO_SERVERS:
{
t_packet packet;
memcpy( &packet, pMsg+1, dwLength-1 );
*(((char *)&packet)+dwLength) = '\0';
// RajaPacket八刘
if( ((dwLength-1) < sizeof(t_header)) || ((dwLength-1) != (sizeof(t_header)+packet.h.header.size)) )
{
MyLog( LOG_FATAL, "PTCL_BROADCAST_TO_SERVERS :: Invalid Packet Size(Expected:%d)(Length:%d)", (sizeof(t_header)+packet.h.header.size), dwLength-1 );
break;
}
// HandleBroadCastedPackets( &packet );
// Modifed by chan78 2000/12/01
HandleCommand( CN_FROM_OTHER_MAPSERVER_MSG, &packet );
}
break;
// Added by chan78 at 2001/03/16
// -----------------------------
case PTCL_MANAGER_QUERY:
{
if( !OnRecvMsgFromManager( (LP_MANAGER_PACKET)pMsg, dwLength ) )
{
MyLog( LOG_FATAL, "PTCL_MANAGER_ANSWER :: OnRecvMsgFromManager() has return false(%d)", pSender->wPort );
break;
}
}
break;
// Added by chan78 at 2001/03/16
case PTCL_MANAGER_ANSWER:
{
// 乐阑 荐 绝促.
MyLog( LOG_FATAL, "PTCL_MANAGER_ANSWER :: has received!!!(%d)", pSender->wPort );
g_pServerTable->DestroyServer( FINISH_TYPE_UNKNOWN_ERROR);
}
break;
// -----------------------------
// 011012 KBS
case PTCL_PROXY_TO_MAP:
{
t_packet packet;
memcpy( &packet, pMsg+1, dwLength-1 );
*(((char *)&packet)+dwLength) = '\0';
HandleCommand( CN_FROM_OTHER_MAPSERVER_MSG, &packet );
}
break;
case PTCL_RM_FROM_PROXY:
{
RMProc(dwConnectionIndex, pMsg, dwLength);
}
break;
//
//<! BBD 040311 橇废矫肺何磐狼 悼立荐 览翠
case PTCL_SERVERSET_USERNUM_REQUEST:
{
memcpy(&g_UsercountInServerSet, &(pMsg[1]), sizeof(g_UsercountInServerSet));
unsigned short count2 = g_pServerTable->GetNumOfUsersInServerSet();
break;
}
//> BBD 040311 橇废矫肺何磐狼 悼立荐 览翠
default:
{
MyLog( LOG_FATAL, "Unknown bID(%d) Received. From %s(wPort:%d) Size(%d) ConnectionID(%d)", bID, GetTypedServerText(pSender->dwServerType), pSender->wPort, dwLength, dwConnectionIndex);
#ifdef __ON_DEBUG
// _asm int 3;
#endif
}
break;
}
}
void __stdcall ReceivedMsgFromUser(DWORD dwConnectionIndex, char* pMsg,DWORD dwLength)
{
return;
}
// 020701 YGI
WORD GetServerPortById( DWORD dwConnectionIndex )
{
if( !g_pServerTable ) return 0;
LP_SERVER_DATA pServerData;
pServerData = g_pServerTable->GetConnectedServerData( dwConnectionIndex );
if ( !pServerData || !pServerData->pHashedServerData )
{
return 0;
}
return pServerData->wPort;
}
extern void DisconnectServer_kein( WORD port ); // 020627 YGI
extern void ConnectServer_kein( WORD port ); // 020627 YGI
void __stdcall OnAcceptServer( DWORD dwConnectionIndex )
{
ConnectServer_kein( GetServerPortById( dwConnectionIndex ) ); // 020627 YGI
}
void __stdcall OnAcceptUser( DWORD dwConnectionIndex )
{
}
void __stdcall OnDisconnectServer( DWORD dwConnectionIndex )
{
g_pServerTable->RemoveConnectedServerDataFromHashTable( dwConnectionIndex );
DisconnectServer_kein( GetServerPortById( dwConnectionIndex ) ); // 020627 YGI
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -