#include "stdafx.h" #include "SCombineDB.h" #include #include #include "KTypes.h" #include #include #include "CombineBase.h" #include "SkillBaseFile.h" #include "SDebug_Util.h" SCombineDB* SCombineDB::m_pThis = NULL; SCombineDB & GetCombineDB() { if( NULL == SCombineDB::m_pThis ) SCombineDB::m_pThis = new SCombineDB; return *SCombineDB::m_pThis; // static SCombineDB CombineDB; // return CombineDB; } SCombineDB::SCombineDB() { Init(); } SCombineDB::~SCombineDB() { Destroy(); } void SCombineDB::Init() { Load(); } void SCombineDB::Destroy() { CombineBase* pCombine = NULL; bool res; res = m_hashCombine.get_first_value( pCombine ); while ( res ) { if ( pCombine != NULL ) { delete pCombine; } res = m_hashCombine.get_next_value( pCombine ); } m_hashCombine.clear(); } void SCombineDB::Load() { KStream * pRes = KFileManager::Instance().CreateStreamFromResource( "db_CombineRes.rdb" ); if( !pRes ) return; GAME_DB db_hdr; pRes->Read( &db_hdr, sizeof(db_hdr) ); for( int i(0); db_hdr.nCount>i; i++ ) { CombineBase * pItem = new CombineBase; memset( pItem, 0, sizeof(CombineBase) ); pRes->Read( pItem, sizeof(CombineBase) ); CombineBase* pFindItem = NULL; if( m_hashCombine.lookup( pItem->id, pFindItem ) == false ) { m_hashCombine.add( pItem->id, pItem ); } else { _oprint( "!!!!Data Error Combine Code 가 중복되었습니다.!!!! %d\n", pItem->id ); assert(0); //기획팀에 알려 주세여. 바로 수정 해야 합니다. delete pItem; } } KFileManager::Instance().DeleteStream( pRes ); } bool SCombineDB::LookUp( int nID, CombineBase * pItem ) { return m_hashCombine.lookup(nID, pItem); } int SCombineDB::GetMainType( int nID ) { CombineBase * pItem(NULL); if( m_hashCombine.lookup(nID, pItem) ) { return pItem->main_type_01; } return -1; } int SCombineDB::GetMainTypeValue( int nID ) { CombineBase * pItem(NULL); if( m_hashCombine.lookup(nID, pItem) ) { return pItem->main_value_01; } return -1; } bool SCombineDB::CheckValue( int nType, int nTypeValue, int nBigGroup, int nGroup, int nID, int nRank, int nLv, const XFlag xFlag, int nEnhance, int nItemCount ) { if( nType == 1 && nTypeValue != nBigGroup ) //1 : 아이템 대분류 return false; if( nType == 2 && nTypeValue != nGroup ) //2 : 아이템 중분류 return false; if( nType == 3 && nTypeValue != nID ) //3 : 아이템 ID return false; if( nType == 4 && nTypeValue != nRank ) //4 : 아이템 랭크 return false; if( nType == 5 && nTypeValue != nLv ) //5 : 아이템 레벨 return false; if( nType == 6 && !xFlag.IsOn( nTypeValue ) ) //6 : 플래그 설정됨 (on) return false; if( nType == 7 && xFlag.IsOn( nTypeValue ) ) //7 : 플래그 설정되지 않음 (off) return false; if( nType == 8 && nEnhance != nTypeValue ) //강화 수치 return false; if( nType == 9 && nEnhance == nTypeValue ) return false; if( nType == 10 && nItemCount != nTypeValue ) return false; return true; } bool SCombineDB::IsMain( int nBigGroup, int nGroup, int nID, int nRank, int nLv, const XFlag xFlag, int nEnhance, int nItemCount ) { // sonador 7.0.15 7.0.12 Rollback & 빗자루 : 2000178 와 가면: 2000182 예외처리 if( nID == 2000178 || nID == 2000182 ) return false; bool bResult; KHash< CombineBase*, hashPr_mod_int >::node* _node = NULL; bResult = m_hashCombine.get_first_node( _node ); while( bResult ) { CombineBase* pCombine = _node->value; while( true ) { if( !pCombine->main_type_01 && !pCombine->main_type_02 && !pCombine->main_type_03 && !pCombine->main_type_04 && !pCombine->main_type_05 ) break; if( pCombine->main_type_01 ) { if( !CheckValue( pCombine->main_type_01, pCombine->main_value_01, nBigGroup, nGroup, nID, nRank, nLv, xFlag, nEnhance, nItemCount) ) break; } if( pCombine->main_type_02 ) { if( !CheckValue( pCombine->main_type_02, pCombine->main_value_02, nBigGroup, nGroup, nID, nRank, nLv, xFlag, nEnhance, nItemCount) ) break; } if( pCombine->main_type_03 ) { if( !CheckValue( pCombine->main_type_03, pCombine->main_value_03, nBigGroup, nGroup, nID, nRank, nLv, xFlag, nEnhance, nItemCount) ) break; } if( pCombine->main_type_04 ) { if( !CheckValue( pCombine->main_type_04, pCombine->main_value_04, nBigGroup, nGroup, nID, nRank, nLv, xFlag, nEnhance, nItemCount) ) break; } if( pCombine->main_type_05 ) { if( !CheckValue( pCombine->main_type_05, pCombine->main_value_05, nBigGroup, nGroup, nID, nRank, nLv, xFlag, nEnhance, nItemCount) ) break; } return true; } bResult = m_hashCombine.get_next_node( _node ); } return false; } bool SCombineDB::IsSub( int nBigGroup, int nGroup, int nID, int nRank, int nLv, const XFlag xFlag, int nEnhance, int nItemCount ) { bool bResult; KHash< CombineBase*, hashPr_mod_int >::node* _node = NULL; bResult = m_hashCombine.get_first_node( _node ); while( bResult ) { CombineBase* pCombine = _node->value; for( int subcnt = 0; subcnt < MAX_SUB; ++subcnt ) { if( pCombine->sub[subcnt].sub_type[0] ) { if( CheckValue( pCombine->sub[subcnt].sub_type[0], pCombine->sub[subcnt].sub_value[0], nBigGroup, nGroup, nID, nRank, nLv, xFlag, nEnhance, nItemCount) ) return true; } } bResult = m_hashCombine.get_next_node( _node ); } return false; } int SCombineDB::GetSubType( int nID, int nIndex ) { CombineBase * pItem(NULL); if( m_hashCombine.lookup(nID, pItem) ) { if( nIndex < MAX_SUB ) return pItem->sub[nIndex].sub_type[0]; } return -1; } int SCombineDB::GetSubTypeValue( int nID, int nIndex ) { CombineBase * pItem(NULL); if( m_hashCombine.lookup(nID, pItem) ) { if( nIndex < MAX_SUB ) pItem->sub[nIndex].sub_value[0]; } return -1; } int SCombineDB::getMixType(int id) { CombineBase * combine = NULL; if( m_hashCombine.lookup(id, combine)) { return combine->mix_type; } return 0; } void SCombineDB::getMainMixList(int nBigGroup, int nGroup, int nID, int nRank, int nLv, const XFlag xFlag, int nEnhance, int nItemCount, std::vector& mainMixList) { // sonador 7.0.15 7.0.12 Rollback & 빗자루 : 2000178 와 가면: 2000182 예외처리 if( nID == 2000178 || nID == 2000182 ) return ; bool bResult; KHash< CombineBase*, hashPr_mod_int >::node* _node = NULL; bResult = m_hashCombine.get_first_node( _node ); while( bResult ) { CombineBase* pCombine = _node->value; while( true ) { if( !pCombine->main_type_01 && !pCombine->main_type_02 && !pCombine->main_type_03 && !pCombine->main_type_04 && !pCombine->main_type_05 ) break; if( pCombine->main_type_01 ) { if( !CheckValue( pCombine->main_type_01, pCombine->main_value_01, nBigGroup, nGroup, nID, nRank, nLv, xFlag, nEnhance, nItemCount) ) break; } if( pCombine->main_type_02 ) { if( !CheckValue( pCombine->main_type_02, pCombine->main_value_02, nBigGroup, nGroup, nID, nRank, nLv, xFlag, nEnhance, nItemCount) ) break; } if( pCombine->main_type_03 ) { if( !CheckValue( pCombine->main_type_03, pCombine->main_value_03, nBigGroup, nGroup, nID, nRank, nLv, xFlag, nEnhance, nItemCount) ) break; } if( pCombine->main_type_04 ) { if( !CheckValue( pCombine->main_type_04, pCombine->main_value_04, nBigGroup, nGroup, nID, nRank, nLv, xFlag, nEnhance, nItemCount) ) break; } if( pCombine->main_type_05 ) { if( !CheckValue( pCombine->main_type_05, pCombine->main_value_05, nBigGroup, nGroup, nID, nRank, nLv, xFlag, nEnhance, nItemCount) ) break; } mainMixList.push_back(pCombine->id); break; } bResult = m_hashCombine.get_next_node( _node ); } } void SCombineDB::getSubMixList(int nBigGroup, int nGroup, int nID, int nRank, int nLv, const XFlag xFlag, int nEnhance, int nItemCount, const std::vector& mainMixList, std::vector& subMixList) { CombineBase* combine; std::vector::const_iterator it_main = mainMixList.begin(); for (; it_main != mainMixList.end(); ++it_main) { if( m_hashCombine.lookup(*it_main, combine) ) { for( int subcnt = 0; subcnt < MAX_SUB; ++subcnt ) { if( combine->sub[subcnt].sub_type[0] ) { if( CheckValue( combine->sub[subcnt].sub_type[0], combine->sub[subcnt].sub_value[0], nBigGroup, nGroup, nID, nRank, nLv, xFlag, nEnhance, nItemCount) ) { subMixList.push_back(combine->id); break; } } } } } }