Advertisement
Guest User

nom nom nom looool

a guest
Mar 30th, 2013
2,069
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 70.83 KB | None | 0 0
  1. **********************************************
  2. |-Jhongeek-|
  3. Proof of fiesta online source code :D here's a sample
  4. **********************************************
  5.  
  6. #include "stdafx.h"
  7. #include "MainApp.h"
  8. #include "resource.h"
  9. #include "RegisterFrameWork.h"
  10. #include "MainHandle.h"
  11. #include "MainInput.h"
  12. #include "Font.h"
  13. // spiegel (2006-06-15) PRECOMP_OPT #include "NetMgr.h"
  14. // spiegel (2006-06-15) PRECOMP_OPT #include "Folder.h"
  15. #include "CharMgr.h"
  16. #include "CharRes.h"
  17. #include "Profile.h"
  18. #include "Engine3D.h"
  19. #include "World.h"
  20. #include "MobInfoTable.h"
  21. #include "SoundMgr.h"
  22. #include "EffectMgr.h"
  23. // spiegel (2006-06-15) PRECOMP_OPT #include "Timer.h"
  24. #include "ScreenBoard.h"
  25. // spiegel (2006-06-15) PRECOMP_OPT #include "MenuTex.h"
  26. #include "DropItem.h"
  27. #include "MachineOpt.h"
  28. #include "MapObjMgr.h"
  29. #include "Debug.h"
  30. #include "TextEffMgr.h"
  31. #include "PortraitBuffer.h"
  32.  
  33. #include "Character.h"
  34.  
  35. #include "GameFrameWork.h"
  36. #include "ScreenBoard.h"
  37.  
  38. #include "QuestDataMgr.h"
  39. #include <EXDISPID.H>
  40. #include <ATLBASE.H>
  41. #include <ATLCONV.H>
  42. #include <ExDisp.h>
  43.  
  44. #include "WebCtrl.h"
  45. #include "SSOWebLib.h"
  46. #include "XTrapDefine.h"
  47. #include "XTrap4Client.h
  48. #include <NiDX9Select.h>
  49. #include "DShowMovie.h"
  50.  
  51. #include "ShineObjectHandleUnion.h"
  52.  
  53. #include "PostProcessEffectManager.h"
  54. #include "DataDocument.h"
  55. //----------------------------------------------------------------------<<
  56.  
  57.  
  58. //#include <conio.h>
  59.  
  60. #include "MaskShader.h"
  61.  
  62. #include "TextFilterTable.h"
  63.  
  64. #ifndef _TEST_VERSION_
  65. #define _CP_ONLY
  66. #endif
  67. #define _CONSOLE_TEST
  68.  
  69. #ifndef _DEBUG
  70. //  #define _XTRAP_ENABLE_
  71. #endif
  72.  
  73.  
  74. #ifdef REPORT_EXCEPTION_TO_SERVER
  75. #include "User.h"
  76. #include "Server.h"
  77. #include "MsgBox.h"
  78. #include "ShineException.h"
  79.  
  80. //#ifdef _TEST_VERSION_
  81. #if (defined _TEST_VERSION_ || defined _CLIENT_ONLY || defined _AUTHOR_MODE )
  82. #define _VIEW_FRAMERATE_
  83. #endif
  84.  
  85.  
  86.  
  87.  
  88. #pragma comment(lib, "ShineException.lib")
  89. class ShineExceptionHandler : public SpException::IExceptionHandler
  90. {
  91. public:
  92.     void Log(SpException::ExceptionReport& rkReport);
  93. };
  94.  
  95. //HS 2007.8.9 Sound File Remove
  96. char _RemoveBGMFile[11][64] ={
  97.     "BGM_BrightField01.mp3",
  98.     "BGM_BrightField02.mp3",
  99.     "BGM_BrightField03.mp3",
  100.     "BGM_BrightField04.mp3",
  101.     "BGM_DarkField01.mp3",
  102.     "BGM_DarkField02.mp3",
  103.     "BGM_Dungeon01.mp3",
  104.     "BGM_Dungeon02.mp3",
  105.     "BGM_Dungeon03.mp3",
  106.     "BGM_KingDomQuest01.mp3",
  107.     "BGM_KingDomQuest02.mp3",
  108. };
  109. //-------------------------------------//
  110.  
  111. void ShineExceptionHandler::Log(SpException::ExceptionReport& rkReport)
  112. {
  113.     char acExceptionMsg[512];
  114.  
  115.     NAME_TO_STRING(SHINE_CHAR_ID, g_kUser.GetMainCharID(), acName);
  116.  
  117. //  {
  118.         char* pcReportBuffer;
  119.         WORD wReportSize;
  120.         char acModulePath[MAX_PATH];
  121.         ::GetModuleFileName(0, acModulePath, MAX_PATH);
  122.         wReportSize = ShineException::GenerateReport(pcReportBuffer, rkReport, acModulePath, acName);
  123.  
  124.         //FILE* fp;
  125.         //fp = fopen("d:\\test.dmp", "ab");
  126.         //fwrite(pcReportBuffer, uiReportSize, 1, fp);
  127.         //fclose(fp);
  128. //  }
  129.     //sprintf(acExceptionMsg, "#User: %s, #Except.: %s(%08X), #Fault Addr.: %08X %02X:%08X, #Ver. %s\n",
  130.     //          acName, SpException::GetExceptionCodeName(rkReport.dwCode), rkReport.dwCode,
  131.     //          (DWORD)rkReport.pvAddress, rkReport.dwSection, rkReport.dwOffset, __TIMESTAMP__);
  132.  
  133.     Net* pkWorld = g_kNetMgr.WorldMgr();
  134.     if (pkWorld)
  135.     {
  136.         NETCOMMAND netcmd;
  137.         netcmd.department = NC_MISC;
  138.         netcmd.command = NC_MISC_CLIENT_DEBUG_MSG_CMD;
  139.         pkWorld->AddNetMsg(&netcmd, sizeof(netcmd));
  140.  
  141.         SHINE_HANDLE_NUMBER wldmanhandle = g_kServer.GetWorldMgrHandle();
  142.         WORD                wLen = strlen(acExceptionMsg) +1;
  143.  
  144.         pkWorld->AddNetMsg(&wldmanhandle, sizeof(wldmanhandle));
  145.         pkWorld->AddNetMsg(&wReportSize, sizeof(wReportSize));
  146.         pkWorld->AddNetMsg(pcReportBuffer, wReportSize);
  147.         pkWorld->SendNetMsg();
  148.         pkWorld->Flush();
  149.     }
  150.  
  151. }
  152.  
  153. ShineExceptionHandler g_kShineExceptionHandler;
  154. #endif //#ifdef REPORT_EXCEPTION_TO_SERVER
  155.  
  156. //---------------------------------------------------------------------->>
  157. // added by kadol( 2007.6.8 )
  158. BYTE* MainApp::st_pbyDummyMemory = NULL;
  159. //----------------------------------------------------------------------<<
  160.  
  161. MainApp * MainApp::ms_pkMainApp = NULL;
  162. NiApplication* NiApplication::Create()
  163. {
  164.     // SadPig (2006-03-25) check window language.
  165.     if(MainApp::CheckWindowLocale() == false)
  166.         return NULL;
  167.     MainApp::ms_pkMainApp = new MainApp;
  168.     return MainApp::ms_pkMainApp;
  169. }
  170.  
  171. MainApp * MainApp::GetMainAppInstance()
  172. {
  173.     return ms_pkMainApp;
  174. }
  175.  
  176. #if   (defined _LOCALE_VER_KR)
  177. #define APP_NAME                "SHINE_KOR"
  178. #define VENDOR_CODE             0x07013010
  179. #elif (defined _LOCALE_VER_JP)
  180. #define APP_NAME                "SHINE_JPN"
  181. #define VENDOR_CODE             0x07013030
  182. #elif (defined _LOCALE_VER_CH)
  183. #define APP_NAME "ShineOnline"
  184. #define VENDOR_CODE             0x07013030
  185. #endif
  186.  
  187. #if defined(_LOCALE_VER_JP)
  188.     #ifdef _VIEW_FRAMERATE_
  189.         MainApp::MainApp() : NiApplication("BrightKingdom", 1024, 768 , 0, 2)
  190.     #else
  191.         MainApp::MainApp() : NiApplication("BrightKingdom", 1024, 768)
  192.     #endif
  193. #else
  194.     #ifdef _VIEW_FRAMERATE_
  195.         MainApp::MainApp() : NiApplication("ShineOnline", 1024, 768 , 0, 2)
  196.     #else
  197.         MainApp::MainApp() : NiApplication("ShineOnline", 1024, 768)
  198.     #endif
  199. #endif
  200. {
  201.     m_bUseFoption = false;
  202.     m_bUseDoption = false;
  203.     m_bUseWinoption = false;
  204.    
  205.     m_fOldDrawTime = 0;
  206.  
  207.     m_bRendererDialog = false;
  208.     m_bExclusiveMouse = false;
  209.  
  210.     m_bEnableInput = true;
  211.  
  212.     // spiegel (2005-05-30) log, exception handler
  213.     splog_init(("Log", "Log.txt", "Shine Online"));
  214.     enable_sperror(true);
  215.     enable_spcritical(true);
  216. //#endif
  217.     splog(("MainApp() enter\n"));
  218.  
  219.     loclog_init(());
  220.  
  221. #ifdef REPORT_EXCEPTION_TO_SERVER
  222.     SpException::SetupExceptionHandler(&g_kShineExceptionHandler);
  223.     SpException::SetMsgBoxEnable(false);
  224. #endif
  225. #ifdef _TEST_VERSION_
  226.     SpException::SetMsgBoxEnable(true);
  227. #endif
  228.  
  229.     EnumDisplaySettings(NULL, ENUM_REGISTRY_SETTINGS, &m_SaveMode);
  230.  
  231.     ProcessCommandLineBeforInit();
  232.  
  233.     SetupWindow();
  234.  
  235.     //MiniHouse_IndoorMode_1.0////////////////////////////////////
  236. #ifdef  SHINEHANDLE_MINIHOUSE
  237.     ShineObjectHandleUnion::sohu_Initialize();
  238. #endif
  239.     //////////////////////////////////////MiniHouse_IndoorMode_1.0
  240.  
  241.  
  242.     //*(int*)0 = 0;
  243. //#if ( defined _CONSOLE_TEST && !defined _DEBUG && defined _CLIENT_ONLY)
  244. #if (defined _LOCALE_VER_KR &&  defined _AUTHOR_MODE)
  245.     AllocConsole();
  246. #endif
  247.     m_dwResetCounter = 0;
  248.     m_pkNetMarbleLogo = NULL;
  249.     splog(("MainApp() out\n"));
  250.  
  251.     InitWebCtrl();
  252.  
  253.  
  254. }
  255.  
  256.  
  257. bool MainApp::OnDefault(NiEventRef pEventRecord)
  258. {
  259.     // 동영상
  260. #if (defined _LOCALE_VER_KR || defined _LOCALE_VER_CH)
  261.     if (m_pkNetMarbleLogo)
  262.     {
  263.         bool bFinished = false;
  264.  
  265.         switch (pEventRecord->uiMsg)
  266.         {
  267.         case WM_ERASEBKGND:
  268.             return true;
  269.         case WM_LBUTTONDOWN:
  270.         case WM_RBUTTONDOWN:
  271.         case WM_MBUTTONDOWN:
  272.         case WM_KEYDOWN:
  273.             bFinished |= true;
  274.             break;
  275.         }
  276.  
  277.         bFinished |= !m_pkNetMarbleLogo->MsgProc(pEventRecord->hWnd, pEventRecord->uiMsg, pEventRecord->wParam, pEventRecord->lParam);
  278.  
  279.         if (bFinished)
  280.         {
  281.             m_pkNetMarbleLogo->Stop();
  282.             delete m_pkNetMarbleLogo;
  283.             m_pkNetMarbleLogo = NULL;
  284.             Pgg_kFrameMgr.Start(AccountFrameWorkID);
  285.  
  286.             ShowCursor(TRUE);
  287.         }
  288.     }
  289. #endif
  290.  
  291.     // kadol temp
  292. //  static bool m_bBacktoFullScreen  = false;
  293. //fennek_080220_0////////////////////////////////////
  294.     static bool m_bMinimize = false;
  295.    
  296. //////////////////////////////////////fennek_080220_0
  297.  
  298.     switch(pEventRecord->uiMsg)
  299.     {
  300.         case WM_ACTIVATE :
  301.         {
  302.            
  303.             switch(LOWORD(pEventRecord->wParam))
  304.             {
  305.             case WA_ACTIVE:
  306.             case WA_CLICKACTIVE:
  307.                 {
  308.                     OnWindowActivate(NULL, true);
  309.                     //fennek_080220_0////////////////////////////////////
  310.                     if (m_bMinimize == false)
  311.                     {
  312.                         m_bMinimize = true;
  313.                         g_kSoundMgr.HoldSound(true);
  314.                        
  315.                     }
  316.                     //////////////////////////////////////fennek_080220_0
  317.  
  318.                     /*
  319.                     //==
  320.                     const MachineOpt::GraphicOption *pkGraphicOption = &MachineOpt::GetGraphicOption();
  321.                     PgAssert(pkGraphicOption);
  322.                     unsigned int uiDisplayWidth = pkGraphicOption->ui_DisplayResolutionWidth;
  323.                     unsigned int uiDisplayHeight = pkGraphicOption->ui_DisplayResolutionHeight;
  324.  
  325.                     DEVMODE dm;
  326.                     ZeroMemory(&dm, sizeof(DEVMODE));
  327.                     dm.dmSize = sizeof(DEVMODE);
  328.                     dm.dmFields=DM_BITSPERPEL|DM_PELSWIDTH|DM_PELSHEIGHT;
  329.                     dm.dmBitsPerPel = 32;
  330.                     dm.dmPelsWidth = uiDisplayWidth;
  331.                     dm.dmPelsHeight = uiDisplayHeight;
  332.  
  333.                     if(ChangeDisplaySettings(&dm,CDS_TEST)==DISP_CHANGE_SUCCESSFUL)
  334.                     {
  335.                         ChangeDisplaySettings(&dm,0);
  336.                     }
  337.                     //==   
  338.                     */
  339. /*
  340.                     // kadol temp
  341.                     if( m_bBacktoFullScreen == true )
  342.                     {
  343.                         m_bBacktoFullScreen = false;
  344.                         if( MachineOpt::GetWindowFullMode() )
  345.                         {
  346.                             const MachineOpt::GraphicOption *pkGraphicOption = &MachineOpt::GetGraphicOption();
  347.                             PgAssert(pkGraphicOption);
  348.                             unsigned int uiDisplayWidth = pkGraphicOption->ui_DisplayResolutionWidth;
  349.                             unsigned int uiDisplayHeight = pkGraphicOption->ui_DisplayResolutionHeight;
  350.  
  351.                             DEVMODE dm;
  352.                             ZeroMemory(&dm, sizeof(DEVMODE));
  353.                             dm.dmSize = sizeof(DEVMODE);
  354.                             dm.dmFields=DM_BITSPERPEL|DM_PELSWIDTH|DM_PELSHEIGHT;
  355.                             dm.dmBitsPerPel = 32;
  356.                             dm.dmPelsWidth = uiDisplayWidth;
  357.                             dm.dmPelsHeight = uiDisplayHeight;
  358.  
  359.                             if(ChangeDisplaySettings(&dm,CDS_TEST)==DISP_CHANGE_SUCCESSFUL)
  360.                             {
  361.                         //      ChangeDisplaySettings(&dm,0);
  362.  
  363.                                 HWND hwndRoot = ::GetAncestor( m_pkAppWindow->GetWindowReference(), GA_ROOTOWNER );
  364.                                 ShowWindow( hwndRoot, SW_RESTORE );
  365.  
  366.                                 OutputDebugString("Valid Mode \n");
  367.                             }
  368.                         }
  369.                     }
  370.                 */
  371.                 }
  372.                 break;
  373.             case WA_INACTIVE:
  374.                 {
  375.                     OnWindowActivate(NULL, false);
  376.                     //fennek_080220_0////////////////////////////////////
  377.                     if (m_bMinimize == true)
  378.                     {
  379.                         m_bMinimize = false;
  380.                        
  381.                         OutputDebugString("false\n");
  382.                         g_kSoundMgr.HoldSound(false);
  383.                        
  384.                     }
  385.                     //////////////////////////////////////fennek_080220_0
  386.  
  387.                     /*
  388.                     //==
  389.                     ChangeDisplaySettings(&m_SaveMode, CDS_UPDATEREGISTRY);
  390.                     //==
  391.                     */
  392. /*
  393.                     // kadol temp
  394.                     if( MachineOpt::GetWindowFullMode() )
  395.                     {
  396.                         HWND hwndRoot = ::GetAncestor( m_pkAppWindow->GetWindowReference(), GA_ROOTOWNER );
  397.                         if( IsIconic( hwndRoot ) == FALSE )
  398.                         {
  399.                             ShowWindow( hwndRoot, SW_MINIMIZE );
  400.                             m_bBacktoFullScreen = true;
  401.                 //          ChangeDisplaySettings(&m_SaveMode, CDS_UPDATEREGISTRY);
  402.  
  403.                             OutputDebugString("INValid Mode \n");
  404.                         }
  405.                     }
  406.                 */
  407.                 }
  408.                 break;
  409.             };
  410.         }
  411.         case WM_SETCURSOR:
  412.             ::SetCursor( NULL );
  413.             Cursor::ShowCursor(true);
  414.             return true; // Prevent Windows from setting cursor to window class cursor
  415.             break;
  416.         case WM_MOUSEMOVE:
  417.             // spiegel (2005-11-16) sis 온보드칩의 경우 위치를 세팅해줘야함
  418.             if (m_bFullscreen)
  419.             {
  420.                 POINT point;
  421.                 point.x = LOWORD(pEventRecord->lParam);
  422.                 point.y = HIWORD(pEventRecord->lParam);
  423.                 ClientToScreen(g_hMainWnd, &point);
  424.                 Cursor::SetHardwareCursorPos(point.x, point.y);
  425.             }
  426.             break;
  427.         case WM_SYSKEYDOWN:
  428.             {
  429.                 if (pEventRecord->wParam == VK_F10 || pEventRecord->wParam == VK_MENU)
  430.                     return 1;
  431.             }
  432.             break;
  433.  
  434.         // spiegel (2005-03-15) 스크린샷
  435.         case WM_KEYUP:
  436.             {
  437.                 if (pEventRecord->wParam == VK_SNAPSHOT)
  438.                 {
  439.                     char        acFilename[MAX_PATH];
  440.                     //fennek_071213_2////////////////////////////////////
  441.                     //---------------------------------------------------------------------->>
  442.                     // temlost_20080319_0
  443.                     #ifdef _SHOW_USERINFO_IN_SCREENSHOT_
  444.                         //ScreenShot(m_spRenderer, m_spFont, m_spStr2D, g_hMainWnd, acFilename, MAX_PATH);
  445.                     #else
  446.                         ScreenShot(m_spRenderer, g_hMainWnd, acFilename, MAX_PATH);
  447.                     #endif
  448.                     //ScreenShot_UserName(m_spRenderer , g_hMainWnd, acFilename, MAX_PATH);
  449.                     //----------------------------------------------------------------------<<
  450.  
  451.                     //////////////////////////////////////fennek_071213_2
  452.                        
  453. #if 0
  454.                     GameFrameWork* pkGame = (GameFrameWork*)Pgg_kFrameMgr.GetFrameWork(GameFrameWorkID);
  455.                     if (pkGame)
  456.                         pkGame->AddSysMsg("%s 로 저장되었습니다.", acFilename);
  457. #endif
  458.                     return 1;
  459.                 }
  460.             }
  461.             break;
  462.  
  463.         case WM_IME_CHAR :
  464.         case WM_IME_COMPOSITION :
  465.         case WM_IME_COMPOSITIONFULL :
  466.         case WM_IME_CONTROL :
  467.         case WM_IME_ENDCOMPOSITION :
  468.         case WM_IME_KEYDOWN :
  469.         case WM_IME_KEYUP :
  470.         case WM_IME_NOTIFY :
  471.         case WM_IME_REQUEST :
  472.         case WM_IME_SELECT :
  473.         case WM_IME_SETCONTEXT :
  474.         case WM_IME_STARTCOMPOSITION :
  475. #ifdef _LOCALE_VER_KR
  476.             // spiegel (2006-04-20) 조합중 글자 안보이도록
  477.             return 1;
  478. #endif
  479.             if(OnIme(pEventRecord) == true )
  480.                 return 1;
  481.             //if(m_kImeCtrl.MsgProc(pEventRecord->uiMsg, pEventRecord->wParam, pEventRecord->lParam) == true)
  482.             //  return 1;
  483.             break;
  484.    
  485.         //////////////////////////////////////////////////////////////////////////
  486.         // added by kadol( 2007.3.12 )
  487.         // commment : 일반적인 강제종료시 logout 화면 나오게 전환
  488.         case WM_CLOSE:
  489.             {
  490. #ifndef _AUTHOR_MODE
  491.                 if( Pgg_kFrameMgr.IsInRun( GameFrameWorkID ) )
  492.                 {
  493.                     PgFrameWork* pkFrameWork = Pgg_kFrameMgr.GetFrameWork( GameFrameWorkID);
  494.                     pkFrameWork->AddMsg(GameFrameWork::PGFM_EXIT, 0, 0);
  495.                    
  496.                     return 1;
  497.                 }
  498. #endif
  499.             }  
  500.             break;
  501.         //////////////////////////////////////////////////////////////////////////
  502.     };
  503.  
  504.  
  505.  
  506.     return NiApplication::OnDefault(pEventRecord);
  507. }
  508.  
  509. #include "EditWin.h"
  510.  
  511. #include "GameFrameWork.h"
  512.  
  513. void MainApp::OnWindowActivate(NiContextRef pDrawContext, bool bActivate)
  514. {
  515.     if(bActivate)
  516.     {
  517.         //EditWin::OnActiveApp();
  518.         EditWin::RecoverFocus();
  519.     }
  520.     else
  521.     {
  522.        
  523.     }
  524. }
  525. void MainApp::OnWindowActivate(NiContextRef pDrawContext, bool bActivate)
  526. {
  527.     if(bActivate)
  528.     {
  529.         //EditWin::OnActiveApp();
  530.         EditWin::RecoverFocus();
  531.     }
  532.     else
  533.     {
  534.        
  535.     }
  536. }
  537.  
  538. void MainApp::InitError(char * pcErrMsg)
  539. {
  540.     MessageBox(NULL, pcErrMsg, "Application Initialize Error!", MB_OK|MB_ICONERROR);
  541.     return;
  542. }
  543.  
  544. bool MainApp::InitAppHandle()
  545. {
  546.     if(GetFullscreen())
  547.         g_hMainWnd = GetWindowReference();
  548.    else                
  549.         g_hMainWnd = GetRenderWindowReference();
  550.    
  551.     g_hMainInstance = GetInstanceReference();
  552.     return true;
  553. }
  554.  
  555. bool MainApp::InitInput()
  556. {
  557.     m_kImeCtrl.SetHWND(g_hMainWnd);
  558.     m_kImeCtrl.SetPreventNativeMode(true);
  559. #ifdef _DEBUG
  560.     m_kImeCtrl.SetName("MainIme");
  561. #endif
  562.  
  563.     g_pkKeyboard = GetInputSystem()->GetKeyboard();
  564.     g_pkMouse = GetInputSystem()->GetMouse();
  565.     Pgg_kWinMgr.SetKeyboard(g_pkKeyboard);
  566.     Pgg_kWinMgr.SetMouse(g_pkMouse);
  567.    
  568.     ::SetCursor(NULL);
  569.     if(Cursor::Init() == false)
  570.         return false;
  571.     Pgg_kWinMgr.SetCursor(Cursor::GetPgCursor());
  572.    
  573.     return true;
  574. }
  575.  
  576. void MainApp::TerminateInput()
  577. {
  578.     Cursor::Terminate();
  579. }
  580.  
  581. bool MainApp::IsSkipDraw(float fCurTime)
  582. {
  583.     return false;
  584. }
  585.  
  586. bool MainApp::InitGameData()
  587. {
  588. //fennek_work_20070726_1////////////////////////////////////
  589.  
  590.     if (CharClass::Load(Folder::Merge(Folder::System(), "ClassName.shn")) == false)  { InitError("ClassName.shn InitError!!");return false;}
  591.     splog(("CharClass::LoadClassName()\n"));
  592.     if (CharRace::Load(Folder::Merge(Folder::System(), "RaceNameInfo.shn")) == false)  { InitError("RaceNameInfo.shn InitError!!");return false;}
  593.     splog(("CharRace::LoadRaceName()\n"));
  594. //  if(MobInfoTable::Load() == false) return false;
  595.     if(MobInfoTab::Load(Folder::Merge(Folder::System(), "MobInfo.shn")) == false)  { InitError("MobInfo.shn InitError!!");return false;}
  596.     if(MobViewInfoTab::Load(Folder::Merge(Folder::System(), "MobViewInfo.shn")) == false)  { InitError("MobViewInfo.shn InitError!!");return false;}
  597.     splog(("MobInfoTable::Load()\n"));
  598.  
  599.    //////////////////////////////////////////////////////////////////////////
  600.     // added by kadol( 2007.4.10 )
  601. #ifdef ENABLE_CHARNPC
  602.     if(NPCViewInfoTab::Load(Folder::Merge(Folder::System(), "NPCViewInfo.shn")) == false)  { InitError("NPCViewInfo.shn InitError!!");return false;}
  603. #endif
  604.     //////////////////////////////////////////////////////////////////////////
  605.  
  606.     if(RidePetTable::Load(Folder::Merge(Folder::System(), "Riding.shn")) == false)  { InitError("Riding.shn InitError!!");return false;}
  607.     if(MapInfoTab::Load(Folder::Merge(Folder::System(), "MapInfo.shn")) == false)  { InitError("MapInfo.shn InitError!!");return false;}
  608.     if(MapViewInfoTab::Load(Folder::Merge(Folder::System(), "MapViewInfo.shn")) == false)  { InitError("MapViewInfo.shn InitError!!");return false;}
  609. //  if(MapInfoTable::Load() == false) return false;
  610.     splog(("MapInfoTable::Load()\n"));
  611. //  if(ItemInfoTable::Load() == false) return false;
  612.     if(ItemInfoTab::Load(Folder::Merge(Folder::System(), "ItemInfo.shn")) == false)  { InitError("ItemInfo.shn InitError!!");return false;}
  613.     if(ItemViewInfoTab::Load(Folder::Merge(Folder::System(), "ItemViewInfo.shn")) == false)  { InitError("ItemViewInfo.shn InitError!!");return false;}
  614.     splog(("ItemInfoTable::Load()\n"));
  615.     //if(UpGradeInfoTable::Load() == false) return false;
  616.     if(UpGradeInfoTab::Load(Folder::Merge(Folder::System(), "UpgradeInfo.shn")) == false)  { InitError("UpgradeInfo.shn InitError!!");return false;}
  617.     splog(("UpGradeInfoTable::Load()\n"));
  618.     if(Skill::Init() == false) return false;
  619.     splog(("Skill::Init()\n"));
  620.     if( ActionViewTable::Load(Folder::Merge(Folder::System(), "ActionViewInfo.shn")) == false)  { InitError("ActionViewInfo.shn InitError!!");return false;}
  621.     splog(("ActionViewTable::Load(...)\n"));
  622.  
  623.     //------------------------------------------------------------------------>>
  624.     // added by hks_080310_0 : splash  
  625.     DisplaySplash(m_SplashTexName.c_str(), m_ProgressBarTexName.c_str(), 40);      
  626.     //------------------------------------------------------------------------<<
  627.  
  628.     if(ActionInfoTable::Init() == false) return false;
  629.     splog(("ActionInfoTable::Init()\n"));
  630.  
  631.     //------------------------------------------------------------------------>>
  632.     // added by hks_080310_0 : splash  
  633.     DisplaySplash(m_SplashTexName.c_str(), m_ProgressBarTexName.c_str(), 50);      
  634.     //------------------------------------------------------------------------<<
  635.  
  636.     if( KQDescTable::Load(Folder::Merge(Folder::System(), "KingdomQuestDesc.shn")) == false) { InitError("KingdomQuestDesc.shn InitError!!");return false;}
  637.     splog(("KQDescTable::Load()\n"));
  638. //  if(HairInfoTable::Init() == false) return false;
  639.     if(HairInfoTab::Load(Folder::Merge(Folder::System(), "HairInfo.shn")) == false) { InitError("HairInfo.shn InitError!!");return false;}
  640.     splog(("HairInfoTab::Load()\n"));
  641.     if(HairColorInfoTab::Load(Folder::Merge(Folder::System(), "HairColorInfo.shn")) == false) { InitError("HairColorInfo.shn InitError!!");return false;}
  642.     splog(("HairInfoTable::Init()\n"));
  643.  
  644.     //---------------------------------------------------------------------->>
  645.     // modified by kadol( 2007.7.4 )
  646.     if(FaceInfoTab::Load(Folder::Merge(Folder::System(), "FaceInfo.shn")) == false) { InitError("FaceInfo.shn InitError!!");return false;}
  647.     splog(("FaceInfoTable::Init()\n"));
  648.     //----------------------------------------------------------------------<<
  649.  
  650.     //---------------------------------------------------------------------->>
  651.     // kadol(07.10.30)_1
  652.     if( WeaponAttribTab::Load( Folder::Merge( Folder::System(), "WeaponAttrib.shn")) == false ) { InitError("WeaponAttrib.shn InitError!!"); return false;}
  653.     //----------------------------------------------------------------------<<
  654.  
  655.     if(IconMgr::Init() == false) return false;
  656.     splog(("IconMgr::Init()\n"));
  657.  
  658.     //if(g_kAbStateMgr.LoadInfo() == false) return false;
  659.     // newsong (2005-06-17)
  660. //  if(AbnormalStateTable::Load() == false) return false;
  661.     if(AbnormalStateInfoTab::Load(Folder::Merge(Folder::System(), "AbState.shn")) == false) { InitError("AbState.shn InitError!!");return false;}
  662.     if(AbnormalStateViewInfoTab::Load(Folder::Merge(Folder::System(), "AbStateView.shn")) == false) { InitError("AbStateView.shn InitError!!");return false;}
  663.     if(SubAbStateInfoTab::Load(Folder::Merge(Folder::System(), "SubAbState.shn")) == false) { InitError("SubAbState.shn InitError!!");return false;}
  664.     splog(("AbnormalStateTable::Load()\n"));
  665.  
  666. //  if(DmgSndTab::Load() == false) return false;
  667.     if(DmgSndTab::Load(Folder::Merge(Folder::System(), "DamageSoundInfo.shn")) == false) { InitError("DamageSoundInfo.shn InitError!!");return false;}
  668.     splog(("DmgSndTab::Load()\n"));
  669.  
  670.     if (WeaponTitleTab::Load(Folder::Merge(Folder::System(), "WeaponTitleData.shn")) == false) { InitError("WeaponTitleData.shn InitError!!");return false;}
  671.     if (g_characterTitleData.Read(Folder::Merge(Folder::System(), "CharacterTitleData.shn")) == false) { InitError("CharacterTitleData.shn InitError!!");return false;}
  672.  
  673.     if (ProduceInfoTable::Load(Folder::Merge(Folder::System(), "Produce.shn")) == false) { InitError("Produce.shn InitError!!");return false;};
  674.     if (ProduceViewInfoTable::Load(Folder::Merge(Folder::System(), "ProduceView.shn")) == false){ InitError("ProduceView.shn InitError!!");return false;}
  675.     if (GatherInfoTable::Load(Folder::Merge(Folder::System(), "Gather.shn")) == false) { InitError("Gather.shn InitError!!");return false;}
  676.     if (NpcDialogDataTable::Load(Folder::Merge(Folder::System(), "NpcDialogData.shn")) == false) { InitError("NpcDialogData.shn InitError!!");return false;}
  677.  
  678.     if (GradeItemOptionTab::Load(Folder::Merge(Folder::System(), "GradeItemOption.shn")) == false) { InitError("GradeItemOption.shn InitError!!");return false;}
  679.     if(g_kShortCutMgr.Init() == false) return false;
  680.     splog(("g_kShortCutMgr.Init()\n"));
  681.     //fennek_080102_1////////////////////////////////////
  682. #ifdef  _ITEMUPGRADE_MAX_12_GRADE
  683.     if (UpEffectTab::Load(Folder::Merge(Folder::System(), "UpEffect.shn")) == false) { InitError("UpEffect.shn InitError!!");return false;}
  684.     if (ItemDismantleTab::Load(Folder::Merge(Folder::System(), "ItemDismantle.shn")) == false) { InitError("ItemDismantle.shn InitError!!");return false;}
  685. #endif
  686.     //////////////////////////////////////fennek_080102_1
  687.  
  688.     // spiegel (2005-06-16) just compile
  689. //  if (MapAmbienceSoundTab::Init()) MapAmbienceSoundTab::Terminate();
  690. //  else return false;
  691. //  splog(("MapAmbienceSoundTab::Init()\n"));
  692.  
  693.     //------------------------------------------------------------------------>>
  694.     // added by hks_080310_0 : splash  
  695.     DisplaySplash(m_SplashTexName.c_str(), m_ProgressBarTexName.c_str(), 60);      
  696.     //------------------------------------------------------------------------<<
  697.  
  698.     if (NpcDlgScriptEncryptor::Init("npcdlgscriptencryptkey") == false) { InitError("NpcDlgScriptEncryptor InitError!!");return false;}
  699.     splog(("NpcDlgScriptEncryptor::Init()\n"));
  700. #ifdef _DEBUG
  701.     if(ItemInfoTab::CheckData() == false) return false;
  702.     splog(("ItemInfoTable::CheckData()\n"));
  703. #endif 
  704.  
  705.     if (ColorInfoTable::Load(Folder::Merge(Folder::System(), "ColorInfo.shn")) == false){ InitError("ColorInfo.shn InitError!!");return false;}
  706.  
  707. #ifdef _CLIENT_ONLY
  708.     if(Dbg::LoadVirtualAvatarInfo() == false) return false;
  709.     splog(("Dbg::LoadVirtualAvatarInfo()\n"));
  710. #endif
  711.    
  712. #ifdef _DEBUG
  713.     if(ActSkillViewInfoTab::CheckActionTable() == false) return false;
  714.     splog(("ActSkillViewInfoTab::CheckActionTable()\n"));
  715. #endif
  716.  
  717.     if (MiniHouseTable::Load(Folder::Merge(Folder::System(), "MiniHouse.shn")) == false){ InitError("MiniHouse.shn InitError!!");return false;}
  718.  
  719.     // spiegel (2006-06-17)
  720.     if (ItemShopViewTable::Load(Folder::Merge(Folder::System(), "ItemShopView.shn")) == false){ InitError("ItemShopView.shn InitError!!");return false;}
  721.  
  722.     // spiegel (2006-06-20)
  723.     if (ChargedEffectTable::Load(Folder::Merge(Folder::System(), "ChargedEffect.shn")) == false){ InitError("ChargedEffect.shn InitError!!"); return false; }
  724.     //fennek_locaUSA_20070726_0////////////////////////////////////
  725.     if (TextFilterTable::LoadSlanderFilter() == false)
  726.     {
  727.         InitError("FilterSlander InitError!!");
  728.         return false;
  729.     }
  730.     //////////////////////////////////////fennek_locaUSA_20070726_0
  731.     //MiniHouse_IndoorMode_1.0////////////////////////////////////
  732. #if defined _MINI_HOUSE_INDOOR_MODE_
  733.     if(MiniHouseFuritureInfoTab::Load(Folder::Merge(Folder::System(), "MiniHouseFurniture.shn")) == false)
  734.     { InitError("MiniHouseFurniture.shn InitError!!");return false;}
  735.     splog(("MiniHouseFuritureInfoTab::Init()\n"));
  736.     if(MiniHouseObjAniInfoTab::Load(Folder::Merge(Folder::System(), "MiniHouseObjAni.shn")) == false)
  737.     { InitError("MiniHouseObjAni.shn InitError!!");return false;}
  738.     splog(("MiniHouseObjAniTab::Init()\n"));
  739. #endif
  740.     //////////////////////////////////////MiniHouse_IndoorMode_1.0
  741. //////////////////////////////////////fennek_work_20070726_1
  742.  
  743.  
  744.     //HS (07.12.06) WorldMap Format Change
  745.     if(WorldMapAvatarInfoTab::Load(Folder::Merge(Folder::System(), "WorldMapAvatarInfo.shn")) == false)
  746.     { InitError("WorldMapAvatarInfo.shn InitError!!");return false;}
  747.     //------------------------------------------------------------------------------------------------//
  748.  
  749.     //HS (08.01.28) Guild Grade Up
  750.     if(GuildGradeInfoTab::Load(Folder::Merge(Folder::System(), "GuildGradeData.shn")) == false)
  751.     { InitError("GuildGradeData.shn InitError!!");return false;}
  752.     //------------------------------------------------------------------------------------------//
  753.     //fennek_080311_1////////////////////////////////////
  754. #ifdef MIHI_HOUSE_OBJ_EFFECT
  755.     if(MHFurnitureObjEffectTab::Load(Folder::Merge(Folder::System(), "MiniHouseFurnitureObjEffect.shn")) == false)
  756.     { InitError("MiniHouseFurnitureObjEffect.shn InitError!!");return false;}
  757. #endif
  758.     //////////////////////////////////////fennek_080311_1
  759.  
  760.     //fennek_071213_2////////////////////////////////////
  761. #ifdef _SHOW_USERINFO_IN_SCREENSHOT_
  762.     m_spFont = NiFont::Create( NiRenderer::GetRenderer(), fs("%s\\CourierNew10.NFF", Folder::Main()) );
  763.     assert (m_spFont);  
  764.  
  765.     if( m_spFont )
  766.     {
  767.         NiColorA kColor(0.0f, 1.0f, 0.0f, 1.0f);
  768.         m_spStr2D = new NiString2D(m_spFont, NiFontString::COLORED, 128, NULL, kColor, 32, 360);
  769.     }
  770.  
  771. #endif
  772.     //////////////////////////////////////fennek_071213_2
  773.     // check upgrade max
  774. //  PgAssert(MAX_UPDATA_ARRAY == MAX_UPEFFECT_ARRAY && MAX_UPDATA_ARRAY == MAX_UPTEXTURE_ARRAY);
  775.     return true;
  776. }
  777.  
  778. void LogZBufferState(PgWin* pkWin)
  779. {
  780.     unsigned int uiPos = 0;
  781.     PgWin * pkChildWin = pkWin->GetNextChildWin(uiPos);
  782.     while(pkChildWin)
  783.     {
  784.         if(NiIsKindOf( PgWinText, pkChildWin))
  785.         {
  786.             PgWinText* pkTestText = (PgWinText*)pkChildWin;
  787.             //
  788.             splog_line;
  789. /*          if (pkTestText->GetText())
  790.             if (strcmp("my", pkTestText->GetText()) == 0)
  791.             {
  792.                 NiPoint3 kPos = pkTestText->GetTextGeometry()->GetTranslate();
  793.                 NiPoint3 kWorld = pkTestText->GetTextGeometry()->GetWorldTranslate();
  794.  
  795.                 bool bCull = pkTestText->GetAppCulled();
  796.  
  797.                 splog(("char position(%d, %d)-(%d, %d), cull flag :%d\n",
  798.                             (int)kPos.x, (int)kPos.y,
  799.                             (int)kWorld.x, (int)kWorld.y,
  800.                             (int)bCull));
  801.                 splog(("alpha:%f", pkTestText->GetAlpha()));
  802.                 NiZBufferProperty* pkProp = (NiZBufferProperty*)pkTestText->GetTextGeometry()->GetProperty(NiZBufferProperty::GetType());
  803.                 if (pkProp)
  804.                 {
  805.                     splog(("zbuffer prop exist\n"));
  806.                     splog(("test: %b, write: %b\n", pkProp->GetZBufferTest(), pkProp->GetZBufferWrite()));
  807.                 }
  808.                 NiAlphaProperty* pkAlpha = (NiAlphaProperty*)pkTestText->GetTextGeometry()->GetProperty(NiAlphaProperty::GetType());
  809.                 if (pkAlpha)
  810.                 {
  811.                     splog(("alpha prop exist\n"));
  812.                 }
  813.                 for (int i = 0; i < pkTestText->GetTextGeometry()->GetChildCount(); i++)
  814.                 {
  815.                     NiScreenElements* pkEle = (NiScreenElements*)pkTestText->GetTextGeometry()->GetAt(i);
  816.                     if (pkEle)
  817.                     {
  818.  
  819.                         splog(("poly:%d", pkEle->GetNumPolygons()));
  820.  
  821.                 NiPoint3 kPos = pkEle->GetTranslate();
  822.                 NiPoint3 kWorld = pkEle->GetWorldTranslate();
  823.  
  824.                 bool bCull = pkEle->GetAppCulled();
  825.  
  826.                 splog(("my  position(%d, %d, %f)-(%d, %d, %f), cull flag :%d\n",
  827.                             (int)kPos.x, (int)kPos.y, kPos.z,
  828.                             (int)kWorld.x, (int)kWorld.y, kWorld.z,
  829.                             (int)bCull));
  830. //              splog(("alpha:%f", pkEle->GetAlpha()));
  831.                 NiZBufferProperty* pkProp = (NiZBufferProperty*)pkEle->GetProperty(NiZBufferProperty::GetType());
  832.                 if (pkProp)
  833.                 {
  834.                     splog(("zbuffer prop exist\n"));
  835.                     splog(("test: %b, write: %b\n", pkProp->GetZBufferTest(), pkProp->GetZBufferWrite()));
  836.                 }
  837.                 NiAlphaProperty* pkAlpha = (NiAlphaProperty*)pkEle->GetProperty(NiAlphaProperty::GetType());
  838.                 if (pkAlpha)
  839.                 {
  840.                     splog(("alpha prop exist\n"));
  841.                 }
  842.  
  843.                    
  844.                     }
  845.                 }
  846.             }*/
  847.  
  848.             bool bCull = pkTestText->GetAppCulled();
  849.             splog(("PgWinText has text %s, position(%d, %d, %f)-(%d, %d, %f), cull flag :%d\n", pkTestText->GetText(),
  850.                             (int)pkTestText->GetTranslate().x, (int)pkTestText->GetTranslate().y,
  851.                                 pkTestText->GetTranslate().z,
  852.                             (int)pkTestText->GetWorldTranslate().x, (int)pkTestText->GetWorldTranslate().y,
  853.                                 pkTestText->GetWorldTranslate().z,
  854.                             (int)bCull));
  855.  
  856.             NiZBufferProperty* pkProp = (NiZBufferProperty*)pkTestText->GetProperty(NiZBufferProperty::GetType());
  857.             if (pkProp)
  858.             {
  859.                 splog(("zbuffer prop exist\n"));
  860.                 splog(("test: %b, write: %b\n", pkProp->GetZBufferTest(), pkProp->GetZBufferWrite()));
  861.             }
  862.             NiAlphaProperty* pkAlpha = (NiAlphaProperty*)pkTestText->GetProperty(NiAlphaProperty::GetType());
  863.             if (pkAlpha)
  864.             {
  865.                 splog(("alpha prop exist\n"));
  866.             }
  867.  
  868.         }
  869.         LogZBufferState(pkChildWin);
  870.         pkChildWin = pkWin->GetNextChildWin(uiPos);
  871.     }
  872. }
  873.  
  874. void MainApp::ProcessInput()
  875. {
  876.     //if(g_pkMouse)
  877.     //{
  878. //       int iX, iY, iZ = 0;
  879. //       if (g_pkMouse->GetPositionDelta(iX, iY, iZ))
  880. //       {
  881. //           if ((iX != 0) || (iY != 0))
  882. //               m_spCursor->Move(0.0f, iX, iY);
  883.     //     
  884. //      }
  885.     //}
  886.  
  887.     POINT kPoint;
  888.     ::GetCursorPos(&kPoint);
  889.     if(m_bFullscreen == false)
  890.         ::ScreenToClient(m_pkAppWindow->GetRenderWindowReference(), &kPoint);
  891.     Cursor::UpdateGraphicCursorPos(kPoint.x, kPoint.y);
  892.  
  893. #ifdef _TEST_VERSION_
  894.     if (g_pkKeyboard)
  895.     {
  896.         if (g_pkKeyboard->KeyIsDown(NiInputKeyboard::KEY_LSHIFT))
  897.         {
  898.             if (g_pkKeyboard->KeyWasPressed(NiInputKeyboard::KEY_F11))
  899.             {
  900.                 // win state logging
  901.                 PgTList<PgWin*>*    pkShowWinList = Pgg_kWinMgr.GetShowWinList();
  902.                 PgWinCamera*            pkCamera = Pgg_kWinMgr.GetCamera();
  903.                 splog_line;
  904.                 splog(("show win list count: %d\n", pkShowWinList->GetSize()));
  905.                 splog(("scene node count: %d\n", pkCamera->GetScene()->GetChildCount()));
  906.                 // show state
  907.                 splog_line;
  908.                 NiTListIterator kIter;
  909.                 PgWin* pkWin;
  910.                 kIter = pkShowWinList->GetHeadPos();
  911.                 while(kIter)
  912.                 {
  913.                     pkWin = pkShowWinList->GetNext(kIter);
  914.                     LogZBufferState(pkWin);
  915.                     //splog(("show state of window at[(%d,%d)-(%d,%d)]: %d\n",
  916.                     //  pkWin->GetXPos(), pkWin->GetYPos(),
  917.                     //  pkWin->GetWidth(), pkWin->GetHeight(), pkWin->GetShow() ));
  918.                 }
  919.                 splog_line;
  920.  
  921.                
  922.  
  923.             }
  924.  
  925.             if (g_pkKeyboard->KeyWasPressed(NiInputKeyboard::KEY_F12))
  926.             {
  927.                 PgWinCamera*            pkCamera = Pgg_kWinMgr.GetCamera();
  928.                 NiNode* pkNode = pkCamera->GetScene();
  929.                 NiWireframeProperty* pkProp = (NiWireframeProperty*)pkNode->GetProperty(NiWireframeProperty::GetType());
  930.                 if (pkProp == 0)
  931.                 {
  932.                     pkProp = new NiWireframeProperty;
  933.                     pkNode->AttachProperty(pkProp);
  934.                 }
  935.                 pkProp->SetWireframe(!pkProp->GetWireframe());
  936.             }
  937.  
  938.             if (g_pkKeyboard->KeyWasPressed(NiInputKeyboard::KEY_F9))
  939.             {
  940.                 PgWinCamera*            pkCamera = Pgg_kWinMgr.GetCamera();
  941.                 NiNode* pkNode = pkCamera->GetScene();
  942.  
  943.                 PgUtil::RemovePropWithChild(pkNode, NiTexturingProperty::GetType());
  944.                 PgUtil::RemovePropWithChild(pkNode, NiAlphaProperty::GetType());
  945.                 PgUtil::RemovePropWithChild(pkNode, NiVertexColorProperty::GetType());
  946.                 PgUtil::RemovePropWithChild(pkNode, NiMaterialProperty::GetType());
  947.                 pkNode->UpdateProperties();
  948.             }
  949.             extern float g_fAttackableDist;
  950.             if (g_pkKeyboard->KeyWasPressed(NiInputKeyboard::KEY_PRIOR))
  951.             {
  952.                 g_fAttackableDist -= 1.0f;
  953.                 if (g_fAttackableDist < 10.0f) g_fAttackableDist = 10.0f;
  954.                 splog(("attackable distance: %f\n", g_fAttackableDist));
  955.             }
  956.             if (g_pkKeyboard->KeyWasPressed(NiInputKeyboard::KEY_NEXT))
  957.             {
  958.                 g_fAttackableDist += 1.0f;
  959.                 splog(("attackable distance: %f\n", g_fAttackableDist));
  960.             }
  961.         }
  962.  
  963.     }
  964. #endif
  965.     //m_spCursor->SetPosition(0.0f, kPoint.x, kPoint.y);
  966.     /*
  967.     ::GetMousePos(&kPoint);
  968.     m_spCursor->Move(0.0f, kPoint.x, kPoint.y);
  969.     */
  970. }
  971.  
  972. void LoadSoundOption()
  973. {
  974.     MachineOpt::SoundOption kOpt = MachineOpt::GetSoundOption();
  975.     if (g_kSoundMgr.GetBgmGroup() == NULL)
  976.     {
  977.         spnever;
  978.         return;
  979.     }
  980.     g_kSoundMgr.SetMasterVolume((float)kOpt.uiMasterVolume /(float)MachineOpt::SoundOption::MAX_VOLUME);
  981.     g_kSoundMgr.SetBgVolume((float)kOpt.uiBgVolume /(float)MachineOpt::SoundOption::MAX_VOLUME);
  982.     g_kSoundMgr.SetEffectVolume((float)kOpt.uiEffectVolume /(float)MachineOpt::SoundOption::MAX_VOLUME);
  983.     g_kSoundMgr.SetEnvEffectVolume((float)kOpt.uiEnvEffectVolume /(float)MachineOpt::SoundOption::MAX_VOLUME);
  984.     //HS 2007.7.30 VoiceVolume
  985.     g_kSoundMgr.SetVoiceVolume((float)kOpt.uiVoiceVolume / (float)MachineOpt::SoundOption::MAX_VOLUME);
  986.     //
  987. }
  988.  
  989. //Header: Declared in Tlhelp32.h.
  990. //Library: Use Kernel32.lib.
  991.  
  992. #include <TlHelp32.h>
  993.  
  994. DWORD g_ProcessID = 0;
  995.  
  996. bool MainApp::Initialize()
  997. {
  998. //#if (defined _DEBUG || defined _AUTHOR_MODE)
  999. //#else
  1000. //  m_pkAppWindow->SetWidth(1024);
  1001. //  m_pkAppWindow->SetHeight(768);
  1002. //#endif
  1003.  
  1004.     //---------------------------------------------------------------------->>
  1005.     // kadol(07.10.17)_1
  1006.  
  1007.     //fennek_071022_0////////////////////////////////////
  1008.     if(TextData::Load(Folder::Merge(Folder::System(), "TextData.shn")) == false)
  1009.     { InitError("Text Data Initialize Fail!"); return false; }
  1010.     //////////////////////////////////////fennek_071022_0
  1011.  
  1012. #ifdef _USE_nPROTECT_
  1013.     if( g_pNpgl && g_dwNpglError != NPGAMEMON_SUCCESS )
  1014.     {
  1015.         bool bExit = CheckNProtectErr();
  1016.  
  1017.         if( bExit == true )
  1018.             return false;
  1019.     }
  1020. #endif
  1021.     //----------------------------------------------------------------------<<
  1022.  
  1023. #ifdef _LOCALE_VER_KR
  1024.     MinimizeProcess(NULL);
  1025. #endif
  1026.     //m_bChangeDisRes = false;
  1027.     //GetProcessWindowStation()
  1028.  
  1029.     //ProcessCommandLineBeforInit();
  1030.     //if(NiApplication::Initialize() == false)
  1031.     //  return false;
  1032.     //
  1033.     //::SetCursor(NULL);
  1034.     //if(Cursor::Init() == false)
  1035.     //  return false;
  1036.     //return true;
  1037.  
  1038.  
  1039.     if( g_kServer.m_bCP )
  1040.     {
  1041.     }
  1042.     else
  1043.     {
  1044.  
  1045. /*#if (defined _LOCALE_VER_KR && defined _CP_ONLY && !defined _AUTHOR_MODE )
  1046.         return false;
  1047. #endif*/
  1048.     }
  1049.  
  1050.     SetClassLongPtr(GetWindowReference(), GCLP_HICON,
  1051.         (LONG_PTR)LoadIcon(GetInstanceReference(),MAKEINTRESOURCE(IDI_GAMEICON)));
  1052.     //fennek_071022_0////////////////////////////////////
  1053. //  if(TextData::Load(Folder::Merge(Folder::System(), "TextData.shn")) == false)
  1054. //  { InitError("Text Data Initialize Fail!"); return false; }
  1055.     //////////////////////////////////////fennek_071022_0
  1056.  
  1057.     // spiegel (2006-04-27) xtrap check
  1058. #ifdef _XTRAP_ENABLE_
  1059. //  if (!IsXTrapValid())
  1060. //      return false;
  1061. #endif
  1062.  
  1063.    
  1064.  
  1065.     splog(("niapplcation::init()\n"));
  1066.     if(NiApplication::Initialize() == false)
  1067.         return false;
  1068.  
  1069.  
  1070.     //------------------------------------------------------------------------>>
  1071.     // added by hks_080204, modified hks_080310_0 : splash
  1072.     std::string SplashTexName, ProgressBarTexName;
  1073.     SplashTexName = Folder::Merge(Folder::Menu(), "loading\\NowLoading.TGA");
  1074.     ProgressBarTexName = Folder::Merge(Folder::Menu(),"loading\\ProgressBar.tga");
  1075.     m_SplashTexName = SplashTexName;
  1076.     m_ProgressBarTexName = ProgressBarTexName;
  1077.    
  1078.     DisplaySplash(m_SplashTexName.c_str(), m_ProgressBarTexName.c_str(), 10);  
  1079.     //------------------------------------------------------------------------<<
  1080.  
  1081.     splog(("niapplcation::init() - succ\n"));
  1082.    
  1083.  
  1084.     if(::PgInitInstance() == false)     { InitError("PgInstance Initialize Fail!"); return false; }
  1085.     if(InitAppHandle() == false)        { InitError("AppHandle Initialize Fail!"); return false; }
  1086.     if(this->InitInput() == false)      { InitError("Input Initialize Fail!"); return false; }
  1087.     if(Font::Init() == false)           { InitError("Font Initialize Fail!"); return false; }
  1088.     if(g_kNetMgr.Init() == false)       { InitError("Network Initialize Fail!"); return false; }
  1089.     //------------------------------------------------------------------------>>
  1090.     // added by hks_080204, modified by hks_080310_0 : splash  
  1091.     DisplaySplash(m_SplashTexName.c_str(), m_ProgressBarTexName.c_str(), 20);      
  1092.     //------------------------------------------------------------------------<<
  1093.     if(InitGameData() == false)         { InitError("Game Data Initialize Fail!"); return false; }
  1094.     //------------------------------------------------------------------------>>
  1095.     // added by hks_080204, modified by hks_080305_0 : splash  
  1096.     DisplaySplash(m_SplashTexName.c_str(), m_ProgressBarTexName.c_str(), 70);  
  1097.     //------------------------------------------------------------------------<<   
  1098.     splog(("step1\n"));
  1099.     if(g_kCharMgr.Init() == false)      { InitError("Character Manager Initialize Fail!"); return false; } 
  1100.     splog(("step2\n"));
  1101.     if(g_kCharResMgr.Init() == false)   { InitError("Character Resource Manager Initialize Fail!"); return false; }
  1102.     //------------------------------------------------------------------------>>
  1103.     // added by hks_080204, modified by hks_080305_0 : splash  
  1104.     DisplaySplash(m_SplashTexName.c_str(), m_ProgressBarTexName.c_str(), 90);  
  1105.     //------------------------------------------------------------------------<<
  1106.     splog(("step3\n"));
  1107.     if(g_kMapObjMgr.Init() == false)    { InitError("Map Object Manager Initialize Fail!"); return false; }
  1108.     splog(("step4\n"));
  1109.     if(g_kDropItemMgr.Init() == false)  { InitError("DropItem Manager Initialize Fail!"); return false; }
  1110.     splog(("step5\n"));
  1111.     if(MenuTexMgr::Init() == false)     { InitError("Menu Texture Manager Initialize Fail!"); return false; }
  1112.     splog(("step6\n"));
  1113.     if(g_kWorld.Init( (float)m_pkAppWindow->GetWidth(), (float)m_pkAppWindow->GetHeight() ) == false)
  1114.     { InitError("World Initialize Fail!"); return false; }
  1115.     splog(("step7\n"));
  1116.     if(Engine3D::Init(g_kWorld.GetCamera()) == false) { InitError("Engine3D Initialize Fail!"); return false; }
  1117.     //------------------------------------------------------------------------>>
  1118.     // added by hks_080204, modified by hks_080305_0 : splash
  1119.     DisplaySplash(m_SplashTexName.c_str(), m_ProgressBarTexName.c_str(), 100);
  1120.     //------------------------------------------------------------------------<<
  1121.  
  1122.     splog(("step8\n"));
  1123.     g_kSoundMgr.Init();
  1124.     LoadSoundOption();
  1125.     splog(("step9\n"));
  1126.     if(g_kEffectMgr.Init() == false)    { InitError("Effect Initialize Fail!"); return false; }
  1127.     if(g_kScrnBDMgr.Init() == false)    { InitError("Speech Initialize Fail!"); return false; }
  1128.     if(g_kTextEffMgr.Init() == false)   { InitError("Text Effect Initialize Fail!"); return false; }
  1129.  
  1130. #ifdef _CLIENT_ONLY
  1131.     if( QuestDataMgr::GetQuest() == NULL )  { InitError("QuestData Initialize Fail!"); return false; } 
  1132. #endif
  1133.  
  1134.     m_dwStyle = GetWindowLong(m_pkAppWindow->GetWindowReference(), GWL_STYLE);
  1135.     RECT kRect;
  1136.     GetWindowRect(m_pkAppWindow->GetRenderWindowReference(),&kRect);
  1137.     m_uiStartHeight = kRect.bottom - kRect.top;
  1138.     if(m_bRendererDialog == false && MachineOpt::GetWindowFullMode())
  1139.     {
  1140.         ReCreateRenderer();
  1141.     }
  1142.  
  1143.     splog(("step2\n"));
  1144.     NiSrand((unsigned int)(GetCurrentTime()*1000.0f));
  1145.     m_spRenderer->SetBackgroundColor(NiColor(1.0f, 0, 1.0f));  
  1146.  
  1147.     NiAlphaAccumulatorPtr spAlphaAccum = new NiAlphaAccumulator;
  1148.     m_spRenderer->SetSorter( spAlphaAccum );
  1149.  
  1150.     Pgg_kFrameMgr.RegisterAllFrameWork();
  1151.     m_kStartFrameWorkID = AccountFrameWorkID;
  1152.    
  1153.     ProcessCommandLine();
  1154.  
  1155.     splog(("loadconfig()\n"));
  1156. #ifdef _DEBUG
  1157.     Dbg::LoadConfig();
  1158. #endif
  1159.    
  1160.     g_kWorld.SetCameraZoomRatePerTick(0.001f);
  1161.     g_kWorld.SetCameraZoomMin(40.0f);
  1162.     // HS Change the Camera Zoom Value 330 -> 360 2007.4.25
  1163.     g_kWorld.SetCameraZoomMax(390.0f);
  1164.     //----------------------------------------------------//
  1165.     //g_kWorld.SetCameraZoomMax(1000.0f);
  1166.     g_kWorld.SetCameraZoomDef(100.0f);
  1167.  
  1168.     // spiegel (2006-04-25)
  1169.     // kadol( 2007-01-31 )..
  1170. /*
  1171. //#ifdef _LOCALE_VER_KR
  1172. #if ( (defined _LOCALE_VER_KR || defined _LOCALE_VER_CH) && !defined _CLIENT_ONLY && !defined _DEBUG && !defined _TEST_VERSION_)
  1173.     m_pkNetMarbleLogo = new DShowMovie;
  1174.     #if (defined _LOCALE_VER_CH)
  1175.     if (m_pkNetMarbleLogo->Load(Folder::Merge(Folder::Menu(), "\\Account\\netmarble_logo.wmv"), g_hMainWnd))
  1176.     #else
  1177.     if (m_pkNetMarbleLogo->Load(Folder::Merge(Folder::Menu(), "\\Account\\netmarble_logo.mpg"), g_hMainWnd))
  1178.     #endif
  1179.     {
  1180.         m_pkNetMarbleLogo->Play();
  1181.         ShowCursor(FALSE);
  1182.     }
  1183.     else
  1184.     {
  1185.         delete m_pkNetMarbleLogo;
  1186.         m_pkNetMarbleLogo = NULL;
  1187.  
  1188.         Pgg_kFrameMgr.Start(AccountFrameWorkID);
  1189.     }
  1190. #else
  1191. */
  1192.     //---------------------------------------------------------------------->>
  1193.     // kadol(07.10.17)_1
  1194. #ifdef _USE_nPROTECT_
  1195.     if( g_pNpgl )
  1196.         g_pNpgl->SetHwnd( g_hMainWnd );
  1197. #endif
  1198.     //----------------------------------------------------------------------<<
  1199.  
  1200.     //---------------------------------------------------------------------->>
  1201.     // temlost_20080326_0
  1202.     // temlost_2008041_0
  1203.     _GetPostProcessEffectMgr();//생성을 위해 미리 호출
  1204.     CDataDocument::Instance()->Load( Folder::Merge( Folder::Main() , "Default.conf" ) );
  1205.     //----------------------------------------------------------------------<<
  1206.     Pgg_kFrameMgr.Start(AccountFrameWorkID);
  1207. //#endif
  1208.     splog(("init sucesses\n"));
  1209.  
  1210. #ifdef _NETMARBLE_SHOP_
  1211.     {
  1212.         RECT            kRect = {0,0,300,300 };
  1213.         const char* WEB_ADDRESS = "http://game3.netmarble.net/game/sso_test/refresh.asp";
  1214.  
  1215.         CPData kCpData;
  1216.         GetAnalyzeArgument(kCpData);
  1217.  
  1218.         if(!InitSSOWebBrowser(g_hMainWnd, kCpData.AuthCookie, kCpData.DataCookie, kCpData.CpCookie))
  1219.         {
  1220.            
  1221.             return FALSE;
  1222.         }
  1223.  
  1224.        
  1225.         //m_ShopWeb.Create(WS_VISIBLE|WS_CHILD, kRect, g_hMainWnd, 1332);
  1226.         //==
  1227.         m_ShopWeb.Create(WS_CHILD, kRect, g_hMainWnd, 1332);
  1228.  
  1229.  
  1230.         //ShowWindow((HWND)m_ShopWeb.GetWnd(), SW_HIDE );
  1231.            
  1232.             m_ShopWeb.Navigate(WEB_ADDRESS);
  1233.     }
  1234. #endif
  1235.  
  1236.     //////////////////////////////////////////////////////////////////////////
  1237.     // modified by kadol( 2007.4.25 )
  1238.     MaskShader::GetShader();
  1239.     //////////////////////////////////////////////////////////////////////////
  1240.    
  1241. //HS 2007.8.9 Sound File Remove
  1242.     WIN32_FIND_DATA FindData;
  1243.     char acFullPath[128];
  1244.    
  1245.     for(int i=0; i<11; i++)
  1246.     {
  1247.         char* pcMp3Name = NULL;
  1248.         pcMp3Name = fs("%s",_RemoveBGMFile[i]);
  1249.         sprintf(acFullPath, "%s", Folder::Sound());
  1250.         strcat(acFullPath,pcMp3Name);
  1251.         HANDLE hFind = FindFirstFile(acFullPath,&FindData);
  1252.  
  1253.         if(hFind != INVALID_HANDLE_VALUE)
  1254.         {
  1255.             if(strcmp(FindData.cFileName,_RemoveBGMFile[i])==0)
  1256.             {
  1257.                 SetFileAttributes(acFullPath,FILE_ATTRIBUTE_NORMAL);
  1258.                 if(!DeleteFile(acFullPath))
  1259.                 {
  1260.                     DeleteFile(acFullPath);
  1261.                 }
  1262.             }
  1263.         }
  1264.     }
  1265.     //--------------------------------------------------------------//
  1266.     return true;
  1267. }
  1268.  
  1269.  
  1270.  
  1271. bool MainApp::MeasureTime()
  1272. {
  1273.     // start performance measurements
  1274.     if (m_fLastTime == -1.0f)
  1275.     {
  1276.         m_fLastTime = NiGetCurrentTimeInSec();
  1277.         //m_fLastTime = timeGetTime()/1000.0f;
  1278.         m_fAccumTime = 0.0f;
  1279.         m_iClicks = 0;
  1280.     }
  1281.  
  1282.     // measure time
  1283.     //m_fCurrentTime = timeGetTime()/1000.0f;
  1284.     m_fCurrentTime = NiGetCurrentTimeInSec();
  1285.  
  1286.     float fDeltaTime = m_fCurrentTime - m_fLastTime;
  1287.  
  1288.     // NVPerfHUD support!
  1289.     if (m_bNVPerfHUD && fDeltaTime == 0.0f)
  1290.     return true;
  1291.  
  1292.     if (fDeltaTime < 0.0f)
  1293.         fDeltaTime = 0.0f;
  1294.     m_fLastTime = m_fCurrentTime;
  1295.     m_fAccumTime += fDeltaTime;
  1296.  
  1297.     // frame rate limiter
  1298.     if (m_fAccumTime < (m_fLastFrame + m_fMinFramePeriod))
  1299.     return false;
  1300.  
  1301.     m_fFrameTime = m_fAccumTime - m_fLastFrame;
  1302.     m_fLastFrame = m_fAccumTime;
  1303.  
  1304.     return true;
  1305. }
  1306. void MainApp::CheckDisplayRealTime()
  1307. {
  1308.     unsigned int NewsystemScreenWidht = GetSystemMetrics(SM_CXSCREEN);
  1309.     unsigned int NewsystemScreenHeight = GetSystemMetrics(SM_CYSCREEN);
  1310.  
  1311.     if(m_uiOldResWidth > NewsystemScreenWidht || m_uiOldResheight > NewsystemScreenHeight)
  1312.         m_bChangeDisRes = true;
  1313. }
  1314.  
  1315. void MainApp::OnIdle()
  1316. {
  1317.    
  1318.     if (m_pkNetMarbleLogo) return;
  1319.    
  1320.     /*if(!GameFrameWork::ms_bWindowSizeChanged)
  1321.         CheckDisplayRealTime();
  1322.    
  1323.     if(m_bChangeDisRes)
  1324.     {
  1325.         ReCreateRenderer();
  1326.         m_bChangeDisRes = false;
  1327.     }*/
  1328.     if(GameFrameWork::ms_bWindowSizeChanged)
  1329.     {
  1330.         GameFrameWork::ms_bWindowSizeChanged = false;
  1331.         ReCreateRenderer();
  1332.     }
  1333.    
  1334.    
  1335.     if (!MeasureTime()) return;
  1336.  
  1337.     PgProfile(MainLoop);
  1338.    
  1339.     Timer::Update(GetCurrentTime());
  1340.  
  1341.     if (m_bEnableInput)
  1342.         UpdateInput();
  1343.  
  1344.     ProcessInput();
  1345.  
  1346.     // cursor update
  1347.     Cursor::Update(Timer::GetCurTime());
  1348.  
  1349.     if (m_bFrameRateEnabled && m_pkFrameRate)
  1350.     {
  1351.         m_pkFrameRate->TakeSample();
  1352.         m_pkFrameRate->Update();
  1353.     }
  1354.  
  1355.     //_PP_TEST_START(true, 5);
  1356.  
  1357.     g_kNetMgr.Update(Timer::GetCurTime());
  1358.  
  1359.     //_PP_TEST_("NetUpdate  ");
  1360.  
  1361.     Pgg_kFrameMgr.Update(Timer::GetCurTime());
  1362.  
  1363.     //_PP_TEST_("FrameUpdate    ");
  1364.  
  1365.     CQuest* pQuest = QuestDataMgr::GetQuest();
  1366.  
  1367.     pQuest->QuestPlayer_TimeProcess();
  1368.  
  1369. //  g_kSoundMgr.Update(Timer::GetCurTime());
  1370.  
  1371.  
  1372.     if(IsSkipDraw(Timer::GetCurTime()) == false)
  1373.     {
  1374.         //bool bNeedDevReset = false;
  1375.         //NiDX9Renderer * pkRenderer = (NiDX9Renderer *)NiRenderer::GetRenderer();
  1376.         //LPDIRECT3DDEVICE9 pkD3DDevice9 = pkRenderer->GetD3DDevice();
  1377.         //if(pkD3DDevice9)
  1378.         //{
  1379.         //  HRESULT eD3dRet = pkD3DDevice9->TestCooperativeLevel();
  1380.         //  if (eD3dRet == D3DERR_DEVICENOTRESET)
  1381.         //  {
  1382.         //      bNeedDevReset = true;
  1383.         //      Font::OnLostDevice();
  1384.         //      Cursor::OnLostDevice();
  1385.         //  }
  1386.         //}
  1387.  
  1388.         NiDX9Renderer* pkRenderer = (NiDX9Renderer *)NiRenderer::GetRenderer();
  1389.         DWORD dwRendererResetCount = pkRenderer->GetResetCounter();
  1390.         if (dwRendererResetCount != m_dwResetCounter)
  1391.         {
  1392. //          Font::OnResetDevice();
  1393.             Cursor::OnResetDevice();
  1394.             PortraitTextureBuffer::Terminate();
  1395.             m_dwResetCounter = dwRendererResetCount;
  1396.         }
  1397.  
  1398.         m_spRenderer->SetBackgroundColor(g_kWorld.GetBackGroundColor());
  1399.  
  1400.         m_spRenderer->BeginFrame();
  1401.         {
  1402.             m_spRenderer->BeginUsingDefaultRenderTargetGroup(NiRenderer::CLEAR_ALL);
  1403.  
  1404.             /*m_spCamera->Clear(NiRenderer::CLEAR_ZBUFFER |
  1405.             NiRenderer::CLEAR_BACKBUFFER |
  1406.             NiRenderer::CLEAR_STENCIL);*/
  1407.  
  1408.             //if(bNeedDevReset)
  1409.             //{
  1410.             //  Font::OnResetDevice();
  1411.             //  Cursor::OnResetDevice();
  1412.             //}
  1413. /*
  1414.             m_spScrEle->UpdateProperties();
  1415.             m_spScrEle->Update(0.0f  );
  1416.  
  1417.             m_spScrEle->Draw( m_spRenderer );
  1418. */
  1419.             Pgg_kFrameMgr.Draw();
  1420.  
  1421.             Cursor::Draw();
  1422.  
  1423.             ////////////////////////////////////////////////////////////////////////////
  1424.             // text drawing for debugging by kadol
  1425. #if 0
  1426.             if( Pgg_kFrameMgr.IsInRun( GameFrameWorkID ) )
  1427.                 g_pkMainChar->DrawDebugInfo();
  1428. #endif
  1429.             ////////////////////////////////////////////////////////////////////////////
  1430.  
  1431.             m_spRenderer->EndUsingRenderTargetGroup();
  1432.         }
  1433.         m_spRenderer->EndFrame();      
  1434.         m_spRenderer->DisplayFrame();      
  1435.  
  1436. #ifdef _VIEW_FRAMERATE_
  1437. //#if ( defined _AUTHOR_MODE || defined _CLIENT_ONLY )
  1438.         if ( !m_bFullscreen && m_pkAppWindow->GetStatusPanesExist() &&
  1439.             m_pkAppWindow->GetNumStatusPanes())
  1440.         {
  1441.             DrawFrameRate();
  1442.         }
  1443. //#endif
  1444. #endif
  1445.         m_iClicks++;
  1446.        
  1447.         PgProfileIncFrameCounter;
  1448.     }
  1449.  
  1450.     //_PP_TEST_("Draw       ");
  1451.  
  1452. //  splog(("%d, %d, %d, %d, %d", dwTime1, dwTime2, dwTime3, dwTime4, dwRenderTime));
  1453.     //Sleep(1);
  1454.  
  1455. #ifdef _DEBUG
  1456.     Dbg::SetFrameRate((float)m_iClicks/GetAccumTime());
  1457. #endif
  1458.  
  1459.     if(Pgg_kFrameMgr.IsQuit())
  1460.     {
  1461.         //---------------------------------------------------------------------->>
  1462.         // kadol(07.10.17)_1
  1463. #ifdef _USE_nPROTECT_
  1464.         CheckNProtectErr();
  1465. #endif
  1466.         //----------------------------------------------------------------------<<
  1467.  
  1468.        QuitApplication();
  1469.     }
  1470.  
  1471. #ifdef _XTRAP_ENABLE_
  1472. //  if (!IsXTrapValid())
  1473. //      QuitApplication();
  1474. #endif
  1475.  
  1476. }
  1477.  
  1478. /*  added by kadol( 07.8.21 )
  1479. bool MainApp::IsXTrapValid()
  1480. {
  1481. #ifndef _XTRAP_ENABLE_
  1482.     return true;
  1483. #endif
  1484.    
  1485.         return true;
  1486.  
  1487. #if 1
  1488.     char* pcErrMsg = NULL;
  1489.  
  1490.     if(g_bApiMal)
  1491.         pcErrMsg = TextData::Get(TextDataType::TI_XTRAP_PROGRAM_INVALID);
  1492.     if(g_bMemoryMdl)
  1493.         pcErrMsg = TextData::Get(TextDataType::TI_XTRAP_MEMORY_INVALID);
  1494.  
  1495.  
  1496.     if(g_bAutoMousMdl)
  1497.         pcErrMsg = TextData::Get(TextDataType::TI_XTRAP_AUTOMOUSE_DETECTED);
  1498.     else if(g_bAutoKeybMdl)
  1499.         pcErrMsg = TextData::Get(TextDataType::TI_XTRAP_AUTOKBD_DETECTED);
  1500.     else if(g_bMalMdl)
  1501.         pcErrMsg = TextData::Get(TextDataType::TI_XTRAP_BAD_PROGRAM_RUNNING);
  1502.     else if(g_bSpeedMdl)
  1503.         pcErrMsg = TextData::Get(TextDataType::TI_XTRAP_GAMESPEED_INVALID);
  1504.     else if(g_bFileMdl)
  1505.         pcErrMsg = TextData::Get(TextDataType::TI_XTRAP_INVALID_FILE);
  1506.     else if(g_bApiHookMdl)
  1507.         pcErrMsg = TextData::Get(TextDataType::TI_XTRAP_WINDOW_INVALID);
  1508.     else if(g_bDebugModMdl)
  1509.         pcErrMsg = TextData::Get(TextDataType::TI_XTRAP_RUNNING_IN_DEBUGMODE);
  1510.     else if(g_bMemoryCrack)
  1511.         pcErrMsg = TextData::Get(TextDataType::TI_XTRAP_INVALID_ACCESS_MC);
  1512.     else if(g_bFileCrack)
  1513.         pcErrMsg = TextData::Get(TextDataType::TI_XTRAP_INVALID_ACCESS_FC);
  1514.     else if(g_bApiHookCrack)
  1515.         pcErrMsg = TextData::Get(TextDataType::TI_XTRAP_INVALID_ACCESS_HC);
  1516.     else if (g_bOsMdl)
  1517.         pcErrMsg = TextData::Get(TextDataType::TI_XTRAP_RELEASE_COMPATIBILITY);
  1518.     else if (g_bPatchMdl)
  1519.         pcErrMsg = TextData::Get(TextDataType::TI_XTRAP_PROBLEM_TO_CONNECT_PATCHSERVER);
  1520.     else if (g_bStartXTrap == FALSE)
  1521.         pcErrMsg = TextData::Get(TextDataType::TI_XTRAP_CANT_RUN_SECURITYMODULE);
  1522.  
  1523.     if (pcErrMsg == NULL)
  1524.         pcErrMsg = "XTrap detected something.";
  1525.  
  1526.     MessageBox(NULL, pcErrMsg, TextData::Get(TextDataType::TI_XTRAP_SECURITY_WARNING), NULL);
  1527.     return false;
  1528. #else
  1529.     if(g_bApiMal)
  1530.     {   MessageBox(NULL,"프로그램이 정상작동하지 않습니다","보안경고",NULL);                                 return false;   }
  1531.  
  1532.     if(g_bMemoryMdl)
  1533.     {   MessageBox(NULL,"메모리 상태이상입니다","보안경고",NULL);                                                 return false;   }
  1534.  
  1535.     if(g_bAutoMousMdl)
  1536.     {   MessageBox(NULL,"오토마우스가 검출되었습니다","보안경고",NULL);                                        return false;   }
  1537.  
  1538.     if(g_bAutoKeybMdl)
  1539.     {   MessageBox(NULL,"오토키보드가 검출되었습니다","보안경고",NULL);                                            return false;   }
  1540.  
  1541.     if(g_bMalMdl)
  1542.     {   MessageBox(NULL,"게임에 영향을주는 프로그램이 실행중입니다","보안경고",NULL);                            return false;   }
  1543.  
  1544.     if(g_bSpeedMdl)
  1545.     {   MessageBox(NULL,"게임속도가 비정상적입니다","보안경고",NULL);                                           return false;   }
  1546.  
  1547.     if(g_bFileMdl)
  1548.     {   MessageBox(NULL,"비정상적인 파일입니다","보안경고",NULL);                                             return false;   }
  1549.  
  1550.     if(g_bApiHookMdl)
  1551.     {   MessageBox(NULL,"윈도우 상태이상입니다","보안경고",NULL);                                                 return false;   }
  1552.  
  1553.     if(g_bDebugModMdl)
  1554.     {   MessageBox(NULL,"디버그 모드로 실행되었습니다","보안경고",NULL);                                       return false;   }
  1555.  
  1556.     if(g_bMemoryCrack)
  1557.     {   MessageBox(NULL,"비정상적인 접근이 탐지되었습니다 [MC]","보안경고",NULL);                                return false;   }
  1558.  
  1559.     if(g_bFileCrack)
  1560.     {   MessageBox(NULL,"비정상적인 접근이 탐지되었습니다 [FC]","보안경고",NULL);                                return false;   }
  1561.  
  1562.     if(g_bApiHookCrack)
  1563.     {   MessageBox(NULL,"비정상적인 접근이 탐지되었습니다 [HC]","보안경고",NULL);                                return false;   }
  1564.  
  1565.     if (g_bOsMdl)
  1566.     {   MessageBox(NULL,"파일 속성에서 호환성 모드가 설정되었습니다. 설정을 해제하십시오.","보안경고",NULL);    return false;   }
  1567.  
  1568.     if (g_bPatchMdl)
  1569.     {   MessageBox(NULL,"패치 서버 접속에 문제가 있습니다. 네트워크 상황을 확인하십시오.","보안경고",NULL);  return false;   }
  1570.  
  1571.     if (g_bStartXTrap == FALSE)
  1572.     {   MessageBox(NULL,"게임 보안모듈을 실행할수 없습니다.","보안경고",NULL);                                   return false;   }
  1573.  
  1574.  
  1575.     return false;
  1576. #endif
  1577. }
  1578. */
  1579.  
  1580. void MainApp::EnableInput(bool bEnable)
  1581. {
  1582.     m_bEnableInput = bEnable;
  1583. }
  1584.  
  1585. //////////////////////////////////////////////////////////////////////////
  1586. // kadol(07.10.17)_1
  1587. #ifdef _USE_nPROTECT_
  1588. bool MainApp::CheckNProtectErr()
  1589. {
  1590.     if( g_dwNpglError == NPGAMEMON_SUCCESS )
  1591.         return false;
  1592.  
  1593.     TCHAR msg[256];
  1594.     LPCSTR lpszMsg;
  1595.  
  1596.    
  1597.  
  1598.     if ( g_dwNpglError == NPGAMEMON_GAMEHACK_KILLED || g_dwNpglError == NPGAMEMON_GAMEHACK_DETECT)
  1599.         wsprintf(msg, TEXT("Game Guard Error "));
  1600.     else
  1601.         wsprintf(msg, TEXT("Game Guard Error : %lu"), g_dwNpglError);
  1602.     MessageBox(NULL, lpszMsg, msg, MB_OK);
  1603.  
  1604.     g_pNpgl->RunFAQ(g_dwNpglError);
  1605.  
  1606.     return true;
  1607. }
  1608. #endif
  1609. //////////////////////////////////////////////////////////////////////////
  1610.  
  1611. //////////////////////////////////////////////////////////////////////////
  1612. // kadol(07.11.6)_1
  1613. #ifdef _SEARCH_PROCESS
  1614. #include "Psapi.h"
  1615. #pragma comment(lib,"Psapi" )
  1616.  
  1617.  
  1618.  
  1619. //////////////////////////////////////////////////////////////////////////
  1620. // added by hks_080204, modified hks_080305_0 : splash window loading image
  1621. void MainApp::DisplaySplash(const char* pcName, const char* pcProgressBarName, int LoadingRate)
  1622. {
  1623.     const float fDesiredAspect = 4.0f/3.0f;
  1624.     float fAspect = (float)m_pkAppWindow->GetWidth()/(float)m_pkAppWindow->GetHeight();
  1625.     if (NiAbs(fAspect - fDesiredAspect) > 0.01f)
  1626.     {
  1627.         // bad aspect ratio
  1628.         NiOutputDebugString("AW: Splash aspect incorrect.\n");
  1629.     }
  1630.  
  1631.     NiScreenElements* pkSplash = new NiScreenElements(new NiScreenElementsData(false, true, 1));
  1632.     NiScreenElements* pkProgressBar = new NiScreenElements(new NiScreenElementsData(false, true, 1));
  1633.    
  1634.     pkSplash->Insert(4);
  1635.     pkProgressBar->Insert(4);
  1636.  
  1637.     pkSplash->SetRectangle(0, 0.0f, 0.0f, 1.0f, 1.0f);
  1638.     pkProgressBar->SetRectangle(0, 0.2773475f, 0.7552f, (float)LoadingRate/100 * 0.5f, 0.015f); // screen
  1639.  
  1640.     pkSplash->UpdateBound();
  1641.     pkProgressBar->UpdateBound();
  1642.  
  1643.     pkSplash->SetColors(0, NiColorA::WHITE);
  1644.     pkProgressBar->SetColors(0, NiColorA::WHITE);
  1645.  
  1646. #if !defined(_XENON)
  1647.     pkSplash->SetTextures(0, 0, 0.0f, 0.0f, 1.0f, 1.0f); // texture
  1648.     pkProgressBar->SetTextures(0,0,0.0f,0.0f,(float)LoadingRate/100, 1.0f);
  1649. #else
  1650.     pkSplash->SetTextures(0, 0, -0.05f, -0.03f, 1.05f, 0.78f);
  1651. #endif
  1652.  
  1653.     // textures
  1654.     NiTexturingProperty* pkTex = new NiTexturingProperty(pcName);
  1655.     pkTex->SetBaseClampMode(NiTexturingProperty::CLAMP_S_CLAMP_T);
  1656.    
  1657.     NiTexturingProperty* pkProgressBarTex = new NiTexturingProperty(pcProgressBarName);
  1658.     pkProgressBarTex->SetBaseClampMode(NiTexturingProperty::CLAMP_S_CLAMP_T);
  1659.  
  1660.     pkSplash->AttachProperty(pkTex);
  1661.     pkProgressBar->AttachProperty(pkProgressBarTex);
  1662.  
  1663.     // use vertex colors
  1664.     NiVertexColorProperty* pkVertex = new NiVertexColorProperty;
  1665.     pkVertex->SetSourceMode(NiVertexColorProperty::SOURCE_EMISSIVE);
  1666.     pkVertex->SetLightingMode(NiVertexColorProperty::LIGHTING_E);
  1667.  
  1668.     pkSplash->AttachProperty(pkVertex);
  1669.     pkProgressBar->AttachProperty(pkVertex);
  1670.  
  1671.     // no alpha blending
  1672.     NiAlphaProperty* pkAlpha = new NiAlphaProperty;
  1673.     pkAlpha->SetAlphaBlending(false);
  1674.  
  1675.     pkSplash->AttachProperty(pkAlpha);
  1676.     pkProgressBar->AttachProperty(pkAlpha);
  1677.  
  1678.     pkSplash->UpdateProperties();
  1679.     pkSplash->Update(0.0f);
  1680.  
  1681.     pkProgressBar->UpdateProperties();
  1682.     pkProgressBar->Update(0.0f);
  1683.  
  1684.     m_spRenderer->BeginFrame();
  1685.     m_spRenderer->BeginUsingDefaultRenderTargetGroup(NiRenderer::CLEAR_ALL);
  1686.     m_spRenderer->SetScreenSpaceCameraData();
  1687.  
  1688.     pkSplash->Draw(m_spRenderer);
  1689.     pkProgressBar->Draw(m_spRenderer);
  1690.  
  1691.     m_spRenderer->EndUsingRenderTargetGroup();
  1692.     m_spRenderer->EndFrame();
  1693.     m_spRenderer->DisplayFrame();
  1694.  
  1695.     delete pkSplash;
  1696.     delete pkProgressBar;
  1697. }
  1698. //////////////////////////////////////////////////////////////////////////
  1699. void MainApp::Terminate()
  1700. {
  1701.     PgProfileReport;
  1702.     //---------------------------------------------------------------------->>
  1703.     // temlost_20080326_0
  1704.     CPostProcessEffectManager::Destroy();
  1705.     //----------------------------------------------------------------------<<
  1706.     g_kTextEffMgr.Terminate();
  1707.     g_kScrnBDMgr.Terminate();
  1708.     g_kEffectMgr.Terminate();
  1709.     Engine3D::Terminate();
  1710.     g_kWorld.Terminate();
  1711.     MenuTexMgr::Terminate();
  1712.     g_kDropItemMgr.Terminate();
  1713.     g_kMapObjMgr.Terminate();
  1714.     g_kCharResMgr.Terminate();
  1715.     g_kCharMgr.Terminate();
  1716.     g_kNetMgr.Terminate();
  1717.    
  1718.     this->TerminateInput();
  1719.     ::PgTerminateInstance();
  1720.  
  1721.     TerminateGameData();
  1722.     MachineOpt::Save();
  1723.     //MachineOpt::RestoreOrgGama();
  1724.  
  1725.     //////////////////////////////////////////////////////////////////////////
  1726.     //modified by kadol( 2007.4.25 )
  1727.     MaskShader::Terminate();
  1728.     //////////////////////////////////////////////////////////////////////////
  1729.  
  1730.     NiApplication::Terminate();
  1731.     g_kSoundMgr.Terminate();
  1732.  
  1733.     if (m_pkNetMarbleLogo)
  1734.     {
  1735.         delete m_pkNetMarbleLogo;
  1736.         m_pkNetMarbleLogo = NULL;
  1737.     }
  1738.  
  1739.     //---------------------------------------------------------------------->>
  1740.     // added by kadol( 2007.6.8 )
  1741.     if( st_pbyDummyMemory )
  1742.     {
  1743.         delete[] st_pbyDummyMemory;
  1744.         st_pbyDummyMemory = NULL;
  1745.     }
  1746.     //----------------------------------------------------------------------<<
  1747.  
  1748.  
  1749.  
  1750. #ifdef _XTRAP_ENABLE_
  1751. //  XTrapStop();
  1752. #endif
  1753.  
  1754.     Font::Termiante();
  1755.  
  1756.     //---------------------------------------------------------------------->>
  1757.     // kadol(07.10.17)_1
  1758. #ifdef _USE_nPROTECT_
  1759.     if( g_pNpgl )
  1760.     {
  1761.         delete g_pNpgl;
  1762.         g_pNpgl = NULL;
  1763.     }
  1764. #endif
  1765.     //----------------------------------------------------------------------<<
  1766.  
  1767.     //---------------------------------------------------------------------->>
  1768.     // kadol(07.12.3)_1
  1769. #ifdef _ENABLE_CHATBLOCK_
  1770.     TextFilterTable::SaveBlockedID();
  1771. #endif
  1772.     //----------------------------------------------------------------------<<
  1773. }
  1774.  
  1775. #include <NiDX9SystemDesc.h>
  1776. bool MainApp::CheckDisplayCard(unsigned int uiWidth,unsigned int uiHeight,unsigned int uiMultisample,bool bFullScreen)
  1777. {
  1778.     static bool ms_bFullscreen = bFullScreen;
  1779.  
  1780.     static const NiDX9SystemDesc* ms_pkInfo = NULL;
  1781.     static const NiDX9AdapterDesc* ms_pkAdapter = NULL;
  1782.     static const NiDX9DeviceDesc* ms_pkDevice = NULL;
  1783.     static const void* ms_pkMode = false;
  1784.     static bool ms_b32BitZBuffer = false;
  1785.  
  1786.  
  1787.     ms_pkInfo = NiDX9Renderer::GetSystemDesc();
  1788.     PgAssert(ms_pkInfo);
  1789.  
  1790.     unsigned int uiAdapterCount = ms_pkInfo->GetAdapterCount();
  1791.         bool bAdaptersExist = false;
  1792.     unsigned int uiAdapter = 0;
  1793.  
  1794.     unsigned int i = 0;
  1795.     uiAdapter = 0;
  1796.  
  1797.     const NiDX9AdapterDesc* pkAdapter = ms_pkInfo->GetAdapter(i);
  1798.     PgAssert(pkAdapter);
  1799.  
  1800.     const NiDX9DeviceDesc* pkDevice = pkAdapter->GetDevice(D3DDEVTYPE_HAL);
  1801.  
  1802.     if (!ms_bFullscreen)
  1803.     {
  1804.         if (!pkAdapter->CanDeviceRenderWindowed(D3DDEVTYPE_HAL))
  1805.             return false;
  1806.     }
  1807.  
  1808.     bAdaptersExist = true;
  1809.  
  1810.     if (bAdaptersExist)
  1811.     {
  1812.         ms_pkAdapter = (const NiDX9AdapterDesc*)ms_pkInfo->GetAdapter(uiAdapter);
  1813.         ms_pkDevice = ms_pkAdapter->GetDevice(D3DDEVTYPE_HAL);
  1814.     }
  1815.     else
  1816.     {
  1817.         ms_pkAdapter = NULL;
  1818.         ms_pkDevice = NULL;
  1819.         return false;
  1820.     }
  1821.  
  1822.     if (!ms_pkAdapter)
  1823.         return false;
  1824.  
  1825.     unsigned int uiModeCount = ms_pkAdapter->GetModeCount();
  1826.  
  1827.     int i16Default = -1;
  1828.     int i32Default = -1;
  1829.     bool bResolutionsExist = false;
  1830.  
  1831.     unsigned int uiMode;
  1832.     bool bDisplayRes = false;
  1833.     for (i = 0; i < uiModeCount; i++)
  1834.     {
  1835.         uiMode = i;
  1836.         const NiDX9AdapterDesc::ModeDesc* pkMode = ms_pkAdapter->GetMode(i);
  1837.  
  1838.         if(pkMode->m_uiWidth == uiWidth && pkMode->m_uiHeight == uiHeight && pkMode->m_uiBPP == 32)
  1839.         {
  1840.             bDisplayRes = true;
  1841.             break;
  1842.         }
  1843.         bResolutionsExist = true;
  1844.     }
  1845.  
  1846.  
  1847.     if (bResolutionsExist)
  1848.     {
  1849.         ms_pkMode = (const void*)ms_pkAdapter->GetMode(uiMode);
  1850.     }
  1851.     else
  1852.     {
  1853.         ms_pkMode = NULL;
  1854.     }
  1855.     if (!ms_pkDevice)
  1856.         return false;
  1857.  
  1858.     D3DFORMAT eFormat;
  1859.     if (ms_pkMode)
  1860.     {
  1861.         NiDX9AdapterDesc::ModeDesc* pkModeDesc = (NiDX9AdapterDesc::ModeDesc*)ms_pkMode;
  1862.         eFormat = pkModeDesc->m_eD3DFormat;
  1863.     }
  1864.     else
  1865.     {
  1866.     }
  1867.  
  1868.     const NiDX9DeviceDesc::DisplayFormatInfo* pkDFI = ms_pkDevice->GetFormatInfo(eFormat);
  1869.  
  1870.     NiDX9Renderer::DepthStencilFormat eNiDSFormat = pkDFI->FindClosestDepthStencil(ms_b32BitZBuffer ? 32 : 16, 0);
  1871.     D3DFORMAT eDSFormat = NiDX9Renderer::GetD3DFormat(eNiDSFormat);
  1872.  
  1873.  
  1874.     unsigned int uiQuality = pkDFI->GetNonmaskableMultiSampleQuality(!ms_bFullscreen, eFormat, eDSFormat);
  1875.  
  1876.     NiDX9Select::ms_uiMultisample = NiDX9Renderer::FBMODE_DEFAULT;
  1877.  
  1878.     bool bNonmaskableMultisample = false;
  1879.     for (i = 0; i < uiQuality; i++)
  1880.     {
  1881.         bNonmaskableMultisample = true;
  1882.         //if(uiMultisample == 1) NiDX9Select::ms_uiMultisample = (LPARAM)(NiDX9Renderer::FBMODE_MULTISAMPLES_NONMASKABLE | i);
  1883.  
  1884.         break;
  1885.     }
  1886.  
  1887.     bool bMultisample = false;
  1888.     for (i = 2; i < 17; i++)
  1889.     {
  1890.         D3DMULTISAMPLE_TYPE eType = (D3DMULTISAMPLE_TYPE)i;
  1891.  
  1892.         if (pkDFI->IsMultiSampleValid(!ms_bFullscreen, eType,eFormat, eDSFormat))
  1893.         {
  1894.             bMultisample = true;
  1895.            
  1896.             if(uiMultisample == 1) NiDX9Select::ms_uiMultisample = (LPARAM)(NiDX9Renderer::FBMODE_MULTISAMPLES_2 - 2 + i);
  1897.             break;
  1898.         }
  1899.     }
  1900.  
  1901.     if(uiMultisample == 0)
  1902.     {
  1903.         //NiDX9Select::ms_uiMultisample = NiDX9Renderer::FBMODE_DEFAULT;
  1904.     }
  1905.     else if(uiMultisample == 1)
  1906.     {
  1907.         if(bMultisample)
  1908.         {
  1909.         }
  1910.     }
  1911.  
  1912.     if(NiDX9Select::ms_uiMultisample == NiDX9Renderer::FBMODE_DEFAULT)
  1913.     {
  1914.         MachineOpt::SetMultisampleMode(0);
  1915.     }
  1916.  
  1917.  
  1918.     return bDisplayRes;
  1919. }
  1920.  
  1921.  
  1922. void MainApp::SetWinMaxmized()
  1923. {
  1924.     const MachineOpt::GraphicOption *pkGraphicOption = &MachineOpt::GetGraphicOption();
  1925.     PgAssert(pkGraphicOption);
  1926.  
  1927.     unsigned int uiDisplayWidth = pkGraphicOption->ui_DisplayResolutionWidth;
  1928.     unsigned int uiDisplayHeight = pkGraphicOption->ui_DisplayResolutionHeight;
  1929.  
  1930.     DEVMODE dm;
  1931.     ZeroMemory(&dm, sizeof(DEVMODE));
  1932.     dm.dmSize = sizeof(DEVMODE);
  1933.     dm.dmFields=DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
  1934.     dm.dmBitsPerPel = 32;
  1935.     dm.dmPelsWidth = uiDisplayWidth;
  1936.     dm.dmPelsHeight = uiDisplayHeight;
  1937.    
  1938.    
  1939.     DWORD dwStyle = GetWindowLong(m_pkAppWindow->GetWindowReference(), GWL_STYLE);
  1940.     dwStyle &= ~WS_SYSMENU;
  1941.     dwStyle &= ~WS_CAPTION;
  1942.     dwStyle |= WS_EX_TOOLWINDOW;
  1943.     SetWindowLong(m_pkAppWindow->GetWindowReference(), GWL_STYLE, dwStyle);  
  1944.  
  1945.         if(ChangeDisplaySettings(&dm,CDS_TEST)==DISP_CHANGE_SUCCESSFUL)
  1946.     {
  1947.         ChangeDisplaySettings(&dm,0);
  1948.         ShowWindow(m_pkAppWindow->GetWindowReference(),SW_SHOWMAXIMIZED);
  1949.         unsigned int statusWinHeight = 0;
  1950.         HWND hStatusWnd = m_pkAppWindow->GetStatusWindowReference();
  1951.  
  1952.         if(::IsWindow(hStatusWnd))
  1953.         {
  1954.             RECT statusRect;
  1955.             GetWindowRect(hStatusWnd,&statusRect);
  1956.             statusWinHeight = statusRect.bottom - statusRect.top;
  1957.             ShowWindow(hStatusWnd,SW_HIDE);
  1958.         }
  1959.  
  1960.         SetWindowPos(m_pkAppWindow->GetWindowReference(),NULL,0,0,uiDisplayWidth,uiDisplayHeight+statusWinHeight,NULL);
  1961.     }
  1962. }
  1963. #include "stdafx.h"
  1964.  
  1965. #include "MainApp.h"
  1966.  
  1967. // SadPig (2006-03-25) check window language.
  1968. bool MainApp::CheckWindowLocale()
  1969. {
  1970. #if ((defined _LOCALE_VER_JP) && (!defined _AUTHOR_MODE))
  1971.     //LANGID kLanID = GetSystemDefaultLangID();
  1972.     LANGID kLanID = GetSystemDefaultUILanguage();
  1973.  
  1974.     if(PRIMARYLANGID( kLanID ) != LANG_JAPANESE)
  1975.     {
  1976.         InitError("Error : Not Japanese Window!");
  1977.         return false;
  1978.     }
  1979. #endif
  1980.     return true;
  1981. }
  1982.  
  1983. static void SetImeNativeModeFalse(HWND hWnd)
  1984. {
  1985.     HIMC hIMCDef;
  1986.     hIMCDef = ImmGetContext( hWnd );
  1987.     //DWORD dwConvMode, dwSentMode;
  1988.     //if(ImmGetConversionStatus(hIMCDef, &dwConvMode, &dwSentMode) == 0)
  1989.     //return ;
  1990.  
  1991.     //dwConvMode &= ~IME_CMODE_NATIVE;
  1992.     //dwSentMode =  IME_SMODE_NONE;
  1993.     //ImmSetConversionStatus(hIMCDef, dwConvMode, dwSentMode);
  1994.  
  1995.     //ImmSetOpenStatus(hIMCDef, false);
  1996.  
  1997.     ImmNotifyIME( hIMCDef, NI_COMPOSITIONSTR, CPS_CANCEL, 0 );
  1998.     ImmNotifyIME( hIMCDef, NI_CLOSECANDIDATE, 0, 0 );
  1999.  
  2000.  
  2001.     ImmReleaseContext( hWnd, hIMCDef );
  2002. }
  2003.  
  2004. bool MainApp::OnIme(NiEventRef pEventRecord)
  2005. {
  2006. #if (defined _LOCALE_VER_KR)
  2007.     return false;
  2008. #else
  2009.     bool bRet = false;
  2010.     switch(pEventRecord->uiMsg)
  2011.     {  
  2012.     case WM_IME_STARTCOMPOSITION:
  2013.         {
  2014.             SetImeNativeModeFalse(pEventRecord->hWnd);
  2015.             bRet = true;
  2016.         }
  2017.         break;
  2018.     case WM_IME_NOTIFY:    
  2019.         if(pEventRecord->wParam == IMN_SETCONVERSIONMODE ||
  2020.             pEventRecord->wParam == IMN_SETOPENSTATUS)
  2021.         {
  2022.             SetImeNativeModeFalse(pEventRecord->hWnd);
  2023.             bRet = true;
  2024.         }
  2025.         break;
  2026.     };
  2027.     return bRet;
  2028. #endif
  2029. }
  2030.  
  2031. void MainApp::SetWinNormal()
  2032. {
  2033.     const MachineOpt::GraphicOption *pkGraphicOption = &MachineOpt::GetGraphicOption();
  2034.     PgAssert(pkGraphicOption);
  2035.  
  2036.     unsigned int uiDisplayWidth = pkGraphicOption->ui_DisplayResolutionWidth;
  2037.     unsigned int uiDisplayHeight = pkGraphicOption->ui_DisplayResolutionHeight;
  2038.    
  2039.         if(ChangeDisplaySettings(&m_SaveMode,CDS_TEST)==DISP_CHANGE_SUCCESSFUL)
  2040.     {
  2041.         ChangeDisplaySettings(&m_SaveMode,0);
  2042.                 unsigned int systemScreenWidht = GetSystemMetrics(SM_CXSCREEN);
  2043.         unsigned int systemScreenHeight = GetSystemMetrics(SM_CYSCREEN);
  2044.     //  m_uiOldResWidth = systemScreenWidht;
  2045.     //  m_uiOldResheight = systemScreenHeight;
  2046.  
  2047.         unsigned int uiDefaultWidth = 1024;
  2048.         unsigned int uiDefaultHeight = 768;
  2049.  
  2050.        
  2051.         uiDefaultHeight = uiDisplayHeight;
  2052.         uiDefaultWidth = uiDisplayWidth;
  2053.  
  2054.  
  2055.         if(systemScreenWidht < uiDisplayWidth || systemScreenHeight < uiDisplayHeight)
  2056.         {
  2057.             uiDefaultHeight = systemScreenHeight;
  2058.             uiDefaultWidth = systemScreenWidht;
  2059.             uiDisplayWidth = systemScreenWidht;
  2060.             uiDisplayHeight = systemScreenHeight;
  2061.         }
  2062.  
  2063.         GameFrameWork::ms_uiDisResWidth = uiDisplayWidth;
  2064.         GameFrameWork::ms_uiDisResHeight = uiDisplayHeight;
  2065.         SetWindowLong(m_pkAppWindow->GetWindowReference(), GWL_STYLE, m_dwStyle);
  2066.         ShowWindow(m_pkAppWindow->GetWindowReference(),SW_RESTORE);
  2067.         unsigned int statusWinHeight = 0;
  2068.         HWND hStatusWnd = m_pkAppWindow->GetStatusWindowReference();
  2069.  
  2070.         if(::IsWindow(hStatusWnd))
  2071.         {
  2072.             ShowWindow(hStatusWnd,SW_SHOW);
  2073.             RECT statusRect;
  2074.             GetWindowRect(hStatusWnd,&statusRect);
  2075.             statusWinHeight = statusRect.bottom - statusRect.top;
  2076.         }
  2077.        
  2078.  
  2079.         unsigned int uiDiffWidth = (GetSystemMetrics(SM_CXBORDER)+GetSystemMetrics(SM_CXEDGE))*2;
  2080.         unsigned int uiDiffHeight = GetSystemMetrics(SM_CYCAPTION) +(GetSystemMetrics(SM_CYBORDER)+GetSystemMetrics(SM_CYEDGE))*2 +statusWinHeight;
  2081.         SetWindowPos(m_pkAppWindow->GetWindowReference(),NULL,0,0,uiDisplayWidth + uiDiffWidth,uiDisplayHeight + uiDiffHeight,NULL);
  2082.  
  2083.  
  2084.         MachineOpt::SetDisplayResolution( uiDisplayWidth,uiDisplayHeight);
  2085.  
  2086.        
  2087.     }
  2088.     else
  2089.     {
  2090.         PgAssert(0);
  2091.     }
  2092. }
  2093.  
  2094. void MainApp::ReCreateRenderer()
  2095. {
  2096.     const MachineOpt::GraphicOption *pkGraphicOption = &MachineOpt::GetGraphicOption();
  2097.     PgAssert(pkGraphicOption);
  2098.  
  2099.     unsigned int uiDisplayMultisample = pkGraphicOption->ui_DisplayMultisample;
  2100.     unsigned int uiDisplayWidth = pkGraphicOption->ui_DisplayResolutionWidth;
  2101.     unsigned int uiDisplayHeight = pkGraphicOption->ui_DisplayResolutionHeight;
  2102.  
  2103.     GameFrameWork::ms_uiDisResWidth = uiDisplayWidth;
  2104.     GameFrameWork::ms_uiDisResHeight = uiDisplayHeight;
  2105.  
  2106.     unsigned int systemScreenWidht = GetSystemMetrics(SM_CXSCREEN);
  2107.     unsigned int systemScreenHeight = GetSystemMetrics(SM_CYSCREEN);
  2108.  
  2109.     if(!MachineOpt::GetWindowFullMode())
  2110.     {
  2111.         unsigned int uiDefaultWidth = 1024;
  2112.         unsigned int uiDefaultHeight = 768;
  2113.        
  2114.         uiDefaultHeight = uiDisplayHeight;
  2115.         uiDefaultWidth = uiDisplayWidth;
  2116.        
  2117.  
  2118.         if(uiDisplayWidth > systemScreenWidht || uiDisplayHeight > systemScreenHeight)
  2119.         {
  2120.             //return;
  2121.             uiDefaultHeight = uiDisplayHeight;
  2122.             uiDefaultWidth = uiDisplayWidth;
  2123.  
  2124.             m_pkAppWindow->SetWidth(uiDefaultWidth);
  2125.             m_pkAppWindow->SetHeight(uiDefaultHeight);
  2126.  
  2127.             MachineOpt::SetDisplayResolution( uiDefaultWidth,uiDefaultHeight);
  2128.            
  2129.            
  2130.             uiDisplayWidth = pkGraphicOption->ui_DisplayResolutionWidth;
  2131.             uiDisplayHeight = pkGraphicOption->ui_DisplayResolutionHeight;
  2132.  
  2133.             GameFrameWork::ms_uiDisResWidth = uiDisplayWidth;
  2134.             GameFrameWork::ms_uiDisResHeight = uiDisplayHeight;
  2135.  
  2136.         }
  2137.  
  2138.         if(!CheckDisplayCard(uiDisplayWidth,uiDisplayHeight,uiDisplayMultisample,m_bFullscreen))
  2139.         {
  2140.  
  2141.         }
  2142.  
  2143.         SetWinNormal();
  2144.     }
  2145.     else
  2146.     {
  2147.         if(!CheckDisplayCard(uiDisplayWidth,uiDisplayHeight,uiDisplayMultisample,m_bFullscreen))
  2148.         {
  2149.             //PgAssert(0);
  2150.             unsigned int uiDefaultWidth = systemScreenWidht;
  2151.             unsigned int uiDefaultHeight = systemScreenHeight;
  2152.            
  2153.  
  2154.             m_pkAppWindow->SetWidth(uiDefaultWidth);
  2155.             m_pkAppWindow->SetHeight(uiDefaultHeight);
  2156.  
  2157.             MachineOpt::SetDisplayResolution( uiDefaultWidth,uiDefaultHeight);
  2158.            
  2159.  
  2160.             uiDisplayWidth = pkGraphicOption->ui_DisplayResolutionWidth;
  2161.             uiDisplayHeight = pkGraphicOption->ui_DisplayResolutionHeight;
  2162.  
  2163.             GameFrameWork::ms_uiDisResWidth = uiDisplayWidth;
  2164.             GameFrameWork::ms_uiDisResHeight = uiDisplayHeight;
  2165.            
  2166.         }
  2167.         SetWinMaxmized();
  2168.     }
  2169.  
  2170.     // kadol temp
  2171.     ::SetForegroundWindow( m_pkAppWindow->GetWindowReference() );
  2172.     ::SetFocus( m_pkAppWindow->GetWindowReference() );
  2173.    
  2174.  
  2175. #if defined(_DX9)
  2176.     NiDX9Renderer* pkDX9Renderer = NiSmartPointerCast(NiDX9Renderer,m_spRenderer);
  2177.     assert(pkDX9Renderer);
  2178.  
  2179.     if(uiDisplayMultisample == 0)
  2180.     {
  2181.         //pkDX9Renderer->Recreate(uiDisplayWidth, uiDisplayHeight, (NiDX9Renderer::FlagType)
  2182.         NiDX9Renderer::RecreateStatus status = pkDX9Renderer->Recreate(0, 0, (NiDX9Renderer::FlagType)
  2183.             (NiDX9Renderer::USE_MULTITHREADED | NiDX9Renderer::USE_STENCIL),m_pkAppWindow->GetRenderWindowReference());
  2184.     }
  2185.     else
  2186.     {
  2187.         if(!m_bStartUseAntiOption)
  2188.         {
  2189.             NiDX9Renderer::RecreateStatus status = pkDX9Renderer->Recreate(0, 0, (NiDX9Renderer::FlagType)
  2190.                 (NiDX9Renderer::USE_MULTITHREADED | NiDX9Renderer::USE_STENCIL),m_pkAppWindow->GetRenderWindowReference());
  2191.         }
  2192.         else
  2193.         {
  2194.             NiDX9Renderer::RecreateStatus status = pkDX9Renderer->Recreate(0, 0, (NiDX9Renderer::FlagType)
  2195.                 (NiDX9Renderer::USE_MULTITHREADED | NiDX9Renderer::USE_STENCIL),m_pkAppWindow->GetRenderWindowReference(),
  2196.                 NiDX9Renderer::FBFMT_UNKNOWN,
  2197.                 NiDX9Renderer::DSFMT_UNKNOWN,
  2198.                 NiDX9Renderer::PRESENT_INTERVAL_ONE,
  2199.                 NiDX9Renderer::SWAPEFFECT_DEFAULT,
  2200.                 NiDX9Select::ms_uiMultisample);
  2201.         }
  2202.     }
  2203.  
  2204.     if(m_bStartUseAntiOption != (uiDisplayMultisample != 0))
  2205.     {
  2206.         if(!m_bStartUseAntiOption)
  2207.         {
  2208.             MsgBox * pkMsgBox;
  2209.             pkMsgBox = MsgBox::Modal(MsgBox::MSGBOX_OK,
  2210.                 TextData::Get(TextDataType::TI_MA_APPLY_AFTER_GAME_RESTART));
  2211.         }
  2212.     }
  2213.  
  2214. #else
  2215.     assert(false);
  2216. #endif
  2217.  
  2218.     PgWin::ms_uiScreenWidth = pkGraphicOption->ui_DisplayResolutionWidth;
  2219.     PgWin::ms_uiScreenHeight = pkGraphicOption->ui_DisplayResolutionHeight;
  2220.  
  2221.     PgWin::ms_iScreenTopPos = 0;
  2222.     PgWin::ms_iScreenLeftPos = 0;
  2223.     PgWin::ms_iScreenRightPos = PgWin::ms_uiScreenWidth - 1;
  2224.     PgWin::ms_iScreenBottomPos = PgWin::ms_uiScreenHeight - 1;
  2225.  
  2226.     //==마우스 재설정.
  2227.     NiRect<int> kRect;
  2228.     kRect.m_top = 0;
  2229.     kRect.m_left = 0;
  2230.  
  2231.     unsigned int uiAppWinWidth = m_pkAppWindow->GetWidth();
  2232.     unsigned int uiAppWinHeight = m_pkAppWindow->GetHeight();
  2233.     kRect.m_right = uiAppWinWidth;
  2234.     kRect.m_bottom = uiAppWinHeight;
  2235.     PgWin::ms_uiScreenWidth = uiAppWinWidth;
  2236.     PgWin::ms_uiScreenHeight = uiAppWinHeight;
  2237.  
  2238.     /*
  2239.     kRect.m_right = PgWin::ms_uiScreenWidth;
  2240.     kRect.m_bottom = PgWin::ms_uiScreenHeight;
  2241.     */
  2242.     if(Pgg_kWinMgr.GetCursor())
  2243.         Pgg_kWinMgr.GetCursor()->SetRect(kRect);
  2244.  
  2245.     float fWidth = (float)PgWin::ms_uiScreenWidth;
  2246.     float fHeight = (float)PgWin::ms_uiScreenHeight;
  2247.  
  2248.     float offsetY = 0.5f;
  2249.  
  2250.     offsetY += (fHeight-(float)m_uiStartHeight);
  2251.  
  2252.     NiFrustum m_kViewFrustum;
  2253.     m_kViewFrustum.m_fLeft = 0.5f;
  2254.     m_kViewFrustum.m_fRight = fWidth + 0.5f;
  2255.     m_kViewFrustum.m_fTop = fHeight - offsetY;
  2256.     m_kViewFrustum.m_fBottom = -offsetY;
  2257.  
  2258.     m_kViewFrustum.m_fNear = 1.0f;
  2259.     m_kViewFrustum.m_fFar = 10000.0f;
  2260.     m_kViewFrustum.m_bOrtho = true;
  2261.  
  2262.     Pgg_kWinMgr.GetCamera()->SetViewFrustum(m_kViewFrustum);
  2263.     g_kScrnBDMgr.GetCamera()->SetViewFrustum(m_kViewFrustum);
  2264.     g_kTextEffMgr.GetCamera()->SetViewFrustum(m_kViewFrustum);
  2265.     g_kWorld.SetCameraFrustum((float)PgWin::ms_uiScreenWidth,(float)PgWin::ms_uiScreenHeight);
  2266.     GameFrameWork::ms_bRendererRecreated = true;
  2267. }
  2268. void MainApp::SetWinMinimized()
  2269. {
  2270.     HWND hWnd = GetWindowReference();
  2271.     ::ShowWindow(hWnd, SW_MINIMIZE); //SW_SHOWMINIMIZED  
  2272. }
  2273. void MainApp::TerminateGameData()
  2274. {
  2275.     g_kShortCutMgr.Terminate();
  2276.     g_kInventory.Clear();
  2277.     g_kInventory.ClearMiniHouse();
  2278.     //MiniHouse_IndoorMode_1.0////////////////////////////////////
  2279.     g_kInventory.ClearMiniHouseAllItemInv();
  2280.     //////////////////////////////////////MiniHouse_IndoorMode_1.0
  2281.  
  2282. //  HairInfoTable::Terminate();
  2283.     IconMgr::Terminate();
  2284.     ActionInfoTable::Terminate();
  2285.     Skill::Terminate();
  2286. }
  2287.  
  2288. bool MainApp::OnWindowDestroy(NiWindowRef pWnd, bool bOption)
  2289. {
  2290.     bool r = NiApplication::OnWindowDestroy(pWnd, bOption);
  2291.  
  2292.     return r;
  2293. }
  2294. //////////////////////////////////////////////////////////////////////////
  2295. MainApp::~MainApp()
  2296. {
  2297.     //ChangeDisplaySettings(NULL, 0);
  2298.     ChangeDisplaySettings(&m_SaveMode, CDS_UPDATEREGISTRY);
  2299.  
  2300.     UninitWebCtrl();
  2301.  
  2302. #ifdef _NETMARBLE_SHOP_
  2303.     m_ShopWeb.Destroy();
  2304.  
  2305.     //UnInitSSOWebBrowser();
  2306. #endif
  2307.  
  2308. //#if ( defined _CONSOLE_TEST && !defined _DEBUG && defined _CLIENT_ONLY)
  2309. #if (defined _LOCALE_VER_KR &&  defined _AUTHOR_MODE)
  2310.     FreeConsole();
  2311. #endif
  2312. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement