#ifndef _GAMESERVER_INVENTORY_SLOTCONTAINER_H #define _GAMESERVER_INVENTORY_SLOTCONTAINER_H #pragma once // InventorySlotContainer.h: interface for the CInventorySlotContainer class. // ////////////////////////////////////////////////////////////////////// #include #include //================================================================================================== namespace nsSlot { ; // f100904.4L, same priority tabs require two phase searching like non-empty if overlapping item, // otherwise empty slot. // iterators of a sorted list that have ranges save to iterator array of the below container // used in an inversed select operation of the ItemQuery. struct SearchOffset { enum eSearchMode { eSearch_1st_FindOverlappingSlot = 0, eSearch_2nd_FindEmptySlot, eSearch_3rd_FindOverlappingSlot, eSearch_4th_FindEmptySlot, eSearch_5th_FindOverlappingSlot, eSearch_6th_FindEmptySlot, // eSearch_Mode_Counts }; SCItemSlotContainer::SLOT_LINEAR_LIST::const_iterator search_it[eSearch_Mode_Counts]; SCItemSlotContainer::SLOT_LINEAR_LIST::const_iterator search_end[eSearch_Mode_Counts]; }; class ItemFunctionToggle; }; //end of namespace //================================================================================================== class CInventorySlotContainer : public SCItemSlotContainer { private: typedef STLX_MAP OPTION_EFFECT_ITEMS; typedef OPTION_EFFECT_ITEMS::iterator OPTION_EFFECT_ITEMS_IT; typedef std::pair OPTION_EFFECT_ITEMS_INFO; public: CInventorySlotContainer(); virtual ~CInventorySlotContainer(); virtual RC::eSLOT_INSERT_RESULT InsertSlot(POSTYPE at_pos, SCSlot& IN rSlot); // ½½·Ô¿¡ °´Ã¼ Ãß°¡ virtual BOOL DeleteSlot(POSTYPE at_pos, SCSlot* pSlotOut); virtual void ClearAll(); void UpdateAttr(); //ItemManager::UpdateAttrForEquipItem½Ã¿¡¸¸... BOOL CheckEnableInsert(const SLOTCODE itemCode); virtual void OnInsert(SCSlot& IN rSlot); virtual void OnDelete(SCSlot& IN rSlot); virtual void OnUpdate(SCSlot& IN rSlot, int AddNum); void SetPlayer(Player* pPlayer) { m_pPlayer = pPlayer; } template< class STREAM_TYPE > BOOL GetTabTotalInfo(BYTE tab_index, JUST_INVENTORY_TOTAL_INFO* OUT pTotalInfo); //Àκ¥Å丮¶ô virtual BOOL ValidState(); virtual void SetValidState(BOOL v); //// The interface to get sorted slot list by configurations //const SLOT_LINEAR_LIST& GetConfiguredSlotList(const nsSlot::InventoryConfig::eInsertRule) const; // f100904.4L, The interface to get sorted slot list start/end offset by configurations void GetConfiguredSlotList(const nsSlot::InventoryConfig::eInsertRule insert_rule, nsSlot::SearchOffset* result_offset_info) const; // update all inventory insert rule configures void UpdateInventoryConfiguration(const nsSlot::InventoryConfig& configure); void ClearConfiguredSlotList(); private: BOOL CheckPrevInsert(SCItemSlot& rInsertSlot); void ApplyEffect(SCItemSlot& item_slot, const int changed_num, const int changed_total_count); protected: Player* m_pPlayer; BYTE m_TabNum; private: OPTION_EFFECT_ITEMS m_OptionEffectItems; // Àκ¥Å丮¿¡ Á¸ÀçÇϸ鼭 ÀåÂøÇÑ È¿°ú ³ªÅ¸³»´Â item SLOT_LINEAR_LIST* m_InsertRuleBaseSlotList[nsSlot::InventoryConfig::kMaxNumberOfInsertRules]; nsSlot::SearchOffset insert_rule_list_offset_[nsSlot::InventoryConfig::kMaxNumberOfInsertRules]; public: struct OptionEffectOperator; friend struct OptionEffectOperator; friend class nsSlot::ItemFunctionToggle; }; //-------------------------------------------------------------------------------------------------- // - ... ¾Æ ±×·¨Áö... template< class STREAM_TYPE > BOOL CInventorySlotContainer::GetTabTotalInfo(BYTE tab_index, JUST_INVENTORY_TOTAL_INFO* OUT pTotalInfo) { if(tab_index >= m_TabNum) return FALSE; pTotalInfo->m_Count = 0; JUST_INVENTORY_TOTAL_INFO::SLOT_TYPE* pSlot = pTotalInfo->m_Slot; POSTYPE start_pos = tab_index * MAX_INVENTORY_SLOT_PER_TAB; const POSTYPE upperbound = start_pos + MAX_INVENTORY_SLOT_PER_TAB; // type overflow ¹ß»ýÇÒ ¼ö Àִ ó¸®Áö¸¸, ¾îÁö°£È÷ ¸Á°¡ÁöÁö ¾Ê´Â ÇÑ ¹®Á¦ ¹ß»ý °¡´É¼ºÀÌ ³·À¸¹Ç·Î, // ³Ñ¾î°¡±â·Î ÇÑ´Ù. BYTE count = 0; for(POSTYPE i = start_pos; i < upperbound; ++i) { if(!IsEmpty(i)) { JUST_INVENTORY_TOTAL_INFO::SLOT_TYPE& rSlot = pSlot[count]; rSlot.m_Pos = i; SerializeItemStream(rSlot.m_Pos, &rSlot.m_Stream, SERIALIZE_LOAD); ++count; } } pTotalInfo->m_Count = count; } #endif //_GAMESERVER_INVENTORY_SLOTCONTAINER_H