155 lines
3.5 KiB
C++
155 lines
3.5 KiB
C++
#include "stdafx.h"
|
|
#include "SEnhanceFXDB.h"
|
|
|
|
#include <Windows.h>
|
|
#include "KTypes.h"
|
|
#include <kfile/KStream.h>
|
|
#include <kfile/KFileManager.h>
|
|
#include <toolkit/XStringUtil.h>
|
|
#include "SkillBaseFile.h"
|
|
#include "ContentStruct.h"
|
|
|
|
#include "SDebug_Util.h"
|
|
|
|
extern HWND g_hWnd;
|
|
|
|
|
|
void SWeapon_EnhanceLevel::AddInfo( EnhanceFX* pEnhanceFx )
|
|
{
|
|
EnhanceFX* pFindItem = NULL;
|
|
if( m_hashEnhanceFX.lookup( pEnhanceFx->enhance_level, pFindItem ) == false )
|
|
{
|
|
m_hashEnhanceFX.add( pEnhanceFx->enhance_level, pEnhanceFx );
|
|
}
|
|
else
|
|
{
|
|
_oprint( "!!!!Data Error SEnhanceFXDB::AddInfo() 강화 레벨 코드가 중복됐습니다. %d %d\n", pEnhanceFx->weapon_id, pEnhanceFx->enhance_level );
|
|
//assert(0 && "duplated pEnhanceFx->enhance_level"); //기획팀에 알려 주세여. 바로 수정 해야 합니다.
|
|
|
|
SAFE_DELETE( pEnhanceFx );
|
|
}
|
|
}
|
|
|
|
EnhanceFX* SWeapon_EnhanceLevel::FindInfo( int nEnhanceLevel )
|
|
{
|
|
EnhanceFX* pFindItem = NULL;
|
|
if( m_hashEnhanceFX.lookup( nEnhanceLevel, pFindItem ) )
|
|
return pFindItem;
|
|
return NULL;
|
|
}
|
|
|
|
SEnhanceFXDB* SEnhanceFXDB::m_pThis = NULL;
|
|
SEnhanceFXDB & GetEnhanceFXDB()
|
|
{
|
|
if( NULL == SEnhanceFXDB::m_pThis )
|
|
SEnhanceFXDB::m_pThis = new SEnhanceFXDB;
|
|
|
|
return *SEnhanceFXDB::m_pThis;
|
|
|
|
// static SEnhanceFXDB EnhanceFXDB;
|
|
// return EnhanceFXDB;
|
|
}
|
|
|
|
SEnhanceFXDB::SEnhanceFXDB()
|
|
{
|
|
Init();
|
|
}
|
|
|
|
SEnhanceFXDB::~SEnhanceFXDB()
|
|
{
|
|
Destroy();
|
|
}
|
|
|
|
void SEnhanceFXDB::Init()
|
|
{
|
|
Load();
|
|
}
|
|
|
|
void SEnhanceFXDB::Destroy()
|
|
{
|
|
SWeapon_EnhanceLevel* pWeaponLevel = NULL;
|
|
bool res;
|
|
res = m_hashWeaponClass.get_first_value( pWeaponLevel );
|
|
while ( res )
|
|
{
|
|
if ( pWeaponLevel != NULL )
|
|
{
|
|
delete pWeaponLevel;
|
|
}
|
|
res = m_hashWeaponClass.get_next_value( pWeaponLevel );
|
|
}
|
|
m_hashWeaponClass.clear();
|
|
}
|
|
|
|
void SEnhanceFXDB::Load()
|
|
{
|
|
KStream * pRes = KFileManager::Instance().CreateStreamFromResource( "db_EnhanceFx.rdb" );
|
|
if( !pRes ) return;
|
|
GAME_DB db_hdr;
|
|
|
|
pRes->Read( &db_hdr, sizeof(db_hdr) );
|
|
|
|
#ifdef _DEV_RDB_
|
|
// RDB 와 Header의 사이즈 비교.
|
|
int fileSize = pRes->Size() - ( STR_DATE_BUFFER + sizeof( int ) );
|
|
int headerSize = sizeof(EnhanceFX) * db_hdr.nCount;
|
|
if( fileSize != headerSize )
|
|
{
|
|
char str[512] = { NULL, };
|
|
sprintf( str, "*** RDB Error !!! ***\n\n생성날짜%s\n파일:%s\n파일사이즈:%d\n헤더사이즈:%d\n ",
|
|
db_hdr.szDate,
|
|
__FILE__,
|
|
fileSize,
|
|
headerSize
|
|
);
|
|
|
|
::MessageBox( g_hWnd, str, "Error", MB_OK );
|
|
|
|
if( ::MessageBox( g_hWnd, "RDB와 클라이언트가 맞지않습니다. 강제종료하시겠습니까?", "Error", MB_YESNO ) == IDYES )
|
|
{
|
|
exit( 1 );
|
|
}
|
|
}
|
|
#endif
|
|
|
|
|
|
for( int i(0); db_hdr.nCount>i; i++ )
|
|
{
|
|
EnhanceFX * pItem = new EnhanceFX;
|
|
memset( pItem, 0, sizeof(EnhanceFX) );
|
|
|
|
pRes->Read( pItem, sizeof(EnhanceFX) );
|
|
|
|
SWeapon_EnhanceLevel* pFindItem = NULL;
|
|
if( m_hashWeaponClass.lookup( pItem->weapon_id, pFindItem ) == false )
|
|
{
|
|
SWeapon_EnhanceLevel* pWeapon_level = new SWeapon_EnhanceLevel;
|
|
pWeapon_level->AddInfo( pItem );
|
|
m_hashWeaponClass.add( pItem->weapon_id, pWeapon_level );
|
|
}
|
|
else
|
|
{
|
|
pFindItem->AddInfo( pItem );
|
|
}
|
|
|
|
// SAFE_DELETE( pItem );
|
|
}
|
|
|
|
KFileManager::Instance().DeleteStream( pRes );
|
|
}
|
|
|
|
EnhanceFX* SEnhanceFXDB::GetEnhanceFx( int nClassID, int nEnhanceLevel )
|
|
{
|
|
SWeapon_EnhanceLevel* pFindItem = NULL;
|
|
if( m_hashWeaponClass.lookup( nClassID, pFindItem ) )
|
|
{
|
|
return pFindItem->FindInfo( nEnhanceLevel );
|
|
}
|
|
else
|
|
{
|
|
_oprint( "!!!!Data Error SEnhanceFXDB::GetEnhanceFxInfo() 강화 정보가 없습니다. %d %d\n", nClassID, nEnhanceLevel );
|
|
// assert(0); //기획팀에 알려 주세여. 바로 수정 해야 합니다.
|
|
}
|
|
|
|
return NULL;
|
|
} |