Move git root from Client/ to src/ to track all source code: - Client: Game client source (moved to Client/Client/) - Server: Game server source - GameTools: Development tools - CryptoSource: Encryption utilities - database: Database scripts - Script: Game scripts - rylCoder_16.02.2008_src: Legacy coder tools - GMFont, Game: Additional resources 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
65 lines
1.4 KiB
C++
65 lines
1.4 KiB
C++
#include "stdafx.h"
|
|
#include "ServerInfo.h"
|
|
//#include "string.h"
|
|
|
|
const char* CServerInfo::ms_szInfoFileName = "AdminToolServerSetup.ini";
|
|
|
|
CServerInfo::CServerInfo()
|
|
{
|
|
Reload(ms_szInfoFileName);
|
|
}
|
|
|
|
|
|
CServerInfo::~CServerInfo()
|
|
{
|
|
m_ServerInfoTable.clear( );
|
|
}
|
|
|
|
const char* CServerInfo::GetFileName( )
|
|
{
|
|
return CServerInfo::ms_szInfoFileName;
|
|
}
|
|
|
|
bool CServerInfo::Reload(const char* szFileName)
|
|
{
|
|
m_ServerInfoTable.clear();
|
|
|
|
FILE* lpFile = fopen(szFileName, "rt");
|
|
if(NULL == lpFile)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
const int MAX_LINE = 4096;
|
|
char szBuffer[MAX_LINE];
|
|
|
|
std::string szKeyString;
|
|
|
|
while(0 != fgets(szBuffer, MAX_LINE, lpFile))
|
|
{
|
|
char* szKey = strtok(szBuffer, " =\t\n");
|
|
char* szValue = strtok(NULL, " =\t\n");
|
|
|
|
if(NULL != szKey && NULL != szValue && '[' != szKey[0] && '#' != szKey[0])
|
|
{
|
|
szKeyString.assign(szKey);
|
|
m_ServerInfoTable[szKeyString] = szValue;
|
|
}
|
|
}
|
|
|
|
fclose(lpFile);
|
|
return true;
|
|
}
|
|
|
|
const char* CServerInfo::GetValue(const char* szKeyName)
|
|
{
|
|
const int MAX_BUFFER = 256;
|
|
char szBuffer[MAX_BUFFER];
|
|
|
|
strncpy(szBuffer, szKeyName, MAX_BUFFER);
|
|
szBuffer[MAX_BUFFER - 1] = 0;
|
|
|
|
ServerInfoTable::iterator finditr = m_ServerInfoTable.find(szBuffer);
|
|
return (finditr != m_ServerInfoTable.end()) ? finditr->second.c_str() : NULL;
|
|
}
|