#include "StdAfx.h" #include ".\QuickStyleManager.h" /* // CHANGES, f100826.2L, removed #include ".\SlotManager.h" #include ".\SCQuickStyleSlot.h" #include ".\SCQuickStyleSlotContainer.h" #include "StyleQuickRegistInfoParser.h" #include "SCSkillSlot.h" #include "Player.h" #include "SCSkillSlotContainer.h" #include "SkillInfoParser.h" #include QuickStyleManager::QuickStyleManager(void) { } QuickStyleManager::~QuickStyleManager(void) { } VOID QuickStyleManager::Release() { } VOID QuickStyleManager::Init( SlotManager * pMGR ) { m_pPlayer = pMGR->m_pPlayer; m_ppSlotContainer = pMGR->m_pSlotContainer; m_pSlotMGR = pMGR; } SCQuickStyleSlotContainer * QuickStyleManager::GetQuickStyleSlotContainer() { return (SCQuickStyleSlotContainer *)m_pSlotMGR->GetSlotContainer(SI_STYLE); } VOID QuickStyleManager::SerializeStyleStream( POSTYPE pos, STYLESTREAM * IN pStream, eSERIALIZE eType ) { if( eType == SERIALIZE_LOAD ) { SCQuickStyleSlot & rSlot = static_cast(GetQuickStyleSlotContainer()->GetSlot(pos)); rSlot.CopyOut(*pStream); } else if( eType == SERIALIZE_STORE ) ((SCQuickStyleSlotContainer*)GetQuickStyleSlotContainer())->InsertSlot( pos, *pStream ); } RC::eSTYLE_RESULT QuickStyleManager::Link( SLOTCODE code, POSTYPE toPos ) { if( !m_pSlotMGR->ValidState() ) return RC::RC_STYLE_INVALIDSTATE; if( !m_pSlotMGR->ValidPos( SI_STYLE, toPos, FALSE ) ) return RC::RC_STYLE_INVALIDPOS; SCSlotContainer * pContainer = GetQuickStyleSlotContainer(); if( !pContainer->IsEmpty(toPos) ) return RC::RC_STYLE_INVALIDPOS; // ¾î¶² °ÍÀ» ¿Ã¸± ¼ö ÀÖ´ÂÁö¿¡ ´ëÇÑ Ã¼Å© ÇÊ¿ä! SCQuickStyleSlot slot; slot.SetOrgCode(code); pContainer->InsertSlot(toPos, slot); return RC::RC_STYLE_SUCCESS; } RC::eSTYLE_RESULT QuickStyleManager::Unlink( POSTYPE atPos ) { if( !m_pSlotMGR->ValidState() ) return RC::RC_STYLE_INVALIDSTATE; if( !m_pSlotMGR->ValidPos( SI_STYLE, atPos ) ) return RC::RC_STYLE_INVALIDPOS; SCSlotContainer * pContainer = GetQuickStyleSlotContainer(); pContainer->DeleteSlot( atPos, NULL ); return RC::RC_STYLE_SUCCESS; } RC::eSTYLE_RESULT QuickStyleManager::Move( POSTYPE fromPos, POSTYPE toPos ) { if( !m_pSlotMGR->ValidState() ) return RC::RC_STYLE_INVALIDSTATE; if( !m_pSlotMGR->ValidPos( SI_STYLE, fromPos ) ) return RC::RC_STYLE_INVALIDPOS; if( !m_pSlotMGR->ValidPos( SI_STYLE, toPos, FALSE ) ) return RC::RC_STYLE_INVALIDPOS; SCSlotContainer *pContainer = GetQuickStyleSlotContainer(); SCQuickStyleSlot FromSlot; pContainer->DeleteSlot( fromPos, &FromSlot ); if( FALSE != pContainer->IsEmpty( toPos ) ) { // ÇÑ ¹æÇâ À̵¿ RC::eSLOT_INSERT_RESULT rt = pContainer->InsertSlot( toPos, FromSlot ); if( RC::RC_INSERT_SLOT_SUCCESS != rt ) { pContainer->InsertSlot( fromPos, FromSlot ); return SlotInsertResultConverter::ConvertToeStyleResult(rt); } } else { // ±³È¯ SCQuickStyleSlot ToSlot; pContainer->DeleteSlot( toPos, &ToSlot ); RC::eSLOT_INSERT_RESULT rt = pContainer->InsertSlot( fromPos, ToSlot ); if( RC::RC_INSERT_SLOT_SUCCESS != rt ) { //rollback pContainer->InsertSlot( fromPos, FromSlot ); pContainer->InsertSlot( toPos, ToSlot ); return SlotInsertResultConverter::ConvertToeStyleResult(rt); } rt = pContainer->InsertSlot( toPos, FromSlot ); if( RC::RC_INSERT_SLOT_SUCCESS != rt ) { //rollback pContainer->DeleteSlot( fromPos, NULL ); pContainer->InsertSlot( fromPos, FromSlot ); pContainer->InsertSlot( toPos, ToSlot ); return SlotInsertResultConverter::ConvertToeStyleResult(rt); } } return RC::RC_STYLE_SUCCESS; } class QuickStyleUpdate { QuickStyleManager* m_pStyleManager; BASE_StyleQuickRegistInfo* m_pStyleQuickInfo; public: QuickStyleUpdate( QuickStyleManager *pStyleManager, BASE_StyleQuickRegistInfo *pStyleQuickInfo ) : m_pStyleManager(pStyleManager), m_pStyleQuickInfo(pStyleQuickInfo) {} VOID operator () ( SCSlot* pSlot ) { SCSkillSlot *pSkillSlot = (SCSkillSlot*)pSlot; ROOT_SKILLINFO *pBaseSkillInfo = SkillInfoParser::Instance()->GetInfo( pSkillSlot->GetCode() ); if( !pBaseSkillInfo ) { SUNLOG( eCRITICAL_LOG, "[QuickStyleUpdate] SkillCode[%d] SkillInfo is NULL!", pSkillSlot->GetCode() ); return; } if( pSkillSlot->IsSKill() ) return; const BASE_STYLEINFO *pBaseStyleInfo = pSkillSlot->GetStyleInfo(); for( BYTE i = 0; i < MAX_STYLE_REGIST_COUNT; i++ ) { if( m_pStyleQuickInfo->m_wStyleClassCode[i] != pBaseStyleInfo->m_SkillClassCode ) continue; // ½ºÅ¸ÀÏÀ» Äü ½ºÅ¸ÀÏ ½½·Ô¿¡ µî·ÏÇÑ´Ù. RC::eSTYLE_RESULT rt = m_pStyleManager->Link( pSkillSlot->GetCode(), i ); break; } } }; VOID QuickStyleManager::UpdateStyleSlot() { BASE_StyleQuickRegistInfo *pStyleQuickInfo = StyleQuickRegistInfoParser::Instance()->GetStyleQuickRegistInfo( m_pPlayer->GetCharType(), m_pPlayer->GetWeaponKind() ); SCSkillSlotContainer *pSkillSlotContainer = (SCSkillSlotContainer *)m_pSlotMGR->GetSlotContainer(SI_SKILL); // ½ºÅ¸ÀÏ Äü ÃʱâÈ­ GetQuickStyleSlotContainer()->ClearAll(); // ½ÀµæÇÑ ½ºÅ¸Àϵé Áß¿¡¼­ pStyleQuickInfo¿¡ Á¤º¸°¡ ÀÖ´Â °Í¸¸ µî·Ï if( pStyleQuickInfo ) { QuickStyleUpdate Opr( this, pStyleQuickInfo ); pSkillSlotContainer->ForEachSlot( Opr ); } } */