MMatchClan.h
00001 #ifndef _MMATCHCLAN_H 00002 #define _MMATCHCLAN_H 00003 00004 00005 #include "MMatchGlobal.h" 00006 #include "MUID.h" 00007 #include "MSmartRefresh.h" 00008 #include <string> 00009 #include <list> 00010 using namespace std; 00011 00012 // 클랜 등급 00013 enum MMatchClanGrade 00014 { 00015 MCG_NONE = 0, // 클랜원이 아님 00016 MCG_MASTER = 1, // 클랜 마스터 00017 MCG_ADMIN = 2, // 클랜 운영자 00018 00019 MCG_MEMBER = 9, // 일반 클랜원 00020 MCG_END 00021 }; 00022 00023 // 클랜등급이 nSrcGrade가 nDstGrade보다 같거나 더 높은지 판별한다. 00024 inline bool IsUpperClanGrade(MMatchClanGrade nSrcGrade, MMatchClanGrade nDstGrade) 00025 { 00026 if ((nSrcGrade != MCG_NONE) && ((int)nSrcGrade <= (int)nDstGrade)) return true; 00027 return false; 00028 } 00029 00031 class MMatchObject; 00032 00034 class MMatchClan 00035 { 00036 private: 00037 int m_nCLID; 00038 char m_szClanName[CLAN_NAME_LENGTH]; 00039 unsigned long m_nDBRefreshLifeTime; 00040 00041 struct ClanInfoEx 00042 { 00043 int nLevel; 00044 int nTotalPoint; 00045 int nPoint; 00046 int nWins; 00047 int nLosses; 00048 int nRanking; 00049 int nTotalMemberCount; 00050 char szMaster[MATCHOBJECT_NAME_LENGTH]; 00051 char szEmblemUrl[256]; 00052 int nEmblemChecksum; 00053 }; 00054 00055 ClanInfoEx m_ClanInfoEx; 00056 MUIDRefCache m_Members; 00057 MSmartRefresh m_SmartRefresh; 00058 00059 int m_nSeriesOfVictories; 00060 list<int> m_MatchedClanList; 00061 00062 void Clear(); 00063 void InitClanInfoEx(const int nLevel, const int nTotalPoint, const int nPoint, const int nRanking, 00064 const int nWins, const int nLosses, const int nTotalMemberCount, const char* szMaster, 00065 const char* szEmblemUrl, int nEmblemChecksum); 00066 public: 00067 MMatchClan(); 00068 virtual ~MMatchClan(); 00069 00070 // MMatchClanMap에서 사용하는 함수 00071 void Create(int nCLID, const char* szClanName); 00072 void AddObject(const MUID& uid, MMatchObject* pObj); 00073 void RemoveObject(const MUID& uid); 00074 00075 00076 void Tick(unsigned long nClock); 00077 void SyncPlayerList(MMatchObject* pObj, int nCategory); 00078 void InitClanInfoFromDB(); // db에서 클랜정보를 초기화한다. 00079 00080 // get 씨리즈 00081 int GetCLID() { return m_nCLID; } 00082 const char* GetName() { return m_szClanName; } 00083 // int GetLevel() { return m_nLevel; } 00084 int GetMemberCount() { return (int)m_Members.size(); } 00085 ClanInfoEx* GetClanInfoEx() { return &m_ClanInfoEx; } 00086 bool IsInitedClanInfoEx() { return (m_ClanInfoEx.nLevel != 0); } 00087 int GetSeriesOfVictories() { return m_nSeriesOfVictories; } 00088 const char* GetEmblemURL() { return m_ClanInfoEx.szEmblemUrl; } 00089 int GetEmblemChecksum() { return m_ClanInfoEx.nEmblemChecksum; } 00090 00091 // Inc 00092 void IncWins(int nAddedWins) { 00093 m_ClanInfoEx.nWins += nAddedWins; m_nSeriesOfVictories++; 00094 } 00095 void IncLosses(int nAddedLosses) { 00096 m_ClanInfoEx.nLosses += nAddedLosses; m_nSeriesOfVictories=0; 00097 } 00098 void IncPoint(int nAddedPoint) { m_ClanInfoEx.nPoint += nAddedPoint; 00099 if (nAddedPoint > 0) m_ClanInfoEx.nTotalPoint += nAddedPoint; 00100 if (m_ClanInfoEx.nPoint < 0) m_ClanInfoEx.nPoint =0; 00101 } 00102 void InsertMatchedClanID(int nCLID); 00103 00104 MUIDRefCache::iterator GetMemberBegin() { return m_Members.begin(); } 00105 MUIDRefCache::iterator GetMemberEnd() { return m_Members.end(); } 00106 }; 00107 00109 00110 class MMatchClanMap : public map<int, MMatchClan*> 00111 { 00112 private: 00113 unsigned long m_nLastTick; 00114 map<std::string, MMatchClan*> m_ClanNameMap; 00115 void CreateClan(int nCLID, const char* szClanName); 00116 void DestroyClan(int nCLID); 00117 bool CheckTick(unsigned long nClock); 00118 public: 00119 MMatchClanMap(); 00120 virtual ~MMatchClanMap(); 00121 void Destroy(); 00122 void Tick(unsigned long nClock); 00123 00124 void AddObject(const MUID& uid, MMatchObject* pObj); 00125 void RemoveObject(const MUID& uid, MMatchObject* pObj); 00126 MMatchClan* GetClan(const int nCLID); 00127 MMatchClan* GetClan(const char* szClanName); 00128 }; 00129 00130 00131 #endif
MAIET entertainment