#include "StdAfx.h" #include ".\handler_sm.h" #include #include #include #include #include "UserSession.h" #include "UserManager.h" #include "ServerSession.h" #include "ServerSessionManager.h" #include "UserInfoParser.h" #include "UserInfo.h" #include "User.h" #include "WorldManager.h" #include "World.h" #include "Channel.h" #include "UnitServer.h" #include "UserSessionFactory.h" #include "ServerInfoParser.h" #include "AgentServerSession.h" #include "AgentInfoParser.h" #include "AccessInfoParser.h" #include "VersionChecker.h" #include "VersionInfo.h" #include "ServerStruct.h" #include "ServerScriptParser.h" #include "Encrypt.h" Handler_SM::Handler_SM(void) { } Handler_SM::~Handler_SM(void) { } // ½Å±Ô À¯Àú Ãß°¡ VOID Handler_SM::OnHandler_SM_USER_REGISTER_SYN( UserSession* pSession, MSG_BASE* pMsg, int nSize ) { MSG_SM_USER_REGISTER_SYN *pRecvMsg = (MSG_SM_USER_REGISTER_SYN*)pMsg; User *pUser = (User*)pSession; MSG_SM_USER_REGISTER_ACK AckMsg; // ADMIN üũ if( pUser->GetGrade() != USER_GRADE_ADMIN ) { AckMsg.m_byResult = RC_USER_DONT_HAVE_RIGHT; pUser->SendPacket( &AckMsg, sizeof(AckMsg) ); return; } // DB¿¡ ÀÖ´Â À¯ÀúÀÎÁö üũ UserInfo *pUserInfo = UserInfoParser::Instance()->GetUserInfo( pRecvMsg->m_szUserID ); if( pUserInfo ) { AckMsg.m_byResult = RC_USER_REGISTERED_USER; pUser->SendPacket( &AckMsg, sizeof(AckMsg) ); return; } BOOL bSuccess = UserInfoParser::Instance()->AddNewUser( pRecvMsg->m_szUserID, pRecvMsg->m_szPassWord, pRecvMsg->m_byGrade, pRecvMsg->m_szUserIP ); if( bSuccess ) { AckMsg.m_byResult = RC_USER_REGISTER_SUCCESS; pUser->SendPacket( &AckMsg, sizeof(AckMsg) ); } else { AckMsg.m_byResult = RC_USER_REGISTER_FAIL; pUser->SendPacket( &AckMsg, sizeof(AckMsg) ); } MSGOUT( "[½Å±ÔÀ¯ÀúÃß°¡] ID : %s , Grade : %d, IP : %s ", pRecvMsg->m_szUserID, pRecvMsg->m_byGrade, pRecvMsg->m_szUserIP ); } // ¼­¹ö ½ÇÇà VOID Handler_SM::OnHandler_SM_SERVER_EXECUTE_SYN( UserSession* pSession, MSG_BASE* pMsg, int nSize ) { MSG_SM_SERVER_EXECUTE_SYN *pRecvMsg = (MSG_SM_SERVER_EXECUTE_SYN*)pMsg; User *pUser = (User*)pSession; //1. Àü¿ùµå ½ÇÇà if( pRecvMsg->m_ServerInfo.m_byWorld == TOTAL_PATCH_VALUE ) { WorldManager::Instance()->ExecuteStart( pUser->GetUserKey() ); } //2. ÇѰ³ÀÇ ¿ùµå ½ÇÇà else if( pRecvMsg->m_ServerInfo.m_byChannel == TOTAL_PATCH_VALUE ) { World *pWorld = WorldManager::Instance()->FindWorld( pRecvMsg->m_ServerInfo.m_byWorld ); if( pWorld ) pWorld->ExecuteStart( pUser->GetUserKey() ); } //3. ÇѰ³ÀÇ Ã¤³Î ½ÇÇà else if( pRecvMsg->m_ServerInfo.m_byServerType == TOTAL_PATCH_VALUE ) { Channel *pChannel = WorldManager::Instance()->FindChannel( pRecvMsg->m_ServerInfo.m_byWorld, pRecvMsg->m_ServerInfo.m_byChannel ); if( pChannel ) pChannel->ExecuteStart( pUser->GetUserKey() ); } //4. ÇѰ³ÀÇ ¼­¹ö ½ÇÇà else { UnitServer *pUnitServer = WorldManager::Instance()->FindUnitServer( pRecvMsg->m_ServerInfo.m_byWorld, pRecvMsg->m_ServerInfo.m_byChannel, pRecvMsg->m_ServerInfo.m_dwServerKey ); if( pUnitServer ) pUnitServer->ExecuteStart( pUser->GetUserKey() ); } MSGOUT( "[¼­¹ö½ÇÇà½ÃÀÛ] ID : %s , World : %d, Channel : %d, ServerType : %d, ServerNum : %d ", pUser->GetID(), pRecvMsg->m_ServerInfo.m_byWorld, pRecvMsg->m_ServerInfo.m_byChannel, pRecvMsg->m_ServerInfo.m_byServerType, pRecvMsg->m_ServerInfo.m_byServerNum ); } //¼­¹ö Á¾·á VOID Handler_SM::OnHandler_SM_SERVER_SHUTDOWN_SYN( UserSession* pSession, MSG_BASE* pMsg, int nSize ) { MSG_SM_SERVER_SHUTDOWN_SYN *pRecvMsg = (MSG_SM_SERVER_SHUTDOWN_SYN*)pMsg; User *pUser = (User*)pSession; if( pRecvMsg->m_ServerInfo.m_byWorld == TOTAL_PATCH_VALUE ) { WorldManager::Instance()->ExecuteEnd( pUser->GetUserKey() ); } else if( pRecvMsg->m_ServerInfo.m_byChannel == TOTAL_PATCH_VALUE ) { World *pWorld = WorldManager::Instance()->FindWorld( pRecvMsg->m_ServerInfo.m_byWorld ); if( pWorld ) pWorld->ExecuteEnd( pUser->GetUserKey() ); } else if( pRecvMsg->m_ServerInfo.m_byServerType == TOTAL_PATCH_VALUE ) { Channel *pChannel = WorldManager::Instance()->FindChannel( pRecvMsg->m_ServerInfo.m_byWorld, pRecvMsg->m_ServerInfo.m_byChannel ); if( pChannel ) pChannel->ExecuteEnd( pUser->GetUserKey() ); } else { UnitServer *pUnitServer = WorldManager::Instance()->FindUnitServer( pRecvMsg->m_ServerInfo.m_byWorld, pRecvMsg->m_ServerInfo.m_byChannel, pRecvMsg->m_ServerInfo.m_dwServerKey ); if( pUnitServer ) pUnitServer->ExecuteEnd( pUser->GetUserKey() ); } } // ÆÐÄ¡½ÇÇà VOID Handler_SM::OnHandler_SM_PATCH_EXECUTE_SYN( UserSession* pSession, MSG_BASE* pMsg, int nSize ) { User *pUser = (User*)pSession; // ÆÐÄ¡ ·ÎÁ÷ // 1. ÆÐÄ¡½ÃŰ·Á´Â ÇöÀç ¿ùµå¿¡ ÄÑÀú ÀÖ´Â ¼­¹ö°¡ Àִ°¡? MSG_SM_PATCH_EXECUTE_SYN *pRecvMsg = (MSG_SM_PATCH_EXECUTE_SYN*)pMsg; // 2. SunServer¸¸ ÆÐÄ¡½ÃÄÑ¾ß ÇÑ´Ù. ==> À̰ÍÀº UnitServer¿¡¼­ üũÇÑ´Ù. World* pWorld = WorldManager::Instance()->FindWorld( pRecvMsg->m_ServerInfo.m_byWorld ); if( !pWorld ) { MSG_SM_PATCH_EXECUTE_ACK Ack; Ack.m_byResult = RC_SERVER_PATCH_EXECUTE_FAIL; Ack.m_ServerInfo = pRecvMsg->m_ServerInfo; pUser->SendPacket( &Ack, sizeof(Ack) ); } if( !pWorld->ExecutePatch( pUser->GetUserKey() ) ) { //¼º°øÀÌµç ½ÇÆÐµç.. UnitServe¿¡¼­ ÇØ´ç ÆÐŶÀ»º¸³»ÁØ´Ù. //´ÜÁö ½ÇÆÐÀÏ °æ¿ì, ´õ ÀÌ»ó ÁøÇàÇÏÁö ¾Ê°í ¹Ù·Î ¸®ÅÏÇÑ´Ù. } } // ¾ÆÁ÷ Áö¿øÇÏÁö ¾Ê±â·Î ÇÑ´Ù!! VOID Handler_SM::OnHandler_SM_SERVER_REGISTER_SYN( UserSession* pSession, MSG_BASE* pMsg, int nSize ) { MSG_SM_SERVER_REGISTER_SYN *pRecvMsg = (MSG_SM_SERVER_REGISTER_SYN*)pMsg; } VOID Handler_SM::OnHandler_SM_USER_LOGOUT_SYN( UserSession* pSession, MSG_BASE* pMsg, int nSize ) { MSG_SM_USER_LOGOUT_SYN* pRecvMsg = (MSG_SM_USER_LOGOUT_SYN*)pMsg; User* pUser = (User*)pSession; if( !pUser ) { //±×·±À¯Àú ¾ø´Ù°í... return; } if( UserManager::Instance()->RemoveUser( pUser->GetUserKey() ) ) { MSG_SM_USER_LOGOUT_ACK ack; ack.m_byResult = RC_USER_LOGOUT_SUCCESS; pUser->SendPacket( &ack, sizeof(ack) ); //·Î±×¾Æ¿ô ¼º°ø //¹Ù·Î »èÁ¦Çϸé... ¹®Á¦ »ý±âÁö ¾ÊÀ»±î? UserSessionFactory::Instance()->FreeUser( pUser ); } else { //·Î±×¾Æ¿ô ½ÇÆÐ } } //¾÷·ÎµåÇÑ ÆÄÀÏ¿¡ ´ëÇÑ ±â·Ï.. VOID Handler_SM::OnHandler_SM_PATCH_UPLOAD_NTF( UserSession* pSession, MSG_BASE* pMsg, int nSize ) { MSG_SM_PATCH_UPLOAD_NTF* pRecvMsg = (MSG_SM_PATCH_UPLOAD_NTF*)pMsg; User* pUser = (User*)pSession; if( !pUser ) return; MSGOUT( "[ÆÐÄ¡ÆÄÀϾ÷·Îµå] UserID = %s, UserIP = %s, Channel = %s, UploadServer = %s, PatchFileVer = %d.%d.%d", pUser->GetID(), pUser->GetIP(), pRecvMsg->m_szChannelName, pRecvMsg->m_szServerName, pRecvMsg->m_byVersion[0], pRecvMsg->m_byVersion[1], pRecvMsg->m_byVersion[2] ); } //·Î±×ÆÄÀϺ¸±â //·Î±×ÆÄÀϺ¸±â´Â Çѹø¿¡ ÇѼ­¹ö¸¸ ½ÇÇàÇÒ ¼ö ÀÖ´Ù. VOID Handler_SM::OnHandler_SM_CHECK_LOGFILE_SYN( UserSession* pSession, MSG_BASE* pMsg, int nSize ) { MSG_SM_CHECK_LOGFILE_SYN* pRecvMsg = (MSG_SM_CHECK_LOGFILE_SYN*)pMsg; User* pUser = (User*)pSession; if( !pUser ) return; if( pRecvMsg->m_ServerInfo.m_byServerType == UNKNOWN_SERVER || pRecvMsg->m_ServerInfo.m_byServerType >= MAX_SERVER ) { MSG_SM_CHECK_LOGFILE_ACK ack; ack.m_byResult = RC_CHECK_LOGFILE_FAIL; ack.m_wFileSize = 0; pUser->SendPacket( &ack, ack.GetSize() ); return; } MSG_SA_CHECK_LOGFILE_SYN msg; msg.m_ServerInfo = pRecvMsg->m_ServerInfo; msg.m_dwUserKey = pUser->GetUserKey(); msg.m_CntLogPage = pRecvMsg->m_CntLogPage; ServerInfo* pServerInfo = ServerInfoParser::Instance()->GetServerInfo( msg.m_ServerInfo.m_dwServerKey ); if( !pServerInfo ) { MSG_SM_CHECK_LOGFILE_ACK ack; ack.m_byResult = RC_CHECK_LOGFILE_FAIL_SERVERINFO_NOT_FOUND; ack.m_wFileSize = 0; pServerInfo->GetServerInfo( &ack.m_ServerInfo ); pUser->SendPacket( &ack, ack.GetSize() ); return; } AgentServerSession* pAgentSession = (AgentServerSession*)ServerSessionManager::Instance()->FindAgentSession( pServerInfo->GetAgentKey() ); if( !pAgentSession ) { MSG_SM_CHECK_LOGFILE_ACK ack; ack.m_byResult = RC_CHECK_LOGFILE_FAIL_UPDATEAGENT_DISCONNECT, ack.m_wFileSize = 0; pServerInfo->GetServerInfo( &ack.m_ServerInfo ); pUser->SendPacket( &ack, ack.GetSize() ); return; } pAgentSession->SendPacket( (BYTE*)&msg, sizeof(msg) ); } VOID Handler_SM::OnHandler_SM_SERVER_FORCE_DISCONNECT_SYN( UserSession* pSession, MSG_BASE* pMsg, int nSize ) { MSG_SM_SERVER_SHUTDOWN_SYN *pRecvMsg = (MSG_SM_SERVER_SHUTDOWN_SYN*)pMsg; User *pUser = (User*)pSession; if( pRecvMsg->m_ServerInfo.m_byWorld == TOTAL_PATCH_VALUE ) { WorldManager::Instance()->ExecuteForceDisconnect( pUser->GetUserKey() ); } else if( pRecvMsg->m_ServerInfo.m_byChannel == TOTAL_PATCH_VALUE ) { World *pWorld = WorldManager::Instance()->FindWorld( pRecvMsg->m_ServerInfo.m_byWorld ); if( pWorld ) pWorld->ExecuteForceDisconnect( pUser->GetUserKey() ); } else if( pRecvMsg->m_ServerInfo.m_byServerType == TOTAL_PATCH_VALUE ) { Channel *pChannel = WorldManager::Instance()->FindChannel( pRecvMsg->m_ServerInfo.m_byWorld, pRecvMsg->m_ServerInfo.m_byChannel ); if( pChannel ) pChannel->ExecuteForceDisconnect( pUser->GetUserKey() ); } else { UnitServer *pUnitServer = WorldManager::Instance()->FindUnitServer( pRecvMsg->m_ServerInfo.m_byWorld, pRecvMsg->m_ServerInfo.m_byChannel, pRecvMsg->m_ServerInfo.m_dwServerKey ); if( pUnitServer ) pUnitServer->ExecuteForceDisconnect( pUser->GetUserKey() ); } } //¹é¾÷Àº Çѹø¿¡ ÇϳªÀÇ ¼­¹ö¸¸ ÇÒ ¼ö ÀÖ´Ù. VOID Handler_SM::OnHandler_SM_SERVER_BACKUP_SYN( UserSession* pSession, MSG_BASE* pMsg, int nSize ) { MSG_SM_SERVER_BACKUP_SYN* pRecvMsg = (MSG_SM_SERVER_BACKUP_SYN*)pMsg; User* pUser = (User*)pSession; if( !pUser ) return; if( pRecvMsg->m_ServerInfo.m_byServerType == UNKNOWN_SERVER || pRecvMsg->m_ServerInfo.m_byServerType >= MAX_SERVER ) { MSG_SM_SERVER_BACKUP_ACK ack; ack.m_byResult = RC_SERVER_BACKUP_FAIL; pUser->SendPacket( &ack, sizeof(ack) ); return; } MSG_SA_SERVER_BACKUP_SYN msg; msg.m_ServerInfo = pRecvMsg->m_ServerInfo; msg.m_dwUserKey = pUser->GetUserKey(); ServerInfo* pServerInfo = ServerInfoParser::Instance()->GetServerInfo( msg.m_ServerInfo.m_dwServerKey ); if( !pServerInfo ) return; AgentServerSession* pAgentSession = (AgentServerSession*)ServerSessionManager::Instance()->FindAgentSession( pServerInfo->GetAgentKey() ); if( !pAgentSession ) { MSG_SM_SERVER_BACKUP_ACK ack; ack.m_byResult = RC_SERVER_BACKUP_FAIL_UPDATEAGENT_NOT_CONNECT; ack.m_dwUserKey = pUser->GetUserKey(); ack.m_ServerInfo = pRecvMsg->m_ServerInfo; pUser->SendPacket( &ack, sizeof(ack) ); return; } pAgentSession->SendPacket( (BYTE*)&msg, sizeof(msg) ); } VOID Handler_SM::OnHandler_SM_SERVER_RESTORE_SYN( UserSession* pSession, MSG_BASE* pMsg, int nSize ) { MSG_SM_SERVER_RESTORE_SYN* pRecvMsg = (MSG_SM_SERVER_RESTORE_SYN*)pMsg; User* pUser = (User*)pSession; if( !pUser ) return; if( pRecvMsg->m_ServerInfo.m_byServerType == UNKNOWN_SERVER || pRecvMsg->m_ServerInfo.m_byServerType >= MAX_SERVER ) { MSG_SM_SERVER_BACKUP_ACK ack; ack.m_byResult = RC_SERVER_RESTORE_FAIL; pUser->SendPacket( &ack, sizeof(ack) ); return; } MSG_SA_SERVER_RESTORE_SYN msg; msg.m_ServerInfo = pRecvMsg->m_ServerInfo; msg.m_dwUserKey = pUser->GetUserKey(); ServerInfo* pServerInfo = ServerInfoParser::Instance()->GetServerInfo( msg.m_ServerInfo.m_dwServerKey ); if( !pServerInfo ) return; AgentServerSession* pAgentSession = (AgentServerSession*)ServerSessionManager::Instance()->FindAgentSession( pServerInfo->GetAgentKey() ); if( !pAgentSession ) { MSG_SM_SERVER_BACKUP_ACK ack; ack.m_byResult = RC_SERVER_RESTORE_FAIL_UPDATEAGENT_NOT_CONNECT; ack.m_dwUserKey = pUser->GetUserKey(); ack.m_ServerInfo = pRecvMsg->m_ServerInfo; pUser->SendPacket( &ack, sizeof(ack) ); return; } pAgentSession->SendPacket( (BYTE*)&msg, sizeof(msg) ); } VOID Handler_SM::OnHandler_SM_AGENT_INFO_REQ_SYN( UserSession* pSession, MSG_BASE* pMsg, int nSize ) { MSG_SM_AGENT_INFO_REQ_SYN* pRecvMsg = (MSG_SM_AGENT_INFO_REQ_SYN*)pMsg; MSG_SM_AGENT_INFO_REQ_ACK Ack; AgentInfoParser::Instance()->SerializeStream( Ack.m_TotalInfo, FALSE ); pSession->SendPacket( &Ack, Ack.GetSize() ); } VOID Handler_SM::OnHandler_SM_AGENT_REGISTER_SYN( UserSession* pSession, MSG_BASE* pMsg, int nSize ) { MSG_SM_AGENT_REGISTER_SYN* pRecvMsg = (MSG_SM_AGENT_REGISTER_SYN*)pMsg; MSG_SM_AGENT_REGISTER_ACK Ack; Ack.m_dwKey = 0; strncpy( Ack.m_szIP, pRecvMsg->m_szIP, MAX_IP_SIZE ); if( !AgentInfoParser::Instance()->Add( pRecvMsg->m_szIP, Ack.m_dwKey ) ) Ack.m_byResult = 0; else Ack.m_byResult = 1; pSession->SendPacket( &Ack, sizeof(Ack) ); } VOID Handler_SM::OnHandler_SM_AGENT_DELETE_SYN( UserSession* pSession, MSG_BASE* pMsg, int nSize ) { MSG_SM_AGENT_DELETE_SYN* pRecvMsg = (MSG_SM_AGENT_DELETE_SYN*)pMsg; MSG_SM_AGENT_DELETE_ACK Ack; Ack.m_dwKey = pRecvMsg->m_dwKey; if( !AgentInfoParser::Instance()->Del( pRecvMsg->m_dwKey ) ) Ack.m_byResult = 0; else Ack.m_byResult = 1; pSession->SendPacket( &Ack, sizeof(Ack) ); } VOID Handler_SM::OnHandler_SM_AGENT_MODIFY_SYN( UserSession* pSession, MSG_BASE* pMsg, int nSize ) { MSG_SM_AGENT_MODIFY_SYN* pRecvMsg = (MSG_SM_AGENT_MODIFY_SYN*)pMsg; MSG_SM_AGENT_MODIFY_ACK Ack; Ack.m_dwKey = pRecvMsg->m_dwKey; strncpy( Ack.m_szIP, pRecvMsg->m_szIP, MAX_IP_SIZE ); if( !AgentInfoParser::Instance()->Modify( pRecvMsg->m_dwKey, pRecvMsg->m_szIP ) ) Ack.m_byResult = 0; else Ack.m_byResult = 1; pSession->SendPacket( &Ack, sizeof(Ack) ); } VOID Handler_SM::OnHandler_SM_USER_MODIFY_PASSWORD_SYN( UserSession* pSession, MSG_BASE* pMsg, int nSize ) { MSG_SM_USER_MODIFY_PASSWORD_SYN* pRecvMsg = (MSG_SM_USER_MODIFY_PASSWORD_SYN*)pMsg; BOOL bRet = UserInfoParser::Instance()->ModifyPassword( pSession->GetUserKey(), pRecvMsg->m_szPassWord ); MSG_SM_USER_MODIFY_PASSWORD_ACK Ack; Ack.m_byResult = bRet; pSession->SendPacket( &Ack, sizeof(Ack) ); } VOID Handler_SM::OnHandler_SM_USER_IDLIST_REQ_SYN( UserSession* pSession, MSG_BASE* pMsg, int nSize ) { MSG_SM_USER_IDLIST_REQ_SYN* pRecvMsg = (MSG_SM_USER_IDLIST_REQ_SYN*)pMsg; //1 À¯ÀúÀÇ ±ÇÇÑ °Ë»ç. UserInfo* pUserInfo = UserInfoParser::Instance()->GetUserInfo( pSession->GetUserKey() ); if( !pUserInfo ) return; // DB¿¡ ÀÖ´Â ¸ðµç À¯ÀúÀÇ ID¸¦ º¸³½´Ù. MSG_SM_USER_IDLIST_REQ_ACK Ack; if( pUserInfo->GetUserGrade() >= USER_GRADE_ADMIN ) { Ack.m_byResult = 1; UserInfoParser::Instance()->GetUserIDTotalInfo( Ack.TotalInfo ); } else Ack.m_byResult = 0; pSession->SendPacket( &Ack, Ack.GetSize() ); } VOID Handler_SM::OnHandler_SM_SERVER_ACCESS_RIGHT_REQ_SYN( UserSession* pSession, MSG_BASE* pMsg, int nSize ) { MSG_SM_SERVER_ACCESS_RIGHT_REQ_SYN* pRecvMsg = (MSG_SM_SERVER_ACCESS_RIGHT_REQ_SYN*)pMsg; //1 À¯ÀúÀÇ ±ÇÇÑ °Ë»ç. UserInfo* pUserInfo = UserInfoParser::Instance()->GetUserInfo( pSession->GetUserKey() ); if( !pUserInfo ) return; // DB¿¡ ÀÖ´Â ¸ðµç À¯ÀúÀÇ ID¸¦ º¸³½´Ù. MSG_SM_SERVER_ACCESS_RIGHT_REQ_ACK Ack; strncpy( Ack.m_szUserID, pRecvMsg->m_szUserID, MAX_USERID_SIZE ); if( pUserInfo->GetUserGrade() >= USER_GRADE_ADMIN ) { // ãÀ»·Á´Â À¯ÀúÀÇ Á¤º¸¸¦ °¡Á®¿Â´Ù. UserInfo* pFindInfo = UserInfoParser::Instance()->GetUserInfo( pRecvMsg->m_szUserID ); if( !pFindInfo ) Ack.m_byResult = RC_SERVER_RIGHT_REQ_FAIL_USER_NOT_FOUND; else { if( AccessInfoParser::Instance()->SerializeStreamForUser( pFindInfo->GetUserGUID(), Ack.m_AccessTotalInfo, FALSE ) ) Ack.m_byResult = RC_SERVER_RIGHT_REQ_SUCCESS; else Ack.m_byResult = RC_SERVER_RIGHT_REQ_FAIL_USER_NOT_FOUND; } } else Ack.m_byResult = 0; pSession->SendPacket( &Ack, Ack.GetSize() ); } VOID Handler_SM::OnHandler_SM_SERVER_ACCESS_RIGHT_SAVE_SYN( UserSession* pSession, MSG_BASE* pMsg, int nSize ) { MSG_SM_SERVER_ACCESS_RIGHT_SAVE_SYN* pRecvMsg = (MSG_SM_SERVER_ACCESS_RIGHT_SAVE_SYN*)pMsg; //1 À¯ÀúÀÇ ±ÇÇÑ °Ë»ç. UserInfo* pUserInfo = UserInfoParser::Instance()->GetUserInfo( pSession->GetUserKey() ); if( !pUserInfo ) return; MSG_SM_SERVER_ACCESS_RIGHT_SAVE_ACK Ack; strncpy( Ack.m_szUserID, pRecvMsg->m_szUserID, MAX_USERID_SIZE ); if( pUserInfo->GetUserGrade() >= USER_GRADE_ADMIN ) { UserInfo* pFindUser = UserInfoParser::Instance()->GetUserInfo( pRecvMsg->m_szUserID ); if( !pFindUser ) return; if( AccessInfoParser::Instance()->SerializeStreamForUser( pFindUser->GetUserGUID(), pRecvMsg->m_AccessTotalInfo, TRUE ) ) Ack.m_byResult = RC_SERVER_RIGHT_SAVE_SUCCESS; else Ack.m_byResult = RC_SERVER_RIGHT_SAVE_FAIL; } else { Ack.m_byResult = RC_SERVER_RIGHT_SAVE_FAIL; } pSession->SendPacket( &Ack, sizeof(Ack) ); } VOID Handler_SM::OnHandler_SM_SERVER_ACCESS_RIGHT_INIT_SYN( UserSession* pSession, MSG_BASE* pMsg, int nSize ) { MSG_SM_SERVER_ACCESS_RIGHT_INIT_SYN* pRecvMsg = (MSG_SM_SERVER_ACCESS_RIGHT_INIT_SYN*)pMsg; //1 À¯ÀúÀÇ ±ÇÇÑ °Ë»ç. UserInfo* pUserInfo = UserInfoParser::Instance()->GetUserInfo( pSession->GetUserKey() ); if( !pUserInfo ) return; AccessInfoParser::Instance()->SyncAllUserRight(); } // °øÁö»çÇ× // 2012.2.22 ±èÁøÈÖ VOID Handler_SM::OnHandler_SM_SERVER_NOTICE_SYN( UserSession* pSession, MSG_BASE* pMsg, int nSize ) { MSG_SM_SERVER_NOTICE_SYN* pRecvMsg = (MSG_SM_SERVER_NOTICE_SYN*)pMsg; User *pUser = (User*)pSession; if( !pUser ) return; //UnitServer find UnitServer *pUnitServer = WorldManager::Instance()->FindUnitServer( pRecvMsg->m_ServerInfo.m_byWorld, pRecvMsg->m_ServerInfo.m_byChannel, pRecvMsg->m_ServerInfo.m_dwServerKey ); if( !pUnitServer ) return; ServerInfo ServerInfo_ = pUnitServer->GetServerInfo(); //AgetnKey find DWORD dwAgentKey = ServerInfo_.GetAgentKey(); // Agent Server¿Í ¿¬°á ¿©ºÎ È®ÀÎ ServerSession *pAgentSession = ServerSessionManager::Instance()->FindAgentSession( dwAgentKey ); if( !pAgentSession ) { // ÇØ´ç Agent Server¿Í ¿¬°áÀÌ ¾ÈµÇ¾úÀ» °æ¿ì.. MSG_SM_SERVER_NOTICE_ACK AckMsg; AckMsg.m_bConnectAgentServer = FALSE; AckMsg.m_ServerInfo = pRecvMsg->m_ServerInfo; strcpy(AckMsg.m_szNotice,"UpdateAgent ¼­¹ö¿ÍÀÇ ¿¬°áÀÌ ¾ÈµÇ¾îÀÖ½À´Ï´Ù."); pUser->SendPacket( &AckMsg, sizeof(AckMsg) ); } else { MSG_SA_SERVER_NOTICE_SYN msg; msg.m_dwUserKey = pUser->GetUserKey(); ServerInfo_.GetServerInfo( &msg.m_ServerInfo ); pAgentSession->SendPacket( (BYTE*)&msg, sizeof(msg) ); } } VOID Handler_SM::OnHandler_SM_SERVER_SEND_NOTICE_SYN( UserSession* pSession, MSG_BASE* pMsg, int nSize ) { MSG_SM_SERVER_SEND_NOTICE_SYN* pRecvMsg = (MSG_SM_SERVER_SEND_NOTICE_SYN*)pMsg; User *pUser = (User*)pSession; if( !pUser ) return; //UnitServer find UnitServer *pUnitServer = WorldManager::Instance()->FindUnitServer( pRecvMsg->m_ServerInfo.m_byWorld, pRecvMsg->m_ServerInfo.m_byChannel, pRecvMsg->m_ServerInfo.m_dwServerKey ); if( !pUnitServer ) return; ServerInfo ServerInfo_ = pUnitServer->GetServerInfo(); //AgetnKey find DWORD dwAgentKey = ServerInfo_.GetAgentKey(); // Agent Server¿Í ¿¬°á ¿©ºÎ È®ÀÎ ServerSession *pAgentSession = ServerSessionManager::Instance()->FindAgentSession( dwAgentKey ); if( !pAgentSession ) { // ÇØ´ç Agent Server¿Í ¿¬°áÀÌ ¾ÈµÇ¾úÀ» °æ¿ì.. MSG_SM_SERVER_SEND_NOTICE_ACK AckMsg; AckMsg.m_ServerInfo = pRecvMsg->m_ServerInfo; AckMsg.m_bFlag = FALSE; pUser->SendPacket( &AckMsg, sizeof(AckMsg) ); } else { MSG_SA_SERVER_SEND_NOTICE_SYN msg; msg.m_dwUserKey = pUser->GetUserKey(); ServerInfo_.GetServerInfo( &msg.m_ServerInfo); strcpy( msg.m_szNotice, pRecvMsg->m_szNotice ); pAgentSession->SendPacket( (BYTE*)&msg, sizeof(msg) ); } } ////////////////////////////////////////////////////////////////////////////////////////////////////////////// //.// ¼­¹ö Á¤º¸ È®ÀÎ --> ÇØ´ç ÆÐÄ¡ Agent ¿¬°á È®ÀÎ --> ¸í·É Àü¼Û #ifdef __20080312__SOLARAUTH_SERVER_PATCH VOID Handler_SM::OnHandler_SM_SERVER_SOLARSCRIPT_BACKUP_SYN( UserSession* pSession, MSG_BASE* pMsg, int nSize ) { MSG_SM_SERVER_SOLARSCRIPT_BACKUP_SYN* pRecvMsg = (MSG_SM_SERVER_SOLARSCRIPT_BACKUP_SYN*)pMsg; User* pUser = (User*)pSession; if( !pUser ) return; ServerInfo* pServer = ServerInfoParser::Instance()->GetServerInfo( pRecvMsg->m_FolderInfo.m_ParentKey ); SERVER_INFO_EX server = pServer->GetServerInfoEx(); if( server.m_byServerType == UNKNOWN_SERVER || server.m_byServerType >= MAX_SERVER ) { MSG_SM_SERVER_SOLARSCRIPT_BACKUP_ACK ack; ack.m_byResult = RC_SERVER_BACKUP_FAIL; ack.m_FolderInfo = pRecvMsg->m_FolderInfo; pUser->SendPacket( &ack, sizeof(ack) ); return; } AgentServerSession* pAgentSession = (AgentServerSession*)ServerSessionManager::Instance()->FindAgentSession( pServer->GetAgentKey() ); if( !pAgentSession ) { MSG_SM_SERVER_SOLARSCRIPT_BACKUP_ACK ack; ack.m_byResult = RC_SERVER_BACKUP_FAIL_UPDATEAGENT_NOT_CONNECT; ack.m_FolderInfo = pRecvMsg->m_FolderInfo; pUser->SendPacket( &ack, sizeof(ack) ); return; } MSG_SA_SOLARSCRIPT_BACKUP_SYN msg; msg.m_ServerInfo = server; msg.m_ScriptFolder = pRecvMsg->m_FolderInfo; msg.m_dwUserKey = pUser->GetUserKey(); pAgentSession->SendPacket( (BYTE*)&msg, sizeof(msg) ); } VOID Handler_SM::OnHandler_SM_SERVER_SOLARSCRIPT_RESTORE_SYN( UserSession* pSession, MSG_BASE* pMsg, int nSize ) { MSG_SM_SERVER_SOLARSCRIPT_RESTORE_SYN* pRecvMsg = ( MSG_SM_SERVER_SOLARSCRIPT_RESTORE_SYN*)pMsg; User* pUser = (User*)pSession; if( !pUser ) return; ServerInfo* pServer = ServerInfoParser::Instance()->GetServerInfo( pRecvMsg->m_FolderInfo.m_ParentKey); SERVER_INFO_EX server = pServer->GetServerInfoEx(); if( server.m_byServerType == UNKNOWN_SERVER || server.m_byServerType >= MAX_SERVER ) { MSG_SM_SERVER_SOLARSCRIPT_RESTORE_ACK ack; ack.m_byResult = RC_SERVER_RESTORE_FAIL; ack.m_FolderInfo = pRecvMsg->m_FolderInfo; pUser->SendPacket( &ack, sizeof( ack)); return; } AgentServerSession* pAgentSession = ( AgentServerSession*)ServerSessionManager::Instance()->FindAgentSession( pServer->GetAgentKey()); if( !pAgentSession ) { MSG_SM_SERVER_SOLARSCRIPT_RESTORE_ACK ack; ack.m_byResult = RC_SERVER_RESTORE_FAIL_UPDATEAGENT_NOT_CONNECT; ack.m_FolderInfo = pRecvMsg->m_FolderInfo; pUser->SendPacket( &ack, sizeof(ack)); return; } MSG_SA_SOLARSCRIPT_RESTORE_SYN msg; msg.m_ServerInfo = server; msg.m_ScriptFolder = pRecvMsg->m_FolderInfo; msg.m_dwUserKey = pUser->GetUserKey(); pAgentSession->SendPacket( (BYTE*)&msg, sizeof(msg) ); } VOID Handler_SM::OnHandler_SM_PATCH_SOLARSCRIPT_EXECUTE_SYN( UserSession* pSession, MSG_BASE* pMsg, int nSize ) { MSG_SM_PATCH_SOLARSCRIPT_EXECUTE_SYN* pRecvMsg = (MSG_SM_PATCH_SOLARSCRIPT_EXECUTE_SYN*)pMsg; User* pUser = (User*)pSession; if( !pUser ) return; ServerInfo* pServer = ServerInfoParser::Instance()->GetServerInfo( pRecvMsg->m_FolderInfo.m_ParentKey); SERVER_INFO_EX server = pServer->GetServerInfoEx(); if( server.m_byServerType == UNKNOWN_SERVER || server.m_byServerType >= MAX_SERVER ) { MSG_SM_PATCH_SOLARSCRIPT_EXECUTE_ACK ack; ack.m_byResult = RC_SERVER_RESTORE_FAIL; ack.m_FolderInfo = pRecvMsg->m_FolderInfo; pUser->SendPacket( &ack, sizeof( ack)); return; } AgentServerSession* pAgentSession = ( AgentServerSession*)ServerSessionManager::Instance()->FindAgentSession( pServer->GetAgentKey()); if( !pAgentSession ) { MSG_SM_PATCH_SOLARSCRIPT_EXECUTE_ACK ack; ack.m_byResult = RC_SERVER_RESTORE_FAIL_UPDATEAGENT_NOT_CONNECT; ack.m_FolderInfo = pRecvMsg->m_FolderInfo; pUser->SendPacket( &ack, sizeof(ack)); return; } MSG_SA_SOLARSCRIPT_EXECUTE_SYN msg; msg.m_ServerInfo = server; msg.m_ScriptFolder = pRecvMsg->m_FolderInfo; msg.m_dwUserKey = pUser->GetUserKey(); pAgentSession->SendPacket( (BYTE*)&msg, sizeof(msg) ); } VOID Handler_SM::OnHandler_SM_SERVER_SOLARSCRIPT_CONVERT_SYN( UserSession* pSession, MSG_BASE* pMsg, int nSize ) { MSG_SM_SERVER_SOLARSCRIPT_CONVERT_SYN *pRecvMsg = (MSG_SM_SERVER_SOLARSCRIPT_CONVERT_SYN *)pMsg; User* pUser = (User*)pSession; if( !pUser ) return; TCHAR strFullPath[MAX_PATH] = {0,}; SERVER_ENV* serInfo = ServerScriptParser::Instance()->GetServerEnv(); std::string strVerPath( serInfo->SCDataInfo.szDefaultPath); _stprintf( strFullPath, _T("%s\\%s\\wz_version.dat"), strVerPath.c_str(), pRecvMsg->m_FolderInfo.m_szName ); VersionEx::VersionChecker check; VersionEx::VersionInfoEx ver; check.Init( strFullPath); check.Load(); ver = check.GetLastVer(); ZeroMemory( strFullPath, MAX_PATH); _stprintf( strFullPath, _T("%s\\%s\\%s"), strVerPath.c_str(), pRecvMsg->m_FolderInfo.m_szName, ver.GetStringVersion() ); MSG_SM_SERVER_SOLARSCRIPT_CONVERT_ACK ack; Encryption crypt(&ack.m_ConvertResult, strFullPath); crypt.TestUnit_FileList_EnDecode(); ack.m_byResult = RC_SERVER_SCFOLDER_CONVERT_SUCCESS; ack.m_FolderInfo = pRecvMsg->m_FolderInfo; pUser->SendPacket( &ack, ack.GetSize()); return; } #endif //////////////////////////////////////////////////////////////////////////////////////////////////////////////