Files
Sun1602/Tools/SUNAutoScriptMaker/MasterServerScript.cpp
T
2022-10-26 12:25:11 +08:00

131 lines
3.7 KiB
C++

#include "StdAfx.h"
#include ".\masterserverscript.h"
#include "MasterServerInfo.h"
#include "InfoManager.h"
#include "WorldInfoManager.h"
#include "WorldInfo.h"
MasterServerScript::MasterServerScript(void)
{
}
MasterServerScript::~MasterServerScript(void)
{
}
BOOL MasterServerScript::Create( CString& strFilePath, _BaseInfo* pBaseInfo, WORLD_LIST& WorldList )
{
if( !MakeScriptFile( strFilePath ) )
return FALSE;
CreateServerInfo( pBaseInfo );
CreateNoWorldInfo();
CreateLogInfo();
return TRUE;
}
void MasterServerScript::CreateServerInfo( _BaseInfo* pBaseInfo )
{
CString strMsg, strTemp;
MasterServerInfo* pInfo = (MasterServerInfo*)ServerInfoManager::GetInstance()->GetServerInfo( GetServerType() );
if( !pInfo ) return;
_IOHANDLER* pHandler = pInfo->GetServerInfo();
if( !pHandler ) return;
strTemp = "[MASTERSERVER]\r\n";
strMsg += strTemp;
strTemp.Format( "IP = %s \r\n", pBaseInfo->m_szPrivateIP );
strMsg += strTemp;
strTemp.Format( "PORT = %d \r\n", pBaseInfo->m_wPrivatePort );
strMsg += strTemp;
strTemp.Format( "MAX_ACCEPT_SESSION = %d \r\n", pHandler->m_nAccept );
strMsg += strTemp;
strTemp.Format( "MAX_CONNECT_SESSION = %d \r\n", pHandler->m_nConnect );
strMsg += strTemp;
strTemp.Format( "SEND_BUFFER_SIZE = %d \r\n", pHandler->m_nSendBuf );
strMsg += strTemp;
strTemp.Format( "RECV_BUFFER_SIZE = %d \r\n", pHandler->m_nRecvBuf );
strMsg += strTemp;
strTemp.Format( "TIME_OUT = %d \r\n", pHandler->m_nTimeOut );
strMsg += strTemp;
strTemp.Format( "MAX_PACKET_SIZE = %d \r\n", pHandler->m_nPacketSize );
strMsg += strTemp;
strTemp.Format( "NUMBER_OF_ACCEPT_THREADs = %d \r\n", pHandler->m_nAcceptThread );
strMsg += strTemp;
strTemp.Format( "NUMBER_OF_CONNECT_THREADS = %d \r\n", pHandler->m_nConnectThread );
strMsg += strTemp;
strTemp.Format( "NUMBER_OF_IO_THREADS = %d \r\n", pHandler->m_nIoThread );
strMsg += strTemp;
strMsg += "\r\n";
WriteMessge( strMsg );
}
//월드에 속하지 않은 전체에 포함되는 정보
void MasterServerScript::CreateNoWorldInfo()
{
// 0번 월드에 속한 모든 서버의 정보를 가져온다.
WORLD_LIST TotalList;
WorldInfo* pWorldInfo = WorldInfoManager::GetInstance()->GetWorldInfo();
if( !pWorldInfo ) return;
pWorldInfo->GetBaseInfo( 0, TotalList );
//현재 월드, 채널, 서버타입에 따른 특화된 정보
//1. ACCOUNT DBP
_BaseInfo* pADBProxyInfo = FindBaseInfo( TotalList, ACCOUNT_DBPROXY );
if( pADBProxyInfo )
{
CString strTemp, strMsg;
strTemp = "[ACCOUNTDBPROXY]\r\n";
strMsg = strTemp;
strTemp.Format("IP = %s \r\n", pADBProxyInfo->m_szPrivateIP );
strMsg += strTemp;
strTemp.Format("PORT = %d \r\n", pADBProxyInfo->m_wPrivatePort );
strMsg += strTemp;
strMsg += "\r\n";
WriteMessge( strMsg );
}
//2. OP SERVER
_BaseInfo* pOPServerInfo = FindBaseInfo( TotalList, OP_SERVER );
if( pOPServerInfo )
{
CString strTemp, strMsg;
strTemp = "[OPSERVER]\r\n";
strMsg = strTemp;
strTemp.Format("IP = %s \r\n", pOPServerInfo->m_szPrivateIP );
strMsg += strTemp;
strTemp.Format("PORT = %d \r\n", pOPServerInfo->m_wPrivatePort );
strMsg += strTemp;
strMsg += "\r\n";
WriteMessge( strMsg );
}
}
void MasterServerScript::CreateLogInfo()
{
CString strMsg, strTemp;
MasterServerInfo* pInfo = (MasterServerInfo*)ServerInfoManager::GetInstance()->GetServerInfo( GetServerType() );
if( !pInfo ) return;
_LOGFILE* pLogFile = pInfo->GetLogfileInfo();
if( !pLogFile ) return;
strTemp = "[LOGFILE]\r\n";
strMsg = strTemp;
strTemp.Format( "SUN_LOGFILE_OPTION = %d \r\n", pLogFile->m_nSunLogOption );
strMsg += strTemp;
strTemp.Format( "SUN_LOGFILE_LEVEL = %d \r\n", pLogFile->m_nSunLogLevel );
strMsg += strTemp;
strTemp.Format( "SUN_LOGFILE_PATH = %s \r\n", pLogFile->m_strSunLogPath );
strMsg += strTemp;
strMsg += "\r\n";
WriteMessge( strMsg );
}