164 lines
3.9 KiB
C++
164 lines
3.9 KiB
C++
#include "stdafx.h"
|
|
#include "SFieldPropResourceDB.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;
|
|
|
|
SFieldPropResourceDB* SFieldPropResourceDB::m_pThis = NULL;
|
|
|
|
SFieldPropResourceDB & GetFieldPropResourceDB()
|
|
{
|
|
//static SFieldPropResourceDB FieldPropResourceDB;
|
|
|
|
if( NULL == SFieldPropResourceDB::m_pThis )
|
|
SFieldPropResourceDB::m_pThis = new SFieldPropResourceDB;
|
|
|
|
return *SFieldPropResourceDB::m_pThis;
|
|
|
|
// return FieldPropResourceDB;
|
|
}
|
|
|
|
SFieldPropResourceDB::SFieldPropResourceDB()
|
|
{
|
|
Init();
|
|
}
|
|
|
|
SFieldPropResourceDB::~SFieldPropResourceDB()
|
|
{
|
|
Destroy();
|
|
}
|
|
|
|
void SFieldPropResourceDB::Init()
|
|
{
|
|
Load();
|
|
}
|
|
|
|
void SFieldPropResourceDB::Destroy()
|
|
{
|
|
FieldPropResource* pFieldPropResource = NULL;
|
|
bool res;
|
|
res = m_hashFieldPropResource.get_first_value( pFieldPropResource );
|
|
while ( res )
|
|
{
|
|
if ( pFieldPropResource != NULL )
|
|
{
|
|
delete pFieldPropResource;
|
|
}
|
|
res = m_hashFieldPropResource.get_next_value( pFieldPropResource );
|
|
}
|
|
m_hashFieldPropResource.clear();
|
|
}
|
|
|
|
void SFieldPropResourceDB::Load()
|
|
{
|
|
KStream * pRes = KFileManager::Instance().CreateStreamFromResource( "db_FieldPropResource.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(FieldPropResource) * 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++ )
|
|
{
|
|
FieldPropResource * pItem = new FieldPropResource;
|
|
memset( pItem, 0, sizeof(FieldPropResource) );
|
|
|
|
pRes->Read( pItem, sizeof(FieldPropResource) );
|
|
|
|
FieldPropResource* pFindItem = NULL;
|
|
if( m_hashFieldPropResource.lookup( pItem->id, pFindItem ) == false )
|
|
{
|
|
m_hashFieldPropResource.add( pItem->id, pItem );
|
|
}
|
|
else
|
|
{
|
|
_oprint( "!!!!Data Error SFieldPropResourceDB::Load() Code 가 중복되었습니다.!!!! %d\n", pItem->id );
|
|
assert(0); //기획팀에 알려 주세여. 바로 수정 해야 합니다.
|
|
|
|
delete pItem;
|
|
}
|
|
}
|
|
|
|
KFileManager::Instance().DeleteStream( pRes );
|
|
}
|
|
|
|
FieldPropResource* SFieldPropResourceDB::GetFieldPropResource( int nQuestPropID )
|
|
{
|
|
FieldPropResource* pFindItem = NULL;
|
|
if( m_hashFieldPropResource.lookup( nQuestPropID, pFindItem ))
|
|
return pFindItem;
|
|
|
|
return NULL;
|
|
}
|
|
|
|
int SFieldPropResourceDB::GetSkillID( int nQuestPropID )
|
|
{
|
|
FieldPropResource* pFindItem = NULL;
|
|
if( m_hashFieldPropResource.lookup( nQuestPropID, pFindItem ))
|
|
return pFindItem->activate_id;
|
|
|
|
return -1;
|
|
}
|
|
|
|
int SFieldPropResourceDB::GetTerrainCheck( int nQuestPropID )
|
|
{
|
|
FieldPropResource* pFindItem = NULL;
|
|
if( m_hashFieldPropResource.lookup( nQuestPropID, pFindItem ))
|
|
return pFindItem->terrain_check;
|
|
|
|
return 0;
|
|
}
|
|
|
|
/// 2011.07.21 - prodongi
|
|
int SFieldPropResourceDB::getDungeonGateType(int id)
|
|
{
|
|
FieldPropResource* prop = GetFieldPropResource(id);
|
|
if (!prop)
|
|
return 0;
|
|
return (int)prop->worldmap_check_type;
|
|
}
|
|
|
|
KHash< FieldPropResource*, hashPr_mod_int> & SFieldPropResourceDB::GetFieldPropResourceInfo()
|
|
{
|
|
return m_hashFieldPropResource;
|
|
}
|
|
|
|
const char* SFieldPropResourceDB::GetQuestPropModelName( int nQuestPropID )
|
|
{
|
|
FieldPropResource* pFindItem = NULL;
|
|
if( m_hashFieldPropResource.lookup( nQuestPropID, pFindItem ))
|
|
return pFindItem->file_name;
|
|
|
|
return "모델 이름을 찾을수 없습니다.";
|
|
} |