CSCommon: MMatchConfig.h 소스 파일

MAIET

MMatchConfig.h

00001 #ifndef _MMATCHCONFIG_H
00002 #define _MMATCHCONFIG_H
00003 
00004 #include <string>
00005 #include <list>
00006 #include <set>
00007 using namespace std;
00008 
00009 #include "MMatchMap.h"
00010 #include "MMatchGlobal.h"
00011 
00012 
00013 class MMatchConfig
00014 {
00015 private:
00016     char                m_szDB_DNS[64];             
00017     char                m_szDB_UserName[64];        
00018     char                m_szDB_Password[64];        
00019 
00020     int                 m_nMaxUser;                 
00021     int                 m_nServerID;
00022     char                m_szServerName[256];        
00023 
00024     MMatchServerMode    m_nServerMode;              
00025     bool                m_bRestrictionMap;          
00026     set<int>            m_EnableMaps;               
00027     list<string>        m_FreeLoginIPList;          
00028 
00029     // enabled 씨리즈 - ini에서 관리하지 않는다.
00030     bool                m_bEnabledCreateLadderGame; 
00031 private:
00032     bool GetPrivateProfileBool(const char* szAppName, const char* szKeyName, 
00033                                bool bDefault, const char* szFileName);
00034     void AddFreeLoginIP(const char* szIP);
00035     void ReadEnableMaps();
00036     void TrimStr(const char* szSrcStr, char* outStr);
00037 
00038 public:
00039     MMatchConfig();
00040     virtual ~MMatchConfig();
00041     static MMatchConfig* GetInstance();
00042     bool Create();
00043     void Destroy();
00044 
00045     // get
00046     const char* GetDB_DNS()                         { return m_szDB_DNS; }
00047     const char* GetDB_UserName()                    { return m_szDB_UserName; }
00048     const char* GetDB_Password()                    { return m_szDB_Password; }
00049     const int GetMaxUser()                          { return m_nMaxUser; }
00050     const int GetServerID()                         { return m_nServerID; }
00051     const char* GetServerName()                     { return m_szServerName; }
00052     const MMatchServerMode      GetServerMode()     { return m_nServerMode; }
00053     bool IsResMap()                             { return m_bRestrictionMap; }   // 맵제한이 있는지 여부
00054     bool IsEnableMap(const MMATCH_MAP nMap)                                     // 플레이가능한 맵인지 여부
00055     {
00056         if (!m_bRestrictionMap) return true;
00057         if (m_EnableMaps.find(nMap) != m_EnableMaps.end()) return true;
00058         return false;
00059     }
00060     bool CheckFreeLoginIPList(const char* pszIP);
00061 
00062     bool IsEnabledCreateLadderGame()                { return m_bEnabledCreateLadderGame; }
00063     void SetEnabledCreateLadderGame(bool bVal)      { m_bEnabledCreateLadderGame = bVal; }
00064 };
00065 
00066 inline MMatchConfig* MGetServerConfig() { return MMatchConfig::GetInstance(); }
00067 
00068 #define SERVER_CONFIG_FILENAME          "./server.ini"
00069 
00070 
00071 #define SERVER_CONFIG_SERVERMODE_NORMAL         "normal"
00072 #define SERVER_CONFIG_SERVERMODE_CLAN           "clan"
00073 #define SERVER_CONFIG_SERVERMODE_LADDER         "ladder"
00074 #define SERVER_CONFIG_SERVERMODE_EVENT          "event"
00075 #define SERVER_CONFIG_SERVERMODE_TEST           "test"
00076 
00077 #endif


MAIET entertainment