414 lines
9.3 KiB
C++
414 lines
9.3 KiB
C++
#include "stdafx.h"
|
|
#include "SBasicStat.h"
|
|
|
|
#include <Windows.h>
|
|
#include <kfile/KStream.h>
|
|
#include <kfile/KFileManager.h>
|
|
#include "KResourceManager.h"
|
|
#include <toolkit/XStringUtil.h>
|
|
|
|
#include "KTypes.h"
|
|
#include "CreatureBase.h"
|
|
#include "SkillBaseFile.h"
|
|
#include "GameDefine.h"
|
|
|
|
//#include "Util.h"
|
|
#include "KRenderObject.h"
|
|
#include "SGameSound.h"
|
|
|
|
#include <mmo/ArTime.h>
|
|
|
|
#include "SDebug_Util.h"
|
|
|
|
|
|
extern HWND g_hWnd;
|
|
|
|
SBasicStatDB::SBasicStatDB()
|
|
{
|
|
Init();
|
|
}
|
|
|
|
SBasicStatDB::~SBasicStatDB()
|
|
{
|
|
Destroy();
|
|
}
|
|
|
|
CreatureStat * SBasicStatDB::GetStatData( int nStatID )
|
|
{
|
|
auto pos = m_mapStatList.find( nStatID );
|
|
if( pos != m_mapStatList.end() )
|
|
{
|
|
return pos->second;
|
|
}
|
|
|
|
return NULL;
|
|
}
|
|
|
|
void SBasicStatDB::Init()
|
|
{
|
|
Load();
|
|
}
|
|
|
|
void SBasicStatDB::Destroy()
|
|
{
|
|
auto pos = m_mapStatList.cbegin();
|
|
auto end = m_mapStatList.cend();
|
|
|
|
for( ; pos != end; ++pos )
|
|
{
|
|
delete pos->second;
|
|
}
|
|
|
|
m_mapStatList.clear();
|
|
}
|
|
|
|
void SBasicStatDB::Load()
|
|
{
|
|
KStream * pRes = KFileManager::Instance().CreateStreamFromResource( "db_BasicStat.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(CreatureStat) * 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++ )
|
|
{
|
|
CreatureStat * pStat = new CreatureStat;
|
|
memset( pStat, 0, sizeof(CreatureStat) );
|
|
|
|
pRes->Read( pStat, sizeof(CreatureStat) );
|
|
|
|
m_mapStatList.insert( std::make_pair( pStat->stat_id, pStat ) );
|
|
}
|
|
|
|
KFileManager::Instance().DeleteStream( pRes );
|
|
}
|
|
|
|
SBasicStatDB & GetBasicStatDB()
|
|
{
|
|
static SBasicStatDB basicDB;
|
|
return basicDB;
|
|
}
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
//
|
|
//SAnimationDB::SAnimationDB()
|
|
//{
|
|
// Init();
|
|
//}
|
|
//
|
|
//SAnimationDB::~SAnimationDB()
|
|
//{
|
|
// Destroy();
|
|
//}
|
|
//
|
|
//void SAnimationDB::Init()
|
|
//{
|
|
// Load();
|
|
//}
|
|
//
|
|
//void SAnimationDB::Destroy()
|
|
//{
|
|
// std::vector< struct AVATAR_ANIINFO* >* anilist;
|
|
// bool res;
|
|
// res = m_hashAniInfo.get_first_value( anilist );
|
|
// while ( res )
|
|
// {
|
|
// if ( anilist != NULL )
|
|
// {
|
|
// std::vector< struct AVATAR_ANIINFO* >::iterator it = anilist->begin();
|
|
// for( ; anilist->end() != it; it++ )
|
|
// {
|
|
// delete (*it);
|
|
// }
|
|
// anilist->clear();
|
|
// delete anilist;
|
|
// }
|
|
// res = m_hashAniInfo.get_next_value( anilist );
|
|
// }
|
|
// m_hashAniInfo.clear();
|
|
//}
|
|
//
|
|
//void SAnimationDB::Load()
|
|
//{
|
|
// LoadAvatar();
|
|
//}
|
|
//
|
|
//std::vector< struct AVATAR_ANIINFO* >* SAnimationDB::GetAnimationList( const char * pAniKey )
|
|
//{
|
|
// std::vector< struct AVATAR_ANIINFO* >* pFindAniInfo = NULL;
|
|
// if( m_hashAniInfo.lookup( pAniKey, pFindAniInfo ) == false )
|
|
// {
|
|
// return NULL;
|
|
// }
|
|
// else
|
|
// {
|
|
// return pFindAniInfo;
|
|
// }
|
|
//
|
|
// return NULL;
|
|
//}
|
|
//
|
|
//void SAnimationDB::LoadAvatar()
|
|
//{
|
|
// //캐릭터
|
|
// KStream * pRes = KFileManager::Instance().CreateStreamFromResource( "db_AniInfo.rdb" );
|
|
// if( !pRes ) return;
|
|
//
|
|
// GAME_DB db_hdr;
|
|
//
|
|
// pRes->Read( &db_hdr, sizeof(GAME_DB) );
|
|
// for( int i(0); db_hdr.nCount>i; i++ )
|
|
// {
|
|
// AVATAR_ANIINFO * pAniData = new AVATAR_ANIINFO;
|
|
// memset( pAniData, 0, sizeof(AVATAR_ANIINFO) );
|
|
// pRes->Read( pAniData, sizeof(AVATAR_ANIINFO) );
|
|
//
|
|
//#ifndef NDEBUG
|
|
// if( strstr( pAniData->szAniName, "_biped" ) == NULL )
|
|
// {
|
|
// assert(0 && "게임 리소스 에러 : AniInfo에 _biped 없음!!" );
|
|
// }
|
|
//#endif
|
|
//
|
|
////#ifndef NDEBUG
|
|
//// for( int i(0); 7>i; i++ )
|
|
//// {
|
|
//// if( strstr( pAniData->szAniName, "dgo_" ) )
|
|
//// _oprint( "Load Ani : [Frame Len:%d] %s -> [Time:%d]- [Script:%s]\n", pAniData->nFrameLength, pAniData->szAniName, pAniData->nSound_Time[i], pAniData->szSound_Script[i] );
|
|
//// //_oprint( "Load Ani : [Frame Len:%d] %s -> [Time:%d]- [Script:%s]\n", pAniData->nFrameLength, pAniData->szAniName, pAniData->nEvent_Time[i], pAniData->szEvent_Script[i] );
|
|
//// }
|
|
////#endif
|
|
//
|
|
// //뒤에 부분만 잘른다.
|
|
// std::string strKey;
|
|
// CStringUtil::GetEventStrKey( pAniData->szAniName, '_', strKey );
|
|
//
|
|
// std::vector< struct AVATAR_ANIINFO* >* pFindAniInfo = NULL;
|
|
// if( m_hashAniInfo.lookup( strKey.c_str(), pFindAniInfo ) == false )
|
|
// {
|
|
// std::vector< struct AVATAR_ANIINFO* >* pAniInfoList = new std::vector< struct AVATAR_ANIINFO* >;
|
|
// pAniInfoList->push_back( pAniData );
|
|
//
|
|
// m_hashAniInfo.add( strKey.c_str(), pAniInfoList );
|
|
// }
|
|
// else
|
|
// {
|
|
// pFindAniInfo->push_back( pAniData );
|
|
// }
|
|
// }
|
|
//
|
|
// KFileManager::Instance().DeleteStream( pRes );
|
|
//
|
|
//// std::string strBuf( pstrTemp );
|
|
// //str_replace( strBuf, "\"\"", "강기현천재" );
|
|
// //str_replace( strBuf, "\"", "" );
|
|
// //str_replace( strBuf, "강기현천재", "\"" );
|
|
//// parseToken( strBuf.c_str(), vString, "\t\r\n", false );
|
|
//}
|
|
//
|
|
//SAnimationDB & GetAnimationDB()
|
|
//{
|
|
// static SAnimationDB aniDB;
|
|
// return aniDB;
|
|
//}
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
// PreLoad Info DB
|
|
SPreLoadDB::SPreLoadDB( SSoundManager * pSoundMng ) : m_pSoundMng(pSoundMng)
|
|
{
|
|
Init();
|
|
}
|
|
|
|
SPreLoadDB::~SPreLoadDB()
|
|
{
|
|
|
|
}
|
|
|
|
void SPreLoadDB::Init()
|
|
{
|
|
return;
|
|
|
|
Load();
|
|
}
|
|
|
|
void SPreLoadDB::Destroy()
|
|
{
|
|
|
|
}
|
|
|
|
void SPreLoadDB::CacheResLoad()
|
|
{
|
|
std::string strFile = KFileManager::Instance().CreateTemporaryFileFromResource( "cacheload.txt" );
|
|
|
|
KFileStream stream( strFile.c_str() );
|
|
if( stream.IsValid() == false ) return;
|
|
|
|
char * pBuf = new char[stream.GetLength()+1];
|
|
memset( pBuf, 0, stream.GetLength() + 1 );
|
|
|
|
stream.Read( pBuf, stream.GetLength() );
|
|
|
|
XStringUtil::Split( pBuf, m_vPreLoadList, "\r\n" ); //Tab or Return
|
|
|
|
delete [] pBuf;
|
|
|
|
int nNXX_Count = 0;
|
|
int nTex_Count = 0;
|
|
int nWav_Count = 0;
|
|
|
|
DWORD dwStart = GetSafeTickCount();
|
|
|
|
for( unsigned int i(0); m_vPreLoadList.size()>i; i++ )
|
|
{
|
|
std::vector< std::string > vString;
|
|
|
|
XStringUtil::Split( m_vPreLoadList[i].c_str(), vString, "\t" );
|
|
if( vString.size() == 1 )
|
|
{
|
|
// if( vString[1] > 메모리 허용 범위 것들 로딩 )
|
|
{
|
|
std::string strName = vString[0].c_str();
|
|
if( strstr( strName.c_str(), ".nx3" ) || strstr( strName.c_str(), ".naf" ) )
|
|
{
|
|
NX3LoadPack loadpack;
|
|
loadpack.Init();
|
|
|
|
KSequencer *seq = KNX3Manager::GetManager()->CreateSequencer( strName.c_str(), &loadpack );
|
|
KNX3Manager::GetManager()->AddToExceptList( strName.c_str() );
|
|
|
|
++nNXX_Count;
|
|
|
|
if( seq ) delete seq;
|
|
}
|
|
if( strstr( strName.c_str(), ".dds" ) || strstr( strName.c_str(), ".tga" ) )
|
|
{
|
|
NX3LoadPack loadpack;
|
|
loadpack.Init();
|
|
|
|
++nTex_Count;
|
|
|
|
K3DTexture * pTex = KTextureManager::GetManager()->GetTexture( strName.c_str(), &loadpack );
|
|
}
|
|
else if( strstr( strName.c_str(), ".wav" ) )
|
|
{
|
|
if( m_pSoundMng )
|
|
{
|
|
std::string file;
|
|
std::string::size_type pos = strName.rfind('/');
|
|
if( pos != std::string::npos )
|
|
{
|
|
file = strName.substr( pos+1, strName.length() );
|
|
m_pSoundMng->PreLoad( file.c_str(), true, false );
|
|
}
|
|
|
|
++nWav_Count;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
vString.clear();
|
|
}
|
|
|
|
_performance_print( "Cache Load Total Time %d ms\n", GetSafeTickCount()-dwStart );
|
|
|
|
_oprint( "CacheLoad : NXX:[%d] TEX:[%d] WAV:[%d]\n", nNXX_Count, nTex_Count, nWav_Count );
|
|
|
|
m_vPreLoadList.clear();
|
|
|
|
KFileManager::Instance().DeleteTemporaryFile( "cacheload.txt" );
|
|
}
|
|
|
|
void SPreLoadDB::Load()
|
|
{
|
|
std::string strFile = KFileManager::Instance().CreateTemporaryFileFromResource( "PreLoad.txt" );
|
|
|
|
KFileStream stream( strFile.c_str() );
|
|
if( stream.IsValid() == false ) return;
|
|
|
|
char * pBuf = new char[stream.GetLength()+1];
|
|
memset( pBuf, 0, stream.GetLength() + 1 );
|
|
|
|
stream.Read( pBuf, stream.GetLength() );
|
|
|
|
XStringUtil::Split( pBuf, m_vPreLoadList, "\r\n" ); //Tab or Return
|
|
|
|
delete [] pBuf;
|
|
|
|
// KSequencer *seq = KNX3Manager::GetManager()->CreateSequencer( "rcfx_ch_cast_intangible_start_lv01.nx3" );
|
|
// if( seq ) delete seq;
|
|
|
|
for( unsigned int i(0); m_vPreLoadList.size()>i; i++ )
|
|
{
|
|
std::vector< std::string > vString;
|
|
|
|
XStringUtil::Split( m_vPreLoadList[i].c_str(), vString, "\t" );
|
|
if( vString.size()>1 )
|
|
{
|
|
// if( vString[1] > 메모리 허용 범위 것들 로딩 )
|
|
{
|
|
std::string strName = vString[0].c_str();
|
|
if( strstr( strName.c_str(), ".nx3" ) || strstr( strName.c_str(), ".naf" ) )
|
|
{
|
|
NX3LoadPack loadpack;
|
|
loadpack.Init();
|
|
|
|
KSequencer *seq = KNX3Manager::GetManager()->CreateSequencer( strName.c_str(), &loadpack );
|
|
if( seq ) delete seq;
|
|
}
|
|
else if( strstr( strName.c_str(), ".wav" ) )
|
|
{
|
|
if( m_pSoundMng )
|
|
{
|
|
std::string file;
|
|
std::string::size_type pos = strName.rfind('/');
|
|
if( pos != std::string::npos )
|
|
{
|
|
file = strName.substr( pos+1, strName.length() );
|
|
m_pSoundMng->PreLoad( file.c_str(), true, false );
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
vString.clear();
|
|
}
|
|
|
|
m_vPreLoadList.erase( m_vPreLoadList.begin(), m_vPreLoadList.end() );
|
|
|
|
KFileManager::Instance().DeleteTemporaryFile( "PreLoad.txt" );
|
|
}
|
|
|
|
|
|
SPreLoadDB & GetPreLoadDB( class SSoundManager * pSoundMng )
|
|
{
|
|
static SPreLoadDB preloaddb(pSoundMng);
|
|
return preloaddb;
|
|
|
|
} |