Files
Sun1602/Tools/SunUpdateManager/SunUpdateServer/Handler_SM.cpp
T
2022-10-26 12:25:11 +08:00

768 lines
24 KiB
C++

#include "StdAfx.h"
#include ".\handler_sm.h"
#include <PacketStruct_SM.h>
#include <PacketStruct_SA.h>
#include <PacketStruct_SMA.h>
#include <Constant.h>
#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
//////////////////////////////////////////////////////////////////////////////////////////////////////////////