90 lines
2.2 KiB
C++
90 lines
2.2 KiB
C++
#include "stdafx.h"
|
|
#include "SAuctionCategoryResourceDB.h"
|
|
|
|
#include <windows.h>
|
|
#include <kfile/KStream.h>
|
|
#include "KTypes.h"
|
|
#include <kfile/KFileManager.h>
|
|
#include "SkillBaseFile.h"
|
|
|
|
#include "SDebug_Util.h"
|
|
|
|
AuctionCategoryDB::AuctionCategoryDB( )
|
|
{
|
|
Load( );
|
|
}
|
|
AuctionCategoryDB::~AuctionCategoryDB( )
|
|
{
|
|
Release( );
|
|
}
|
|
void AuctionCategoryDB::GetCategoryInfo( category_info_container_t& out, int nLocalFlag )
|
|
{
|
|
category_info_container_t::iterator it = m_CategoryInfos.begin( ), end = m_CategoryInfos.end( );
|
|
for( ; it != end; ++it )
|
|
{
|
|
category_info_t* pInfo = *it;
|
|
if( pInfo && pInfo->local_flag == nLocalFlag )
|
|
{
|
|
out.push_back( pInfo );
|
|
}
|
|
}
|
|
}
|
|
void AuctionCategoryDB::Load( )
|
|
{
|
|
Release( );
|
|
|
|
KStream* pResource = KFileManager::Instance( ).CreateStreamFromResource( "db_AuctionCategoryResource.rdb" );
|
|
if( !pResource ) return;
|
|
|
|
GAME_DB dbHeader;
|
|
int nCategoryCount = 0;
|
|
|
|
pResource->Read( &dbHeader, sizeof( dbHeader ) );
|
|
|
|
for( int i( 0 ); i < dbHeader.nCount; ++i )
|
|
{
|
|
category_info_t* pCategory = new category_info_t;
|
|
assert( pCategory );
|
|
memset( pCategory, 0, sizeof( category_info_t ) );
|
|
pResource->Read( pCategory, sizeof( category_info_t ) );
|
|
|
|
if( !IsValid( *pCategory ) )
|
|
{
|
|
_oprint( "!!!!Data Error Auction Category 가 정상적이지 않습니다.!!!! id:%d sub_id:%d\n", pCategory->category_id, pCategory->sub_category_id );
|
|
assert( 0 ); //기획팀에 알려 주세여. 바로 수정 해야 합니다.
|
|
}
|
|
|
|
m_CategoryInfos.push_back( pCategory );
|
|
++nCategoryCount;
|
|
}
|
|
|
|
//_oprint( "경매 카테고리 갯수 : %d\n", nCategoryCount );
|
|
|
|
KFileManager::Instance().DeleteStream( pResource );
|
|
}
|
|
void AuctionCategoryDB::Release( )
|
|
{
|
|
category_info_container_t::iterator it = m_CategoryInfos.begin( ), it_end = m_CategoryInfos.end( );
|
|
for( ; it != it_end; ++it )
|
|
{
|
|
category_info_t* pInfo = *it;
|
|
SAFE_DELETE( pInfo );
|
|
}
|
|
m_CategoryInfos.clear( );
|
|
}
|
|
|
|
bool AuctionCategoryDB::IsValid( category_info_t& info )
|
|
{
|
|
if( info.category_id < -1 || info.sub_category_id < -1 )
|
|
return false;
|
|
if( info.category_id == -1 && info.sub_category_id == -1 )
|
|
return false;
|
|
return true;
|
|
}
|
|
|
|
AuctionCategoryDB& GetAuctionCategoryDB( )
|
|
{
|
|
static AuctionCategoryDB auctionCategoryDB;
|
|
return auctionCategoryDB;
|
|
}
|