#include "stdafx.h" #include "./ItemManager_ItemFunction.h" #include "ItemManager.h" #include "InventorySlotContainer.h" #include "ChaoState.h" #include "ImplementUtil.h" //================================================================================================== namespace nsSlot { ; //-------------------------------------------------------------------------------------------------- // @history // 09/06/25|~~~ // 09/07/16|shogen|enchant facility uniformity|<- Àû¿ëÇϱä ÇÏ´Â °É±î? // 09/10/22|namka199|rank facility improvement|(WARNING) ÀÎþƮ ÀÏ¿øÈ­ ÀÛ¾÷ÀÌ ÀϺΠ´©¶ôµÈ µí. // 10/01/28|waverix|code arrangement // |delete macros '__NA_676_PK_SYSTEM_IMPROVEMENT' // | '__NA_977_PREVENTION_PARTY_RETURN_ABUSE' // | '__NA_1339_ENCHANT_RENEWAL_EX' // | '__NA_1168_ADD_CONTENTS_ADD_LOG' // | '__BUG_35162_COMPOSE_BUG_BY_FULL_IVEN' // | '__CN_1194__ELITE_1_5_ITEM' // | '__MOD_CRYSTALIZE_MAX_CREATE_ITEM_NUM' // 10/02/23|hukim|remove warnings level 4... etc... // |(waverix: i think this changes have fragmentary knowledge) // 10/02/24|waverix|rollback to revision 46727| // |Çö¿õ¾¾, ´Ù½Ã ÇÑ ¹ø Àç°ËÅä ÇØº¸½Ã±¸·ª. ¹°·Ð °æ°í¸¦ ¹«½ÃÇÏ´Â °ÍÀº ³ª»Û °ÅÁö¸¸, // warning level 4¶ó´Â ³à¼®ÀÇ ÇÔÁ¤¿¡ ºüÁ® ¹«¸®ÇÑ º¯°æÀ» ¼öÇàÇÑ °É·Î »ý°¢µË´Ï´Ù. // 11/06/11|waverix|show the below description about the changes //-------------------------------------------------------------------------------------------------- // NOTE: sub-manager is implemented to decompose ItemManager. // this object has not extra members and virtual function table except the instance of ItemManager. BOOST_STATIC_ASSERT(sizeof(nsSlot::ItemFunctionSocket) == sizeof(ItemManager*) * 2); }; //end of namespace //================================================================================================== // CHANGES: f110611.1L, moved from ItemManager_Composite.cpp RC::eITEM_RESULT nsSlot::ItemFunctionSocket::FillSocket( const POSTYPE zard_position, const POSTYPE target_position) { if (root_->IsRestrictFunction(eFUNCTIONALRESTRICT_FILLSOCKET)) { return RC::RC_ITEM_UNUSABLE_FUNCTION; } if (root_->player_->GetChaoState().IsChaoState()) { return RC::RC_ITEM_UNABLE_FUNCTION_FOR_CHAOSTATE; } if (root_->ValidState() == false) { return RC::RC_ITEM_INVALIDSTATE; } if (root_->ValidPos(SI_INVENTORY, zard_position) == false) { return RC::RC_ITEM_INVALIDPOS; } if (root_->ValidPos(SI_INVENTORY, target_position) == false) { return RC::RC_ITEM_INVALIDPOS; } SCSlotContainer* const inventory = root_->GetItemSlotContainer(SI_INVENTORY); const SCItemSlot& zard_slot = static_cast(inventory->GetSlot(zard_position)); SCItemSlot& target_slot = static_cast(inventory->GetSlot(target_position)); const BASE_ITEMINFO* const zard_item = zard_slot.GetItemInfo(); const BASE_ITEMINFO* const target_item = target_slot.GetItemInfo(); // _NA_000251_20100727_SOCKET_SYSTEM if(zard_item->m_wType == eITEMTYPE_SOCKET_ZARD) { //xiaomi add FillSocket if(!target_item->IsWeapon() && !target_item->IsArmor()) { SUNLOG(eCRITICAL_LOG, _T("|%s|ÎïÆ·²»ÄܶԷÇÎäÆ÷»ò»¤¼×ʹÓã¡.|ÎïÆ·´úÂë = %u, ÎïÆ·ÖÖÀà = %d, ½ÇÉ«Ãû³Æ = %s|"), __FUNCTION__, target_item->m_Code, target_item->m_wType, root_->player_->GetCharName()); return RC::RC_ITEM_INVALID_CONDITION; } } if(zard_item->m_wType == eITEMTYPE_SOCKET_ZARD_RINGS) {//xiaomi add FillSocket if(!target_item->IsAccessory() && !target_item->IsSpecialAccessory()) { //xiaomi Ìí¼ÓÌØÊâ×°±¸ ÏâǶ SUNLOG(eCRITICAL_LOG, _T("|%s|ÎïÆ·²»ÄܶԷÇÎäÆ÷»ò»¤¼×ʹÓã¡.|ÎïÆ·´úÂë = %u, ÎïÆ·ÖÖÀà = %d, ½ÇÉ«Ãû³Æ = %s|"), __FUNCTION__, target_item->m_Code, target_item->m_wType, root_->player_->GetCharName()); return RC::RC_ITEM_INVALID_CONDITION; } } if (zard_item->m_wType != eITEMTYPE_SOCKET_ZARD && zard_item->m_wType != eITEMTYPE_SOCKET_ZARD_RINGS) { return RC::RC_ITEM_INVALID_CONDITION; } if (target_slot.CanUseMixture(MIXTURE_SOCKET_HOLE_FILL) == false) { return RC::RC_ITEM_NOT_MIXTURE; } /* if ((target_item->IsWeapon() || target_item->IsArmor()) == false) { return RC::RC_ITEM_INVALID_CONDITION; }*/ //xiaomi cancel FillSocket eSOCKET found_empty_socket = SOCKET_1; if (target_slot.ExistEmptySocket(found_empty_socket) == false) { return RC::RC_ITEM_FULLSOCKET; } SocketOptionParser* const socket_option_parser = SocketOptionParser::Instance(); //_NA_000251_20100727_SOCKET_SYSTEM // Àðµå ¿É¼ÇÀ» °Ë»çÇÑ´Ù. const SOCKETINDEX zard_option_index = zard_slot.GetExtendData(); const sSOCKET_OPTION* const socket_option = socket_option_parser->FindSocketOption(zard_option_index); if (socket_option == NULL) { SUNLOG(eCRITICAL_LOG, _T("|%s|»ðÀÔÇÏ·Á´Â ¿É¼Ç Á¤º¸¸¦ ãÀ» ¼ö ¾ø½À´Ï´Ù.|¿É¼Ç = %u, ij¸¯ÅÍÀ̸§ = %s|"), __FUNCTION__, zard_option_index, root_->player_->GetCharName()); return RC::RC_ITEM_INVALID_CONDITION; } // Àðµå µî±ÞÀ» °Ë»çÇÑ´Ù. if (target_slot.IsEnableFillSocketByGrade(socket_option->zard_grade) == false) { SUNLOG(eCRITICAL_LOG, _T("|%s|ÇØ´ç Àðµå µî±ÞÀº ´õ ÀÌ»ó »ðÀÔÇÒ ¼ö ¾ø½À´Ï´Ù.|Àðµåµî±Þ = %u, ij¸¯ÅÍÀ̸§ = %s|"), __FUNCTION__, socket_option->zard_grade, root_->player_->GetCharName()); return RC::RC_ITEM_SOCKET_FAILED_TO_FILL_BY_GRADE; } target_slot.SetSocketOption(found_empty_socket, zard_option_index); GAMELOG->LogFillSocket( root_->player_, zard_slot, target_slot, static_cast(socket_option->zard_grade), socket_option->item_option_kind, socket_option->option_value); root_->Lose(inventory, zard_position, 1); return RC::RC_ITEM_SUCCESS; } //-------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------- // CHANGES: f110611.1L, moved from ItemManager_Composite.cpp // ¼ÒÄÏ ±¸¸Û ¶Õ±â // ±âȹÀûÀÎ °í·Á»çÇ×ÀÌ À־ ¿ì¼± º¸·ù! RC::eITEM_RESULT nsSlot::ItemFunctionSocket::AddSocket(POSTYPE target_pos) { if (root_->IsRestrictFunction(eFUNCTIONALRESTRICT_ADDSOCKET)) { return RC::RC_ITEM_UNUSABLE_FUNCTION; } if (root_->player_->GetChaoState().IsChaoState()) { return RC::RC_ITEM_UNABLE_FUNCTION_FOR_CHAOSTATE; } return RC::RC_ITEM_SUCCESS; } // CHANGES: f110611.1L, moved from ItemManager_Use_EXCEPTION_PACKET.cpp // ¼Ò¸êÀÇ ·éÀ» »ç¿ëÇÏ¿© ¼ÒÄÏ¿¡ ¹ÚÈù Àðµå¸¦ Á¦°ÅÇÑ´Ù. RC::eITEM_RESULT nsSlot::ItemFunctionSocket::ExtractSocket( const POSTYPE extract_item_position, const POSTYPE zard_owner_position, const BYTE socket_number) { if (root_->IsRestrictFunction(eFUNCTIONALRESTRICT_EXTRACTSOCKET)) { return RC::RC_ITEM_UNUSABLE_FUNCTION; } if (root_->player_->GetChaoState().IsChaoState()) { return RC::RC_ITEM_UNABLE_FUNCTION_FOR_CHAOSTATE; } if (!root_->ValidState()) { return RC::RC_ITEM_INVALIDSTATE; } if (!root_->ValidPos(SI_INVENTORY, extract_item_position)) { return RC::RC_ITEM_NOT_INVENTORY; } if (!root_->ValidPos(SI_INVENTORY, zard_owner_position)) { return RC::RC_ITEM_NOT_INVENTORY; } SCSlotContainer* const inventory = root_->GetItemSlotContainer(SI_INVENTORY); const SCItemSlot& extract_item_slot = static_cast(inventory->GetSlot(extract_item_position)); const BASE_ITEMINFO* const extract_item = extract_item_slot.GetItemInfo(); const RC::eITEM_RESULT can_use_result = root_->player_->CanUseItem(extract_item); if (can_use_result != RC::RC_ITEM_SUCCESS) { return can_use_result; } SCItemSlot& zard_owner_slot = static_cast(inventory->GetSlot(zard_owner_position)); if (zard_owner_slot.CanUseMixture(MIXTURE_SOCKET_EXTRACT) == false) { return RC::RC_ITEM_NOT_MIXTURE; } // Àðµå ÃßÃâ ¾ÆÀÌÅÛÀÎÁö °Ë»çÇÑ´Ù. if ((extract_item->m_wType != eITEMTYPE_SOCKETEXTRACT) || (extract_item_slot.GetNum() == 0)) { SUNLOG(eCRITICAL_LOG, _T("|%s|Àðµå ÃßÃâ ¾ÆÀÌÅÛÀÌ ¾Æ´Õ´Ï´Ù.|¾ÆÀÌÅÛŸÀÔ = %u, ij¸¯ÅÍÀ̸§ = %s|"), __FUNCTION__, extract_item->m_wType, root_->player_->GetCharName()); return RC::RC_ITEM_SOKET_NOT_RUNE_ITEM; } // Àðµå¸¦ ÃßÃâÇÒ ¼ÒÄÏ ¹øÈ£¸¦ °Ë»çÇÑ´Ù. if (socket_number >= zard_owner_slot.GetSocketNum()) { SUNLOG(eCRITICAL_LOG, _T("|%s|À¯È¿ÇÑ ¼ÒÄϹøÈ£°¡ ¾Æ´Õ´Ï´Ù.|¼ÒÄϹøÈ£ = %u, ij¸¯ÅÍÀ̸§ = %s|"), __FUNCTION__, socket_number, root_->player_->GetCharName()); return RC::RC_ITEM_INVALID_SOCKET_NUM; } const eSOCKET extract_socket = static_cast(socket_number); // _NA_000251_20100727_SOCKET_SYSTEM // ÃßÃâÇÒ Àðµå°¡ Á¸ÀçÇÏ´ÂÁö °Ë»çÇÑ´Ù. const sSOCKET_OPTION* const socket_option = zard_owner_slot.GetSocketOption(extract_socket); if (socket_option == NULL) { SUNLOG(eCRITICAL_LOG, _T("|%s|ÃßÃâÇÒ Àðµå°¡ ¼ÒÄÏ¿¡ Á¸ÀçÇÏÁö ¾Ê½À´Ï´Ù.|¼ÒÄϹøÈ£ = %u, ij¸¯ÅÍÀ̸§ = %s|"), __FUNCTION__, extract_socket, root_->player_->GetCharName()); return RC::RC_ITEM_SOCKET_HAS_NOT_OPTION; } // ÃßÃâÇÑ Àðµå°¡ ÆÄ±«µÇÁö ¾Ê¾ÒÀ¸¸é ÃßÃâÇÑ Àðµå¸¦ ¾ò´Â´Ù. enum { kMaxDestroyRatio = 1000 }; const int destroy_ratio = random(1, kMaxDestroyRatio); if (extract_item->zard_success_per >= destroy_ratio) { typedef util::internal::ItemCompositionOrDecompositionReward ZardRewards; ZardRewards zard_rewards; if (zard_rewards.Init(root_->player_, ZardRewards::kItemCodeReward) == false) { SUNLOG(eCRITICAL_LOG, _T("|%s|ÃßÃâÇÑ Àðµå º¸»óÀ» ÃʱâÈ­ Çϴµ¥ ½ÇÆÐ Çß½À´Ï´Ù.|ij¸¯ÅÍÀ̸§ = %s|"), __FUNCTION__, root_->player_->GetCharName()); return RC::RC_ITEM_INVALIDSTATE; } ZardRewards::ItemReward zard_reward; { zard_reward.item_code = socket_option->item_code; zard_reward.number_of_item = 1; zard_reward.zard_option = socket_option->index; } if (zard_rewards.AddItemReward(zard_reward) == false) { SUNLOG(eCRITICAL_LOG, _T("|%s|ÃßÃâÇÑ Àðµå º¸»óÀ» Ãß°¡Çϴµ¥ ½ÇÆÐ Çß½À´Ï´Ù.|ij¸¯ÅÍÀ̸§ = %s|"), __FUNCTION__, root_->player_->GetCharName()); RC::RC_ITEM_INVALIDSTATE; } INVENTORY_TOTAL_INFO modified_inven; { modified_inven.m_InvenCount = 0; modified_inven.m_TmpInvenCount = 0; } const RC::eITEM_RESULT obtain_result = zard_rewards.ObtainRewardToInventory(ZardRewards::kDoNotUseLog, modified_inven); if (obtain_result != RC::RC_ITEM_SUCCESS) { SUNLOG(eCRITICAL_LOG, _T("|%s|ÃßÃâÇÑ Àðµå¸¦ ¾ò´Âµ¥ ½ÇÆÐ Çß½À´Ï´Ù.|ij¸¯ÅÍÀ̸§ = %s|"), __FUNCTION__, root_->player_->GetCharName()); return obtain_result; } MSG_CG_ITEM_OBTAIN_ITEM_CMD zard_obtain_cmd; zard_obtain_cmd.m_tagInventory = modified_inven; root_->player_->SendPacket(&zard_obtain_cmd, zard_obtain_cmd.GetSize()); } // ·Î±×¸¦ ±â·ÏÇÑ´Ù. GAMELOG->LogItemExtrackSocket( root_->player_, zard_owner_slot, extract_item->m_wType, extract_item_slot.GetNum()); GAMELOG->LogItem(ITEM_USE, root_->player_, &extract_item_slot); // ÄðŸÀÓÀ» ¼³Á¤ÇÑ´Ù. const WORD cool_time = extract_item->m_wCoolTimeType; root_->Lose(inventory, extract_item_position, 1); root_->player_->ResetUseItem(cool_time); //_NA_000251_20100727_SOCKET_SYSTEM zard_owner_slot.SetSocketOption(extract_socket, SocketOptionParser::kEmptySocketOptionIndex); return RC::RC_ITEM_EXTRACTSOCKET_SUCCESS; }