#include "SunClientPrecompiledHeader.h" #include "RiderContainer.h" #include "Character.h" #include "ObjectManager.h" #include "SlotKeyGenerator.h" #include "Rider.h" #include "InterfaceManager.h" #include "GlobalFunc.h" #include "SCItemSlot.h" #include "Hero.h" #ifdef _NA_007732_20141024_RIDER_MOVESPEED_SYNC #include "RidingInfoParser.h" #include "SetItemOptionInfoParser.h" #endif //_NA_007732_20141024_RIDER_MOVESPEED_SYNC //---------------------------------------------------------------------------- /** */ WzID RiderContainer::m_wzId[RIDER_MAX] = { StrToWzID("B001"),//RIDER_SLOT_01(BODY) StrToWzID("B002"),//RIDER_SLOT_02(BOOTS) StrToWzID("B003"),//RIDER_SLOT_03(HELM) StrToWzID("BT00"),//RIDER_BTN_LEFT StrToWzID("BT01"),//RIDER_BTN_RIGHT StrToWzID("B999"),//RIDER_BTN_EXIT StrToWzID("T999"),//RIDER_BTN_TEXT StrToWzID("PI00"),//RIDER_SLOT_VIEW }; RiderContainer::RiderContainer() { m_dwOwnerKey = 0; Init(MAX_RIDER_SLOT, SI_RIDER); #ifdef _NA_007732_20141024_RIDER_MOVESPEED_SYNC rider_speed_ = 0; dwRiderCode = 0; #endif //_NA_007732_20141024_RIDER_MOVESPEED_SYNC } RiderContainer::~RiderContainer() { Release(); } //------------------------------------------------------------------------------------------- /** ½ºÆ®¸²À» ÅëÇØ¼­ ½½·ÔÀ» À籸ÃàÇÑ´Ù ¶óÀÌ´õ¾ÆÀÌÅÛ(SCItemSlot)¿äÇϳª¿¡ º¯¼ö½ÄÀÇ·Î 3°³ÀÇ ¶óÀÌ´õÆÄÃ÷°¡ Æ÷ÇԵǾîÀÖ´Ù. ¿ä¾ÆÀÌÅÛÀ» ³Ö¾î¼­ ÆÄÃ÷Á¤º¸¸¦ ²ôÁý¾î ³»¾ßµÈ´Ù. */ DWORD RiderContainer::CopyItem(SCItemSlot& RiderSlot) { //ÆÄÃ÷º¯°æ½Ã ±âÁ¸ ÄÁÅ×À̳ʸ¦ ÀüºÎ ³¯¸°´Ù. Clear(); #ifdef _NA_007732_20141024_RIDER_MOVESPEED_SYNC // Çì´õ·Î À̵¿ #else DWORD dwRiderCode = 0; #endif //_NA_007732_20141024_RIDER_MOVESPEED_SYNC Player *pPlayer = (Player *)g_ObjectManager.GetObject(m_dwOwnerKey); if(!pPlayer) { return 0; } if(RiderSlot.IsRiderItem()) { dwRiderCode = RiderSlot.GetItemInfo()->m_wSkillCode; //eRIDER_PARTS_POS::StartIndex(91)ºÎÅÍ ¶óÀÌ´õPosÀÌ´Ù for(int i=0;iInsertSlot( i, ItemSlot); } } else { //assert(!"ÆÄÃ÷¾ÆÀÌÅÛ»ý¼º½ÇÆÐ"); _asm nop; } } } else { assert(!"¶óÀÌ´õ ¾ÆÀÌÅÛÀÌ ¾Æ´Õ´Ï´Ù."); } return dwRiderCode; } //------------------------------------------------------------------------------------------- /** ¿ÜÇü¾÷µ¥ÀÌÆ®¸¦ÇØÁØ´Ù. */ void RiderContainer::RefreshApperance() { Player *pPlayer =(Player *)g_ObjectManager.GetObject(m_dwOwnerKey); if(pPlayer) { for(int i=0;iIsRiderPartsItem()) { pPlayer->AttachRiderPart(i,ItemSlot.GetItemInfo()->m_Code); pPlayer->RiderSubtype(i,ItemSlot.GetEnchant()); } else { pPlayer->DetachRiderPart(i); } } } } //------------------------------------------------------------------------------------------- /** */ void RiderContainer::Clear() { for ( POSTYPE pos = 0; pos < MAX_RIDER_SLOT; ++pos ) { if ( !IsEmpty(pos) ) { DeleteSlot(pos, NULL); } } } //------------------------------------------------------------------------------------------- /** */ void RiderContainer::Release() { Clear(); } //---------------------------------------------------------------------------- /** ½½·Ô»ðÀÔ */ RC::eSLOT_INSERT_RESULT RiderContainer::InsertSlot(POSTYPE AtPos, SCSlot& rSlot) { //slot_safe_code:¾ÈÀüÇÑ ½½·Ôüũ ±¸¹®(»ðÀÔ) if (ValidPos(AtPos) == false) { return RC::RC_INSERT_SLOT_FAILED; } // ½½·Ô¿¡ ³ÖÀ½ RC::eSLOT_INSERT_RESULT eInsertSlotResult = SCSlotContainer::InsertSlot( AtPos, rSlot ); SCSlot &refSlot = GetSlot(AtPos); refSlot.SetSerial(g_SlotKeyGenerator.GetKey()); return eInsertSlotResult; } //---------------------------------------------------------------------------- /** ½½·ÔÁ¦°Å */ BOOL RiderContainer::DeleteSlot( POSTYPE AtPos, SCSlot * pSlotOut ) { //slot_safe_code:¾ÈÀüÇÑ ½½·Ôüũ ±¸¹®(»èÁ¦) if ((ValidPos(AtPos) == false) || IsEmpty(AtPos)) { return FALSE; } SCItemSlot & rItemSlot = (SCItemSlot & )GetSlot(AtPos); g_SlotKeyGenerator.Restore((DWORD)rItemSlot.GetSerial()); SCSlotContainer::DeleteSlot(AtPos, pSlotOut ); return TRUE; } #ifdef _NA_007732_20141024_RIDER_MOVESPEED_SYNC void RiderContainer::RefreshRiderSpeed() // Å»°Í À̵¿¼Óµµ °»½Å { rider_speed_ = 100; // ÃÖÁ¾ °á°ú int base_speed = 0; // ±âº» ÀÌ¼Ó int parts_speed = 0; // ÆÄÃ÷ ÀÌ¼Ó int setitem_increase = 0; // Ç®¼¼Æ®¿É¼Ç Áõ°¡·® // ±âº» ÀÌ¼Ó const sRiderInfo* rider_info = RidingInfoParser::Instance()->GetInfo(dwRiderCode); if (rider_info) { base_speed = rider_info->set_speed_; } // ÆÄÃ÷ ÀÌ¼Ó Player *player = static_cast(g_ObjectManager.GetObject(m_dwOwnerKey)); if (player == NULL) { return; } int is_pcroom_player = !!(player->GetPCBangMode()); WORD setitem_group = 0; BYTE setitem_count = 1; for (int i = 0; i < MAX_RIDER_SLOT; ++i) { SCItemSlot& item_slot = (SCItemSlot&)GetSlot(i); const BASE_ITEMINFO* item_info = item_slot.GetItemInfo(); //½½·Ô¿¡ ¸Õ°¡°¡ µé¾îÀÖ³× if (item_info && item_info->IsRiderPartsItem()) { int loop_count = is_pcroom_player ? 2 : 1; for (int loop = 0; loop < loop_count; ++loop) { const BASE_ITEMINFO::OptionIndexes* _option_indexs = \ (loop == 0) ? &item_info->m_wOptionIndex : &item_info->m_wPCOptionIndex; const BASE_ITEMINFO::OptionTypes* _option_types = \ (loop == 0) ? &item_info->m_byOptionType : &item_info->m_byPCOptionType; const BASE_ITEMINFO::OptionValues* _option_values = \ (loop == 0) ? &item_info->m_iOptionValue : &item_info->m_iPCOptionValue; const BASE_ITEMINFO::OptionIndexes& option_indexs = *_option_indexs; const BASE_ITEMINFO::OptionTypes& option_types = *_option_types; const BASE_ITEMINFO::OptionValues& option_values = *_option_values; for (int i = 0; i < BASE_ITEMINFO::_MAX_OPTION_NUM; ++i) { if ((option_indexs[i] == 0) || (option_values[i] == 0) || (option_indexs[i] >= _countof(g_ITEM_OPTION))) { continue; } const eATTR_TYPE attr_type = g_ITEM_OPTION[option_indexs[i]]; if (attr_type != eATTR_MOVE_SPEED) { continue; } if (option_types[i] != 1) // °íÁ¤¼öÄ¡°ªÀÌ ¾Æ´Ï¸é ÀÏ´Ü ÆÐ½º { continue; } parts_speed += option_values[i]; } } //¼¼Æ® ¾ÆÀÌÅÛüũ (MAX_RIDER_SLOT°¡ 3ÀÏ °æ¿ì¿¡¸¸ ·ÎÁ÷ÀÌ ¸ÂÀ½) SUN_ASSERT(MAX_RIDER_SLOT==3); for (int j = i+1; j < MAX_RIDER_SLOT; ++j) { SCItemSlot& item_slot2 = (SCItemSlot&)GetSlot(j); const BASE_ITEMINFO* item_info2 = item_slot2.GetItemInfo(); //½½·Ô¿¡ ¸Õ°¡°¡ µé¾îÀÖ³× if (item_info2 && item_info2->IsRiderPartsItem()) { if ((item_info->set_group_code == item_info2->set_group_code) && (1 == item_info->m_bySetOptionType) && (1 == item_info2->m_bySetOptionType)) { // °°Àº ¼¼Æ®¾ÆÀÌÅÛÀ̸é ++setitem_count; setitem_group = item_info->set_group_code; } } } }//if (item_info && item_info->IsRiderPartsItem()) } //¼¼Æ®¿É¼Ç Àû¿ë (¶óÀÌ´õ ¼¼Æ®¿É¼ÇÀº Ç®¼¼Æ® ¿É¼Ç¸¸ Àû¿ë. ±×·±°¡º¸³×¿ä?) if (setitem_group != 0) { SETITEM_OPTION_INFO* option_info = SetItemOptionInfoParser::Instance()->Find(setitem_group); if (option_info && (option_info->m_byActiveFullOptionNum <= setitem_count)) { for (int i = 0; i < MAX_SETITEM_FULL_OPTION; ++i) { if ((option_info->m_FullOption[i].m_byOptionKind == 0) || (option_info->m_FullOption[i].m_nOption == 0) || (option_info->m_FullOption[i].m_byOptionKind >= _countof(g_ITEM_OPTION))) { continue; } const eATTR_TYPE attr_type = g_ITEM_OPTION[option_info->m_FullOption[i].m_byOptionKind]; if (attr_type != eATTR_MOVE_SPEED) { continue; } if (option_info->m_FullOption[i].m_byUseType != 1) // °íÁ¤¼öÄ¡°ªÀÌ ¾Æ´Ï¸é ÀÏ´Ü ÆÐ½º { continue; } setitem_increase += option_info->m_FullOption[i].m_nOption; } } } // ÃÖÁ¾ °á°ú rider_speed_ = base_speed + parts_speed + setitem_increase; } #endif //_NA_007732_20141024_RIDER_MOVESPEED_SYNC