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.2 KiB
C++
65 lines
1.2 KiB
C++
#include "Config.h"
|
|
#include <windows.h>
|
|
|
|
|
|
CConfigurator::CConfigurator()
|
|
{
|
|
|
|
|
|
}
|
|
|
|
CConfigurator::~CConfigurator()
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
bool CConfigurator::Load(const char* szFileName)
|
|
{
|
|
FILE* lpFile = fopen(szFileName, "rt");
|
|
|
|
if(NULL != lpFile)
|
|
{
|
|
const int MAX_READ = 4096;
|
|
char szRead[MAX_READ];
|
|
char* szDelimitChars = " =\t\n\r";
|
|
|
|
while(fgets(szRead, MAX_READ, lpFile))
|
|
{
|
|
const char* szCommand = strtok(szRead, szDelimitChars);
|
|
const char* szValue = strtok(NULL, szDelimitChars);
|
|
|
|
if(0 != szCommand && 0 != szValue)
|
|
{
|
|
if(0 != strncmp(szCommand, TEXT("//"), strlen(TEXT("//"))))
|
|
{
|
|
m_ConfigMap.insert(std::make_pair(szCommand, szValue));
|
|
}
|
|
}
|
|
}
|
|
|
|
fclose(lpFile);
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
const char* CConfigurator::Get(const char* szKey)
|
|
{
|
|
ConfigMap::iterator end = m_ConfigMap.end();
|
|
ConfigMap::iterator find = m_ConfigMap.find(szKey);
|
|
|
|
if(end != find)
|
|
{
|
|
return find->second.c_str();
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
void CConfigurator::Clear()
|
|
{
|
|
m_ConfigMap.clear();
|
|
} |