#ifndef _CCREAUTRE_MANAGER_H_ #define _CCREAUTRE_MANAGER_H_ #pragma once #pragma warning(disable:4800) #include #include #include #include #include #include #include #include #include #include "CreatureStructure.h" // Àü¹æ ÂüÁ¶ class CCreature; class CAggresiveCreature; class CCharacter; class CMonster; class CNPC; class CSiegeObject; namespace Item { class CShopContainer; }; // SingleThread Ŭ·¡½º class CCreatureManager { private: // Map¿¡¼­ second ¸â¹ö·Î ÇÔ¼öÀÚ ½ÇÇà template class CProcessSecond : public std::unary_function { public: CProcessSecond(FnSecondProcess& fnSecondProcess) : m_fnSecondProcess(fnSecondProcess) { } bool operator() (PairType& Pair) { m_fnSecondProcess(Pair.second); return true; } protected: FnSecondProcess& m_fnSecondProcess; }; public: typedef std::map, boost::fast_pool_allocator > > CharacterMap; typedef std::map, boost::fast_pool_allocator > > MonsterMap; typedef std::map, boost::fast_pool_allocator > > AdminMonsterUIDMap; // < KindID, NextUID(»óÀ§16ºñÆ®) > typedef std::map, boost::fast_pool_allocator > > NPCMap; // ÀÌ°Ç boost::pool¾²Áö ¸» °Í. typedef std::list CharacterList; typedef std::multimap, boost::fast_pool_allocator > > CharacterMultimap; typedef std::map, boost::fast_pool_allocator > > SiegeObjectMap; static CCreatureManager& GetInstance(); enum eAdminMonster { NO_BLANK_UID = 0x8FFF, INIT_UID = 0x8FFE }; // -------------------------------------------------------------------------------------------- // interface // ij¸¯ÅÍ »ý¼º ¹× »èÁ¦¸¦ À§ÇÑ Wrapper. CCharacter* CreateCharacter(unsigned long dwCID, unsigned long dwSessionID); void DeleteCharacter(CCharacter* lpCharacter); // Creature¸¦ ¸Å´ÏÀú¿¡ µî·Ï ¹× »èÁ¦. bool AddCreature(CCreature* lpCreature); bool DeleteCreature(unsigned long dwCID); CCreature* GetCreature(unsigned long dwCID); CAggresiveCreature* GetAggresiveCreature(unsigned long dwCID); CNPC* GetNPC(unsigned long dwCID); CMonster* GetMonster(unsigned long dwCID); CSiegeObject* GetSiegeObject(unsigned long dwCID); CCharacter* GetCharacter(unsigned long dwCID); CCharacter* GetCharacter(const char* szCharacterName); void DestoryCharacterList(); void DestoryMonsterList(); void DestorySiegeObjectList(); void DestoryNPCList(); void DestroyAll(); void EnqueueLogout(CCharacter* lpCharacter); bool CancelLogout(CCharacter* lpCharacter); bool ProcessCharacterLogout(void); void ProcessSummonMonsterDead(void); void SetNationToCastleNPC(unsigned long dwCastleID, unsigned char cNation); template inline void ProcessAllCharacter(FnCharacterProcess fnCharacterProcess) { std::for_each(m_CharacterMap.begin(), m_CharacterMap.end(), CProcessSecond(fnCharacterProcess)); } template inline void ProcessAllMonster(FnMonsterProcess fnMonsterProcess) { std::for_each(m_MonsterMap.begin(), m_MonsterMap.end(), CProcessSecond(fnMonsterProcess)); } template inline void ProcessAllNPC(FnNPCProcess fnNPCProcess) { std::for_each(m_NPCMap.begin(), m_NPCMap.end(), CProcessSecond(fnNPCProcess)); } unsigned short GetCharacterNum(unsigned char cNation) { return m_wCharacterNum[cNation]; } unsigned short GetCharacterNum(void) { return static_cast(m_CharacterMap.size()); } unsigned short GetMonsterNum(void) { return static_cast(m_MonsterMap.size()); } unsigned short GetSiegeObjectNum(void) { return static_cast(m_SiegeObjectMap.size()); } unsigned short GetAvailableMonsterUID(unsigned short wKindID); // ¸ó½ºÅ͸¦ »ý¼ºÇÒ¶§ CID°¡ °ãÄ¡Áö ¾Ê°Ô Çϱâ À§Çؼ­ È£ÃâÇÏ´Â ÇÔ¼ö bool IsSummonee(unsigned long dwCID); Item::CShopContainer* GetShopContainer(unsigned long dwCID); void SendAllCharacter(const char* szBuffer, unsigned long dwLength, unsigned char cCMD_In, bool bSendAllMap = true); void SendFindPartyMsg(unsigned long dwSenderCID, const char* szCompressedPacket, unsigned long dwPacketSize); // bAll ÀÌ true ÀÌ¸é ¸ðµÎ, // false À̸é MapIndex °¡ 0 ÀÎ Character µé¸¸... bool ChangeCharacterName(unsigned long dwCID, const char* szChangedName); // ±æµåÀü°ú ±¹°¡Àü ÀüÀï ½Ã°£½Ã¿¡ Á¸À̵¿ ó¸® ÇÔ¼ö void MoveCharacterToGuildWarZone(unsigned char cType, bool bOn = true); void MoveCharacterToRealmWarZone(unsigned char cType, bool bOn = true); // ±æµåÀü°ú ±¹°¡Àü ÀüÀïÀÌ ³¡³­ÈÄ Ç÷¡±× ²ô±â void ClearGuildWarInstanceFlag(); void ClearRealmWarInstanceFlag(); // -------------------------------------------------------------------------------------------- // ±¹°¡ ÀüÀï ¼®»ó °ü·Ã public: // ±¹°¡Àü ¼®»ó ÃʱⰪ ¼ÂÆÃ ¹× »óÅ ÃʱâÈ­ ÇÔ¼ö void SetRealmStatueInfo(unsigned long dwIndex, unsigned short wKID, unsigned long dwLostHP); void InitRealmStatue(); void InitRealmLoadingStatue(); bool SendRealmStatueDisplayInfo(CSendStream& SendStream); bool SendRealmStatueDisplayInfo(unsigned long dwIndex = 0, bool bAttacked = false); void CalculateRealmStatueEnchantInfo(); void AddRealmStatueEnchant(CCharacter* lpCharacter); void AddRealmStatueEnchant(); void ClearRealmStatueEnchant(); private: int GetRealmStatueNum(); struct sRealmEnchant { unsigned char m_cHPPercent; unsigned char m_cMPPercent; unsigned char m_cExpPercent; unsigned char m_cDropRate; }; sRealmEnchant m_RealmEnchantInfo[CClass::MAX_RACE]; // -------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------- // °ø¼ºÀü º¸»ó °ü·Ã private: void AddCastleBonus(); // -------------------------------------------------------------------------------------------- private: CCreatureManager(); ~CCreatureManager(); NPCMap m_NPCMap; MonsterMap m_MonsterMap; AdminMonsterUIDMap m_AdminMonsterUIDMap; CharacterMap m_CharacterMap; CharacterMultimap m_CharacterNameMap; // CSiegeObjectMgr °¡ ´ëºÎºÐÀÇ °ü¸®¸¦ Çϰí, // CCreatureMgr Àº ¸®½ºÆ®¸¸ °¡Áö°í ÀÖÀ½ SiegeObjectMap m_SiegeObjectMap; CharacterList m_LogoutWaitList; boost::pool<> m_CharacterPool; // -------------------------------------------------------------------------------------------- // ¿¤¸®Æ® º¸³Ê½º °ü·Ã public: enum FightResult { WIN = 0, LOSE = 1 }; void CalculateEliteBonus(unsigned short *usPeopleNum); void SetEliteBonus(EliteBonus::EliteBonusData eliteBonus); const EliteBonus::EliteBonusData& GetEliteBonus(void) { return m_EliteBonus; } void SetAutoBalance(bool bAutoBalance) { m_bAutoBalance = bAutoBalance; } bool GetAutoBalance(void) { return m_bAutoBalance; } float GetFameBonus(CClass::RaceType eRace, FightResult eResult); private: EliteBonus::EliteBonusData m_EliteBonus; bool m_bAutoBalance; // -------------------------------------------------------------------------------------------- // ¿ùµå ¿þÆù °ü·Ã public: void AddWorldWeaponEnchant(CAggresiveCreature* lpWeapon, unsigned char cNation); void ClearWorldWeaponEnchant(); void ProcessWorldWeaponDamage(int iX, int iZ, unsigned char cUpgradeStep); // -------------------------------------------------------------------------------------------- // ¹èƲ ±×¶ó¿îµå °ü·Ã public: void PushRespawnQueue(CCharacter* lpCharacter, unsigned char cPointNumber); void PopRespawnQueue(CCharacter* lpCharacter); void ProcessRespawnQueue(void); bool SendRespawnQueue(unsigned long dwCID); unsigned char GetBonusTurn(const unsigned short wMapIndex); void ProcessBattleGround(); enum StatueConst { STATUE_REST_TIME_1ST_START = 25, // ¼­¹ö ½Ã°£À¸·Î 25ºÐ°ú 55ºÐºÎÅÍ 5ºÐ°£ ¼®»óÀÌ ¾ø¾Ö°í, STATUE_REST_TIME_1ST_END = 29, // ¸ðµç ij¸¯Å͵éÀ» ÃÊ·¾Á¸À¸·Î ¸®½ºÆù ½ÃŲ´Ù. STATUE_REST_TIME_2ND_START = 55, STATUE_REST_TIME_2ND_END = 59, STATUE_RESPAWN_TIME_1ST = 0, // ¼­¹ö ½Ã°£À¸·Î 0ºÐ°ú 30ºÐ¿¡´Â ¼®»óÀÌ ÃʱâÈ­ »óÅ·Π¼ÒȯµÇ¾î¾ß ÇÑ´Ù. STATUE_RESPAWN_TIME_2ND = 30, }; private: bool m_bRest; // ¼®»óÀÌ Çϳªµµ ¾ø´Â È޽Ľð£Àΰ¡? private: enum RespawnPoint { POINT_HUMAN1 = 0, POINT_HUMAN2 = 1, POINT_HUMAN3 = 2, POINT_AKHAN1 = 3, POINT_AKHAN2 = 4, POINT_AKHAN3 = 5, MAX_POINT_NUM = 6 }; struct BattleGroundRespawnInfo { CCharacter* m_lpCharacter; Position m_RespawnPos; long m_lLeftTime; BattleGroundRespawnInfo() : m_lpCharacter(NULL), m_lLeftTime(0) { } BattleGroundRespawnInfo(CCharacter* lpCharacter, Position Pos, long lTime) : m_lpCharacter(lpCharacter), m_RespawnPos(Pos), m_lLeftTime(lTime) { } }; typedef std::list RespawnQueue; RespawnQueue m_lstRespawn[MAX_POINT_NUM]; Position m_RespawnPoint[MAX_POINT_NUM]; unsigned long m_dwLastUpdateTime; unsigned short m_wCharacterNum[CClass::MAX_RACE]; }; #endif