#include "stdafx.h" #include "SPetDB.h" #include #include #include #include #include "KTypes.h" #include "SkillBaseFile.h" #include "SDebug_Util.h" K3DVector SPetInfoEx::getFaceCutCameraPosition() const { return K3DVector( m_Pet->camera_x, m_Pet->camera_y, m_Pet->camera_z ); } K3DVector SPetInfoEx::getTargetFxPosition() const { return K3DVector( m_Pet->target_x, m_Pet->target_y, m_Pet->target_z ); } SPetDB* SPetDB::m_pThis = NULL; SPetDB::SPetDB() { _init(); } SPetDB::~SPetDB() { _destroy(); } void SPetDB::_init() { _load(); #ifdef _DEBUG m_DummyPet.debug_name = "dummy pet"; #endif } void SPetDB::_destroy() { _PET_INFO_CLIENT* PetInfo = 0; bool Found = m_PetHash.get_first_value( PetInfo ); while( Found ) { SAFE_DELETE( PetInfo ); Found = m_PetHash.get_next_value( PetInfo ); } m_PetHash.clear(); } void SPetDB::_load() { _destroy(); KStream* Stream = KFileManager::Instance().CreateStreamFromResource( "db_pet.rdb" ); if( !Stream ) return; int PetCount = 0; GAME_DB DBHeader; Stream->Read( &DBHeader, sizeof( DBHeader ) ); for( int i = 0; i < DBHeader.nCount; ++i ) { _PET_INFO_CLIENT* PetInfo = new _PET_INFO_CLIENT; Stream->Read( PetInfo, sizeof( _PET_INFO_FILE ) ); PetInfo->uid_client = PetInfo->uid; PetInfo->uid = XFastRandom(); _PET_INFO_CLIENT* FoundPetInfo = 0; if( m_PetHash.lookup( PetInfo->uid_client, FoundPetInfo ) == false ) { ++PetCount; m_PetHash.add( PetInfo->uid_client, PetInfo ); } else { #ifdef _DEV char szBuffer[256] = { NULL, }; _stprintf_s( szBuffer, _countof(szBuffer), _T( "[Pet DB] 아이디가 중복되었습니다 [%u]"), PetInfo->uid_client ); assert( NULL ); MessageBox( HWND_DESKTOP, szBuffer, "Pet DB", MB_OK | MB_ICONERROR ); #endif delete PetInfo; } } _oprint( "[Pet DB] Pet 정보 로딩 개수 : [%d]\n", PetCount ); KFileManager::Instance().DeleteStream( Stream ); // prepare a dummy pet m_DummyPet.name_id = 0; m_DummyPet.cage_id = 0; m_DummyPet.attribute_flag = 0; m_DummyPet.size = 1.0f; m_DummyPet.scale = 1.0f; m_DummyPet.target_fx_size = 7.0f; m_DummyPet.walk_type = 4; // 4족 소형 m_DummyPet.slant_type = 1; // 기울임 m_DummyPet.texture_group = -1; m_DummyPet.camera_x = -5; m_DummyPet.camera_y = -21; m_DummyPet.camera_z = 14; m_DummyPet.target_x = -0.308f; m_DummyPet.target_y = -0.063f; m_DummyPet.target_z = -14.865f; ::sprintf( m_DummyPet.model, "%s", "beast_panthera_lv1" ); m_DummyPet.motion_file_id = 131; } SPetDB& GetPetDB() { if( NULL == SPetDB::m_pThis ) SPetDB::m_pThis = new SPetDB; return *SPetDB::m_pThis; // static SPetDB PetDB; // return PetDB; }