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

312 lines
10 KiB
C++

#include "StdAfx.h"
#include ".\sunserverscript.h"
#include "InfoManager.h"
#include "SunServerInfo.h"
#include "WorldInfo.h"
#include "WorldInfoManager.h"
SunServerScript::SunServerScript(void)
{
}
SunServerScript::~SunServerScript(void)
{
}
BOOL SunServerScript::Create( CString& strFilePath, _BaseInfo* pBaseInfo, WORLD_LIST& WorldList )
{
if( !MakeScriptFile( strFilePath ) )
return FALSE;
CreateCommonInfo();
CreateClientInfo( pBaseInfo, WorldList );
CreateServerInfo( pBaseInfo, WorldList );
CreateConnectInfo( pBaseInfo, WorldList );
CreateNoWorldInfo( pBaseInfo );
CreateLogInfo();
return TRUE;
}
void SunServerScript::CreateCommonInfo()
{
CString strMsg, strTemp;
SunServerInfo* pInfo = (SunServerInfo*)ServerInfoManager::GetInstance()->GetServerInfo( GetServerType() );
if( !pInfo ) return;
_COMMON* pCommon = pInfo->GetCommonInfo();
if( !pCommon ) return;
strTemp = "[COMMON]\r\n";
strMsg += strTemp;
strTemp.Format( "GET_SERVERINFO_FROM_FILE = %d \r\n", pCommon->m_nCommonFile );
strMsg += strTemp;
strTemp.Format( "GMLIST_APPLY = %d \r\n", pCommon->m_nCommonGM );
strMsg += strTemp;
strTemp.Format( "FIELD_SERVER_TYPE = %d \r\n", pCommon->m_nCommonField );
strMsg += strTemp;
strTemp.Format( "BATTLE_SERVER_TYPE = %d \r\n", pCommon->m_nCommonBattle );
strMsg += strTemp;
strTemp.Format( "VILLAGE_RENDERINFO = %d \r\n", pCommon->m_nCommonVillage );
strMsg += strTemp;
strTemp.Format( "SERVICE_MODE = %d \r\n", pCommon->m_nCommonService );
strMsg += strTemp;
strTemp.Format( "AGE_GRADE = %d \r\n", pCommon->m_nCommonAgeGrade );
strMsg += strTemp;
strTemp.Format( "CRYPTOGRAPHY_ENABLED = %d \r\n", pCommon->m_nCommonCryptoGraphy );
strMsg += strTemp;
strTemp.Format( "CRYPTO_KEY_CHANGED = %d \r\n", pCommon->m_nCommonCryptoKeyChanged );
strMsg += strTemp;
strTemp.Format( "CRYPTO_KEY_CHANGE_INTERVAL = %d \r\n", pCommon->m_nCommonCryptoKeyChangeInterval );
strMsg += strTemp;
strTemp.Format( "SERVER_STATUS = %d \r\n", pCommon->m_nCommonServerStatus );
strMsg += strTemp;
strMsg += "\r\n";
WriteMessge( strMsg );
}
void SunServerScript::CreateLogInfo()
{
CString strMsg, strTemp;
SunServerInfo* pInfo = (SunServerInfo*)ServerInfoManager::GetInstance()->GetServerInfo( GetServerType() );
if( !pInfo ) return;
_LOGFILE* pLogFile = pInfo->GetLogfileInfo();
if( !pLogFile ) return;
strTemp = "[LOGFILE]\r\n";
strMsg += strTemp;
strTemp.Format( "WOPS_LOGFILE_PATH = %s \r\n", pLogFile->m_strWopsLogPath );
strMsg += strTemp;
strTemp.Format( "WOPS_LOGFILE_OPTION = %d \r\n", pLogFile->m_nWopsLogOption );
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 );
}
void SunServerScript::CreateServerInfo( _BaseInfo* pBaseInfo, WORLD_LIST& WorldList )
{
CString strMsg, strTemp;
SunServerInfo* pInfo = (SunServerInfo*)ServerInfoManager::GetInstance()->GetServerInfo( GetServerType() );
if( !pInfo ) return;
_IOHANDLER* pHandler = pInfo->GetServerInfo();
if( !pHandler ) return;
strTemp = "[SERVER_IOHANDLER]\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 SunServerScript::CreateClientInfo( _BaseInfo* pBaseInfo, WORLD_LIST& WorldList )
{
CString strMsg, strTemp;
SunServerInfo* pInfo = (SunServerInfo*)ServerInfoManager::GetInstance()->GetServerInfo( GetServerType() );
if( !pInfo ) return;
_IOHANDLER* pHandler = pInfo->GetClientInfo();
if( !pHandler ) return;
strTemp = "[CLIENT_IOHANDLER]\r\n";
strMsg += strTemp;
strTemp.Format( "IP = %s \r\n", pBaseInfo->m_szPublicIP );
strMsg += strTemp;
strTemp.Format( "PORT = %d \r\n", pBaseInfo->m_wPublicPort );
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 );
}
//여기서 WorldList는 pBaseInfo에 있는 월드의 모든 정보를 가지고 있다.
void SunServerScript::CreateConnectInfo( _BaseInfo* pBaseInfo, WORLD_LIST& WorldList )
{
CString strMsg, strTemp;
_BaseInfo* pInfo = NULL;
//3. GameDBProxy
pInfo = FindBaseInfo( WorldList, GAME_DBPROXY );
if( pInfo )
{
strTemp = "[GAMEDBPROXYSERVER]\r\n";
strMsg = strTemp;
strTemp.Format("GAMEDBPROXYSERVER_IP = %s \r\n", pInfo->m_szPrivateIP );
strMsg += strTemp;
strTemp.Format("GAMEDBPROXYSERVER_PORT = %d \r\n", pInfo->m_wPrivatePort );
strMsg += strTemp;
strMsg += "\r\n";
WriteMessge( strMsg );
}
//4. AGENT_SERVER
pInfo = FindBaseInfoEx( WorldList, AGENT_SERVER, pBaseInfo );
if( pInfo )
{
strTemp = "[AGENTSERVER]\r\n";
strMsg = strTemp;
strTemp.Format("AGENTSERVER_OUTSIDE_IP = %s \r\n", pInfo->m_szPublicIP );
strMsg += strTemp;
strTemp.Format("AGENTSERVER_OUTSIDE_PORT = %d \r\n", pInfo->m_wPublicPort );
strMsg += strTemp;
strTemp.Format("AGENTSERVER_INSIDE_IP = %s \r\n", pInfo->m_szPrivateIP );
strMsg += strTemp;
strTemp.Format("AGENTSERVER_INSIDE_PORT = %d \r\n", pInfo->m_wPrivatePort );
strMsg += strTemp;
strMsg += "\r\n";
WriteMessge( strMsg );
}
//6. GuildServer
pInfo = FindBaseInfo( WorldList, GUILD_SERVER );
if( pInfo )
{
strTemp = "[GUILDSERVER]\r\n";
strMsg = strTemp;
strTemp.Format("GUILDSERVER_IP = %s \r\n", pInfo->m_szPrivateIP );
strMsg += strTemp;
strTemp.Format("GUILDSERVER_PORT = %d \r\n", pInfo->m_wPrivatePort );
strMsg += strTemp;
strMsg += "\r\n";
WriteMessge( strMsg );
}
//7. WorldServer
pInfo = FindBaseInfo( WorldList, WORLD_SERVER );
if( pInfo )
{
strTemp = "[WORLDSERVER]\r\n";
strMsg = strTemp;
strTemp.Format("WORLDSERVER_IP = %s \r\n", pInfo->m_szPrivateIP );
strMsg += strTemp;
strTemp.Format("WORLDSERVER_PORT = %d \r\n", pInfo->m_wPrivatePort );
strMsg += strTemp;
strTemp.Format("WORLDSERVER_CLIENT_IP = %s \r\n", pInfo->m_szPublicIP );
strMsg += strTemp;
strTemp.Format("WORLDSERVER_CLIENT_PORT = %d \r\n", pInfo->m_wPublicPort );
strMsg += strTemp;
strMsg += "\r\n";
WriteMessge( strMsg );
}
}
//월드에 속하지 않은 전체에 포함되는 정보
void SunServerScript::CreateNoWorldInfo( _BaseInfo* pBaseInfo )
{
//1. SunServe.ini를 사용하는 각 서버별 공통된 자료
SunServerInfo* pServerInfo = (SunServerInfo*)ServerInfoManager::GetInstance()->GetServerInfo( GetServerType() );
if( !pServerInfo ) return;
//2. AUTH_AGENT_SERVER
WorldInfo* pWorldInfo = WorldInfoManager::GetInstance()->GetWorldInfo();
if( !pWorldInfo ) return;
WORLD_LIST WorldList;
pWorldInfo->GetBaseInfo( 0, WorldList ); //전체에 속하는 정보..
CString strTemp, strMsg;
//현재 월드, 채널, 서버타입에 따른 특화된 정보
//1. 인증 서버
_BaseInfo* pAuthInfo = FindBaseInfo( WorldList, AUTH_AGENT_SERVER );
_AUTH* pAuth = pServerInfo->GetAuthInfo();
if( pAuthInfo && pAuth )
{
strTemp = "[AUTHAGENTSERVER]\r\n";
strMsg = strTemp;
strTemp.Format("ENABLE_AUTH_AGENT_SERVER = %d \r\n", pAuth->m_bEnable );
strMsg += strTemp;
//인증서버 번호 : (현재 생성하려는 서버의 월드-1) * (월드당 채널수) + 현재 생성하려는 서버의 채널번호
WORD wAuthID = ( pBaseInfo->m_wWorld - 1) * pAuth->m_wChannel + pBaseInfo->m_wChannel;
strTemp.Format("AGENTSERVER_ID = %d \r\n", wAuthID );
strMsg += strTemp;
strTemp.Format("AUTHAGENTSERVER_IP = %s \r\n", pAuthInfo->m_szPrivateIP );
strMsg += strTemp;
strTemp.Format("AUTHAGENTSERVER_PORT = %d \r\n", pAuthInfo->m_wPrivatePort );
strMsg += strTemp;
strMsg += "\r\n";
WriteMessge( strMsg );
}
//2. 마스터 서버
_BaseInfo* pMasterInfo = FindBaseInfo( WorldList, MASTER_SERVER );
if( pMasterInfo )
{
strTemp = "[MASTERSERVER]\r\n";
strMsg = strTemp;
strTemp.Format("MASTERSERVER_IP = %s \r\n", pMasterInfo->m_szPrivateIP );
strMsg += strTemp;
strTemp.Format("MASTERSERVER_PORT = %d \r\n", pMasterInfo->m_wPrivatePort );
strMsg += strTemp;
strMsg += "\r\n";
WriteMessge( strMsg );
}
//2. AccountDBProxy
_BaseInfo* pAccountInfo = FindBaseInfo( WorldList, ACCOUNT_DBPROXY );
if( pAccountInfo )
{
strTemp = "[ACCOUNTDBPROXYSERVER]\r\n";
strMsg = strTemp;
strTemp.Format("ACCOUNTDBPROXYSERVER_IP = %s \r\n", pAccountInfo->m_szPrivateIP );
strMsg += strTemp;
strTemp.Format("ACCOUNTDBPROXYSERVER_PORT = %d \r\n", pAccountInfo->m_wPrivatePort );
strMsg += strTemp;
strMsg += "\r\n";
WriteMessge( strMsg );
}
}