186 lines
3.6 KiB
C++
186 lines
3.6 KiB
C++
#include "stdafx.h"
|
|
#include "STenacityDB.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 "SkillBaseFile.h"
|
|
|
|
#include "SDebug_Util.h"
|
|
|
|
extern HWND g_hWnd;
|
|
|
|
STenacityDB::STenacityDB()
|
|
{
|
|
Init();
|
|
}
|
|
|
|
STenacityDB::~STenacityDB()
|
|
{
|
|
Destroy();
|
|
}
|
|
|
|
|
|
int STenacityDB::GetToolTipID( int nStateID )
|
|
{
|
|
StateInfoEx* pState = GetTenacityData(nStateID);
|
|
if( pState ) return pState->tooltip_id;
|
|
|
|
return 0;
|
|
}
|
|
int STenacityDB::GetNameID( int nStateID )
|
|
{
|
|
StateInfoEx* pState = GetTenacityData(nStateID);
|
|
if( pState ) return pState->name_id;
|
|
|
|
return 0;
|
|
}
|
|
|
|
StateInfoEx * STenacityDB::GetTenacityData( int nTenacityID )
|
|
{
|
|
StateInfoEx * pFindStatInfo = NULL;
|
|
if( m_hashTenacity.lookup( nTenacityID, pFindStatInfo ) == false )
|
|
{
|
|
return NULL;
|
|
}
|
|
else
|
|
{
|
|
return pFindStatInfo;
|
|
}
|
|
|
|
return NULL;
|
|
}
|
|
|
|
const char * STenacityDB::GetIconName( int nStateID )
|
|
{
|
|
StateInfoEx* pState = GetTenacityData(nStateID);
|
|
if( pState ) return pState->icon_file_name;
|
|
|
|
return "NotFound";
|
|
}
|
|
|
|
int STenacityDB::GetIconID( int nStateID )
|
|
{
|
|
StateInfoEx* pState = GetTenacityData(nStateID);
|
|
if( pState ) return pState->nIcon_id;
|
|
|
|
return 0;
|
|
}
|
|
|
|
int STenacityDB::GetFXPos( int nStateID )
|
|
{
|
|
StateInfoEx* pState = GetTenacityData(nStateID);
|
|
if( pState ) return pState->pos_id;
|
|
|
|
return 0;
|
|
}
|
|
|
|
int STenacityDB::IsHarmful( int nStateID )
|
|
{
|
|
StateInfoEx* pState = GetTenacityData(nStateID);
|
|
if( pState ) return pState->is_harmful;
|
|
|
|
return 0;
|
|
}
|
|
|
|
int STenacityDB::GetFXID( int nStateID )
|
|
{
|
|
StateInfoEx* pState = GetTenacityData(nStateID);
|
|
if( pState ) return pState->fx_id;
|
|
|
|
return -1;
|
|
}
|
|
|
|
void STenacityDB::Init()
|
|
{
|
|
Load();
|
|
}
|
|
|
|
void STenacityDB::Destroy()
|
|
{
|
|
StateInfoEx* pState = NULL;
|
|
bool res;
|
|
res = m_hashTenacity.get_first_value( pState );
|
|
while ( res )
|
|
{
|
|
if ( pState != NULL )
|
|
{
|
|
delete pState;
|
|
}
|
|
res = m_hashTenacity.get_next_value( pState );
|
|
}
|
|
m_hashTenacity.clear();
|
|
}
|
|
|
|
void STenacityDB::Load()
|
|
{
|
|
KStream * pRes = KFileManager::Instance().CreateStreamFromResource( "db_tenacity.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(StateInfoEx) * 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++ )
|
|
{
|
|
StateInfoEx * pState = new StateInfoEx;
|
|
memset( pState, 0, sizeof(StateInfoEx) );
|
|
|
|
pRes->Read( pState, sizeof(StateInfoEx) );
|
|
|
|
StateInfoEx * pFindStatInfo = NULL;
|
|
if( m_hashTenacity.lookup( pState->id, pFindStatInfo ) == false )
|
|
{
|
|
m_hashTenacity.add( pState->id, pState );
|
|
}
|
|
else
|
|
{
|
|
_oprint( "!!!!Data Error StateInfo Code 가 중복되었습니다.!!!! %d\n", pState->id );
|
|
assert(0); //기획팀에 알려 주세여. 바로 수정 해야 합니다.
|
|
}
|
|
|
|
}
|
|
|
|
KFileManager::Instance().DeleteStream( pRes );
|
|
}
|
|
|
|
|
|
STenacityDB* STenacityDB::m_pThis = NULL;
|
|
STenacityDB & GetTenacityDB()
|
|
{
|
|
if( NULL == STenacityDB::m_pThis )
|
|
STenacityDB::m_pThis = new STenacityDB;
|
|
|
|
return *STenacityDB::m_pThis;
|
|
|
|
// static STenacityDB tenacitydb;
|
|
// return tenacitydb;
|
|
}
|