HRESULT KG3DScenePvsEditor::UnInit() { IIniFile* pIniFile = g_OpenIniFile("data\\public\\PvsEditorSetting.ini", false, true); if (pIniFile) { GetEnvironment().SaveMapSetting(pIniFile); pIniFile->Save("data\\public\\PvsEditorSetting.ini"); } if (m_lpPointLightRender) m_lpPointLightRender->UnInit(); SAFE_DELETE(m_lpPointLightRender); SAFE_RELEASE(pIniFile); KG3DSceneSelectionTool& selTool = this->GetSelectionTool(); selTool.ClearSelection(); SAFE_DELETE(m_lpLightMapBaker); SAFE_RELEASE(m_pGroundGridVertexs); SAFE_RELEASE(m_pPvs); SAFE_RELEASE(m_pHandObj); SAFE_DELETE(m_pHandPtl); SAFE_DELETE(m_pRunder); KG3DSceneEditorBase::UnInit(); return S_OK; }
LRESULT KGSFXGlobPage::OnColorBkDialogClose(WPARAM w, LPARAM l) { GET_SFX_EDITOR_RET(0); TCHAR szIniPath[MAX_PATH]; g_GetFullPath(szIniPath, TEXT("config.ini")); IIniFile* pIniFile = g_OpenIniFile(szIniPath, true, true); if (pIniFile) { pIniFile->WriteStruct(TEXT("SfxEditor"), TEXT("bkcolor"), pScene->GetBkColorPtr(), sizeof(DWORD)); pIniFile->Save(szIniPath); pIniFile->Release(); } return 1; }
void KG3DSelector::UnInit() { IIniFile *pConfig = g_OpenIniFile(g_szConfigFilePath, false, true); int nResult = 0; KG_PROCESS_ERROR(pConfig); nResult = pConfig->WriteInteger("KG3DENGINE", "SelectorScale", static_cast<int>(m_nScale)); KG_PROCESS_ERROR(nResult); pConfig->Save(g_szConfigFilePath); Exit0: SAFE_RELEASE(pConfig); SAFE_RELEASE(m_pStencilRT); SAFE_RELEASE(m_pStencilDepth); SAFE_RELEASE(m_pRT); SAFE_RELEASE(m_pResult); }
void KSceneEditorDialogAutoGrass::SaveTextureSettings() { CString strTextureName; TCHAR strIniFileName[MAX_PATH]; IIniFile* pInIFile = NULL; int nReturnCode = 0; KG_PROCESS_ERROR(m_nLastSel != -1); m_ComboxBoxTexture.GetLBText(m_nLastSel, strTextureName); sprintf(strIniFileName, "%s%s.ini", m_GrassTexturePath, strTextureName); pInIFile = g_OpenIniFile(strIniFileName, false, true); KG_PROCESS_ERROR(pInIFile); pInIFile->WriteInteger("Texture", "StrideX", m_nWidhtCount); pInIFile->WriteInteger("Texture", "StrideY", m_nHeightCount); pInIFile->Save(strIniFileName); Exit0: SAFE_RELEASE(pInIFile); return; }
int TestLoadAllBSP() { int nResult = false; int nRetCode = false; HRESULT hrRetCode = E_FAIL; unsigned uTotalCount = 0; unsigned uFailedCount = 0; unsigned uFailedCountSave = 0; BYTE *pbyTestFileData = NULL; BYTE *pbySourceFileData = NULL; IIniFile *pFile = NULL; IFile *piTestFile = NULL; IKG3DModel *piModel = NULL; IKG3DResourceManager *piModelTable = NULL; char szMessage[MAX_PATH] = ""; char szDirPath[MAX_PATH] = ""; TCHAR strBSPPathName[MAX_PATH] = ""; //vector<string> vecModelList; //vector<string> vecMeshList; MSG msg; nRetCode = GetCurrentDirectory(MAX_PATH, szDirPath); KG_PROCESS_ERROR(nRetCode > 0 && nRetCode < MAX_PATH + 1); strcat(szDirPath, "\\data\\source\\*.*"); szDirPath[MAX_PATH - 1] = '\0'; //strcpy(szDirPath, "D:\\Kingsoft\\Game\\sword3-products\\trunk\\client\\data\\source\\NPC_source\\*.*"); piModelTable = g_cEngineManager.Get3DModelTable(); KGLOG_PROCESS_ERROR(piModelTable); pFile = g_OpenIniFile(g_cszErrorFileName[EXT_MESH],false,true); KGLOG_PROCESS_ERROR(pFile); nRetCode = GetFileList(szDirPath, &g_vecSourceList/*vecMeshList*/, EXT_MESH); KGLOG_PROCESS_ERROR(nRetCode); //g_vecSourceList.push_back("D:\\Kingsoft\\Game\\trunk\\data\\source\\maps_source\\亭塔\\T_erg风车塔001A.Mesh"); uTotalCount = (unsigned)/*vecMeshList*/g_vecSourceList.size(); for (unsigned i = 0; i < uTotalCount; ++i) { char szKeyName[32] = ""; snprintf( szMessage, sizeof(szMessage), "Mesh模型的BSP文件检查:%s", /*vecMeshList*/g_vecSourceList[i].c_str() ); szMessage[sizeof(szMessage) - 1] = '\0'; SetWindowText(g_hWnd, szMessage); TCHAR strDriver[MAX_PATH]; TCHAR strPath[MAX_PATH]; TCHAR strFile[MAX_PATH]; _splitpath_s(g_vecSourceList[i].c_str(), strDriver, MAX_PATH, strPath, MAX_PATH, strFile, MAX_PATH, NULL, 0); //sprintf_s(strBSPPathName, // MAX_PATH, // "%s%s%s.bsp", // strDriver, // strPath, // strFile); //nRetCode = g_IsFileExist(strBSPPathName); //if (!nRetCode) //{ // /*itoa(uFailedCount, szKeyName, 10); // pFile->WriteString("BSP_NotExited",szKeyName, g_vecSourceList[i].c_str()); // ++uFailedCount;*/ // continue; //} try { g_bForceGenerateBspForMesh = /*FALSE*/TRUE; hrRetCode = piModelTable->LoadResourceFromFile(/*vecMeshList*/g_vecSourceList[i].c_str(), 0, 0, (IKG3DResourceBase**)&piModel); if (FAILED(hrRetCode)) { itoa(uFailedCount, szKeyName, 10); pFile->WriteString("ErrorMesh",szKeyName, /*vecMeshList*/g_vecSourceList[i].c_str()); ++uFailedCount; } KG_COM_RELEASE(piModel); g_cEngineManager.FrameMove(); g_bForceGenerateBspForMesh = FALSE; if (FAILED(hrRetCode)) { continue; } //cmp unsigned uTestFileDataSize = 0; unsigned uSourceFileDataSize = 0; unsigned uSizeRead = 0; sprintf_s(strBSPPathName, MAX_PATH, "%s%s%s.bsp", strDriver, strPath, strFile); nRetCode = g_IsFileExist(strBSPPathName); if (!nRetCode) { sprintf_s(strBSPPathName, MAX_PATH, "%s%s%s_test.bsp", strDriver, strPath, strFile); nRetCode = g_IsFileExist(strBSPPathName); if (nRetCode) { itoa(uFailedCount, szKeyName, 10); pFile->WriteString("BSP_NotGenerate",szKeyName, g_vecSourceList[i].c_str()); ++uFailedCount; DeleteFile(strBSPPathName); } continue; } piTestFile = g_OpenFile(strBSPPathName); KGLOG_PROCESS_ERROR(piTestFile); uSourceFileDataSize = piTestFile->Size(); KGLOG_PROCESS_ERROR(uSourceFileDataSize > sizeof(DWORD)); pbySourceFileData = new BYTE[uSourceFileDataSize]; KGLOG_PROCESS_ERROR(pbySourceFileData); uSizeRead = piTestFile->Read(pbySourceFileData, uSourceFileDataSize); KGLOG_PROCESS_ERROR(uSizeRead == uSourceFileDataSize); KG_COM_RELEASE(piTestFile); sprintf_s(strBSPPathName, MAX_PATH, "%s%s%s_test.bsp", strDriver, strPath, strFile); piTestFile = g_OpenFile(strBSPPathName); if (!piTestFile) { itoa(uFailedCount, szKeyName, 10); pFile->WriteString("BSP_Don't Exited",szKeyName, g_vecSourceList[i].c_str()); ++uFailedCount; SAFE_DELETE_ARRAY(pbySourceFileData); continue; } uTestFileDataSize = piTestFile->Size(); KGLOG_PROCESS_ERROR(uTestFileDataSize > sizeof(DWORD)); pbyTestFileData = new BYTE[uTestFileDataSize]; KGLOG_PROCESS_ERROR(pbyTestFileData); uSizeRead = piTestFile->Read(pbyTestFileData, uTestFileDataSize); KGLOG_PROCESS_ERROR(uSizeRead == uTestFileDataSize); KG_COM_RELEASE(piTestFile); if (uTestFileDataSize != uSourceFileDataSize) { itoa(uFailedCount, szKeyName, 10); pFile->WriteString("BSP_NotMatchedSize",szKeyName, g_vecSourceList[i].c_str()); ++uFailedCount; DeleteFile(strBSPPathName); SAFE_DELETE_ARRAY(pbyTestFileData); SAFE_DELETE_ARRAY(pbySourceFileData); continue; } nRetCode = memcmp(pbyTestFileData, pbySourceFileData, uSourceFileDataSize); if (nRetCode) { itoa(uFailedCount, szKeyName, 10); pFile->WriteString("BSP_NotMatched",szKeyName, g_vecSourceList[i].c_str()); ++uFailedCount; DeleteFile(strBSPPathName); SAFE_DELETE_ARRAY(pbyTestFileData); SAFE_DELETE_ARRAY(pbySourceFileData); continue; } DeleteFile(strBSPPathName); SAFE_DELETE_ARRAY(pbyTestFileData); SAFE_DELETE_ARRAY(pbySourceFileData); } catch (...) { itoa(uFailedCount, szKeyName, 10); pFile->WriteString("Mesh_Exception",szKeyName, /*vecMeshList*/g_vecSourceList[i].c_str()); ++uFailedCount; } while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { switch (msg.message) { case WM_QUIT: break; default: TranslateMessage(&msg); DispatchMessage(&msg); } } if (msg.message == WM_QUIT) break; } //uFailedCount += uFailedCountSave; //uTotalCount = (unsigned)(vecModelList.size() + vecMeshList.size()); // snprintf( // szMessage, sizeof(szMessage), // "模型加载检查完成:共检查模型 %u 个 已发现错误 %u 个,请检查文件%s", // uTotalCount, uFailedCount, g_cszErrorFileName[TYPE_MDL] //); //szMessage[sizeof(szMessage) - 1] = '\0'; //::MessageBox(g_hWnd, szMessage, "检查报告", MB_OK); nResult = true; Exit0: if (pFile) { pFile->WriteInteger("ErrorMesh", "ErrorNum", uFailedCount); pFile->Save(g_cszErrorFileName[EXT_MESH]); } SAFE_DELETE_ARRAY(pbyTestFileData); SAFE_DELETE_ARRAY(pbySourceFileData); if (strstr(strBSPPathName, "_test.bsp")) { DeleteFile(strBSPPathName); } KG_COM_RELEASE(piModel); KG_COM_RELEASE(pFile); KG_COM_RELEASE(piTestFile); g_bForceGenerateBspForMesh = FALSE; g_vecSourceList.clear(); return nResult; }
int TestLoadAllDetail() { int nResult = false; int nRetCode = false; HRESULT hrRetCode = E_FAIL; unsigned uTotalCount = 0; unsigned uFailedCount = 0; unsigned uFailedCountSave = 0; IIniFile *pFile = NULL; IKG3DModel *piModel = NULL; IKG3DResourceManager *piModelTable = NULL; char szMessage[MAX_PATH] = ""; char szDirPath[MAX_PATH] = ""; //vector<string> vecModelList; //vector<string> vecMeshList; MSG msg; nRetCode = GetCurrentDirectory(MAX_PATH, szDirPath); KG_PROCESS_ERROR(nRetCode > 0 && nRetCode < MAX_PATH + 1); strcat(szDirPath, "\\data\\source\\NPC_source\\*.*"); szDirPath[MAX_PATH - 1] = '\0'; //strcpy(szDirPath, "D:\\Kingsoft\\Game\\sword3-products\\trunk\\client\\data\\source\\NPC_source\\*.*"); piModelTable = g_cEngineManager.Get3DModelTable(); KGLOG_PROCESS_ERROR(piModelTable); pFile = g_OpenIniFile(g_cszErrorFileName[EXT_MESH],false,true); KGLOG_PROCESS_ERROR(pFile); nRetCode = GetFileList(szDirPath, &g_vecSourceList/*vecMeshList*/, EXT_MESH); KGLOG_PROCESS_ERROR(nRetCode); uTotalCount = (unsigned)/*vecMeshList*/g_vecSourceList.size(); /*uFailedCountSave = uFailedCount;*/ for (unsigned i = 0; i < uTotalCount; ++i) { char szKeyName[32] = ""; snprintf( szMessage, sizeof(szMessage), "Mesh模型加载检查文件:%s", /*vecMeshList*/g_vecSourceList[i].c_str() ); szMessage[sizeof(szMessage) - 1] = '\0'; SetWindowText(g_hWnd, szMessage); try { hrRetCode = piModelTable->LoadResourceFromFile(/*vecMeshList*/g_vecSourceList[i].c_str(), 0, 0, (IKG3DResourceBase**)&piModel); if (SUCCEEDED(hrRetCode)) { KG3DModel *pModel = (KG3DModel*)piModel; if(pModel->GetDetail() == NULL) { itoa(uFailedCount, szKeyName, 10); pFile->WriteString("ErrorDetail",szKeyName, /*vecMeshList*/g_vecSourceList[i].c_str()); ++uFailedCount; KGLogPrintf(KGLOG_ERR, "%s", g_vecSourceList[i].c_str()); } } KG_COM_RELEASE(piModel); g_cEngineManager.FrameMove(); } catch (...) { itoa(uFailedCount, szKeyName, 10); pFile->WriteString("Detail_Exception",szKeyName, /*vecMeshList*/g_vecSourceList[i].c_str()); ++uFailedCount; } while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { switch (msg.message) { case WM_QUIT: break; default: TranslateMessage(&msg); DispatchMessage(&msg); } } if (msg.message == WM_QUIT) break; } pFile->WriteInteger("ErrorDetail", "ErrorNum", uFailedCount); pFile->Save(g_cszErrorFileName[EXT_MESH]); //uFailedCount += uFailedCountSave; //uTotalCount = (unsigned)(vecModelList.size() + vecMeshList.size()); // snprintf( // szMessage, sizeof(szMessage), // "模型加载检查完成:共检查模型 %u 个 已发现错误 %u 个,请检查文件%s", // uTotalCount, uFailedCount, g_cszErrorFileName[TYPE_MDL] //); //szMessage[sizeof(szMessage) - 1] = '\0'; //::MessageBox(g_hWnd, szMessage, "检查报告", MB_OK); nResult = true; Exit0: KG_COM_RELEASE(piModel); KG_COM_RELEASE(pFile); g_vecSourceList.clear(); return nResult; }
int TestLoadAllMaterial() { int nResult = false; int nRetCode = false; HRESULT hrRetCode = E_FAIL; unsigned uTotalCount = 0; unsigned uFailedCount = 0; unsigned uFailedCountSave = 0; IIniFile *pFile = NULL; IEKG3DMaterial *piMTL = NULL; char szMessage[MAX_PATH] = ""; char szDirPath[MAX_PATH] = ""; //vector<string> vecMTLList; MSG msg; nRetCode = GetCurrentDirectory(MAX_PATH, szDirPath); KG_PROCESS_ERROR(nRetCode > 0 && nRetCode < MAX_PATH + 1); strcat(szDirPath, "\\data\\*.*"); szDirPath[MAX_PATH - 1] = '\0'; pFile = g_OpenIniFile(g_cszErrorFileName[EXT_MTL],false,true); KGLOG_PROCESS_ERROR(pFile); g_vecSourceList.clear(); nRetCode = GetFileList(szDirPath, &g_vecSourceList/*vecMTLList*/, EXT_MTL); KGLOG_PROCESS_ERROR(nRetCode); uTotalCount = (unsigned)/*vecMTLList*/g_vecSourceList.size(); for (unsigned i = 0; i < uTotalCount; ++i) { char szKeyName[32] = ""; snprintf( szMessage, sizeof(szMessage), "材质加载检查文件:%s", /*vecMTLList*/g_vecSourceList[i].c_str() ); szMessage[sizeof(szMessage) - 1] = '\0'; SetWindowText(g_hWnd, szMessage); try { hrRetCode = g_cMaterialTable.LoadResourceFromFile(/*vecMTLList*/g_vecSourceList[i].c_str(), 0, 0, (IKG3DResourceBase**)&piMTL); if (FAILED(hrRetCode)) { itoa(uFailedCount, szKeyName, 10); pFile->WriteString("ErrorMTL",szKeyName, /*vecMTLList*/g_vecSourceList[i].c_str()); ++uFailedCount; } KG_COM_RELEASE(piMTL); } catch (...) { itoa(uFailedCount, szKeyName, 10); pFile->WriteString("MTL_Exception",szKeyName, /*vecMTLList*/g_vecSourceList[i].c_str()); ++uFailedCount; } while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { switch (msg.message) { case WM_QUIT: break; default: TranslateMessage(&msg); DispatchMessage(&msg); } } if (msg.message == WM_QUIT) break; } pFile->WriteInteger("ErrorMTL", "ErrorNum", uFailedCount); //uFailedCount += uFailedCountSave; //uTotalCount = (unsigned)(vecModelList.size() + vecMeshList.size()); // snprintf( // szMessage, sizeof(szMessage), // "模型加载检查完成:共检查模型 %u 个 已发现错误 %u 个,请检查文件%s", // uTotalCount, uFailedCount, g_cszErrorFileName[TYPE_MDL] //); //szMessage[sizeof(szMessage) - 1] = '\0'; //::MessageBox(g_hWnd, szMessage, "检查报告", MB_OK); pFile->Save(g_cszErrorFileName[EXT_MTL]); nResult = true; Exit0: KG_COM_RELEASE(piMTL); KG_COM_RELEASE(pFile); return nResult; }
int TestLoadAllSound() { int nResult = false; int nRetCode = false; HRESULT hrRetCode = E_FAIL; unsigned uTotalCount = 0; unsigned uFailedCount = 0; IIniFile *pFile = NULL; KG3DAnimationTagContainer *pContainer = NULL; char szMessage[MAX_PATH] = ""; char szDirPath[MAX_PATH] = ""; //vector<string> vecContainerList; vector<string> vecErrorSoundList; MSG msg; BOOL bSave = g_eEngineOption.bUseMultiThreadAni; g_eEngineOption.bUseMultiThreadAni = FALSE; nRetCode = GetCurrentDirectory(MAX_PATH, szDirPath); KG_PROCESS_ERROR(nRetCode > 0 && nRetCode < MAX_PATH + 1); strcat(szDirPath, "\\data\\*.*"); szDirPath[MAX_PATH - 1] = '\0'; pFile = g_OpenIniFile(g_cszErrorFileName[EXT_TANI], false,true); KGLOG_PROCESS_ERROR(pFile); g_vecSourceList.clear(); nRetCode = GetFileList(szDirPath, &g_vecSourceList/*vecContainerList*/, EXT_TANI); KGLOG_PROCESS_ERROR(nRetCode); uTotalCount = (unsigned)/*vecContainerList*/g_vecSourceList.size(); for (unsigned i = 0; i < uTotalCount; ++i) { char szKeyName[32] = ""; snprintf( szMessage, sizeof(szMessage), "加载检查标签文件:%s", /*vecContainerList*/g_vecSourceList[i].c_str() ); szMessage[sizeof(szMessage) - 1] = '\0'; SetWindowText(g_hWnd, szMessage); try { pContainer = new KG3DAnimationTagContainer(); hrRetCode = pContainer->_Load(/*vecContainerList*/g_vecSourceList[i].c_str()); if (FAILED(hrRetCode)) { itoa(uFailedCount, szKeyName, 10); pFile->WriteString("ErrorTani",szKeyName, /*vecContainerList*/g_vecSourceList[i].c_str()); ++uFailedCount; } /* else { for (int i = 0; i < (int)(pContainer->m_vecTags.size()); ++i) { KG3DAnimationTagContainer::Item Tag = (pContainer->m_vecTags)[i]; if (Tag.Type == 1) { KG3DAnimationSoundTag *pTag = (KG3DAnimationSoundTag *)Tag.pTag; KG3DAnimationSoundTag::DataStructure::iterator itFind = pTag->m_Tags.begin(); while (itFind != pTag->m_Tags.end()) { for (int j = 0; j < (itFind->second).Data.dwValidateCandidate; ++j) { char *pSoundName = (itFind->second).Data.SoundCandidates[j].strSoundFileName.strFileName; nRetCode = g_IsFileExist(pSoundName); if (!nRetCode && pSoundName[0]) { vecErrorSoundList.push_back(pSoundName); } } ++itFind; } } if (vecErrorSoundList.size()) { ++uFailedCount; } for (int j =0; j < vecErrorSoundList.size(); ++j) { itoa(j, szKeyName, 10); pFile->WriteString(vecContainerList[i].c_str(), szKeyName, vecErrorSoundList[i].c_str()); } } }*/ SAFE_RELEASE(pContainer); } catch (...) { itoa(uFailedCount, szKeyName, 10); pFile->WriteString("Tani_Exception",szKeyName, /*vecContainerList*/g_vecSourceList[i].c_str()); ++uFailedCount; } while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { switch (msg.message) { case WM_QUIT: break; default: TranslateMessage(&msg); DispatchMessage(&msg); } } if (msg.message == WM_QUIT) break; } pFile->WriteInteger("ErrorTani", "ErrorNum", uFailedCount); //snprintf( // szMessage, sizeof(szMessage), // "模型加载检查完成:共检查标签 %u 个 已发现错误 %u 个,请检查文件%s", // uTotalCount, uFailedCount, g_cszErrorFileName[TYPE_SOUND] //); //szMessage[sizeof(szMessage) - 1] = '\0'; //::MessageBox(g_hWnd, szMessage, "检查报告", MB_OK); pFile->Save(g_cszErrorFileName[EXT_TANI]); nResult = true; Exit0: SAFE_DELETE(pContainer); KG_COM_RELEASE(pFile); g_eEngineOption.bUseMultiThreadAni = bSave; return nResult; }