📄 servertable.cpp
字号:
if ( !(pDummyServerData = this->GetNewServerData( pServerList->pServerData[i].szIP, pServerList->pServerData[i].wPort) ) || !this->AddServerDataToList( pDummyServerData ) )
{
// failed
if( pDummyServerData )
{
delete pDummyServerData;
pDummyServerData = NULL;
}
// Build Answer Packet
memcpy( pFailedServerList->pServerData[pFailedServerList->wNum].szIP, pServerList->pServerData[i].szIP, MM_IP_LENGTH );
pFailedServerList->pServerData[pFailedServerList->wNum].wPort = pServerList->pServerData[i].wPort;
pFailedServerList->wNum++;
}
}
if( !pFailedServerList->wNum )
{
// ---------------------------------------------------------------------------------------------
#ifndef __IS_PROXY_SERVER
// SERVER SIDE Socket阑 官牢靛 茄促.(瘤陛何磐 促弗 辑滚狼 目池记阑 罐阑 荐 乐促.
if( !this->StartServer( TYPE_SERVER_SIDE ) )
{
MyLog( LOG_FATAL, "SERVER_SIDE Socket Bind Failed!!!" );
this->DestroyServer( FINISH_TYPE_BIND_FAILED );
}
MyLog( LOG_NORMAL, "SERVER_SIDE Socket Binded." );
#ifdef __IS_AGENT_SERVER
// USER SIDE Socket 官牢靛.
if( !this->StartServer( TYPE_USER_SIDE ) )
{
MyLog( LOG_NORMAL, "USER_SIDE Socket Bind Failed!!!" );
this->DestroyServer( FINISH_TYPE_BIND_FAILED );
}
MyLog( LOG_NORMAL, "USER_SIDE Socket Binded" );
#endif
#endif
// ---------------------------------------------------------------------------------------------
// 己傍. 立加且 辑滚狼 府胶飘甫 夸备茄促.
szDummyMsg[0] = (BYTE)PTCL_REQUEST_TO_CONNECT_SERVER_LIST;
if( !this->Send( pSender->dwConnectionIndex, szDummyMsg, 1 ) )
{
#ifdef __ON_DEBUG
// _asm int 3;
#endif
}
this->SetServerStatus( STATUS_AWAITING_CONNECTION_ORDER );
}
else
{
// 角菩.
#ifdef __ON_DEBUG
// _asm int 3;
#endif
// 捞 辑滚绰 辆丰等促.
MyLog( LOG_FATAL, "CServerTable::OnRecvMsgNegotiationMsgs() - Failed To accept Server List" );
this->DestroyServer( FINISH_TYPE_SERVER_LIST_ACCEPT_FAIL );
}
}
break;
// ---------------------
// 立加 疙飞 菩哦
// ---------------------
case PTCL_ORDER_CONNECT_TO_SERVERS:
{
LP_AWAITING_CONNECTION_RESULT_DATA pResult = this->GetConnectionResultData();
LP_SERVER_PORT_LIST_PACKET pToConnectList = (LP_SERVER_PORT_LIST_PACKET)pMsg;
LP_SERVER_PORT_LIST_PACKET pConnectedList = (LP_SERVER_PORT_LIST_PACKET)(pResult->szAnswer+1);
LP_SERVER_DATA pTargetServer;
// Added by chan78 at 2001/03/16 :: this->m_ConnectionResultData 啊 荤侩吝老订 公矫.
// 捞繁 惑炔篮 缴阿窍促. 惯积秦急 救凳.
if( this->GetConnectionResultData()->dwConnectionType != CONNECT_TYPE_NONE )
{
MyLog( LOG_FATAL, "PTCL_ORDER_SET_SERVER_LIST :: this->m_ConnectionResultData is Already Using!!!(%d)", this->GetConnectionResultData()->dwConnectionType );
#ifdef __ON_DEBUG
// _asm int 3;
#else
this->DestroyServer( FINISH_TYPE_UNKNOWN_ERROR );
#endif
}
pResult->dwConnectionType = CONNECT_TYPE_BY_PROXY_ORDER;
pResult->dwToConnectServers = 0;
pResult->dwResultCheckedServers = 0;
pResult->pSender = pSender;
pConnectedList->wNum = 0;
for( i = 0; i < pToConnectList->wNum; i++ )
{
pTargetServer = GetServerData( pToConnectList->wPort[i] );
if( pTargetServer && pTargetServer->dwConnectionIndex )
{
// 捞固 立加登绢 乐绰 版快.
pConnectedList->wPort[pConnectedList->wNum++] = pTargetServer->wPort;
}
else
{
if( pTargetServer && this->ConnectToServer( pTargetServer, CONNECT_TYPE_BY_PROXY_ORDER ) )
{
// 矫档绰 己傍...
// 搬苞 贸府绰 妮归窃荐俊辑.
pResult->dwToConnectServers++;
}
else
{
if( !pTargetServer )
{
MyLog( LOG_FATAL, "PTCL_ORDER_CONNECT_TO_SERVERS :: pTargetServer is NULL!!!(port:%d)", pTargetServer->wPort );
}
else
{
MyLog( LOG_FATAL, "INETWORK::ConnectToServer() returned NULL!!!(port:%d)", pTargetServer->wPort );
this->DestroyServer( FINISH_TYPE_UNKNOWN_ERROR );
}
}
}
}
// 立加 搬苞甫 扁促副 辑滚啊 绝绰 版快.
if( pResult->dwToConnectServers == 0 )
{
this->ReportOrderedConnectionResult();
}
}
break;
// ------------------
// DB Demon 硅沥 菩哦
// ------------------
case PTCL_ORDER_SET_DB_DEMON:
{
WORD wDBDemonPort = *(WORD*)pMsg;
LP_SET_DB_DEMON_RESULT_PACKET pPacket = (LP_SET_DB_DEMON_RESULT_PACKET)(szDummyMsg+1);
szDummyMsg[0] = PTCL_DB_DEMON_SETTING_RESULT;
LP_SERVER_DATA pDBDemon;
if( pDBDemon = GetServerData( wDBDemonPort ) )
{
if( pDBDemon->dwConnectionIndex )
{
// 技泼
this->m_pOwnDBDemonData = pDBDemon;
// 己傍 舅覆.
pPacket->dwResult = RESULT_DB_DEMON_SETTING_SUCCESSED;
this->SetServerStatus( STATUS_ACTIVATED );
}
else
{
pPacket->dwResult = RESULT_DB_DEMON_IS_NOT_CONNECTED;
// 犁夸没.
this->RequestToSetDBDemon();
}
}
else
{
pPacket->dwResult = RESULT_DB_DEMON_IS_NOT_IN_LIST;
}
szDummyMsg[0] = (BYTE)PTCL_DB_DEMON_SETTING_RESULT;
if( !this->Send( pSender->dwConnectionIndex, szDummyMsg, (sizeof(BYTE)+sizeof(SET_DB_DEMON_RESULT_PACKET))) )
{
#ifdef __ON_DEBUG
// _asm int 3;
#endif
this->SetServerStatus( STATUS_AWAITING_DB_DEMON_SETTING );
}
}
break;
// ---------------
// 辑滚府胶飘 焊绊
// ---------------
case PTCL_ORDER_TO_REPORT_SERVER_DATAS:
{
LP_SERVER_CINFO_LIST_PACKET pPacket = (LP_SERVER_CINFO_LIST_PACKET)(szDummyMsg+1);
LP_SERVER_CINFO pCInfo = NULL;
LP_SERVER_DATA pDummyServerData = NULL;
pPacket->dwServerSetNumber = this->m_dwServerSetNumber;
pPacket->wNum = 0;
for( pDummyServerData = this->GetServerListHead(); pDummyServerData; pDummyServerData = pDummyServerData->pNextServerData )
{
// Own Proxy绰 力寇.
if( pDummyServerData == pSender )
continue;
memcpy( pPacket->pServerData[pPacket->wNum].szIP, pDummyServerData->szIP, MM_IP_LENGTH );
pPacket->pServerData[pPacket->wNum].wPort = pDummyServerData->wPort;
pPacket->pServerData[pPacket->wNum].bConnected = (pDummyServerData->dwConnectionIndex?true:false);
pPacket->wNum++;
}
szDummyMsg[0] = (BYTE)PTCL_REPORT_SERVER_DATAS;
// Send it
if( !this->Send( pSender->dwConnectionIndex, szDummyMsg, sizeof(BYTE)+sizeof(WORD)+(sizeof(SERVER_CINFO)*pPacket->wNum) ) )
{
#ifdef __ON_DEBUG
// _asm int 3;
#endif
}
}
break;
// ------------------
// 牢刘犬牢 菩哦 贸府
// ------------------
case PTCL_NOTIFY_YOU_ARE_CERTIFIED:
{
// Proxy Is Activated
this->SetServerStatus( pSender, STATUS_ACTIVATED );
// 立加且 辑滚狼 格废阑 夸备茄促.
szDummyMsg[0] = (BYTE)PTCL_REQUEST_TO_CONNECT_SERVER_LIST;
if( !this->Send( pSender->dwConnectionIndex, szDummyMsg, (sizeof(BYTE))) )
{
#ifdef __ON_DEBUG
// _asm int 3;
#endif
}
}
break;
#endif
// ----------------------------------------------------------------------------
// PROXY 傈侩 Packet甸
// ----------------------------------------------------------------------------
#ifdef __IS_PROXY_SERVER
// -----------------------------------
// SERVER LIST 硅沥 菩哦 夸没阑 贸府窃
// -----------------------------------
case PTCL_REQUEST_SET_SERVER_LIST:
{
LP_SERVER_CINFO_LIST_PACKET pPacket = (LP_SERVER_CINFO_LIST_PACKET)(szDummyMsg + 1);
LP_SERVER_DATA pDummyServer;
pPacket->dwServerSetNumber = this->m_dwServerSetNumber;
pPacket->wNum = 0;
for( pDummyServer = this->GetServerListHead(); pDummyServer; pDummyServer = pDummyServer->pNextServerData )
{
// 傈价磊狼 沥焊绰 硅沥窍瘤 臼绰促.
if( pDummyServer->wPort == pSender->wPort )
continue;
memcpy( pPacket->pServerData[pPacket->wNum].szIP, pDummyServer->szIP, MM_IP_LENGTH );
pPacket->pServerData[pPacket->wNum].wPort = pDummyServer->wPort;
pPacket->wNum++;
this->SetServerConnectionStatus( pSender, pDummyServer, (BYTE)CONNECTION_STATUS_NOT_CONNECTED );
}
szDummyMsg[0] = (BYTE)PTCL_ORDER_SET_SERVER_LIST;
// Send it
if( !this->Send( pSender->dwConnectionIndex, szDummyMsg, sizeof(BYTE)+sizeof(WORD)+(sizeof(SERVER_CINFO_LIST_PACKET)*pPacket->wNum) ) )
{
#ifdef __ON_DEBUG
// _asm int 3;
#endif
return true;
}
// Change Sender Status
this->SetServerStatus( pSender, STATUS_AWAITING_SET_SERVER_LIST_RESULT );
}
break;
// ------------------------------------------
// 立加且 辑滚狼 格废 硅沥 菩哦 夸没阑 贸府窃
// ------------------------------------------
case PTCL_REQUEST_TO_CONNECT_SERVER_LIST:
{
LP_SERVER_PORT_LIST_PACKET pPacket = (LP_SERVER_PORT_LIST_PACKET)(szDummyMsg + 1);
LP_SERVER_DATA pDummyServer;
pPacket->wNum = 0;
for( pDummyServer = this->GetServerListHead(); pDummyServer; pDummyServer = pDummyServer->pNextServerData )
{
// 傈价磊狼 沥焊绰 硅沥窍瘤 臼绰促.
if( pDummyServer->wPort == pSender->wPort )
continue;
if( pDummyServer->dwConnectionIndex )
if( (pDummyServer->dwStatus > STATUS_AWAITING_SERVER_LIST) && (pDummyServer->dwStatus < STATUS_CLOSING ) )
{
pPacket->wPort[pPacket->wNum++] = pDummyServer->wPort;
this->SetServerConnectionStatus( pSender, pDummyServer, (BYTE)CONNECTION_STATUS_TRYING_TO_CONNECT );
}
}
MyLog( LOG_DEBUG, "%s(%d) 俊霸 %d俺狼 辑滚俊 立加窍档废 硅沥窃", GetTypedServerText(pSender->dwServerType), pSender->wPort, pPacket->wNum );
// 焊辰促
szDummyMsg[0] = (BYTE)PTCL_ORDER_CONNECT_TO_SERVERS;
if( !this->Send( pSender->dwConnectionIndex, szDummyMsg, sizeof(BYTE)+sizeof(WORD)+(sizeof(WORD)*pPacket->wNum) ) )
{
// 角菩.
#ifdef __ON_DEBUG
// _asm int 3;
#endif
MyLog( LOG_IGNORE, "Failed To Send PTCL_ORDER_CONNECT_SERVERS For %s(%d)", GetTypedServerText( pSender->dwServerType ), pSender->wPort );
return true;
}
// Change Sender Status
this->SetServerStatus( pSender, STATUS_AWAITING_CONNECTION_RESULT );
}
break;
// -----------------------------------
// 立加搬苞 菩哦阑 罐酒 贸府.
// -----------------------------------
case PTCL_SERVER_CONNECTING_RESULT:
{
LP_SERVER_PORT_LIST_PACKET pToConnectList = (LP_SERVER_PORT_LIST_PACKET)pMsg;
LP_SERVER_DATA pTargetServer;
for( DWORD i = 0; i< pToConnectList->wNum; i++ )
{
pTargetServer = this->GetServerData( pToConnectList->wPort[i] );
if( !pTargetServer )
{
#ifdef __ON_DEBUG
// _asm int 3;
#endif
continue;
}
this->SetServerConnectionStatus( pSender, pTargetServer, (BYTE)CONNECTION_STATUS_CONNECTED );
}
// Change Sender Status
if( pSender->dwServerType == SERVER_TYPE_AGENT || pSender->dwServerType == SERVER_TYPE_MAP )
{
this->SetServerStatus( pSender, STATUS_AWAITING_DB_DEMON_SETTING );
}
else
{
this->SetServerStatus( pSender, STATUS_ACTIVATED );
if( pSender->dwServerType == SERVER_TYPE_DB )
{
LP_SERVER_DATA pDummyServer;
for( pDummyServer = this->GetServerListHead(); pDummyServer; pDummyServer = pDummyServer->pNextServerData )
{
if( pDummyServer->dwConnectionIndex && (pDummyServer->dwStatus == STATUS_AWAITING_DB_DEMON_SETTING) )
{
if( this->SetDBDemon( pDummyServer, pSender ) == false )
{
MyLog( LOG_IMPORTANT, "Failed To Set DB Demon To %s Server(%d)", GetTypedServerText( pDummyServer->dwServerType ), pDummyServer->wPort );
}
else
{
this->SetServerStatus( pDummyServer, STATUS_AWAITING_SET_DB_DEMON_RESULT );
}
}
}
}
}
}
break;
// -----------------------------------
// DB DEMON 硅沥 菩哦 夸没阑 贸府窃
// -----------------------------------
case PTCL_REQUEST_SET_DB_DEMON:
{
if( this->SetDBDemon( pSender ) == false )
{
MyLog( LOG_IMPORTANT, "Failed To Set DB Demon To %s Server(%d)", GetTypedServerText( pSender->dwServerType ), pSender->wPort );
this->SetServerStatus( pSender, STATUS_AWAITING_DB_DEMON_SETTING );
}
else
{
this->SetServerStatus( pSender, STATUS_AWAITING_SET_DB_DEMON_RESULT );
}
}
break;
// -----------------------------------
// DB DEMON 硅沥 搬苞 菩哦阑 贸府窃
// -----------------------------------
case PTCL_DB_DEMON_SETTING_RESULT:
{
LP_SET_DB_DEMON_RESULT_PACKET pResultPacket = (LP_SET_DB_DEMON_RESULT_PACKET)pMsg;
switch( pResultPacket->dwResult )
{
case RESULT_DB_DEMON_SETTING_SUCCESSED:
{
this->SetServerStatus( pSender, STATUS_ACTIVATED );
return true;
}
break;
case RESULT_DB_DEMON_IS_NOT_ACTIVATED:
{
MyLog( LOG_IMPORTANT, "PTCL_DB_DEMON_SETTING_RESULT(RESULT_DB_DEMON_IS_NOT_ACTIVATED) from %s(%d)", GetTypedServerText(pSender->dwServerType), pSender->wPort );
}
break;
case RESULT_DB_DEMON_IS_NOT_CONNECTED:
{
MyLog( LOG_IMPORTANT, "PTCL_DB_DEMON_SETTING_RESULT(RESULT_DB_DEMON_IS_NOT_CONNECTED) from %s(%d)", GetTypedServerText(pSender->dwServerType), pSender->wPort );
}
break;
case RESULT_DB_DEMON_IS_NOT_IN_LIST:
{
MyLog( LOG_IMPORTANT, "PTCL_DB_DEMON_SETTING_RESULT(RESULT_DB_DEMON_IS_NOT_IN_LIST) from %s(%d)", GetTypedServerText(pSender->dwServerType), pSender->wPort );
}
break;
default:
{
MyLog( LOG_IMPORTANT, "PTCL_DB_DEMON_SETTING_RESULT:: from %s(%d) has Wrong dwResult(%d)!!!", GetTypedServerText(pSender->dwServerType), pSender->wPort, pResultPacket->dwResult );
}
break;
}
this->SetServerStatus( pSender, STATUS_AWAITING_DB_DEMON_SETTING );
return true;
}
break;
// -------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -