111 lines
2.6 KiB
C++
111 lines
2.6 KiB
C++
#include "stdafx.h"
|
|
#include <windows.h>
|
|
#include "KTypes.h"
|
|
#include <kfile/KStream.h>
|
|
#include <kfile/KFileManager.h>
|
|
#include "SkillBaseFile.h"
|
|
#include "SSetItemEffectResourceDB.h"
|
|
#include "TemplateUtil.h"
|
|
|
|
#include "SDebug_Util.h"
|
|
|
|
SSetItemEffectResourceDB::SSetItemEffectResourceDB()
|
|
{
|
|
Init();
|
|
}
|
|
|
|
SSetItemEffectResourceDB::~SSetItemEffectResourceDB()
|
|
{
|
|
Destroy();
|
|
}
|
|
|
|
void SSetItemEffectResourceDB::Find( int setId, SSetItemEffectResourceDB::FoundResult& result ) const
|
|
{
|
|
std::pair< DBType::const_iterator, DBType::const_iterator > found = mDB.equal_range( setId );
|
|
|
|
for( ; found.first != found.second; ++found.first )
|
|
result.push_back( found.first->second );
|
|
}
|
|
|
|
void SSetItemEffectResourceDB::Find( int setId, int partCompositionId,SSetItemEffectResourceDB::FoundResult& result ) const
|
|
{
|
|
std::pair< DBType::const_iterator, DBType::const_iterator > found = mDB.equal_range( setId );
|
|
|
|
for( ; found.first != found.second; ++found.first )
|
|
{
|
|
const SetItemEffectResource* fx = found.first->second;
|
|
|
|
if( fx->isPartOfSetItemComposition( partCompositionId ) )
|
|
result.push_back( fx );
|
|
}
|
|
}
|
|
|
|
void SSetItemEffectResourceDB::Init()
|
|
{
|
|
Load();
|
|
}
|
|
|
|
void SSetItemEffectResourceDB::Destroy()
|
|
{
|
|
rp::wipe_assoc( mDB );
|
|
}
|
|
|
|
void SSetItemEffectResourceDB::Load()
|
|
{
|
|
KStream * pRes = KFileManager::Instance().CreateStreamFromResource( "db_SetItemEffectResource.rdb" );
|
|
if( !pRes ) return;
|
|
|
|
_oprint( "* SetItemEffectResource DB Loading...\n" );
|
|
|
|
GAME_DB db_hdr;
|
|
|
|
pRes->Read( &db_hdr, sizeof(db_hdr) );
|
|
|
|
for( int i(0); db_hdr.nCount>i; i++ )
|
|
{
|
|
SetItemEffectResource* pSetItemFx = new SetItemEffectResource;
|
|
|
|
memset( pSetItemFx, 0, sizeof(SetItemEffectResource) );
|
|
|
|
pRes->Read( pSetItemFx, sizeof(SetItemEffectResource) );
|
|
|
|
std::pair< DBType::iterator, DBType::iterator > found = mDB.equal_range( pSetItemFx->set_id );
|
|
|
|
if( found.first == found.second )
|
|
{
|
|
mDB.insert( std::make_pair( pSetItemFx->set_id, pSetItemFx ) );
|
|
}
|
|
else
|
|
{
|
|
bool unique = true;
|
|
for( ; found.first != found.second; ++found.first )
|
|
{
|
|
if( found.first->second->set_part_id == pSetItemFx->set_id )
|
|
{
|
|
unique = false;
|
|
break;
|
|
}
|
|
}
|
|
|
|
if( unique )
|
|
{
|
|
mDB.insert( std::make_pair( pSetItemFx->set_id, pSetItemFx ) );
|
|
}
|
|
else
|
|
{
|
|
_oprint( "* Error: key( %d, %d )가 중복되었습니다.\n", pSetItemFx->set_id, pSetItemFx->set_part_id );
|
|
delete pSetItemFx;
|
|
}
|
|
}
|
|
}
|
|
|
|
KFileManager::Instance().DeleteStream( pRes );
|
|
|
|
_oprint( "* SetItemEffectResource DB Loading Complete...( Total: %d )\n", (int)mDB.size() );
|
|
}
|
|
|
|
SSetItemEffectResourceDB& GetSetItemEffectResourceDB()
|
|
{
|
|
static SSetItemEffectResourceDB setitemEffectResourceDB;
|
|
return setitemEffectResourceDB;
|
|
} |