// EffectCasher.cpp: implementation of the CEffectCasher class. // ////////////////////////////////////////////////////////////////////// #include "EffectCasher.h" #include "SceneManager.h" ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// CEffectCashObj::CEffectCashObj() { m_pData = NULL; } CEffectCashObj::CEffectCashObj(const char *strName) { EffectLoad(strName); } bool CEffectCashObj::EffectLoad(const char *strName) { m_pData = new CEffScript; m_pData->GetScriptBinData((char *)strName); m_pData->SetDevice(CSceneManager::GetDevice()); /* m_pData->SetStartPos(0.0f,0.0f,0.0f); m_pData->SetEndPos(0.0f,0.0f,0.0f); m_pData->ProcessEffect(); */ return true; } CEffectCashObj::~CEffectCashObj() { if(m_pData != NULL) { delete m_pData; m_pData = NULL; } } CEffectCasher::CEffectCasher() { } CEffectCasher::~CEffectCasher() { } bool CEffectCasher::LoadCashData(const char *strPath) { return true; } bool CEffectCasher::BuildHashTable(const char *strPath) { char strFilePath[256] = {0,}; strcpy(strFilePath,strPath); strcat(strFilePath,"/*.esf"); WIN32_FIND_DATA FindFileData; HANDLE hFind; hFind = FindFirstFile(strFilePath, &FindFileData); if (hFind == INVALID_HANDLE_VALUE) { MessageBox(NULL,"Effect Loader°¡ ½ÇÆÐ Çß½À´Ï´Ù.","ERROR",MB_OK); return false; } m_iCashNum = 0; while(1) { unsigned long ulTmp; CEffectCashObj *pNode = new CEffectCashObj(FindFileData.cFileName); ulTmp = CheckHashIndex(FindFileData.cFileName); ISDATAITER itr = m_HashTable.find(ulTmp); if(itr == m_HashTable.end()) { m_HashTable.insert(DATACASHOBJ(ulTmp,pNode)); m_iCashNum++; } else {// map ¾È¿¡ ¶È°°Àº Hash Index ¸¦ °¡Áö´Â ¿ä¼Ò Á¸Àç ((*itr).second)->m_pNext.push_back(pNode); ((*itr).second)->m_iNext++; } if(!FindNextFile(hFind,&FindFileData)) break; } FindClose(hFind); return true; } void *CEffectCasher::GetCashData(const char *strName) { unsigned long ulTmp = CheckHashIndex(strName); ISDATAITER itr = m_HashTable.find(ulTmp); if(itr == m_HashTable.end()) return NULL; if((*itr).second != NULL) { if(!strcmp(((CEffectCashObj *)((*itr).second))->m_pData->m_FileName,strName)) return ((CEffectCashObj *)((*itr).second))->m_pData; else { for(int i=0;i < ((*itr).second)->m_iNext; i++) { if(!strcmp(((CEffectCashObj *)(((*itr).second)->m_pNext[i]))->m_pData->m_FileName,strName)) return ((CEffectCashObj *)(((*itr).second)->m_pNext[i]))->m_pData; } } } return NULL; } // Hash Index Check( ¹®ÀÚ¿­ ) unsigned long CEffectCasher::CheckHashIndex(const char *strFileName) { unsigned long ulHashId = 0; int iLength = strlen(strFileName); for(int i=0;i < iLength; i++) { ulHashId += (( i + 1) * strFileName[i]); } return ulHashId; }