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

191 lines
9.6 KiB
C++

#include "StdAfx.h"
#include ".\worldserverinfo.h"
WorldServerInfo::WorldServerInfo(void)
{
}
WorldServerInfo::~WorldServerInfo(void)
{
}
void WorldServerInfo::LoadScript( CString strFilePath )
{
LoadCommonInfo( strFilePath );
LoadLogfileInfo( strFilePath );
LoadServerInfo( strFilePath );
LoadClientInfo( strFilePath );
LoadChatLog( strFilePath );
}
void WorldServerInfo::LoadCommonInfo( CString strFilePath )
{
m_Common.m_nCommonFile = GetPrivateProfileInt( "COMMON", "GET_SERVERINFO_FROM_FILE", 0, strFilePath );
m_Common.m_nCommonService = GetPrivateProfileInt( "COMMON", "SERVICE_MODE ", 0, strFilePath );
m_Common.m_nCommonCryptoGraphy = GetPrivateProfileInt( "COMMON", "CRYPTOGRAPHY_ENABLED ", 0, strFilePath );
m_Common.m_nCommonWorldID = GetPrivateProfileInt( "COMMON", "WORLD_ID", 0, strFilePath );
m_Common.m_nCommonStatistics = GetPrivateProfileInt( "INTERVAL", "STATISTICS", 0, strFilePath );
m_Common.m_nCommonShout = GetPrivateProfileInt( "INTERVAL", "SHOUT", 0, strFilePath );
}
void WorldServerInfo::LoadLogfileInfo( CString strFilePath )
{
TCHAR szFilePath[MAX_PATH];
GetPrivateProfileString( "LOGFILE", "WOPS_LOGFILE_PATH", "", szFilePath, MAX_PATH, strFilePath );
m_LogFile.m_strWopsLogPath = szFilePath;
m_LogFile.m_nWopsLogOption = GetPrivateProfileInt( "LOGFILE", "WOPS_LOGFILE_OPTION", 0, strFilePath );
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 WorldServerInfo::LoadServerInfo( CString strFilePath )
{
m_ServerHandler.m_nAccept = GetPrivateProfileInt( "SERVER_IO", "MAX_ACCEPT_SESSION ", 0, strFilePath );
m_ServerHandler.m_nConnect = GetPrivateProfileInt( "SERVER_IO", "MAX_CONNECT_SESSION ", 0, strFilePath );
m_ServerHandler.m_nSendBuf = GetPrivateProfileInt( "SERVER_IO", "SEND_BUFFER_SIZE ", 0, strFilePath );
m_ServerHandler.m_nRecvBuf = GetPrivateProfileInt( "SERVER_IO", "RECV_BUFFER_SIZE ", 0, strFilePath );
m_ServerHandler.m_nTimeOut = GetPrivateProfileInt( "SERVER_IO", "TIME_OUT ", 0, strFilePath );
m_ServerHandler.m_nPacketSize = GetPrivateProfileInt( "SERVER_IO", "MAX_PACKET_SIZE ", 0, strFilePath );
m_ServerHandler.m_nAcceptThread = GetPrivateProfileInt( "SERVER_IO", "NUMBER_OF_ACCEPT_THREADs ", 0, strFilePath );
m_ServerHandler.m_nConnectThread = GetPrivateProfileInt( "SERVER_IO", "NUMBER_OF_CONNECT_THREADS ", 0, strFilePath );
m_ServerHandler.m_nIoThread = GetPrivateProfileInt( "SERVER_IO", "NUMBER_OF_IO_THREADS ", 0, strFilePath );
}
void WorldServerInfo::LoadClientInfo( CString strFilePath )
{
m_ClientHandler.m_nAccept = GetPrivateProfileInt( "CLIENT_IO", "MAX_ACCEPT_SESSION ", 0, strFilePath );
m_ClientHandler.m_nConnect = GetPrivateProfileInt( "CLIENT_IO", "MAX_CONNECT_SESSION ", 0, strFilePath );
m_ClientHandler.m_nSendBuf = GetPrivateProfileInt( "CLIENT_IO", "SEND_BUFFER_SIZE ", 0, strFilePath );
m_ClientHandler.m_nRecvBuf = GetPrivateProfileInt( "CLIENT_IO", "RECV_BUFFER_SIZE ", 0, strFilePath );
m_ClientHandler.m_nTimeOut = GetPrivateProfileInt( "CLIENT_IO", "TIME_OUT ", 0, strFilePath );
m_ClientHandler.m_nPacketSize = GetPrivateProfileInt( "CLIENT_IO", "MAX_PACKET_SIZE ", 0, strFilePath );
m_ClientHandler.m_nAcceptThread = GetPrivateProfileInt( "CLIENT_IO", "NUMBER_OF_ACCEPT_THREADs ", 0, strFilePath );
m_ClientHandler.m_nConnectThread = GetPrivateProfileInt( "CLIENT_IO", "NUMBER_OF_CONNECT_THREADS ", 0, strFilePath );
m_ClientHandler.m_nIoThread = GetPrivateProfileInt( "CLIENT_IO", "NUMBER_OF_IO_THREADS ", 0, strFilePath );
}
void WorldServerInfo::LoadChatLog( CString strFilePath )
{
m_ChatLog.m_bNormal = GetPrivateProfileInt( "CHATLOG", "CHAT_NORMAL ", 0, strFilePath );
m_ChatLog.m_bShout = GetPrivateProfileInt( "CHATLOG", "CHAT_SHOUT ", 0, strFilePath );
m_ChatLog.m_bParty = GetPrivateProfileInt( "CHATLOG", "CHAT_PARTY ", 0, strFilePath );
m_ChatLog.m_bGuild = GetPrivateProfileInt( "CHATLOG", "CHAT_GUILD ", 0, strFilePath );
m_ChatLog.m_bPrivate = GetPrivateProfileInt( "CHATLOG", "CHAT_PRIVATE ", 0, strFilePath );
m_ChatLog.m_bFriend = GetPrivateProfileInt( "CHATLOG", "CHAT_FRIEND ", 0, strFilePath );
}
void WorldServerInfo::SaveScript( CString strFilePath )
{
SaveCommonInfo( strFilePath );
SaveLogfileInfo( strFilePath );
SaveServerInfo( strFilePath );
SaveClientInfo( strFilePath );
SaveChatLog( strFilePath );
}
void WorldServerInfo::SaveCommonInfo( CString strFilePath )
{
CString strTemp;
strTemp.Format("%d", m_Common.m_nCommonFile );
WritePrivateProfileString( "COMMON", "GET_SERVERINFO_FROM_FILE", strTemp, strFilePath );
strTemp.Format("%d", m_Common.m_nCommonGM );
WritePrivateProfileString( "COMMON", "SERVICE_MODE ", strTemp, strFilePath );
strTemp.Format("%d", m_Common.m_nCommonCryptoGraphy );
WritePrivateProfileString( "COMMON", "CRYPTOGRAPHY_ENABLED ", strTemp, strFilePath );
strTemp.Format("%d", m_Common.m_nCommonWorldID );
WritePrivateProfileString( "COMMON", "WORLD_ID", strTemp, strFilePath );
strTemp.Format("%d", m_Common.m_nCommonStatistics );
WritePrivateProfileString( "INTERVAL", "STATISTICS", strTemp, strFilePath );
strTemp.Format("%d", m_Common.m_nCommonShout );
WritePrivateProfileString( "INTERVAL", "SHOUT", strTemp, strFilePath );
}
void WorldServerInfo::SaveLogfileInfo( CString strFilePath )
{
CString strTemp;
WritePrivateProfileString( "LOGFILE", "WOPS_LOGFILE_PATH", m_LogFile.m_strWopsLogPath, strFilePath );
strTemp.Format("%d", m_LogFile.m_nWopsLogOption );
WritePrivateProfileString( "LOGFILE", "WOPS_LOGFILE_OPTION", 0, strFilePath );
strTemp.Format("%d", m_LogFile.m_nSunLogOption );
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 WorldServerInfo::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 );
}
void WorldServerInfo::SaveClientInfo( CString strFilePath )
{
CString strTemp;
strTemp.Format("%d", m_ClientHandler.m_nAccept );
WritePrivateProfileString( "CLIENT_IOHANDLER", "MAX_ACCEPT_SESSION ", strTemp, strFilePath );
strTemp.Format("%d", m_ClientHandler.m_nConnect );
WritePrivateProfileString( "CLIENT_IOHANDLER", "MAX_CONNECT_SESSION ", strTemp, strFilePath );
strTemp.Format("%d", m_ClientHandler.m_nSendBuf );
WritePrivateProfileString( "CLIENT_IOHANDLER", "SEND_BUFFER_SIZE ", strTemp, strFilePath );
strTemp.Format("%d", m_ClientHandler.m_nRecvBuf );
WritePrivateProfileString( "CLIENT_IOHANDLER", "RECV_BUFFER_SIZE ", strTemp, strFilePath );
strTemp.Format("%d", m_ClientHandler.m_nTimeOut );
WritePrivateProfileString( "CLIENT_IOHANDLER", "TIME_OUT", strTemp, strFilePath );
strTemp.Format("%d", m_ClientHandler.m_nPacketSize );
WritePrivateProfileString( "CLIENT_IOHANDLER", "MAX_PACKET_SIZE ", strTemp, strFilePath );
strTemp.Format("%d", m_ClientHandler.m_nAcceptThread );
WritePrivateProfileString( "CLIENT_IOHANDLER", "NUMBER_OF_ACCEPT_THREADs ", strTemp, strFilePath );
strTemp.Format("%d", m_ClientHandler.m_nConnectThread );
WritePrivateProfileString( "CLIENT_IOHANDLER", "NUMBER_OF_CONNECT_THREADS ", strTemp, strFilePath );
strTemp.Format("%d", m_ClientHandler.m_nIoThread );
WritePrivateProfileString( "CLIENT_IOHANDLER", "NUMBER_OF_IO_THREADS ", strTemp, strFilePath );
}
void WorldServerInfo::SaveChatLog( CString strFilePath )
{
CString strTemp;
strTemp.Format("%d", m_ChatLog.m_bNormal );
WritePrivateProfileString( "CHATLOG", "CHAT_NORMAL ", strTemp, strFilePath );
strTemp.Format("%d", m_ChatLog.m_bShout );
WritePrivateProfileString( "CHATLOG", "CHAT_SHOUT ", strTemp, strFilePath );
strTemp.Format("%d", m_ChatLog.m_bParty );
WritePrivateProfileString( "CHATLOG", "CHAT_PARTY ", strTemp, strFilePath );
strTemp.Format("%d", m_ChatLog.m_bGuild );
WritePrivateProfileString( "CHATLOG", "CHAT_GUILD ", strTemp, strFilePath );
strTemp.Format("%d", m_ChatLog.m_bPrivate );
WritePrivateProfileString( "CHATLOG", "CHAT_PRIVATE ", strTemp, strFilePath );
strTemp.Format("%d", m_ChatLog.m_bFriend );
WritePrivateProfileString( "CHATLOG", "CHAT_FRIEND ", strTemp, strFilePath );
}