89 lines
1.9 KiB
C++
89 lines
1.9 KiB
C++
|
|
#include "stdafx.h"
|
|
#include "SCreatureFarmDB.h"
|
|
|
|
#include <Windows.h>
|
|
#include <kfile/KStream.h>
|
|
#include "KTypes.h"
|
|
#include <kfile/KFileManager.h>
|
|
#include <toolkit/XStringUtil.h>
|
|
#include "SkillBaseFile.h"
|
|
|
|
#include "SDebug_Util.h"
|
|
|
|
|
|
SCreatureFarmDB::SCreatureFarmDB()
|
|
{
|
|
Init();
|
|
}
|
|
|
|
SCreatureFarmDB::~SCreatureFarmDB()
|
|
{
|
|
Destroy();
|
|
}
|
|
|
|
void SCreatureFarmDB::Init()
|
|
{
|
|
Load();
|
|
}
|
|
|
|
void SCreatureFarmDB::Destroy()
|
|
{
|
|
SAFE_DELETE_VECTOR( m_vCreatureFarmInfo );
|
|
}
|
|
|
|
void SCreatureFarmDB::Load()
|
|
{
|
|
KStream * pRes = KFileManager::Instance().CreateStreamFromResource( "db_CreatureFarm.rdb" );
|
|
if( !pRes ) return;
|
|
|
|
GAME_DB db_hdr;
|
|
|
|
pRes->Read( &db_hdr, sizeof(GAME_DB) );
|
|
|
|
#ifdef _DEV_RDB_
|
|
// RDB 와 Header의 사이즈 비교.
|
|
int fileSize = pRes->Size() - ( STR_DATE_BUFFER + sizeof( int ) );
|
|
int headerSize = sizeof(_SUMMON_INFO_FILE) * 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++ )
|
|
{
|
|
_CREATURE_FARM_INFO* pFarmInfo = new _CREATURE_FARM_INFO;
|
|
memset( pFarmInfo, 0, sizeof(_CREATURE_FARM_INFO) );
|
|
pRes->Read( pFarmInfo, sizeof(_CREATURE_FARM_INFO) );
|
|
|
|
m_vCreatureFarmInfo.push_back( pFarmInfo );
|
|
}
|
|
|
|
KFileManager::Instance().DeleteStream( pRes );
|
|
}
|
|
|
|
SCreatureFarmDB* SCreatureFarmDB::m_pThis = NULL;
|
|
SCreatureFarmDB & GetCreatureFarmDB()
|
|
{
|
|
if( NULL == SCreatureFarmDB::m_pThis )
|
|
SCreatureFarmDB::m_pThis = new SCreatureFarmDB;
|
|
|
|
return *SCreatureFarmDB::m_pThis;
|
|
// static SCreatureFarmDB creatureFarmdb;
|
|
// return creatureFarmdb;
|
|
}
|