⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 recvmsgfromserver.cpp

📁 Agent in c++ for DragonRaja
💻 CPP
📖 第 1 页 / 共 2 页
字号:
							}
						}
					}
					break;
				case CMD_ACCEPT_LOGIN:
					{	//< CSD-030322 
						pMsg[0] = BYTE(PTCL_PROXY_TO_ACCESS);

						if(LocalMgr.IsAbleNation(JAPAN))
						{
							t_packet packet;
							::memcpy(packet.h.data, pMsg+1+4,5);
							::memcpy(packet.u.data, pMsg+1+4+5, packet.h.header.size);
							
							DWORD pUniqID = *(DWORD*)(pMsg + 1);
							USERINFO *pUserInfo = g_pUserTable->GetUserInfo(pUniqID);

							if(!pUserInfo)
							{
								MyLog(LOG_IMPORTANT, "RecvMsgFromServer(CMD_ACCEPT_LOGIN) Can Not Take UserInfo (%d)", pUniqID);
								break;
							}

							::memcpy(pUserInfo->szName, packet.u.server_accept_login.id,20);
							MyLog(LOG_IMPORTANT, "RecvMsgFromServer(CMD_ACCEPT_LOGIN) User ID Copy: '%s'",pUserInfo->szName);
						}

						if (!g_pServerTable->SendToProxyServer(pMsg, dwLength))
						{
							MyLog(LOG_IMPORTANT, "Failed To send 'PTCL_PROXY_TO_ACCESS' to Proxy");
							break;
						}
						return;
					}//> CSD-030322

					case CMD_INVALID_ID		:
					case CMD_INVALID_PW		:
					case CMD_INVALID_DB		:
					case CMD_INVALID_PAY		:
					case CMD_INVALID_VERSION	:
					case CMD_INVALID_AGE		: // 030923 kyo
						{
							//010925 lsw
							//if( !g_pUserTable->SendToUserNoEncode( pUser, (pMsg+1+4), (dwLength-1-4) ) )
							if( !g_pUserTable->SendToUser( pUser, (pMsg+1+4), (dwLength-1-4) ) )
							{
								MyLog( LOG_FATAL, "WARNNING:: Failed To Redirect DB Demon's Packet to User(%d)", pUser->dwConnectionIndex );
							}
							return;
						}
						break;
				default:
					break;
				}

				if( redirect_to_client )
				{
					if( !g_pUserTable->SendToUser( pUser, (pMsg+1+4), (dwLength-1-4) ) )
					{
						MyLog( LOG_FATAL, "WARNNING:: Failed To Redirect DB Demon's Packet to User(%d)", pUser->dwConnectionIndex );
					} else {
						//MyLog( LOG_FATAL, "Got Message From DB Demon(id:%d UniqID:%d dwLength:%d)(type:%d)", bID, *dwUniqID, dwLength, p->h.header.type );
					}
				}
			}
			else	// pUser Is NULL
			{
				// Added by chan78 at 2001/02/09
				if( p->h.header.type == CMD_ACCEPT_LOGIN )
				{	
					// Request Remove From '[TotalDB].LoginTable' to DB DEMON
					szMsg[0] = (BYTE)PTCL_AGENT_TO_DB_REMOVE_USER_FROM_LOGIN_TABLE;

					memcpy(szMsg+1, &(*dwUniqID),4);
					memcpy(szMsg+1+4, p->u.server_accept_login.id, ID_LENGTH );
					memcpy(szMsg+1+4+ID_LENGTH, &g_pServerTable->GetOwnServerData()->wPort, 2 );
					if( !g_pServerTable->Send(dwConnectionIndex, szMsg, 1+4+ID_LENGTH+2) )
					{
						MyLog( LOG_FATAL, "--- Warnning!!! Failed to Send PTCL_USER_LIST_CONNECTION!!!" );
					}
				}
				else if( p->h.header.type == CMD_CLOSE_LOGIN_ID )
				{
					// CMD_CLOSE_LOGIN_ID甫 罐疽瘤父 蜡历啊 USERLIST俊 粮犁窍瘤 臼绰 版快.
					// 捞版快绰 肺弊且 鞘夸啊 乐促.
					szMsg[0] = (BYTE)PTCL_AGENT_TO_DB_REMOVE_USER_FROM_LOGIN_TABLE;

					memcpy(szMsg+1, &(*dwUniqID),4);
					memcpy(szMsg+1+4, p->u.login_close_login_id.id, ID_LENGTH );
					memcpy(szMsg+1+4+ID_LENGTH, &g_pServerTable->GetOwnServerData()->wPort, 2 );
					
					if( !g_pServerTable->Send(dwConnectionIndex, szMsg, 1+4+ID_LENGTH+2) )
					{
						MyLog( LOG_FATAL, "--- Warnning!!! Failed to Send PTCL_USER_LIST_CONNECTION!!!" );
					}
					MyLog( LOG_IMPORTANT, "CMD_CLOSE_LOGIN_ID received illegal pUser!!!" );
				}
//				else MyLog( LOG_FATAL, "DB Demon Sent Illegal dwUniqID(%d)", *dwUniqID );
			}		
		}			
		break;
	case PTCL_MAP_TO_AGENT_PACKED_MSG:
		{
			t_packet *packet;
			// bSend 绰 Agent啊 啊肺盲 贸府茄 饶 client俊霸 傈价 且巴牢啊 富巴牢啊甫 搬沥茄促. 扁夯蔼 曼.
			bool bSend = true;

			CPackedMsg*	pPackedMsg = (CPackedMsg*)pMsg;
			DWORD dwUserNum = pPackedMsg->GetUserNum();
			//USERINFO_CLIENT_RECV* pInfo = (USERINFO_CLIENT_RECV*)pMsg->GetMsg();

			// 罐篮 菩哦阑 努扼捞攫飘肺 焊郴霖促.
			packet = (t_packet*)(pPackedMsg->GetMsg());
			if( (sizeof(t_header) + packet->h.header.size) != pPackedMsg->GetMsgLength() )
			{
				MyLog( LOG_IGNORE, "MapServer(%d) Send Illegal PackedMsg, Ignore It!", dwConnectionIndex);
				return;
			}

			for (DWORD i=0; i<dwUserNum; i++)
			{
				DWORD dwUserID = pPackedMsg->GetUser(i);
				USERINFO *pUser = g_pUserTable->GetUserInfo(dwUserID);
				if( !pUser )
				{
					//MyLog( LOG_FATAL, "PTCL_PACKED_USER :: User %d Not Found from MAP(%d)", dwUserID, dwConnectionIndex );

					// Modified by chan78 at 2000/12/16 :: 奥 绝促 谗绢崔扼绊 夸没.
					szMsg[0] = (BYTE)PTCL_AGENT_TO_MAP_REQUEST_REMOVE_USER;
					memcpy(szMsg+1,&dwUserID,4);

					if( !g_pServerTable->Send( dwConnectionIndex, szMsg, 5 ) ) {
						MyLog( LOG_IMPORTANT, "-- Requst Remove that Player(dwUniqID:%d) to Map Server(dwConnectionIndex:%d)", dwUserID, dwConnectionIndex );
						LP_SERVER_DATA pServerData = g_pServerTable->GetServerData( dwConnectionIndex );
						if( pServerData == NULL )
						{
							MyLog( LOG_IMPORTANT, "-- PSList(%d) is NULL!" );
						}
						else
						{
							MyLog( LOG_IMPORTANT, "-- %s(%s:%d)", GetTypedServerText(pServerData->dwServerType), pServerData->szIP, pServerData->wPort );
						}
					}
					continue;
				}

				switch(packet->h.header.type)
				{
				//-----------------------------------------------------------------------------
				// Map Change狼 贸府 :: Agent绰 捞 Packet阑 hooking秦 Map Server狼 ID甫 官槽促.
				//-----------------------------------------------------------------------------
				case CMD_CHANGE_MAP:
					{
						char szAnswer[16+1];
						t_packet *pAnswer;
						pAnswer = (t_packet *)(szAnswer+1+4);

						LP_SERVER_DATA pServerData = g_pServerTable->GetConnectedServerData((WORD)packet->u.server_change_map.port);
						if( !pServerData || !pServerData->dwConnectionIndex ) {
							// 辑滚 ID(port)肺 dwConnectionIndex甫 备且 荐 绝栏搁 立加阑 谗绢滚赴促.
							// 舅覆 菩哦阑 焊郴妨搁 咯扁辑 焊郴具茄促.
							MyLog( LOG_FATAL, "User %s Failed to CHANGE MAP :: Server(port:%d) Is Not Connected", pUser->szName, packet->u.server_change_map.port );
							g_pINet->CompulsiveDisconnectUser( pUser->dwConnectionIndex );
						}

						// Change Map Server
						pUser->dwMapServerConnectionIndex = pServerData->dwConnectionIndex;
						//MyLog( LOG_FATAL, "User %d CHANGE map Server to %d(%d)", dwUserID, pServerData->wPort, pServerData->dwConnectionIndex );

						// Added by chan78 at 2001/02/22 :: Answer To Map
						szAnswer[0] = (BYTE)PTCL_AGENT_TO_MAP;
						memcpy( szAnswer+1, &dwUserID, sizeof(DWORD) );

						pAnswer->h.header.type = CMD_CHANGE_MAP_DETECTED;
						pAnswer->h.header.size = 0;

						if( !g_pServerTable->Send( dwConnectionIndex, szAnswer, 1+4+sizeof(t_header) ) )
						{
							//MyLog( LOG_IMPORTANT, "Fail to Send 'CMD_CHANGE_MAP_DETECTED' to MAP(%d)", dwConnectionIndex );
						}
					
						// FOR DEBUG by chan78 2001/02/21
						dwMapChangeCounter++;
						//MyLog( LOG_NORMAL, "CMD_CHANGE_MAP (%d) (uID:%d, MapdwID:%d port:%d )", dwMapChangeCounter, dwUserID, pServerData->dwConnectionIndex, packet->u.server_change_map.port );

						bSend = true;
					}
					break;

				default:
					// Do nothing.
					break;
				}
				// 傈价茄促.
				if( bSend ) {
					if (pUser)
					{
						//菩哦 虐 牢内爹 且 磊府 
						if( !g_pUserTable->SendToUser(pUser, pPackedMsg->GetMsg(), pPackedMsg->GetMsgLength() ) )
						{
							// 谗绰促.
						}
					} else {
						MyLog( LOG_FATAL, "PTCL_PACKED_USER :: User %d Not Found", i );
					}
				}
			}
		}
		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;
	// -----------------------------

	// Added by KBS 011012
	case PTCL_RM_FROM_PROXY:
		{
			RMProc(dwConnectionIndex, pMsg, dwLength);
		}
		break;
	//
	case PTCL_AGENT_TO_COMMIT:
		{	//< CSD-030322
			// When A User Connaction Accepted
			DWORD* pUniqID = (DWORD*)(pMsg + 1);
			pUser = g_pUserTable->GetUserInfo(*pUniqID);

			if (pUser == NULL)
			{
				break;
			}

			pUser->bAmILogon = true;
			//2001/01/29 zhh
			time_t Login;
			struct tm *now;
			time( &Login );
			now = localtime(&Login);
			int year = now->tm_year + 1900;
			int mon  = now->tm_mon+1;
			int day  = now->tm_mday;
			int hour = now->tm_hour;
			int min  = now->tm_min;
			int sec  = now->tm_sec;

			char logintime[15];
			memset(logintime,0,15);
			sprintf(logintime,"%4d%2d%2d%2d%2d%2d", year, mon, day, hour, min, sec );
			memcpy(pUser->logintime, logintime, 15);
			
			if (!g_pUserTable->SendToUser(pUser, (pMsg + 1 + 4), dwLength - 4 - 1))
			{
				MyLog( LOG_FATAL, "WARNNING:: Failed To Redirect DB Demon's Packet to User(%d)", pUser->dwConnectionIndex );
			}
						
			break;
		}	//> CSD-030322
	default:
		{
			MyLog( LOG_FATAL, "Unknown SERVER PACKET(%d, %d)!", bID, dwConnectionIndex );
//			_asm int 3;
			break;
		}
		break;
	}
	return;
}
// ==========================================================================================

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -