MMatchStage.h
00001 #ifndef MMATCHSTAGE_H 00002 #define MMATCHSTAGE_H 00003 00004 #include <list> 00005 using namespace std; 00006 #include "MMatchItem.h" 00007 #include "MMatchTransDataType.h" 00008 #include "MUID.h" 00009 #include "MMatchRule.h" 00010 #include "MMatchObject.h" 00011 #include "MMatchWorldItem.h" 00012 #include "MMatchStageSetting.h" 00013 #include "MVoteMgr.h" 00014 #include "MMatchGlobal.h" 00015 00016 #define MTICK_STAGE 100 00017 00018 class MMatchObject; 00019 class MMatchStage; 00020 class MMatchServer; 00021 class MLadderGroup; 00022 00023 // 스테이지 타입 00024 enum MMatchStageType 00025 { 00026 MST_NORMAL = 0, // 일반 00027 MST_LADDER, // 레더나 클랜게임 00028 00029 MST_MAX 00030 }; 00031 00032 struct MMatchStageTeamBonus 00033 { 00034 bool bApplyTeamBonus; // 해당 게임에서 경험치 보너스가 적용되는지 여부 00035 }; 00036 00037 // Ladder전일경우 래더팀 정보 00038 struct MMatchLadderTeamInfo 00039 { 00040 int nTID; // Ladder Team ID 00041 int nFirstMemberCount; // 초기멤버수 00042 00043 // Clan전에서만 사용하는 변수 00044 int nCLID; // 클랜ID 00045 int nCharLevel; // 캐릭터 평균 레벨 00046 int nContPoint; // 캐릭터 기여도 평균 00047 }; 00048 00049 00050 // Stage에서 사용하는 팀의 추가정보 00051 struct MMatchStageTeam 00052 { 00053 int nTeamBonusExp; // 누적된 팀 경험치 00054 int nTeamTotalLevel; // 팀원들의 레벨 총합 - 팀보너스 배분시 사용한다 00055 int nScore; // 스코어 00056 MMatchLadderTeamInfo LadderInfo; 00057 }; 00058 00059 00060 // 스테이지 메인 클래스 - 스테이지와 관련된 일을 총괄한다. 00061 class MMatchStage { 00062 private: 00063 int m_nIndex; 00064 STAGE_STATE m_nState; 00065 MMatchStageType m_nStageType; 00066 MUID m_uidStage; 00067 MUID m_uidOwnerChannel; 00068 char m_szStageName[STAGENAME_LENGTH]; 00069 bool m_bPrivate; // 비밀방 00070 char m_szStagePassword[STAGENAME_LENGTH]; 00071 MMatchStageTeamBonus m_TeamBonus; 00072 MMatchStageTeam m_Teams[MMT_END]; 00073 00074 MUIDRefCache m_ObjUIDCaches; 00075 list<int> m_BanCIDList; 00076 00077 unsigned long m_nStateTimer; 00078 unsigned long m_nLastTick; 00079 unsigned long m_nChecksum; // 목록및 정보 갱신용 00080 unsigned long m_nLastChecksumTick; 00081 int m_nAdminObjectCount; 00082 00083 00084 MMatchStageSetting m_StageSetting; 00085 MMatchRule* m_pRule; 00086 00087 MUID m_uidAgent; 00088 bool m_bAgentReady; 00089 int m_nRoundObjCount[MMT_END]; 00090 00091 MVoteMgr m_VoteMgr; 00092 00093 char m_szFirstMasterName[MATCHOBJECT_NAME_LENGTH]; 00094 00095 void SetMasterUID(const MUID& uid) { m_StageSetting.SetMasterUID(uid);} 00096 MMatchRule* CreateRule(MMATCH_GAMETYPE nGameType); 00097 protected: 00098 inline bool IsChecksumUpdateTime(unsigned long nTick); 00099 void UpdateChecksum(unsigned long nTick); 00100 void OnStartGame(); 00101 void OnFinishGame(); 00102 void OnApplyTeamBonus(MMatchTeam nTeam); 00103 protected: 00104 friend MMatchServer; 00105 void SetStageType(MMatchStageType nStageType); 00106 void SetLadderTeam(MMatchLadderTeamInfo* pRedLadderTeamInfo, MMatchLadderTeamInfo* pBlueLadderTeamInfo); 00107 public: 00108 MMatchWorldItemManager m_WorldItemManager; 00109 00110 void UpdateStateTimer(); 00111 unsigned long GetStateTimer() { return m_nStateTimer; } 00112 unsigned long GetChecksum() { return m_nChecksum; } 00113 public: 00114 MMatchStage(); 00115 virtual ~MMatchStage(); 00116 00117 bool Create(const MUID& uid, const char* pszName, bool bPrivate, const char* pszPassword); 00118 void Destroy(); 00119 void OnCommand(MCommand* pCommand); 00120 00121 const char* GetName() { return m_szStageName; } 00122 const char* GetPassword() { return m_szStagePassword; } 00123 void SetPassword(const char* pszPassword) { strcpy(m_szStagePassword, pszPassword); } 00124 const bool IsPrivate() { return m_bPrivate; } 00125 void SetPrivate(bool bVal) { m_bPrivate = bVal; } 00126 MUID GetUID() { return m_uidStage; } 00127 00128 const char* GetMapName() { return m_StageSetting.GetMapName(); } 00129 void SetMapName(char* pszMapName) { m_StageSetting.SetMapName(pszMapName); } 00130 00131 char* GetFirstMasterName() { return m_szFirstMasterName; } 00132 void SetFirstMasterName(char* pszName) { strcpy(m_szFirstMasterName, pszName); } 00133 00134 size_t GetObjCount() { return m_ObjUIDCaches.size(); } 00135 MUIDRefCache::iterator GetObjBegin() { return m_ObjUIDCaches.begin(); } 00136 MUIDRefCache::iterator GetObjEnd() { return m_ObjUIDCaches.end(); } 00137 int GetObjInBattleCount(); 00138 int GetCountableObjCount() { return ((int)GetObjCount() - m_nAdminObjectCount); } 00139 00140 00141 void AddBanList(int nCID); 00142 bool CheckBanList(int nCID); 00143 00144 void AddObject(const MUID& uid, const MMatchObject* pObj); 00145 MUIDRefCache::iterator RemoveObject(const MUID& uid); 00146 bool KickBanPlayer(const char* pszName, bool bBanPlayer=true); 00147 00148 const MUID RecommandMaster(bool bInBattleOnly); 00149 void EnterBattle(MMatchObject* pObj); 00150 void LeaveBattle(MMatchObject* pObj); 00151 00152 STAGE_STATE GetState() { return m_nState; } 00153 void ChangeState(STAGE_STATE nState) { m_nState = nState; UpdateStateTimer(); } 00154 00155 bool CheckTick(unsigned long nClock); 00156 void Tick(unsigned long nClock); 00157 00158 MMatchStageSetting* GetStageSetting() { return &m_StageSetting; } 00159 00160 MMatchRule* GetRule() { return m_pRule; } 00161 void ChangeRule(MMATCH_GAMETYPE nRule); 00162 int GetTeamMemberCount(MMatchTeam nTeam); 00163 MMatchTeam GetRecommandedTeam(); 00164 00165 MVoteMgr* GetVoteMgr() { return &m_VoteMgr; } 00166 00167 MUID GetAgentUID() { return m_uidAgent; } 00168 void SetAgentUID(MUID uid) { m_uidAgent = uid; } 00169 bool GetAgentReady() { return m_bAgentReady; } 00170 void SetAgentReady(bool bReady) { m_bAgentReady = bReady; } 00171 00172 MUID GetMasterUID() { return m_StageSetting.GetMasterUID(); } 00173 int GetIndex() { return m_nIndex; } 00174 00175 void SetOwnerChannel(MUID& uidOwnerChannel, int nIndex); 00176 MUID GetOwnerChannel() { return m_uidOwnerChannel; } 00177 00178 void PlayerTeam(const MUID& uidPlayer, unsigned int nTeam); 00179 void PlayerState(const MUID& uidPlayer, MMatchObjectStageState nStageState); 00180 bool StartGame(); 00181 bool FinishGame(); 00182 bool CheckBattleEntry(); 00183 00184 void RoundStateFromClient(const MUID& uidStage, int nState, int nRound); 00185 void ObtainWorldItem(MMatchObject* pObj, const int nItemID); 00186 void RequestSpawnWorldItem(MMatchObject* pObj, const int nItemID, 00187 const float x, const float y, const float z); 00188 void SpawnServerSideWorldItem(MMatchObject* pObj, const int nItemID, 00189 const float x, const float y, const float z, 00190 int nLifeTime, int nExtraValue); 00191 00192 bool IsApplyTeamBonus(); // 팀전 보너스 적용여부 확인 00193 void AddTeamBonus(int nExp, MMatchTeam nTeam); 00194 int GetTeamScore(MMatchTeam nTeam) { return m_Teams[nTeam].nScore; } 00195 const MMatchStageType GetStageType() { return m_nStageType; } 00196 int GetMinPlayerLevel(); // 방에 있는 플레이어중 최소 레벨을 구한다. 00197 public: 00198 // Rule에서 호출하는 함수들 00199 void OnRoundWinFromTeamGame(MMatchTeam nTeam); 00200 void OnInitRound(); // 라운드 시작시 Rule클래스에서 호출 00201 }; 00202 00203 00204 class MMatchStageMap : public map<MUID, MMatchStage*> { 00205 MUID m_uidGenerate; 00206 public: 00207 MMatchStageMap() { m_uidGenerate = MUID(0,0); } 00208 virtual ~MMatchStageMap() { } 00209 MUID UseUID() { m_uidGenerate.Increase(); return m_uidGenerate; } 00210 void Insert(const MUID& uid, MMatchStage* pStage) { insert(value_type(uid, pStage)); } 00211 }; 00212 00213 00214 00215 #define TRANS_STAGELIST_NODE_COUNT 8 // 한번에 클라이언트에게 보내주는 스테이지노드 개수 00216 00217 00218 00219 #endif
MAIET entertainment