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

81 lines
3.6 KiB
C++

#include "StdAfx.h"
#include ".\masterserverinfo.h"
MasterServerInfo::MasterServerInfo(void)
{
}
MasterServerInfo::~MasterServerInfo(void)
{
}
void MasterServerInfo::LoadScript( CString strFilePath )
{
LoadLogfileInfo( strFilePath );
LoadServerInfo( strFilePath );
}
void MasterServerInfo::LoadLogfileInfo( CString strFilePath )
{
TCHAR szFilePath[MAX_PATH];
m_LogFile.m_nSunLogOption = GetPrivateProfileInt( "LOGFILE", "SUN_LOGFILE_OPTION ", 0, strFilePath );
m_LogFile.m_nSunLogLevel = GetPrivateProfileInt( "LOGFILE", "SUN_LOGFILE_LEVEL ", 0, strFilePath );
GetPrivateProfileString( "LOGFILE", "SUN_LOGFILE_PATH", "", szFilePath, MAX_PATH, strFilePath );
m_LogFile.m_strSunLogPath = szFilePath;
}
void MasterServerInfo::LoadServerInfo( CString strFilePath )
{
m_ServerHandler.m_nAccept = GetPrivateProfileInt( "MASTERSERVER", "MAX_ACCEPT_SESSION ", 0, strFilePath );
m_ServerHandler.m_nConnect = GetPrivateProfileInt( "MASTERSERVER", "MAX_CONNECT_SESSION ", 0, strFilePath );
m_ServerHandler.m_nSendBuf = GetPrivateProfileInt( "MASTERSERVER", "SEND_BUFFER_SIZE ", 0, strFilePath );
m_ServerHandler.m_nRecvBuf = GetPrivateProfileInt( "MASTERSERVER", "RECV_BUFFER_SIZE ", 0, strFilePath );
m_ServerHandler.m_nTimeOut = GetPrivateProfileInt( "MASTERSERVER", "TIME_OUT ", 0, strFilePath );
m_ServerHandler.m_nPacketSize = GetPrivateProfileInt( "MASTERSERVER", "MAX_PACKET_SIZE ", 0, strFilePath );
m_ServerHandler.m_nAcceptThread = GetPrivateProfileInt( "MASTERSERVER", "NUMBER_OF_ACCEPT_THREADs ", 0, strFilePath );
m_ServerHandler.m_nConnectThread = GetPrivateProfileInt( "MASTERSERVER", "NUMBER_OF_CONNECT_THREADS ", 0, strFilePath );
m_ServerHandler.m_nIoThread = GetPrivateProfileInt( "MASTERSERVER", "NUMBER_OF_IO_THREADS ", 0, strFilePath );
}
void MasterServerInfo::SaveScript( CString strFilePath )
{
SaveLogfileInfo( strFilePath );
SaveServerInfo( strFilePath );
}
void MasterServerInfo::SaveLogfileInfo( CString strFilePath )
{
CString strTemp;
WritePrivateProfileString( "LOGFILE", "SUN_LOGFILE_OPTION ", 0, strFilePath );
strTemp.Format("%d", m_LogFile.m_nSunLogLevel );
WritePrivateProfileString( "LOGFILE", "SUN_LOGFILE_LEVEL ", 0, strFilePath );
WritePrivateProfileString( "LOGFILE", "SUN_LOGFILE_PATH", m_LogFile.m_strSunLogPath, strFilePath );
}
void MasterServerInfo::SaveServerInfo( CString strFilePath )
{
CString strTemp;
strTemp.Format("%d", m_ServerHandler.m_nAccept );
WritePrivateProfileString( "SERVER_IOHANDLER", "MAX_ACCEPT_SESSION ", strTemp, strFilePath );
strTemp.Format("%d", m_ServerHandler.m_nConnect );
WritePrivateProfileString( "SERVER_IOHANDLER", "MAX_CONNECT_SESSION ", strTemp, strFilePath );
strTemp.Format("%d", m_ServerHandler.m_nSendBuf );
WritePrivateProfileString( "SERVER_IOHANDLER", "SEND_BUFFER_SIZE ", strTemp, strFilePath );
strTemp.Format("%d", m_ServerHandler.m_nRecvBuf );
WritePrivateProfileString( "SERVER_IOHANDLER", "RECV_BUFFER_SIZE ", strTemp, strFilePath );
strTemp.Format("%d", m_ServerHandler.m_nTimeOut );
WritePrivateProfileString( "SERVER_IOHANDLER", "TIME_OUT", strTemp, strFilePath );
strTemp.Format("%d", m_ServerHandler.m_nPacketSize );
WritePrivateProfileString( "SERVER_IOHANDLER", "MAX_PACKET_SIZE ", strTemp, strFilePath );
strTemp.Format("%d", m_ServerHandler.m_nAcceptThread );
WritePrivateProfileString( "SERVER_IOHANDLER", "NUMBER_OF_ACCEPT_THREADs ", strTemp, strFilePath );
strTemp.Format("%d", m_ServerHandler.m_nConnectThread );
WritePrivateProfileString( "SERVER_IOHANDLER", "NUMBER_OF_CONNECT_THREADS ", strTemp, strFilePath );
strTemp.Format("%d", m_ServerHandler.m_nIoThread );
WritePrivateProfileString( "SERVER_IOHANDLER", "NUMBER_OF_IO_THREADS ", strTemp, strFilePath );
}