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

157 lines
4.5 KiB
C++

#include "StdAfx.h"
#include ".\guildserverscript.h"
#include "InfoManager.h"
#include "GuildServerInfo.h"
#include "WorldInfo.h"
#include "WorldInfoManager.h"
GuildServerScript::GuildServerScript(void)
{
}
GuildServerScript::~GuildServerScript(void)
{
}
BOOL GuildServerScript::Create( CString& strFilePath, _BaseInfo* pBaseInfo, WORLD_LIST& WorldList )
{
if( !MakeScriptFile( strFilePath ) )
return FALSE;
CreateCommonInfo( pBaseInfo );
CreateServerInfo( pBaseInfo, WorldList );
CreateConnectInfo( WorldList );
CreateNoWorldInfo();
return TRUE;
}
void GuildServerScript::CreateCommonInfo( _BaseInfo* pBaseInfo )
{
CString strMsg, strTemp;
GuildServerInfo* pInfo = (GuildServerInfo*)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;
strMsg += "\r\n";
WriteMessge( strMsg );
}
void GuildServerScript::CreateServerInfo( _BaseInfo* pBaseInfo, WORLD_LIST& WorldList )
{
CString strMsg, strTemp;
GuildServerInfo* pInfo = (GuildServerInfo*)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";
//Connection 수
strTemp.Format( "CONEECTION_NUM = %d \r\n", pInfo->GetConnectionCount() );
strMsg += strTemp;
strMsg += "\r\n";
WriteMessge( strMsg );
}
//여기서 WorldList는 pBaseInfo에 있는 월드의 모든 정보를 가지고 있다.
void GuildServerScript::CreateConnectInfo( WORLD_LIST& WorldList )
{
_BaseInfo* pDBProxyInfo = FindBaseInfo( WorldList, GAME_DBPROXY );
if( pDBProxyInfo )
{
CString strMsg, strTemp;
strTemp = "[CONNECTION_0]\r\n";
strMsg += strTemp;
strTemp.Format( "IP = %s \r\n", pDBProxyInfo->m_szPrivateIP );
strMsg += strTemp;
strTemp.Format( "PORT = %d \r\n", pDBProxyInfo->m_wPrivatePort );
strMsg += strTemp;
strTemp.Format( "TYPE = %d \r\n", GAME_DBPROXY );
strMsg += strTemp;
strMsg += "\r\n";
WriteMessge( strMsg );
}
_BaseInfo* pWorldInfo = FindBaseInfo( WorldList, WORLD_SERVER );
if( pWorldInfo )
{
CString strMsg, strTemp;
strTemp = "[CONNECTION_2]\r\n";
strMsg += strTemp;
strTemp.Format( "IP = %s \r\n", pWorldInfo->m_szPrivateIP );
strMsg += strTemp;
strTemp.Format( "PORT = %d \r\n", pWorldInfo->m_wPrivatePort );
strMsg += strTemp;
strTemp.Format( "TYPE = %d \r\n", WORLD_SERVER );
strMsg += strTemp;
strMsg += "\r\n";
WriteMessge( strMsg );
}
}
//월드에 속하지 않은 전체에 포함되는 정보
void GuildServerScript::CreateNoWorldInfo()
{
// 0번 월드에 속한 모든 서버의 정보를 가져온다.
WORLD_LIST TotalList;
WorldInfo* pWorldInfo = WorldInfoManager::GetInstance()->GetWorldInfo();
if( !pWorldInfo ) return;
pWorldInfo->GetBaseInfo( 0, TotalList );
//현재 월드, 채널, 서버타입에 따른 특화된 정보
CString strTemp, strMsg;
//1. 마스터 서버
_BaseInfo* pMasterInfo = FindBaseInfo( TotalList, MASTER_SERVER );
if( pMasterInfo )
{
strTemp = "[CONNECTION_1]\r\n";
strMsg += strTemp;
strTemp.Format("IP = %s \r\n", pMasterInfo->m_szPrivateIP );
strMsg += strTemp;
strTemp.Format("PORT = %d \r\n", pMasterInfo->m_wPrivatePort );
strMsg += strTemp;
strTemp.Format("TYPE = %d \r\n", MASTER_SERVER );
strMsg += strTemp;
strMsg += "\r\n";
WriteMessge( strMsg );
}
}