#include "stdafx.h" #include #include #include "KTypes.h" #include #include #include "SkillBaseFile.h" #include "SDebug_Util.h" #include "MixCategoryBase.h" #include "SMixCategoryDB.h" SMixCategoryDB* SMixCategoryDB::m_pThis = NULL; SMixCategoryDB & GetMixCategoryDB() { if( NULL == SMixCategoryDB::m_pThis ) SMixCategoryDB::m_pThis = new SMixCategoryDB; return *SMixCategoryDB::m_pThis; // static SMixCategoryDB mixCategoryDB; // return mixCategoryDB; } SMixCategoryDB::SMixCategoryDB() { Init(); } SMixCategoryDB::~SMixCategoryDB() { Destroy(); } void SMixCategoryDB::Init() { Load(); } void SMixCategoryDB::Destroy() { MixCategoryBase* pMixCategory = NULL; bool res; res = m_hashData.get_first_value( pMixCategory ); while ( res ) { SAFE_DELETE( pMixCategory ); res = m_hashData.get_next_value( pMixCategory ); } m_hashData.clear(); // 공식을 찾기위한 Key 배열. for( int i=0; iRead( &db_hdr, sizeof(db_hdr) ); // 분류가 변했는지를 검사할 이전값. int synthetic_id, high, middle, low; synthetic_id = high = middle = low = -1; // 분류당 개수. int sIndex, hIndex, mIndex; sIndex = hIndex = mIndex = -1; int local_flag = GameRule::GetCurrentLocalBitSet(); // 국가코드. for( int i(0); db_hdr.nCount>i; i++ ) { MixCategoryBase * pItem = new MixCategoryBase; memset( pItem, 0, sizeof(MixCategoryBase) ); pRes->Read( pItem, sizeof(MixCategoryBase) ); MixCategoryBase* pFindItem = NULL; if( m_hashData.lookup( pItem->id, pFindItem ) == false ) { // 국가코드. if( pItem->local_flag != 0 && ( pItem->local_flag & local_flag ) != local_flag ) { delete pItem; // 2011.08.31 - servantes pItem = NULL; continue; } m_hashData.add( pItem->id, pItem ); // 합성구분(강화, 조합, 수리, 복원, 충전) 에 따른분류. m_Category[ pItem->synthetic_id ].push_back( SKey( pItem->id, pItem->high_category_id, pItem->middle_category_id, pItem->low_category_id ) ); //-------------------------------------------------- // 합성분류당 대,중,소 분류의 개수 구하기. classification(pItem); /// 2011.09.20 리펙토링 - prodongi /* SCount & rCategory = m_arrCategorySize[ pItem->synthetic_id ]; // 합성분류가 바뀌면 모두 초기화. if( synthetic_id != pItem->synthetic_id ) { high = middle = low = -1; synthetic_id = pItem->synthetic_id; ++sIndex; hIndex = -1; } // 대. if( high != pItem->high_category_id ) { ++rCategory.highSize; high = pItem->high_category_id; middle = low = -1; ++hIndex; mIndex = -1; // 대분류당 중분류 개수. rCategory.arrMiddle.resize( hIndex + 1 ); } // 중 if( pItem->middle_category_id > -1 && middle != pItem->middle_category_id ) { ++rCategory.middleSize; middle = pItem->middle_category_id; // 대분류당 중분류 개수. rCategory.arrMiddle[ hIndex ] += 1; ++mIndex; // 중분류당 소분류 개수. rCategory.arrLow.resize( hIndex + 1 ); rCategory.arrLow[ hIndex ].resize( rCategory.arrMiddle[ hIndex ] ); low = -1; } // 소 if( pItem->low_category_id > -1 && low != pItem->low_category_id ) { ++rCategory.lowSize; low = pItem->low_category_id; //// 중분류당 소분류 개수. rCategory.arrLow[ hIndex ][ mIndex ] += 1; } //-------------------------------------------------- */ } else { _oprint( "!!!!Data Error Combine Code 가 중복되었습니다.!!!! %d\n", pItem->id ); assert(0); //기획팀에 알려 주세여. 바로 수정 해야 합니다. delete pItem; } } KFileManager::Instance().DeleteStream( pRes ); } bool SMixCategoryDB::LookUp( int nID, MixCategoryBase * pItem ) { return m_hashData.lookup(nID, pItem); } // 합성구분, 국가코드, 대분류, 중분류, 소분류 MixCategoryBase * SMixCategoryDB::GetCategory( int synthetic_separation, int local_flag, short high, short midle, short low ) { MixCategoryBase * pItem = NULL; if( synthetic_separation < MixCategoryBase::SYNTHETIC_MAX ) { SKey key; // key int size = m_Category[ synthetic_separation ].size(); for( int i=0; ilocal_flag & local_flag ) // pItem = NULL; break; } } } return pItem; } void SMixCategoryDB::classification(MixCategoryBase const* item) { SCount& count = GetCategorySize(item->synthetic_id); std::vector id; id.reserve(3); id.push_back(item->high_category_id); id.push_back(item->middle_category_id); id.push_back(item->low_category_id); count.classification(0, id); id.clear(); }