int main(int argc, char* argv[]) { int nResult = false; int nRetCode = false; int nLogInitFlag = false; int nRdbFlag = false; KGLOG_PARAM LogParam; KSO3RoleDBUpdater* pKSO3RoleDBUpdater = NULL; #ifdef WIN32 SetConsoleInfo(); #endif setlocale(LC_ALL, ""); g_SetRootPath(NULL); strncpy(LogParam.szPath, "logs", sizeof(LogParam.szPath)); LogParam.szPath[sizeof(LogParam.szPath) - 1] = '\0'; strncpy(LogParam.szIdent, "SO3RoleDBUpdaterTest", sizeof(LogParam.szIdent)); LogParam.szIdent[sizeof(LogParam.szIdent) - 1] = '\0'; LogParam.Options = (KGLOG_OPTIONS)(KGLOG_OPTION_FILE | KGLOG_OPTION_CONSOLE); LogParam.nMaxLineEachFile = 160000; nRetCode = KGLogInit(LogParam, NULL); KGLOG_PROCESS_ERROR(nRetCode); nLogInitFlag = true; pKSO3RoleDBUpdater = new KSO3RoleDBUpdater(); KGLOG_PROCESS_ERROR(pKSO3RoleDBUpdater); nRetCode = pKSO3RoleDBUpdater->Init(); KGLOG_PROCESS_ERROR(nRetCode); nRdbFlag = true; KGLogPrintf(KGLOG_INFO, "SO3RoleDBUpdaterTest had started up ... ..."); nRetCode = pKSO3RoleDBUpdater->Run(); KGLOG_PROCESS_ERROR(nRetCode); KGLogPrintf(KGLOG_INFO, "SO3RoleDB UpdateTest Complete..."); nResult = true; Exit0: if (nRdbFlag) { pKSO3RoleDBUpdater->UnInit(); nRdbFlag = false; } KG_DELETE(pKSO3RoleDBUpdater); if (nLogInitFlag) { KGLogUnInit(NULL); nLogInitFlag = false; } return nResult ? 0 : 1; }
int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) { int nResult = false; int nRetCode = false; int nKGLogInitFlag = false; KGLOG_PARAM KGLogParm = {"logs", "GameUpdater", KGLOG_OPTION_FILE, 1000 * 10}; int nGameUpdaterInitFlag = false; KGU_GameUpdater GameUpdater; TCHAR szApplicationName[MAX_PATH]; TCHAR szCurrentDir[MAX_PATH]; nRetCode = _SetCurrentDirectory(); KG_PROCESS_ERROR(nRetCode); nRetCode = KGLogInit(KGLogParm, NULL); KG_PROCESS_ERROR(nRetCode); nKGLogInitFlag = true; // Log the build time which is useful for debugging. KGLogPrintf(KGLOG_INFO, "The gameupdater.exe is built at "__DATE__" "__TIME__"\n"); // Log the application name, which could be distinguished the client is main version or child version. nRetCode = GetModuleFileName(NULL, szApplicationName, _countof(szApplicationName)); KGLOG_PROCESS_ERROR(nRetCode > 0); KGLOG_PROCESS_ERROR(nRetCode < _countof(szApplicationName)); KGLogPrintf(KGLOG_INFO, "The full file name is `%s`", szApplicationName); // Log the current working path, which is useful for debugging. nRetCode = GetCurrentDirectory(_countof(szCurrentDir), szCurrentDir); KGLOG_PROCESS_ERROR(nRetCode > 0); KGLOG_PROCESS_ERROR(nRetCode < _countof(szCurrentDir)); KGLogPrintf(KGLOG_INFO, "The current working path is `%s`", szCurrentDir); nRetCode = GameUpdater.Init(lpCmdLine, NULL); KGLOG_PROCESS_ERROR(nRetCode && "Init()"); nGameUpdaterInitFlag = true; nRetCode = GameUpdater.Run(); KGLOG_PROCESS_ERROR(nRetCode && "Run()"); nResult = true; Exit0: if (nGameUpdaterInitFlag) { GameUpdater.UnInit(NULL); nGameUpdaterInitFlag = false; } if (nKGLogInitFlag) { KGLogUnInit(NULL); nKGLogInitFlag = false; } return nResult ? 0 : 1; }
int main(int nArgc, char *pszArgv[]) { int nRetCode = false; int nResult = false; BOOL bLogInited = false; CppUnit::KG_Cppunit TestSuit(TESTING_NAME); KGLOG_PARAM LogParam = {_T(""), _T(""), KGLOG_OPTION_FILE, 65535 * 2}; nRetCode = _tcscpy_s(LogParam.szPath, PATH_MAX, TESTING_LOG_DIR); KG_PROCESS_ERROR(nRetCode == 0); LogParam.szPath[PATH_MAX - 1] = _T('\0'); nRetCode = _tcscpy_s(LogParam.szIdent, PATH_MAX, TESTING_LOG_NAME); KG_PROCESS_ERROR(nRetCode == 0); LogParam.szIdent[PATH_MAX - 1] = _T('\0'); nRetCode = KGLogInit(LogParam, (PVOID)TESTING_LOG_NAME); KG_PROCESS_ERROR(nRetCode); bLogInited = true; nRetCode = Init(); KG_PROCESS_ERROR(nRetCode); nRetCode = TestSuit.RunTest(); KG_PROCESS_ERROR(nRetCode); nRetCode = TestSuit.Output(); KG_PROCESS_ERROR(nRetCode); nResult = true; Exit0: if (bLogInited) { KGLogUnInit((PVOID)TESTING_LOG_NAME); } system("Pause"); return nResult ? 0 : 1; }
void InitLog() { int nRetCode = false; int nLogInitFlag = false; int nMemoryInitFlag = false; char szLogsPath[MAX_PATH] = { 0 }; char szRootPath[MAX_PATH] = { 0 }; KGLOG_PARAM LogParam; memset(&LogParam, 0, sizeof(LogParam)); GetCurrentDirectoryA(MAX_PATH, szRootPath); _snprintf(LogParam.szPath, _countof(LogParam.szPath), "%s\\%s", szRootPath, "logs"); strncpy(LogParam.szIdent, "AtlRecordeOperator", _countof(LogParam.szIdent)); LogParam.nMaxLineEachFile = 65536 * 2; LogParam.Options = (KGLOG_OPTIONS)KGLOG_OPTION_FILE; nRetCode = KGLogInit(LogParam, NULL); KG_PROCESS_ERROR(nRetCode); nLogInitFlag = true; Exit0: return; }
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) { HRESULT hRetCode = E_FAIL; int nRetCode = false; int nKGLogInitFlag = false; int nKG3DEngineInitFlag = false; int nX = 0; int nY = 0; int nWidth = 0; int nHeight = 0; char szBuffer[MAX_PATH] = ""; KGLOG_PARAM LogParam = {"logs", "KG3DEngine", KGLOG_OPTION_FILE, 65536}; WNDCLASSEX wcex = {0}; MSG msg = {0}; UNREFERENCED_PARAMETER(hPrevInstance); UNREFERENCED_PARAMETER(lpCmdLine); nRetCode = KGLogInit(LogParam, NULL); KG_PROCESS_ERROR(nRetCode); nKGLogInitFlag = true; g_SetRootPath(NULL); //SetLowerConfig(); wcex.cbSize = sizeof(WNDCLASSEX); wcex.style = CS_HREDRAW | CS_VREDRAW; wcex.lpfnWndProc = WndProc; wcex.hInstance = hInstance; wcex.hCursor = LoadCursor(NULL, IDC_ARROW); wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); wcex.lpszClassName = TEXT("KG3DEnginePerformanceAnalyzer"); RegisterClassEx(&wcex); nX = 0; nY = 0; nWidth = 800; nHeight = 600; g_hWnd = ::CreateWindow( wcex.lpszClassName, TEXT("3D引擎性能分析程序"), WS_OVERLAPPEDWINDOW | WS_VISIBLE/*WS_CAPTION | WS_SYSMENU*/, nX, nY, nWidth, nHeight, NULL, NULL, hInstance, NULL ); KGLOG_PROCESS_ERROR(g_hWnd); ShowWindow(g_hWnd, true/*nCmdShow*/); UpdateWindow(g_hWnd); //ASSERT(FALSE); //-------------------------------- hRetCode = g_cEngineManager.Init(0, KG3DENG_CLIENT, g_hWnd, g_hWnd); KGLOG_COM_PROCESS_ERROR(hRetCode); nKG3DEngineInitFlag = true; for (int nIndex = 0; nIndex < EXT_T0TAL; ++nIndex) { DeleteFile(g_cszErrorFileName[nIndex]); } ::MessageBox(NULL, "搜索所有列表,进行Mesh,Mdl,Speedtree,Sfx,Mtl,Tani的检查,请耐心等待……", "提示", MB_OK); //TestScene(); //TestLoadAllMesh(); //KGLogPrintf(KGLOG_INFO, "Load Mesh Over\n"); //TestLoadAllDetail(); //KGLogPrintf(KGLOG_INFO, "Load Detail Over\n"); //TestLoadAllMDL(); //KGLogPrintf(KGLOG_INFO, "Load MDL Over\n"); //TestLoadAllSPEEDTREE(); //KGLogPrintf(KGLOG_INFO, "Load SPEEDTREE Over\n"); //TestLoadAllSFX(); //KGLogPrintf(KGLOG_INFO, "Load SFX Over\n"); //TestLoadAllMaterial(); //TestLoadAllSound(); TestLoadAllBSP(); KGLogPrintf(KGLOG_INFO, "Load Bsp Over\n"); snprintf( szBuffer, sizeof(szBuffer), "检查完毕,请查看文件%s", g_cszErrorFileName ); szBuffer[sizeof(szBuffer) - 1] = '\0'; ::MessageBox(NULL, szBuffer, "提示", MB_OK); Exit0: if (nKG3DEngineInitFlag) { g_cEngineManager.UnInit(); nKG3DEngineInitFlag = false; } if (nKGLogInitFlag) { KGLogUnInit(NULL); nKGLogInitFlag = false; } return (int) msg.wParam; }
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) { typedef HRESULT (*fnGet3DEngineInterface)(void**); fnGet3DEngineInterface pfnGet3DEngineInterface = NULL; g_hMod = NULL; HRESULT hr = E_FAIL; if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1) return -1; if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) || !m_wndToolBar.LoadToolBar(IDR_MAINFRAME)) { //TRACE0("Failed to create toolbar\n"); return -1; // fail to create } if (!m_wndStatusBar.Create(this) || !m_wndStatusBar.SetIndicators(indicators, sizeof(indicators)/sizeof(UINT))) { //TRACE0("Failed to create status bar\n"); return -1; // fail to create } if(!m_wndProgressDialogBar.Create(this,IDD_PROGRESS_DIALOGBAR, CBRS_ALIGN_BOTTOM | CBRS_BOTTOM | CBRS_TOOLTIPS | CBRS_FLYBY,IDD_PROGRESS_DIALOGBAR)) { //TRACE0("Failed to create toolbar\n"); return -1; } if(!m_wndMasterlistDialogBar.Create(this,IDD_MASTERLIST_DIALOGBAR, CBRS_ALIGN_RIGHT | CBRS_RIGHT | CBRS_TOOLTIPS | CBRS_FLYBY,IDD_MASTERLIST_DIALOGBAR)) { //TRACE0("Failed to create toolbar\n"); return -1; } // TODO: Delete these three lines if you don't want the toolbar to be dockable m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY); EnableDocking(CBRS_ALIGN_ANY); DockControlBar(&m_wndToolBar); m_wndMasterlistDialogBar.EnableDocking(CBRS_ALIGN_RIGHT); DockControlBar(&m_wndMasterlistDialogBar); m_wndProgressDialogBar.EnableDocking(CBRS_ALIGN_BOTTOM); DockControlBar(&m_wndProgressDialogBar); g_bSlider = TRUE; KGLOG_PARAM LogParam = {"logs", "Record", KGLOG_OPTION_FILE, 65536}; int nRetCode = KGLogInit(LogParam, NULL); g_SetRootPath(); g_SetFilePath(""); g_GetRootPath(g_szDefWorkDirectory); //SetCurrentDirectory(); #ifdef _DEBUG g_hMod = ::LoadLibraryA("KG3DEngineD.dll"); #else g_hMod = ::LoadLibraryA("KG3DEngine.dll"); #endif if (g_hMod == NULL) return -1; pfnGet3DEngineInterface = (fnGet3DEngineInterface)GetProcAddress(g_hMod, "Get3DEngineInterface"); if (pfnGet3DEngineInterface == NULL) return -1; hr = pfnGet3DEngineInterface((void**)&g_p3DEngine); if (hr == E_FAIL) return -1; ASSERT(g_p3DEngine); IEKG3DEngineManager* pEngine = static_cast<IEKG3DEngineManager*>(g_p3DEngine); ASSERT(pEngine); pEngine->GetGraphicsTool(&g_p3DTools); ASSERT(g_p3DTools); hr = g_p3DEngine->Init(0,KG3DENG_CLIENT | KG3DENG_RECORD, m_hWnd, m_hWnd); if (hr == E_FAIL) return -1; //pEngine->SetAutoReloadTexture(TRUE); RecordOption recordOption; recordOption.Size.cx = 1024; recordOption.Size.cy = 768; recordOption.nAutoScale = FALSE; recordOption.FiterType = D3DTEXF_LINEAR; recordOption.fInterval = 41; recordOption.ImageType = D3DXIFF_JPG; recordOption.bKeep = FALSE; g_p3DEngine->SetRecordOption(&recordOption); return 0; }
BOOL Init3DEngine(unsigned uMode, unsigned int uFlag, HWND hBaseWindow, HWND hRenderWindow, BSTR strEnginePath, BSTR strStartUpPath) { ATLTRACE("#####################3DEngine Initializing!##################\r\n"); BOOL bRetCode = false; KGLOG_PARAM LogParam; char szCWD[MAX_PATH]; getcwd(szCWD, sizeof(szCWD)); memset(&LogParam, 0, sizeof(LogParam)); snprintf(LogParam.szPath,sizeof(LogParam.szPath),"%s\\logs",szCWD); LogParam.szPath[sizeof(LogParam.szPath) - 1] = '\0'; strcpy(LogParam.szIdent, "AtlaxKG3D"); LogParam.nMaxLineEachFile = 65536; LogParam.Options = (KGLOG_OPTIONS)KGLOG_OPTION_FILE; bRetCode = KGLogInit(LogParam, NULL); if (!bRetCode) { ::MessageBox(NULL, "Log文件初始化失败!", NULL, NULL); return FALSE; } TCHAR szCurDir[MAX_PATH]; sprintf(szCurDir, BSTR_TO_STRING(strStartUpPath)); strcat(szCurDir, "/3DProxy/"); g_SetRootPath(szCurDir); SetCurrentDirectory(szCurDir); KGLogPrintf(KGLOG_DEBUG, "strStartUpPath=%s", BSTR_TO_STRING(strStartUpPath)); #ifdef _DEBUG strcat(szCurDir, "KG3DEngineD.dll"); #else strcat(szCurDir, "KG3DEngine.dll"); #endif g_3dEngineDll.Init(szCurDir); KGLogPrintf(KGLOG_DEBUG, "%s loaddll成功", szCurDir); g_SetRootPath(BSTR_TO_STRING(strEnginePath)); // in Engine_lua5(D).dll lstrcpy(g_EnginePath, BSTR_TO_STRING(strEnginePath)); SetCurrentDirectory(BSTR_TO_STRING(strEnginePath)); lstrcpy(g_szDefWorkDirectory, g_EnginePath); HMODULE h = g_3dEngineDll.GetDllHandle(); _ASSERTE(h); if (!h) return FALSE; KGLogPrintf(KGLOG_DEBUG, "g_3dEngineDll loaddll成功"); if (lstrlen(g_EnginePath) <= 0) { HMODULE hDll = GetModuleHandle("atlax.dll"); if (hDll) { KGLogPrintf(KGLOG_DEBUG, "atlax.dll loaddll成功"); TCHAR szBuf[MAX_PATH + 1]; GetModuleFileName(hDll, szBuf, MAX_PATH); CString strTemp = szBuf; CString strDir = strTemp.Left(strTemp.ReverseFind('\\')); SetCurrentDirectory(strDir); } } else // { SetCurrentDirectory(g_EnginePath); } typedef HRESULT (*pfnGet3DEngineInterface)(void** pEngineManager); pfnGet3DEngineInterface Get3DEngineInterface = (pfnGet3DEngineInterface)GetProcAddress(h, "Get3DEngineInterface"); _ASSERTE(Get3DEngineInterface); if (!Get3DEngineInterface) return FALSE; IEKG3DEngineManager* pInterface = NULL; HRESULT hret = Get3DEngineInterface((void**)&pInterface); if (FAILED(hret)) return FALSE; else { KGLogPrintf(KGLOG_DEBUG, "pre pInterface->Init"); if (FAILED(pInterface->Init(uMode, uFlag, hBaseWindow, hRenderWindow))) { return FALSE; } pInterface->SetAutoReloadTexture(TRUE); InitGlobalVars(pInterface); ATLTRACE("=================3DEngine Initialized!==================\r\n"); return TRUE; } }
int main(int argc, char *argv[]) { int nResult = false; int nRetCode = false; KGLOG_PARAM LogParam = {"Logs", "KG_BoneCheker", KGLOG_OPTION_FILE, 65535}; vector<string>vecBipList; char szDir[MAX_PATH]; int nIsCheckClientAni = false; g_SetRootPath(); nRetCode = KGLogInit(LogParam, NULL); KG_PROCESS_ERROR(nRetCode); KGLogPrintf(KGLOG_INFO, "%s\n", "BoneChecker Build at " __TIME__ " " __DATE__); KGLogPrintf(KGLOG_INFO, "Begin...\n"); szDir[0] = '\0'; if (argc == 3) { if (!stricmp(argv[1], "-client")) nIsCheckClientAni = true; else if (!stricmp(argv[1], "-bip")) nIsCheckClientAni = false; else KGLOG_PROCESS_ERROR(false && "wrong argument"); memcpy(szDir, argv[2], _countof(szDir) - 1); szDir[_countof(szDir) - 1] = '\0'; } else { nRetCode = LoadConfig(&nIsCheckClientAni, szDir, _countof(szDir)); KGLOG_PROCESS_ERROR(nRetCode && "Load Config Failed"); } if (nIsCheckClientAni) { KGLogPrintf( KGLOG_INFO, "Check all SO3Client bip && clip...\n" "SO3ClientDir=\"%s\"\n", szDir ); nRetCode = GenerateJX3BipFileList(szDir, vecBipList); KG_PROCESS_ERROR(nRetCode); nRetCode = AnalyseBip(vecBipList); KG_PROCESS_ERROR(nRetCode); } else { KGLogPrintf(KGLOG_INFO, "Check Ani file with bip \"%s\"\n", szDir); nRetCode = IsBipFileExist(szDir); KG_PROCESS_ERROR(nRetCode); vecBipList.push_back(szDir); } nRetCode = AnalyseAni(vecBipList); KG_PROCESS_ERROR(nRetCode); nResult = true; Exit0: if (nResult) KGLogPrintf(KGLOG_INFO, "done successful."); else KGLogPrintf(KGLOG_INFO, "!!!done with some error, please check log file."); KGLogUnInit(NULL); return nResult ? 0 : 1; }
int main(int argc, char* argv[]) { int nResult = false; int nRetCode = false; int nLogInitFlag = false; int nMemInitFlag = false; BOOL bMemoryPoolInit = false; BOOL bHeapCheckInitFlag = false; BOOL bSOEditorInitFlag = false; KGLOG_PARAM LogParam; char szCWD[MAX_PATH]; char* pszRetCWD = NULL; #ifdef WIN32 SetConsoleInfo(); #endif #ifdef __GNUC__ nRetCode = fork(); if (nRetCode != 0) { // if fork error(-1), exit ! // if parent process(!=0), exit ! return 0; } setsid(); //umask(0); #endif #if defined( __GNUC__ ) && defined( _DEBUG ) HeapLeakChecker HeapChecker("HeapChecker"); bHeapCheckInitFlag = true; #endif tzset(); // initialize time conversion information (timezone) pszRetCWD = getcwd(szCWD, sizeof(szCWD)); KG_PROCESS_ERROR(pszRetCWD); memset(&LogParam, 0, sizeof(LogParam)); snprintf(LogParam.szPath, sizeof(LogParam.szPath), "%s/logs", szCWD); strcpy(LogParam.szIdent, "SOEditorServer"); LogParam.nMaxLineEachFile = 65536; LogParam.Options = (KGLOG_OPTIONS)(KGLOG_OPTION_FILE | KGLOG_OPTION_CONSOLE); nRetCode = KGLogInit(LogParam, NULL); KG_PROCESS_ERROR(nRetCode); nLogInitFlag = true; nRetCode = KG_MemoryInit(NULL); KG_PROCESS_ERROR(nRetCode); nMemInitFlag = true; nRetCode = KMemory::Initialize(NULL); KGLOG_PROCESS_ERROR(nRetCode); bMemoryPoolInit = true; KGLogPrintf(KGLOG_INFO, "%s\n", "Editor server for JXOnline III"); KGLogPrintf(KGLOG_INFO, "%s\n", "Build at " __TIME__ " " __DATE__); #if defined(_WIN64) || defined(__x86_64__) KGLogPrintf(KGLOG_INFO, "%s\n", "x64 Version"); #endif #if defined( __GNUC__ ) && defined( _DEBUG ) if (bHeapCheckInitFlag && HeapChecker.IsActive()) { KGLogPrintf(KGLOG_INFO, "Perftools heap leak checker is active -- Performance may suffer"); } else { KGLogPrintf(KGLOG_INFO, "Heap checker is not active, to activate set the HEAPCHECK environment variable."); } #endif g_pSOEditor = new KSOEditor(); KGLOG_PROCESS_ERROR(g_pSOEditor); nRetCode = g_pSOEditor->Init(); KGLOG_PROCESS_ERROR(nRetCode); bSOEditorInitFlag = true; KGLogPrintf(KGLOG_INFO, "Editor server startup ... ... [OK]\n"); #ifdef WIN32 KGLogPrintf(KGLOG_INFO, "Press [Ctrl + C] to exit !\n"); #endif #ifdef __GNUC__ nRetCode = SetDaemon(); KGLOG_PROCESS_ERROR(nRetCode); #endif g_pSOEditor->Run(); g_pSOEditor->UnInit(); KGLogPrintf(KGLOG_INFO, "Game server exit !"); nResult = true; Exit0: #ifdef WIN32 puts("\nPress any key to exit !"); getch(); #endif if (bSOEditorInitFlag) { g_pSOEditor->UnInit(); bSOEditorInitFlag = false; } if (g_pSOEditor) { delete g_pSOEditor; g_pSOEditor = NULL; } if (bMemoryPoolInit) { KMemory::Finalize(); bMemoryPoolInit = false; } if (nMemInitFlag) { KG_MemoryUnInit(NULL); nMemInitFlag = false; } if (nLogInitFlag) { KGLogUnInit(NULL); nLogInitFlag = false; } #if defined( __GNUC__ ) && defined( _DEBUG ) if (bHeapCheckInitFlag && !HeapChecker.NoLeaks()) { bHeapCheckInitFlag = false; assert(NULL == "Heap Memory Leak"); } #endif return 0; }
int main(int argc, char *argv[]) { int nResult = false; int nRetCode = false; KGLOG_PARAM LogParam = {"Logs", "Jx3DBChecker", (KGLOG_OPTIONS)(KGLOG_OPTION_FILE | KGLOG_OPTION_CONSOLE), 100000}; int nKGLogInitFlag = false; KG_Jx3DBChecker Jx3DBChecker; int nJx3DBCheckerFlag = false; time_t lStartTime = 0; time_t lStopTime = 0; struct tm *ptmTime = NULL; unsigned uRunningSeconds = 0; #ifdef WIN32 SetConsoleInfo(); #ifdef _DEBUG EnableMemLeakCheck(); #endif #endif lStartTime = time(NULL); ptmTime = localtime(&lStartTime); KG_PROCESS_ERROR(ptmTime); printf( "Start Time: %d-%d-%d %d:%d:%d\n", ptmTime->tm_year + 1900, ptmTime->tm_mon + 1, ptmTime->tm_mday, ptmTime->tm_hour, ptmTime->tm_min, ptmTime->tm_sec ); puts("[Jx3DBChecker] Initializing ..."); nRetCode = _SetRuntimeEnvironment(argv[0]); KG_PROCESS_ERROR(nRetCode); nRetCode = KGLogInit(LogParam, NULL); KG_PROCESS_ERROR(nRetCode); nKGLogInitFlag = true; nRetCode = Jx3DBChecker.Init(); KGLOG_PROCESS_ERROR(nRetCode); nJx3DBCheckerFlag = true; nRetCode = Jx3DBChecker.Run(); KGLOG_PROCESS_ERROR(nRetCode); lStopTime = time(NULL); ptmTime = localtime(&lStopTime); KGLOG_PROCESS_ERROR(ptmTime); printf( "Stop Time: %d-%d-%d %d:%d:%d\n", ptmTime->tm_year + 1900, ptmTime->tm_mon + 1, ptmTime->tm_mday, ptmTime->tm_hour, ptmTime->tm_min, ptmTime->tm_sec ); uRunningSeconds = (unsigned)(lStopTime - lStartTime); printf( "Program Running Time: %d days ,%d hours ,%d minutes, %d seconds.\n", (uRunningSeconds / (60 * 60 * 24)), ((uRunningSeconds % (60 * 60 * 24)) / (60 * 60)), ((uRunningSeconds % (60 * 60)) / 60), (uRunningSeconds % 60) ); nResult = true; Exit0: if (nJx3DBCheckerFlag) { Jx3DBChecker.UnInit(); nJx3DBCheckerFlag = false; } if (nKGLogInitFlag) { KGLogUnInit(NULL); nKGLogInitFlag = false; } return nResult ? 0 : 1; }
BOOL KSceneEditorApp::InitInstance() { BOOL bResult = false; BOOL bRetCode = false; HRESULT hr = E_FAIL; char* pszRetCWD = NULL; IRecorderFactory* piRecorderFactory = NULL; CMultiDocTemplate* pDocTemplate = NULL; MFCFramework::CMainFrame* pMainFrame = NULL; KGLOG_PARAM LogParam; char szCWD[MAX_PATH]; CCommandLineInfo cmdInfo; //使用Dummper m_hDummperModule = LoadLibrary(_T("dumper.dll")); pszRetCWD = getcwd(szCWD, sizeof(szCWD)); KGLOG_PROCESS_ERROR(pszRetCWD); g_SetRootPath(); g_SetFindFileMode(TRUE); g_SetFilePath(""); g_LoadPackageFiles("config.ini", "PackFile"); memset(&LogParam, 0, sizeof(LogParam)); snprintf(LogParam.szPath,sizeof(LogParam.szPath),"%s\\logs",szCWD); LogParam.szPath[sizeof(LogParam.szPath) - 1] = '\0'; strcpy(LogParam.szIdent, "SceneEditor"); LogParam.nMaxLineEachFile = 65536; LogParam.Options = (KGLOG_OPTIONS)KGLOG_OPTION_FILE; bRetCode = KGLogInit(LogParam, NULL); KGLOG_PROCESS_ERROR(bRetCode); m_bLogInitFlag = true; bRetCode = KMemory::Initialize("SceneEditor.memory"); KGLOG_PROCESS_ERROR(bRetCode); m_bMemoryInitFlag = true; g_cEditorDirectory.Load(); { TCHAR AppDir[256] = {0}; GetCurrentDirectory(256, AppDir); wsprintf(g_szDefWorkDirectory,"%s\\",AppDir); wsprintf(g_szDefExeDirectory,"%s\\",AppDir); } AfxEnableControlContainer(); // Standard initialization // If you are not using these features and wish to reduce the size // of your final executable, you should remove from the following // the specific initialization routines you do not need. // Change the registry key under which our settings are stored. // TODO: You should modify this string to be something appropriate // such as the name of your company or organization. SetRegistryKey(_T("Local AppWizard-Generated Applications")); LoadStdProfileSettings(10); // Load standard INI file options (including MRU) // Register the application's document templates. Document templates // serve as the connection between documents, frame windows and views. pDocTemplate = new CMultiDocTemplate( IDR_SCENEETYPE, RUNTIME_CLASS(KSceneEditorDoc), RUNTIME_CLASS(CChildFrame), // custom MDI child frame RUNTIME_CLASS(KSceneEditorView)); pDocTemplate->SetContainerInfo(IDR_SCENEETYPE_CNTR_IP); AddDocTemplate(pDocTemplate); pDocTemplate = new CMultiDocTemplate( IDR_MESHETYPE, RUNTIME_CLASS(KSceneModelEditorDoc), RUNTIME_CLASS(KSceneModelEditorFrameWnd), // custom MDI child frame RUNTIME_CLASS(KSceneModelEditorView)); pDocTemplate->SetContainerInfo(IDR_SCENEETYPE_CNTR_IP); AddDocTemplate(pDocTemplate); pDocTemplate = new CMultiDocTemplate( IDS_OBJECTTYPE, RUNTIME_CLASS(KSceneObjectEditorDoc), RUNTIME_CLASS(KSceneObjectEditorFrameWnd), // custom MDI child frame RUNTIME_CLASS(KSceneObjectEditorView)); pDocTemplate->SetContainerInfo(IDR_SCENEETYPE_CNTR_IP); AddDocTemplate(pDocTemplate); pDocTemplate = new CMultiDocTemplate( IDR_SFXEDITOR, RUNTIME_CLASS(KSceneSFXEditorDoc), RUNTIME_CLASS(KSceneSFXEditorFrame), // custom MDI child frame RUNTIME_CLASS(KSceneSFXEditorView)); pDocTemplate->SetContainerInfo(IDR_SFXEDITOR); AddDocTemplate(pDocTemplate); pDocTemplate = new CMultiDocTemplate( IDR_MODELTYPE, RUNTIME_CLASS(KSceneModelEditorDoc), RUNTIME_CLASS(KSceneModelEditorFrameWnd), // custom MDI child frame RUNTIME_CLASS(KSceneModelEditorView)); pDocTemplate->SetContainerInfo(IDR_SCENEETYPE_CNTR_IP); AddDocTemplate(pDocTemplate); pDocTemplate = new CMultiDocTemplate( IDS_DATAFLOWFILE, RUNTIME_CLASS(KSceneDataFlowEditorDoc), RUNTIME_CLASS(KScneDataFlowEditorFrameWnd), // custom MDI child frame RUNTIME_CLASS(KSceneDataFlowEditorView)); pDocTemplate->SetContainerInfo(IDR_SCENEETYPE_CNTR_IP); AddDocTemplate(pDocTemplate); pDocTemplate = new CMultiDocTemplate( IDR_PVSTYPE, RUNTIME_CLASS(KPvsEditorDoc), RUNTIME_CLASS(KPvsEditorFrame), // custom MDI child frame RUNTIME_CLASS(KPvsEditorView)); pDocTemplate->SetContainerInfo(IDR_PVSTYPE); AddDocTemplate(pDocTemplate); pDocTemplate = new CMultiDocTemplate( IDR_MODELTYPE2, RUNTIME_CLASS(KSceneModelEditorDoc), RUNTIME_CLASS(KSceneModelEditorFrameWnd), // custom MDI child frame RUNTIME_CLASS(KSceneModelEditorView)); pDocTemplate->SetContainerInfo(IDR_SCENEETYPE_CNTR_IP); AddDocTemplate(pDocTemplate); pDocTemplate = new CMultiDocTemplate( IDR_SPEEDTREETYPE, RUNTIME_CLASS(KSceneModelEditorDoc), RUNTIME_CLASS(KSceneModelEditorFrameWnd), // custom MDI child frame RUNTIME_CLASS(KSceneModelEditorView)); pDocTemplate->SetContainerInfo(IDR_SCENEETYPE_CNTR_IP); AddDocTemplate(pDocTemplate); pDocTemplate = new CMultiDocTemplate( IDR_MODELTYPE3, RUNTIME_CLASS(KSceneModelEditorDoc), RUNTIME_CLASS(KSceneModelEditorFrameWnd), // custom MDI child frame RUNTIME_CLASS(KSceneModelEditorView)); pDocTemplate->SetContainerInfo(IDR_SCENEETYPE_CNTR_IP); AddDocTemplate(pDocTemplate); // create main MDI Frame window pMainFrame = new MFCFramework::CMainFrame; bRetCode = pMainFrame->LoadFrame(IDR_SCENEETYPE); KGLOG_PROCESS_ERROR(bRetCode); m_pMainWnd = pMainFrame; //(by dengzhihui 2006年12月7日 15:48:16 extern BYTE* g_SceneEditorKeyState;//键盘状态 ZeroMemory(g_SceneEditorKeyState,sizeof(BYTE)*256); //) // Parse command line for standard shell commands, DDE, file open ParseCommandLine(cmdInfo); // Dispatch commands specified on the command line //if (!ProcessShellCommand(cmdInfo)) // return FALSE; // The main window has been initialized, so show and update it. pMainFrame->ShowWindow(SW_MAXIMIZE); pMainFrame->UpdateWindow(); g_pEngineManager->GetUseSO3Logical(&g_bUseSO3Logical); if (g_bUseSO3Logical) { piRecorderFactory = CreateRecorderFactoryInterface(ermNormal); KGLOG_PROCESS_ERROR(piRecorderFactory); g_pSO3World = new KSO3World; KGLOG_PROCESS_ERROR(g_pSO3World); bRetCode = g_pSO3World->Init(piRecorderFactory); KGLOG_PROCESS_ERROR(bRetCode); m_bGameWorldOpenFlag = true; if (InitRepresent() && InitUI()) { HWND hWnd = NULL; g_SetGameWorldUIHandler(&g_pUI->GetGameWorldUIHandler()); g_SetGameWorldRepresentHandler(g_pRepresent->GetGameWorldRepresentHandler()); g_pRepresentHandler = g_pRepresent->GetRepresentHandelr(); g_pRepresent->GetRepresentHandelr()->AttachGameWorld(g_pSO3World, QuerySO3WorldClientInterface()); g_pRepresent->GetRepresentHandelr()->Attach3DEngine(g_GetEngineIEInterface(), g_pEngineManager->Get3DModelTable(), g_pEngineManager->Get3DUI()); g_pRepresent->GetRepresentHandelr()->AttachUI(g_pUI, &g_pUI->GetGameWorldUIHandler()); g_pEngineManager->GetBaseWnd(&hWnd); g_pRepresent->GetRepresentHandelr()->InitHWND(hWnd); if (!g_pRepresent->Init()) { ::MessageBox(NULL, "表现逻辑初始化失败!", NULL, 0); } } } //创建声音 g_pSoundShell = Create3DSoundShell(); if (!g_pSoundShell) { KGLogPrintf(KGLOG_WARNING, "声音创建失败."); } else { g_pSoundShell->Init(m_pMainWnd->GetSafeHwnd()); } //在这里把需要使用sound的地方都统一设置上soundshell g_pEngineManager->SetSoundShell(g_pSoundShell); if (g_pRepresent) { g_pRepresent->SetSoundShell(g_pSoundShell); } bResult = true; Exit0: if (!bResult) { if (m_bGameWorldOpenFlag) { g_pSO3World->UnInit(); m_bGameWorldOpenFlag = false; } KG_DELETE(g_pSO3World); if (m_bMemoryInitFlag) { KMemory::Finalize(); m_bMemoryInitFlag = false; } if (m_bLogInitFlag) { KGLogUnInit(NULL); m_bLogInitFlag = false; } } KG_COM_RELEASE(piRecorderFactory); return bResult; }
int main(int argc, char* argv[]) { BOOL bRetCode = false; int nRetCode = 0; const char* pcszRetCWD = NULL; BOOL bLockInitFlag = false; BOOL bMergeToolInitFlag = false; BOOL bMemoryPoolInit = false; BOOL bLogInitFlag = false; char szCWD[MAX_PATH]; KProcessLock Lock; KGLOG_PARAM LogParam; g_SetRootPath(); bMemoryPoolInit = KMemory::Initialize("MergeTool.memory"); KG_PROCESS_ERROR(bMemoryPoolInit); pcszRetCWD = getcwd(szCWD, sizeof(szCWD)); KG_PROCESS_ERROR(pcszRetCWD); memset(&LogParam, 0, sizeof(LogParam)); snprintf(LogParam.szPath, sizeof(LogParam.szPath), "%s/logs", szCWD); strcpy(LogParam.szIdent, "MergeTool"); LogParam.nMaxLineEachFile = 65536 * 2; LogParam.Options = (KGLOG_OPTIONS)(KGLOG_OPTION_FILE | KGLOG_OPTION_CONSOLE); bLogInitFlag = KGLogInit(LogParam, NULL); KG_PROCESS_ERROR(bLogInitFlag); bLockInitFlag = Lock.CreateLock(LOCK_FILE_NAME); KG_PROCESS_ERROR(bLockInitFlag); g_pMergeTool = KMemory::New<KMergeTool>(); KG_PROCESS_ERROR(g_pMergeTool); bMergeToolInitFlag = g_pMergeTool->Init(); KGLOG_PROCESS_ERROR(bMergeToolInitFlag); bRetCode = g_pMergeTool->Run(); KGLOG_PROCESS_ERROR(bRetCode); Exit0: if (bMergeToolInitFlag) { g_pMergeTool->UnInit(); bMergeToolInitFlag = false; } if (g_pMergeTool) { KMemory::Delete(g_pMergeTool); g_pMergeTool = NULL; } if (bLogInitFlag) { KGLogUnInit(NULL); bLogInitFlag = false; } if (bMemoryPoolInit) { KMemory::Finalize(); bMemoryPoolInit = false; } if (bLockInitFlag) { Lock.FreeLock(); bLockInitFlag = false; } return 0; }