CSCommon: MZoneServer.h 소스 파일

MAIET

MZoneServer.h

00001 #ifndef MZONESERVER_H
00002 #define MZONESERVER_H
00003 
00004 #include "winsock2.h"
00005 #include "MCharacterDesc.h"
00006 #include "MServer.h"
00007 #include "MMap.h"
00008 #include "MSpawnManager.h"
00009 #include "RTypes.h"
00010 #include "MObjectCharacter.h"
00011 #include <vector>
00012 using namespace std;
00013 
00014 class MObject;
00015 class MObjectCharacter;
00016 class MObjectItem;
00017 
00018 //class MCharacterList : public map<MUID, MObjectCharacter*>{};
00019 //class MItemList : public map<MUID, MObjectItem*>{};
00020 class MObjectList : public map<MUID, MObject*>{};
00021 
00032 class MZoneServer : public MServer{
00033 private:
00034     static MZoneServer* m_pInstance;        
00035 protected:
00036     MUID            m_Master;               
00037 
00038     MMapManager     m_Maps;                 
00039     MSpawnManager   m_SpawnManager;         
00040 
00041     bool            m_bRequestUIDToMaster;  
00042 
00043     //MCharacterList    m_Characters;
00044     //MItemList     m_Items;
00045     MObjectList     m_Objects;
00046     //MGridMap<MObjectCharacter*>   m_MapRefCharacter;
00047     //MGridMap<MObjectItem*>    m_MapRefItem;
00048 
00049     float           m_fSharedVisionRadius;  
00050 
00051     MUIDRANGE       m_CommAllocRange;       
00052     MUIDRANGE       m_NextCommAllocRange;   
00053 
00054 protected:
00056     virtual bool OnCreate(void);
00058     virtual void OnDestroy(void);
00060     virtual void OnRegisterCommand(MCommandManager* pCommandManager);
00062     virtual bool OnCommand(MCommand* pCommand);
00064     virtual void OnRun(void);
00065 
00067     void OnInitialize();
00069     void OnLogin(MUID CommUID, MUID PlayerUID);
00071     void SetClientClockSynchronize(MUID& CommUID);
00072     void AssignPlayerCharacter(MUID& CommUID, MUID& PlayerUID);
00073     void ResponsePlayerCharacterAssign(MUID& CommUID, MObject* pObject);
00074     void ReleasePlayerCharacter(MUID& uid);
00075         
00077     void ResponseObjectUpdate(MUID& TargetUID, MObject* pObject);
00078     void ResponseCharacterBasicAttr(MUID& TargetUID, MUID& RequestUID);
00079 
00081     void ResponseCharacterSkillList(const MUID& CommUID, const MUID& CharUID);
00082 
00084     void ResponseInfo(MUID& Target);
00085     void ResponseMapList(MUID& Target);
00086 
00088     MObject* LoadCharacter(MUID& uid);
00090     void UnloadCharacter(MUID& uid);
00091 
00093     MObjectCharacter* FindCharacter(const MUID& uidChr);
00094 
00096     void BuildActionPipe(MObjectCharacter* pCharacter);
00097 
00099     int MessageSay(MUID& uid, char* pszSay);
00100 
00102     int ObjectAdd(MUID* pAllocUID, int nObjID, int nMapID, int nNodeID, rvector& Pos);
00104     int ObjectRemove(const MUID& uid, MObjectList::iterator* pNextItor);
00105 
00107     int ObjectMoveMode(const MUID& uid, int nMoveMode);
00108     int ObjectMode(const MUID& uid, int nMode);
00109     int ObjectState(const MUID& uid, int nState);
00110 
00112     //int ObjectMove(MUID& uid, unsigned long int nStartTime, unsigned long int nEndTime, rvector& StartPos, rvector& EndPos);
00114     int ObjectMove(MUID& uid, void* pPathArray);
00116     int ObjectAttack(MUID& uid, MUID& uidTarget);
00118     int ObjectSkill(const MUID& uid, const MUID& uidTarget, int nSkillID);
00120     void ResponseObjectList(MUID& Target, int nMapID, int nNodeID);
00122     void ResponseObjectList(MUID& Target, int nMapID);
00123 
00125     int ObjectEquipItem(MUID& TargetUID, MUID& ChrUID, MUID& ItemUID, MEquipmentSlot slot);
00126 
00128     MObjectItem* CreateObjectItem(int nItemDescID);
00129     MObjectItem* FindItem(MUID& ItemUID);       
00130 
00131     void ResponseEquipItem(MUID& TargetUID, MUID& ItemUID, MEquipmentSlot slot);
00132 
00134     int AdminCreateItem(MUID uid, unsigned int nItemIndex);
00136     void ResponseAdminCharacterInfo(MUID& TargetUID, MUID& RequestUID);
00137 
00139     virtual MUID UseUID(void);
00140 public:
00141     MZoneServer(void);
00142     virtual ~MZoneServer(void);
00143 
00145     static MZoneServer* GetInstance(void);
00146 
00148     unsigned long int GetGlobalClockCount(void);
00149 
00151     bool Create(int nPort);
00153     void Destroy(void);
00154 
00156     virtual int OnAccept(MCommObject* pCommObj);
00158     virtual int OnConnected(MUID* pTargetUID, MUID* pAllocUID, MCommObject* pCommObj);
00160     virtual int OnDisconnect(MCommObject* pCommObj);
00161 
00163     int ConnectToMaster(MCommObject* pCommObj);
00165     void DisconnectToMaster(void);
00166 
00168     void RequestUIDToMaster(int nSize);
00169 
00170     void DebugTest();
00171 
00172 public:
00174     MObject* GetObject(const MUID& uid);
00176     MObjectCharacter* GetObjectCharacter(const MUID& uid);
00178     MObjectItem* GetObjectItem(const MUID& uid);
00180     MObjectCharacter* GetPlayerByCommUID(const MUID& uid);
00181 
00183     void UpdateObjectRecognition(MObject* pObject);
00184 
00186     void RouteToListener(MObject* pObject, MCommand* pCommand);
00188     void RouteToAllClient(MCommand* pCommand);
00190     void RouteToAllExcludeSender(MUID& uidSender, MCommand* pCommand);
00192     void RouteToRegion(int nMapID, const rvector& Pos, float fRange, MCommand* pCommand);
00193 
00194     int SpawnObject(int nSpawnID, int nObjID, int nMapID, int nNodeID, rvector& Pos);
00195     
00196 };
00197 
00198 #define DEFAULT_REQUEST_UID_SIZE    10000   
00199 
00200 
00202 struct MMAPDESCRIPTION{
00203     char    szName[MMAP_NAME_LENGTH];
00204 };
00205 
00207 struct MMAPLIST{
00208     int                 nMapCount;  
00209     MMAPDESCRIPTION*    pMaps;      
00210 };
00211 
00213 unsigned long int ConvertLocalClockToGlobalClock(unsigned long int nLocalClock, unsigned long int nLocalClockDistance);
00215 unsigned long int ConvertGlobalClockToLocalClock(unsigned long int nGlobalClock, unsigned long int nLocalClockDistance);
00216 
00217 
00218 #endif


MAIET entertainment