CSCommon: MMatchServer.h 소스 파일

MAIET

MMatchServer.h

00001 #ifndef MMATCHSERVER_H
00002 #define MMATCHSERVER_H
00003 
00004 #include "MMatchDBMgr.h"
00005 #include "winsock2.h"
00006 #include "MXml.h"
00007 #include "MServer.h"
00008 #include "MMatchObject.h"
00009 #include "MAgentObject.h"
00010 #include "MMatchChannel.h"
00011 #include "MMatchStage.h"
00012 #include "MMatchClan.h"
00013 #include "MSafeUDP.h"
00014 #include "MMatchTransDataType.h"
00015 #include "MMatchAdmin.h"
00016 #include "MAsyncProxy.h"
00017 #include "MMatchGlobal.h"
00018 #include "MMatchShutdown.h"
00019 #include "MMatchChatRoom.h"
00020 #include "MLadderMgr.h"
00021 #include "MMatchQuest.h"
00022 #include "MTypes.h"
00023 #include "MMatchLanguageConf.h"
00024 #include "MMatchDebug.h"
00025 
00026 #include <vector>
00027 using namespace std;
00028 
00029 class MMatchAuthBuilder;
00030 
00031 class MMatchScheduleMgr;
00032 class MMessenger;
00033 class MMatchMessageNameGroup;
00034 class MMatchMessengerManager;
00035 
00036 
00037 #define MATCHSERVER_UID     MUID(0, 2)  
00038 
00039 
00040 class MMatchServer : public MServer{
00041 private:
00042     static MMatchServer*    m_pInstance;        
00043     unsigned long int       m_nTickTime;        
00044     inline void SetTickTime(unsigned long int nTickTime);       
00045 protected:
00046     MUID                m_NextUseUID;
00047     MCriticalSection    m_csUIDGenerateLock;
00048     MCriticalSection    m_csTickTimeLock;
00049 
00050     MMatchObjectList    m_Objects;
00051 
00052     MMatchChannelMap    m_ChannelMap;
00053     char                m_szDefaultChannelName[CHANNELNAME_LEN];
00054     char                m_szDefaultChannelRuleName[CHANNELRULE_LEN];
00055 
00056     MMatchStageMap      m_StageMap;
00057     MMatchClanMap       m_ClanMap;
00058     MAgentObjectMap     m_AgentMap;
00059 
00060 
00061     MSafeUDP            m_SafeUDP;
00062     MMatchDBMgr         m_MatchDBMgr;
00063     MAsyncProxy         m_AsyncProxy;
00064     MMatchAdmin         m_Admin;
00065     MMatchShutdown      m_MatchShutdown;
00066     MMatchChatRoomMgr   m_ChatRoomMgr;
00067     MLadderMgr          m_LadderMgr;
00068     MMatchQuest         m_Quest;
00069 
00070     bool                m_bCreated;
00071 
00072     MMatchAuthBuilder*  m_pAuthBuilder;
00073 
00074     unsigned long       m_nItemFileChecksum;    // ZItem.xml 의 변조방지 검사
00075 
00076     MMatchScheduleMgr*  m_pScheduler;
00077 
00078     MMatchLanguageConf      m_LangConf;
00079     MMatchMessengerManager* m_pMessengerManager;
00080 
00081 public:
00082     MMatchServer(void);
00083     virtual ~MMatchServer(void);
00084 
00086     static MMatchServer* GetInstance(void);
00087 
00089     bool Create(int nPort);
00091     void Destroy(void);
00092     virtual void Shutdown();
00094     virtual MUID UseUID(void);
00095 
00096     MMatchAuthBuilder* GetAuthBuilder()                 { return m_pAuthBuilder; }
00097     void SetAuthBuilder(MMatchAuthBuilder* pBuilder)    { m_pAuthBuilder = pBuilder; }
00098 
00099     MMatchChatRoomMgr* GetChatRoomMgr()                 { return &m_ChatRoomMgr; }
00100 
00101 protected:
00103     virtual bool OnCreate(void);
00105     virtual void OnDestroy(void);
00107     virtual void OnRegisterCommand(MCommandManager* pCommandManager);
00109     virtual bool OnCommand(MCommand* pCommand);
00111     virtual void OnRun(void);
00113     virtual void OnPrepareRun();
00114 
00115     virtual void OnNetClear(const MUID& CommUID);
00116     void OnMatchLogin(MUID CommUID, const char* szUserID, const char* szPassword, int nCommandVersion, unsigned long nChecksumPack);
00117     void OnMatchLoginFromNetmarble(const MUID& CommUID, const char* szCPCookie, const char* szSpareData, int nCmdVersion, unsigned long nChecksumPack);
00118     void OnBridgePeer(const MUID& uidChar, char* szLocalIP, DWORD nLocalPort, char* szIP, DWORD nPort);
00119 
00120     void LockUIDGenerate()      { m_csUIDGenerateLock.Lock(); }
00121     void UnlockUIDGenerate()    { m_csUIDGenerateLock.Unlock(); }
00122 
00124     int ObjectAdd(const MUID& uidComm);
00126     int ObjectRemove(const MUID& uid, MMatchObjectList::iterator* pNextItor);
00127 
00129     int MessageSay(MUID& uid, char* pszSay);
00130 
00132     MSafeUDP* GetSafeUDP() { return &m_SafeUDP; }
00133     void SendCommandByUDP(MCommand* pCommand, char* szIP, int nPort);
00134     void ParsePacket(char* pData, MPacketHeader* pPacketHeader, DWORD dwIP, WORD wRawPort);
00135     static bool UDPSocketRecvEvent(DWORD dwIP, WORD wRawPort, char* pPacket, DWORD dwSize);
00136     void ParseUDPPacket(char* pData, MPacketHeader* pPacketHeader, DWORD dwIP, WORD wRawPort);
00137 
00139     void PostAsyncJob(MAsyncJob* pJob);
00140     void ProcessAsyncJob();
00141     void OnAsyncGetAccountCharList(MAsyncJob* pJobResult);
00142     void OnAsyncGetAccountCharInfo(MAsyncJob* pJobResult);
00143     void OnAsyncGetCharInfo(MAsyncJob* pJobResult);
00144     void OnAsyncCreateChar(MAsyncJob* pJobResult);
00145     void OnAsyncDeleteChar(MAsyncJob* pJobResult);
00146     void OnAsyncGetFriendList(MAsyncJob* pJobInput);
00147     void OnAsyncGetLoginInfo(MAsyncJob* pJobInput);
00148     void OnAsyncWinTheClanGame(MAsyncJob* pJobInput);
00149     void OnAsyncUpdateCharInfoData(MAsyncJob* pJobInput);
00150     void OnAsyncCharFinalize(MAsyncJob* pJobInput);
00151     void OnAsyncBringAccountItem(MAsyncJob* pJobResult);
00152     void OnAsyncInsertConnLog(MAsyncJob* pJobResult);
00153     void OnAsyncInsertGameLog(MAsyncJob* pJobResult);
00154     void OnAsyncCreateClan(MAsyncJob* pJobResult);
00155     void OnAsyncExpelClanMember(MAsyncJob* pJobResult);
00156 
00158     bool InitScheduler();
00159 
00160 public :
00162     bool SetLanguageType( const char* pszLangType );
00163     bool InitMessengerManager();
00164 
00165     inline MMatchMessengerManager* GetMessengerManager() { return m_pMessengerManager; }
00166     const char* GetErrMsgrStr( const int nStrKey );
00167 
00168     // 스케쥴 처리 함수.
00169     // 공지사항.
00170     void OnScheduleAnnounce( const char* pszAnnounce );
00171     // 클랜서버 Disable.
00172     void OnScheduleClanServerSwitch( const bool bEnabled );
00173 
00174 private :
00175     // 추가적인 스케쥬을 추가하려면 이 함수를 재정의 하면 됨.
00176     virtual bool InitSubTaskSchedule() { return true; }
00177 
00178 protected:
00180     void DisconnectObject(const MUID& uidObject);
00181     void DebugTest();
00182 protected:
00183     // 채널 관련
00184     const char* GetDefaultChannelName()                 { return m_szDefaultChannelName; }
00185     void SetDefaultChannelName(const char* pszName)     { strcpy(m_szDefaultChannelName, pszName); }
00186     const char* GetDefaultChannelRuleName()             { return m_szDefaultChannelRuleName; }
00187     void SetDefaultChannelRuleName(const char* pszName) { strcpy(m_szDefaultChannelRuleName, pszName); }
00188 
00189     bool ChannelAdd(const char* pszChannelName, const char* pszRuleName, MUID* pAllocUID, MCHANNEL_TYPE nType=MCHANNEL_TYPE_PRESET, int nMaxPlayers=DEFAULT_CHANNEL_MAXPLAYERS, int nLevelMin=-1, int nLevelMax=-1);
00190     bool ChannelJoin(const MUID& uidPlayer, const MUID& uidChannel);
00191     bool ChannelJoin(const MUID& uidPlayer, const MCHANNEL_TYPE nChannelType, const char* pszChannelName);
00192     bool ChannelLeave(const MUID& uidPlayer, const MUID& uidChannel);
00193     bool ChannelChat(const MUID& uidPlayer, const MUID& uidChannel, char* pszChat);
00194 
00195     void ResponseChannelRule(const MUID& uidPlayer, const MUID& uidChannel);
00196 
00197     void OnRequestRecommendedChannel(const MUID& uidComm);
00198     void OnRequestChannelJoin(const MUID& uidPlayer, const MUID& uidChannel);
00199     void OnRequestChannelJoin(const MUID& uidPlayer, const MCHANNEL_TYPE nChannelType, const char* pszChannelName);
00200     void OnChannelChat(const MUID& uidPlayer, const MUID& uidChannel, char* pszChat);
00201     void OnStartChannelList(const MUID& uidPlayer, const int nChannelType);
00202     void OnStopChannelList(const MUID& uidPlayer);
00203 
00204     void OnChannelRequestPlayerList(const MUID& uidPlayer, const MUID& uidChannel, int nPage);
00205     void OnChannelRequestAllPlayerList(const MUID& uidPlayer, const MUID& uidChannel, unsigned long int nPlaceFilter, unsigned long int nOptions);
00206 
00207 public:
00208     void ChannelResponsePlayerList(const MUID& uidPlayer, const MUID& uidChannel, int nPage);
00209     void ChannelResponseAllPlayerList(const MUID& uidPlayer, const MUID& uidChannel, unsigned long int nPlaceFilter, unsigned long int nOptions);
00210 
00211 public:
00212     MMatchStage* FindStage(const MUID& uidStage);
00213 protected:
00214     friend MMatchStage;
00215     bool StageAdd(MMatchChannel* pChannel, const char* pszStageName, bool bPrivate, const char* pszStagePassword, MUID* pAllocUID);
00216     bool StageRemove(const MUID& uidStage, MMatchStageMap::iterator* pNextItor);
00217     bool StageJoin(const MUID& uidPlayer, const MUID& uidStage);
00218     bool StageLeave(const MUID& uidPlayer, const MUID& uidStage);
00219     bool StageEnterBattle(const MUID& uidPlayer, const MUID& uidStage);
00220     bool StageLeaveBattle(const MUID& uidPlayer, const MUID& uidStage);
00221     bool StageChat(const MUID& uidPlayer, const MUID& uidStage, char* pszChat);
00222     bool StageTeam(const MUID& uidPlayer, const MUID& uidStage, unsigned int nTeam);
00223     bool StagePlayerState(const MUID& uidPlayer, const MUID& uidStage, MMatchObjectStageState nStageState);
00224     bool StageMaster(const MUID& uidStage);
00225 
00226 protected:
00227     MCommand* CreateCmdResponseStageSetting(const MUID& uidStage);
00228     MCommand* CreateCmdMatchResponseLogin(const MUID& uidComm, const int nResult, MUID& uidPlayer);
00229 
00230     
00231     void CalcExpOnGameKill(MMatchStage* pStage, MMatchObject* pAttacker, MMatchObject* pVictim, 
00232                        int* poutAttackerExp, int* poutVictimExp);
00233     void ProcessOnGameKill(MMatchStage* pStage, MMatchObject* pAttacker, MMatchObject* pVictim);
00234     void PostGameDeadOnGameKill(MUID& uidStage, MMatchObject* pAttacker, MMatchObject* pVictim,
00235                                     int nAddedAttackerExp, int nSubedVictimExp);    // ProcessOnGameKill함수에서 사용
00236 
00237 
00238     void OnStageCreate(const MUID& uidChar, char* pszStageName, bool bPrivate, char* pszStagePassword);
00239     void OnStageJoin(const MUID& uidPlayer, const MUID& uidStage);
00240     void OnPrivateStageJoin(const MUID& uidPlayer, const MUID& uidStage, char* pszPassword);
00241     void OnStageFollow(const MUID& uidPlayer, const char* pszTargetName);
00242     void OnStageLeave(const MUID& uidPlayer, const MUID& uidStage);
00243     void OnStageRequestPlayerList(const MUID& uidPlayer, const MUID& uidStage);
00244     void OnStageEnterBattle(const MUID& uidPlayer, const MUID& uidStage);
00245     void OnStageLeaveBattle(const MUID& uidPlayer, const MUID& uidStage);
00246     void OnStageChat(const MUID& uidPlayer, const MUID& uidStage, char* pszChat);
00247     void OnRequestQuickJoin(const MUID& uidPlayer, void* pQuickJoinBlob);
00248     void ResponseQuickJoin(const MUID& uidPlayer, MTD_QuickJoinParam* pQuickJoinParam);
00249     void OnStageTeam(const MUID& uidPlayer, const MUID& uidStage, unsigned int nTeam);
00250     void OnStagePlayerState(const MUID& uidPlayer, const MUID& uidStage, MMatchObjectStageState nStageState);
00251     void OnStageStart(const MUID& uidPlayer, const MUID& uidStage, int nCountdown);
00252     void OnStartStageList(const MUID& uidComm);
00253     void OnStopStageList(const MUID& uidComm);
00254     void OnStageRequestStageList(const MUID& uidPlayer, const MUID& uidChannel, const int nStageCursor);
00255     void OnStageMap(const MUID& uidStage, char* pszMapName);
00256     void OnStageSetting(const MUID& uidPlayer, const MUID& uidStage, void* pStageBlob, int nStageCount);
00257     void OnRequestStageSetting(const MUID& uidComm, const MUID& uidStage);
00258     void OnRequestPeerList(const MUID& uidChar, const MUID& uidStage);
00259     void OnRequestGameInfo(const MUID& uidChar, const MUID& uidStage);
00260     void OnMatchLoadingComplete(const MUID& uidPlayer, int nPercent);
00261     void OnRequestRelayPeer(const MUID& uidChar, const MUID& uidPeer);
00262     void OnPeerReady(const MUID& uidChar, const MUID& uidPeer);
00263     void OnGameRoundState(const MUID& uidStage, int nState, int nRound);
00264     void OnGameKill(const MUID& uidAttacker, const MUID& uidVictim);
00265     void OnRequestSpawn(const MUID& uidChar, const MVector& pos, const MVector& dir);
00266     void OnGameRequestTimeSync(const MUID& uidComm, unsigned long nLocalTimeStamp);
00267     void OnGameReportTimeSync(const MUID& uidComm, unsigned long nLocalTimeStamp, unsigned int nDataChecksum);
00268     void OnUpdateFinishedRound(const MUID& uidStage, const MUID& uidChar, 
00269                                void* pPeerInfo, void* pKillInfo);
00270     void OnRequestForcedEntry(const MUID& uidStage, const MUID& uidChar);
00271     void OnRequestSuicide(const MUID& uidPlayer);
00272     void OnRequestObtainWorldItem(const MUID& uidPlayer, const int nItemUID);
00273     void OnRequestSpawnWorldItem(const MUID& uidPlayer, const int nItemID, const float x, const float y, const float z);
00274     void OnUserWhisper(const MUID& uidComm, char* pszSenderName, char* pszTargetName, char* pszMessage);
00275     void OnUserWhere(const MUID& uidComm, char* pszTargetName);
00276     void OnUserOption(const MUID& uidComm, unsigned long nOptionFlags);
00277     void OnChatRoomCreate(const MUID& uidPlayer, const char* pszChatRoomName);
00278     void OnChatRoomJoin(const MUID& uidComm, char* pszPlayerName, char* pszChatRoomName);
00279     void OnChatRoomLeave(const MUID& uidComm, char* pszPlayerName, char* pszChatRoomName);
00280     void OnChatRoomSelectWrite(const MUID& uidComm, const char* szChatRoomName);
00281     void OnChatRoomInvite(const MUID& uidComm, const char* pszTargetName);
00282     void OnChatRoomChat(const MUID& uidComm, const char* pszMessage);
00283 
00284 protected:  // 래더
00285     friend MLadderMgr;
00286     bool LadderJoin(const MUID& uidPlayer, const MUID& uidStage, MMatchTeam nTeam);
00287     void LadderGameLaunch(MLadderGroup* pGroupA, MLadderGroup* pGroupB);
00288 
00289 protected:  // 래더
00290     void OnLadderRequestInvite(const MUID& uidPlayer, void* pGroupBlob);
00291     void OnLadderInviteAgree(const MUID& uidPlayer);
00292     void OnLadderInviteCancel(const MUID& uidPlayer);
00293     void OnLadderRequestChallenge(const MUID& uidPlayer, void* pGroupBlob, unsigned long int nOptions);
00294     void OnLadderRequestCancelChallenge(const MUID& uidPlayer);
00295 
00296     void OnRequestProposal(const MUID& uidProposer, const int nProposalMode, const int nRequestID, 
00297                            const int nReplierCount, void* pReplierNamesBlob);
00298     void OnReplyAgreement(MUID& uidProposer, MUID& uidReplier, const char* szReplierName, 
00299                           const int nProposalMode, const int nRequestID, const bool bAgreement);
00300 protected:
00301     void OnRequestCopyToTestServer(const MUID& uidPlayer);                      // 현재 사용하지 않는다.
00302     void ResponseCopyToTestServer(const MUID& uidPlayer, const int nResult);    // 현재 사용하지 않는다.
00303 
00304     void OnRequestMySimpleCharInfo(const MUID& uidPlayer);
00305     void ResponseMySimpleCharInfo(const MUID& uidPlayer);
00306     void OnRequestCharInfoDetail(const MUID& uidChar, const char* szCharName);
00307     void ResponseCharInfoDetail(const MUID& uidChar, const char* szCharName);
00308     void OnRequestAccountCharList(const MUID& uidPlayer);
00309     void OnRequestAccountCharInfo(const MUID& uidPlayer, int nCharNum);
00310     void OnRequestSelectChar(const MUID& uidPlayer, const int nCharIndex);
00311     void OnRequestDeleteChar(const MUID& uidPlayer, const int nCharIndex, const char* szCharName);
00312     bool ResponseDeleteChar(const MUID& uidPlayer, const int nCharIndex, const char* szCharName);
00313     void OnRequestCreateChar(const MUID& uidPlayer, const int nCharIndex, const char* szCharName,
00314                 const unsigned int nSex, const unsigned int nHair, const unsigned int nFace, 
00315                 const unsigned int nCostume);
00316     bool ResponseCreateChar(const MUID& uidPlayer, const int nCharIndex, const char* szCharName,
00317         MMatchSex nSex, const unsigned int nHair, const unsigned int nFace, 
00318         const unsigned int nCostume);
00319     void OnCharClear(const MUID& uidPlayer);
00320     bool CharInitialize(const MUID& uidPlayer);
00321     bool CharFinalize(const MUID& uidPlayer);
00322     bool CorrectEquipmentByLevel(MMatchObject* pPlayer, MMatchCharItemParts nPart, int nLegalItemLevelDiff=0);  // 수정되면 true
00323     bool RemoveCharItem(MMatchObject* pObject, MUID& uidItem);
00324 protected: // 친구
00325     void OnFriendAdd(const MUID& uidPlayer, const char* pszName);
00326     void OnFriendRemove(const MUID& uidPlayer, const char* pszName);
00327     void OnFriendList(const MUID& uidPlayer);
00328     void OnFriendMsg(const MUID& uidPlayer, const char* szMsg);
00329     void FriendList(const MUID& uidPlayer);
00330 
00331 protected:  // 클랜
00332     int ValidateCreateClan(const char* szClanName, MMatchObject* pMasterObject, MMatchObject** ppSponsorObject);
00333     void UpdateCharClanInfo(MMatchObject* pObject, const int nCLID, const char* szClanName, const MMatchClanGrade nGrade);
00334 
00335     void OnClanRequestCreateClan(const MUID& uidPlayer, const int nRequestID, const char* szClanName, char** szSponsorNames);
00336     void OnClanAnswerSponsorAgreement(const int nRequestID, const MUID& uidClanMaster, char* szSponsorCharName, const bool bAnswer);
00337     void OnClanRequestAgreedCreateClan(const MUID& uidPlayer, const char* szClanName, char** szSponsorNames);
00338     void OnClanRequestCloseClan(const MUID& uidClanMaster, const char* szClanName);
00339     void ResponseCloseClan(const MUID& uidClanMaster, const char* szClanName);
00340     void OnClanRequestJoinClan(const MUID& uidClanAdmin, const char* szClanName, const char* szJoiner);
00341     void ResponseJoinClan(const MUID& uidClanAdmin, const char* szClanName, const char* szJoiner);
00342     void OnClanAnswerJoinAgreement(const MUID& uidClanAdmin, const char* szJoiner, const bool bAnswer);
00343     void OnClanRequestAgreedJoinClan(const MUID& uidClanAdmin, const char* szClanName, const char* szJoiner);
00344     void ResponseAgreedJoinClan(const MUID& uidClanAdmin, const char* szClanName, const char* szJoiner);
00345 
00346     void OnClanRequestLeaveClan(const MUID& uidPlayer);
00347     void ResponseLeaveClan(const MUID& uidPlayer);
00348     void OnClanRequestChangeClanGrade(const MUID& uidClanMaster, const char* szMember, int nClanGrade);
00349     void ResponseChangeClanGrade(const MUID& uidClanMaster, const char* szMember, int nClanGrade);
00350     void OnClanRequestExpelMember(const MUID& uidClanAdmin, const char* szMember);
00351     void ResponseExpelMember(const MUID& uidClanAdmin, const char* szMember);
00352     void OnClanRequestMsg(const MUID& uidSender, const char* szMsg);
00353     void OnClanRequestMemberList(const MUID& uidChar);
00354     void OnClanRequestClanInfo(const MUID& uidChar, const char* szClanName);
00355 
00356     void OnClanRequestEmblemURL(const MUID& uidChar, int nCLID);
00357 public:
00358     MMatchClan* FindClan(const int nCLID);
00359     void ResponseClanMemberList(const MUID& uidChar);
00360 public:
00361     int GetLadderTeamIDFromDB(const int nTeamTableIndex, const int* pnMemberCIDArray, const int nMemberCount);
00362     void SaveLadderTeamPointToDB(const int nTeamTableIndex, const int nWinnerTeamID, const int nLoserTeamID, const bool bIsDrawGame);
00363     void SaveClanPoint(MMatchClan* pWinnerClan, MMatchClan* pLoserClan, const bool bIsDrawGame,
00364                         const int nRoundWins, const int nRoundLosses, const int nMapID, const int nGameType,
00365                         const int nOneTeamMemberCount, list<MUID>& WinnerObjUIDs,
00366                         const char* szWinnerMemberNames, const char* szLoserMemberNames, float fPointRatio);
00367     void BroadCastClanRenewVictories(const char* szWinnerClanName, const char* szLoserClanName, const int nVictories);
00368     void BroadCastClanInterruptVictories(const char* szWinnerClanName, const char* szLoserClanName, const int nVictories);
00369 public:
00370     friend MVoteDiscuss;
00371     void OnVoteCallVote(const MUID& uidPlayer, const char* pszDiscuss, const char* pszArg);
00372     void OnVoteYes(const MUID& uidPlayer);
00373     void OnVoteNo(const MUID& uidPlayer);
00374     void VoteAbort( const MUID& uidPlayer );
00375 
00376     void OnAdminServerHalt(void);
00377 
00378 protected:
00379     // 관리자 기능
00380     void OnAdminTerminal(const MUID& uidAdmin, const char* szText);
00381     void OnAdminAnnounce(const MUID& uidAdmin, const char* szChat, unsigned long int nType);
00382     void OnAdminRequestServerInfo(const MUID& uidAdmin);
00383     void OnAdminServerHalt(const MUID& uidAdmin);
00384     
00385     void OnAdminRequestBanPlayer(const MUID& uidAdmin, const char* szPlayer);
00386     void OnAdminRequestUpdateAccountUGrade(const MUID& uidAdmin, const char* szPlayer);
00387     void OnAdminPingToAll(const MUID& uidAdmin);
00388     void OnAdminRequestSwitchLadderGame(const MUID& uidAdmin, const bool bEnabled);
00389     void OnAdminHide(const MUID& uidAdmin);
00390 
00391     // 이벤트 마스터 기능
00392     void OnEventChangeMaster(const MUID& uidAdmin);
00393     void OnEventChangePassword(const MUID& uidAdmin, const char* szPassword);
00394     void OnEventRequestJjang(const MUID& uidAdmin, const char* pszTargetName);
00395     void OnEventRemoveJjang(const MUID& uidAdmin, const char* pszTargetName);
00396 
00397 public:
00398     void AdminTerminalOutput(const MUID& uidAdmin, const char* szText);
00399     bool OnAdminExecute(MAdminArgvInfo* pAI, char* szOut);
00400     void ApplyObjectTeamBonus(MMatchObject* pObject, int nAddedExp);
00401     void ProcessPlayerXPBP(MMatchStage* pStage, MMatchObject* pPlayer, int nAddedXP, int nAddedBP);
00402 protected:
00403     bool BuyItem(MMatchObject* pObject, MMatchItemDesc* pItemDesc);
00404     void OnRequestBuyItem(const MUID& uidPlayer, const unsigned long int nItemID);
00405     bool ResponseBuyItem(const MUID& uidPlayer, const unsigned long int nItemID);
00406     void OnRequestSellItem(const MUID& uidPlayer, const MUID& uidItem);
00407     bool ResponseSellItem(const MUID& uidPlayer, const MUID& uidItem);
00408     void OnRequestShopItemList(const MUID& uidPlayer, const int nFirstItemIndex, const int nItemCount);
00409     void ResponseShopItemList(const MUID& uidPlayer, const int nFirstItemIndex, const int nItemCount);
00410     void OnRequestCharacterItemList(const MUID& uidPlayer);
00411     void ResponseCharacterItemList(const MUID& uidPlayer);
00412     void OnRequestAccountItemList(const MUID& uidPlayer);
00413     void ResponseAccountItemList(const MUID& uidPlayer);
00414     void OnRequestEquipItem(const MUID& uidPlayer, const MUID& uidItem, const long int nEquipmentSlot);
00415     void ResponseEquipItem(const MUID& uidPlayer, const MUID& uidItem, const MMatchCharItemParts parts);
00416     void OnRequestTakeoffItem(const MUID& uidPlayer, const unsigned long int nEquipmentSlot);
00417     void ResponseTakeoffItem(const MUID& uidPlayer, const MMatchCharItemParts parts);
00418     void OnRequestBringAccountItem(const MUID& uidPlayer, const int nAIID);
00419     void ResponseBringAccountItem(const MUID& uidPlayer, const int nAIID);
00420     void OnRequestBringBackAccountItem(const MUID& uidPlayer, const MUID& uidItem);
00421     void ResponseBringBackAccountItem(const MUID& uidPlayer, const MUID& uidItem);
00422 protected:
00423     // 퀘스트 관련
00424     void OnRequestNPCDead(const MUID& uidSender, const MUID& uidKiller, MUID& uidNPC, MVector& pos);
00425     void OnQuestRequestDead(const MUID& uidVictim);
00426     void OnQuestTestRequestNPCSpawn(const MUID& uidPlayer, int nNPCType, int nNPCCount);
00427     void OnQuestTestRequestClearNPC(const MUID& uidPlayer);
00428     void OnQuestTestRequestSectorClear(const MUID& uidPlayer);
00429     void OnQuestTestRequestQuestFinish(const MUID& uidPlayer);
00430     void OnQuestRequestMovetoPortal(const MUID& uidPlayer);
00431     void OnQuestReadyToNewSector(const MUID& uidPlayer);
00432 #ifdef _QUEST_ITEM
00433     void OnRequestCharQuestItemList( const MUID& uidSender );
00434     void OnResponseCharQuestItemList( const MUID& uidSender );
00435     void OnRequestBuyQuestItem( const MUID& uidSender, const unsigned long int nItemID );
00436     void OnResponseBuyQeustItem( const MUID& uidSender, const unsigned long int nItemID );
00437     void OnRequestSellQuestItem( const MUID& uidSender, const unsigned long int nItemID );
00438     void OnResponseSellQuestItem( const MUID& uidSender, const unsigned long int nItemID );
00439     void OnRequestDropSacrificeItemOnSlot( MCommand* pCmd );
00440 #endif
00441 
00442 protected:
00444     int AgentAdd(const MUID& uidComm);
00446     int AgentRemove(const MUID& uidAgent, MAgentObjectMap::iterator* pNextItor);
00447 
00449     MAgentObject* GetAgent(const MUID& uidAgent);
00450     MAgentObject* GetAgentByCommUID(const MUID& uidComm);
00451     bool CheckBridgeFault();
00452     MAgentObject* FindFreeAgent();
00453     void ReserveAgent(MMatchStage* pStage);
00454     void LocateAgentToClient(const MUID& uidPlayer, const MUID& uidAgent);
00455 
00456     void OnRegisterAgent(const MUID& uidComm, char* szIP, int nTCPPort, int nUDPPort);
00457     void OnUnRegisterAgent(const MUID& uidComm);
00458     void OnAgentStageReady(const MUID& uidCommAgent, const MUID& uidStage);
00459     void OnRequestLiveCheck(const MUID& uidComm, unsigned long nTimeStamp, 
00460                             unsigned long nStageCount, unsigned long nUserCount);
00461 
00462 public:
00464     MMatchObject* GetObject(const MUID& uid);
00466     MMatchObject* GetPlayerByCommUID(const MUID& uid);
00468     MMatchObject* GetPlayerByName(const char* pszName);
00470     MMatchObject* GetPlayerByAID(unsigned long int nAID);
00471 
00473     MMatchChannel* FindChannel(const MUID& uidChannel);
00475     MMatchChannel* FindChannel(const MCHANNEL_TYPE nChannelType, const char* pszChannelName);
00476 
00478     void Announce(const MUID& CommUID, char* pszMsg);
00479     void Announce(MObject* pObj, char* pszMsg);
00481     void AnnounceErrorMsg(const MUID& CommUID, const int nErrorCode);
00482     void AnnounceErrorMsg(MObject* pObj, const int nErrorCode);
00484     void RouteToListener(MObject* pObject, MCommand* pCommand);
00486     void RouteToAllConnection(MCommand* pCommand);
00488     void RouteToAllClient(MCommand* pCommand);
00490     void RouteToChannel(const MUID& uidChannel, MCommand* pCommand);
00492     void RouteToChannelLobby(const MUID& uidChannel, MCommand* pCommand);
00494     void RouteToStage(const MUID& uidStage, MCommand* pCommand);
00496     void RouteToBattle(const MUID& uidStage, MCommand* pCommand);
00498     void RouteToClan(const int nCLID, MCommand* pCommand);
00499     // int 결과값있는 Command를 지정 Object Listener에게 전송
00500     void RouteResponseToListener(MObject* pObject, const int nCmdID, int nResult);
00501 
00502 //  void ResponseObjectUpdate(MUID& TargetUID, MObject* pObject);
00503     void ResponseBridgePeer(const MUID& uidChar, int nCode);
00504     void ResponseRoundState(const MUID& uidStage);
00505     void ResponseRoundState(MMatchObject* pObj, const MUID& uidStage);
00506     void ResponsePeerList(const MUID& uidChar, const MUID& uidStage);
00507     void ResponseGameInfo(const MUID& uidChar, const MUID& uidStage);
00508 
00509     void NotifyMessage(const MUID& uidChar, int nMsgID);
00510 
00511     unsigned long GetChannelListChecksum()  { return m_ChannelMap.GetChannelListChecksum(); }
00512     void ChannelList(const MUID& uidPlayer, MCHANNEL_TYPE nChannelType);
00513 
00514     unsigned long int GetStageListChecksum(MUID& uidChannel, int nStageCursor, int nStageCount);
00515     void StageList(const MUID& uidPlayer, int nStageStartIndex, bool bCacheUpdate);
00516     void StageLaunch(const MUID& uidStage);
00517     void StageFinishGame(const MUID& uidStage);
00518 
00519     void StandbyClanList(const MUID& uidPlayer, int nClanListStartIndex, bool bCacheUpdate);
00520 
00521 
00523     unsigned long int GetGlobalClockCount(void);
00525     void SetClientClockSynchronize(const MUID& CommUID);
00527     static unsigned long int ConvertLocalClockToGlobalClock(unsigned long int nLocalClock, unsigned long int nLocalClockDistance);
00529     static unsigned long int ConvertGlobalClockToLocalClock(unsigned long int nGlobalClock, unsigned long int nLocalClockDistance);
00530 
00531     bool IsCreated() { return m_bCreated; }
00532     inline unsigned long int GetTickTime();         
00533 protected:
00534     void InsertChatDBLog(const MUID& uidPlayer, const char* szMsg);
00535     int ValidateMakingName(const char* szCharName, int nMinLength, int nMaxLength);     // 등록가능한 이름인지 확인한다.
00536 
00537     int ValidateStageJoin(const MUID& uidPlayer, const MUID& uidStage);
00538     int ValidateChannelJoin(const MUID& uidPlayer, const MUID& uidChannel);
00539     int ValidateEquipItem(MMatchObject* pObj, MMatchItem* pItem, const MMatchCharItemParts parts);
00540     int ValidateChallengeLadderGame(MMatchObject** ppMemberObject, int nMemberCount);
00541     void CheckExpiredItems(MMatchObject* pObj);
00542     void ResponseExpiredItemIDList(MMatchObject* pObj, vector<unsigned long int>& vecExpiredItemIDList);
00543 
00544     bool LoadInitFile();
00545     bool LoadChannelPreset();
00546     bool InitDB();
00547     void UpdateServerLog();
00548     void UpdateServerStatusDB();
00549 
00550     void UpdateCharDBCachingData(MMatchObject* pObject);
00551 protected:
00552     unsigned long GetItemFileChecksum()                 { return m_nItemFileChecksum; }
00553     void SetItemFileChecksum(unsigned long nChecksum)   { m_nItemFileChecksum = nChecksum; }
00554 
00555     bool CheckItemXML();
00556 
00557 friend bool StageKick(MMatchServer* pServer, const MUID& uidPlayer, const MUID& uidStage, char* pszChat);
00558 
00559 public:
00560     MLadderMgr* GetLadderMgr()              { return &m_LadderMgr; }
00561     MMatchObjectList*   GetObjects()        { return &m_Objects; }
00562     MMatchStageMap*     GetStageMap()       { return &m_StageMap; }
00563     MMatchChannelMap*   GetChannelMap()     { return &m_ChannelMap; }
00564     MMatchClanMap*      GetClanMap()        { return &m_ClanMap; }
00565     MMatchDBMgr*        GetDBMgr()          { return &m_MatchDBMgr; }
00566     MMatchQuest*        GetQuest()          { return &m_Quest; }
00567     int GetClientCount()    { return (int)m_Objects.size(); }
00568     int GetCommObjCount()   { return (int)m_CommRefCache.size(); }
00569     int GetAgentCount()     { return (int)m_AgentMap.size(); }
00570 };
00571 
00572 void CopyCharInfoForTrans(MTD_CharInfo* pDest, MMatchCharInfo* pSrc, MMatchObject* pSrcObject);
00573 void CopyCharInfoDetailForTrans(MTD_CharInfo_Detail* pDest, MMatchCharInfo* pSrcCharInfo, MMatchObject* pSrcObject);
00574 
00575 
00576 // line functions ///////////////////////////////////////////////////////////////////
00577 inline unsigned long int MMatchServer::GetTickTime()
00578 { 
00579     m_csTickTimeLock.Lock();        
00580     unsigned long int ret = m_nTickTime; 
00581     m_csTickTimeLock.Unlock();
00582     return ret;
00583 }
00584 
00585 inline void MMatchServer::SetTickTime(unsigned long int nTickTime)
00586 {
00587     m_csTickTimeLock.Lock();        
00588     m_nTickTime = nTickTime;
00589     m_csTickTimeLock.Unlock();
00590 }
00591 
00592 
00593 #endif


MAIET entertainment