Advertisement
Guest User

Untitled

a guest
Mar 2nd, 2012
388
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 37.52 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <Stdio.h>
  3. #include <Process.h>
  4. #include <Direct.h>
  5. #include "resource.h"
  6. #include "dragon.h"
  7. #include "math.h"
  8.  
  9. #include "gameproc.h"
  10. #include "network.h"
  11. #include "map.h"
  12. #include "char.h"
  13. #include "FPS.h"
  14. #include "object.h"
  15.  
  16. #include "Hong_Sprite.h"
  17. #include "Hong_Light.h"
  18. #include "Hong_Sub.h"
  19.  
  20. #include "Hangul.h"
  21. #include "Menudef.h"
  22. #include "Menu.h"
  23. #include "MenuStartSet.h"
  24. #include "DirectSound.h"
  25. #include "Effect.h"
  26. #include "LineCommand.h"
  27. #include "Tool.h"
  28. #include "ItemTable.h"
  29. #include "Midi.h"
  30. #include "MouseCursor.h"
  31. #include "SkillTool.h"
  32. #include "Skill.h"
  33. #include "House.h"
  34. #include "CharDataTable.h"
  35. #include "Item.h"
  36. #include "SmallMenu.h"
  37. #include "Counseler.h"
  38. #include "NPC_Pattern.h"
  39. #include "Music.h"
  40. //1206 zhh
  41. #include "CReadArgument.h"
  42. #include "FrameMgr.h"
  43. #include "LottoMgr.h"//soto-030501
  44. //< CSD-CN-031215
  45. #include "SecuritySystem.h"
  46. //> CSD-CN-031215
  47. extern SMENU SMenu[ MAX_MENU]; // startmenu.cpp
  48. extern NPC_INFO g_infNpc[MAX_CHARACTER_SPRITE_]; // CSD-030419
  49. extern int ListenCommand; // network.cpp
  50. extern void DoQuickmemoryByKeyInput(const int iInputKey,bool bIsDikCheck);
  51.  
  52. ///////////////////////////////////////////////////////////////////////////////
  53. // Global Variables:
  54. HWND g_hwndMain;
  55. HINSTANCE g_hInstance;
  56.  
  57. GAMEINFO g_GameInfo;
  58.  
  59. TCHAR g_szTitle[ MAX_LOADSTRING ];
  60. TCHAR g_szWindowClass[ MAX_LOADSTRING ];
  61. TCHAR g_szCWD[ _MAX_PATH ];
  62. TCHAR g_szInfoFile[ _MAX_PATH ];
  63.  
  64. BOOL g_bIsActive = FALSE;
  65. //////////// 0309 lkh Ãß°¡ //////////////
  66. BOOL g_bCommandMode = CM_COMMAND;
  67.  
  68. DIRECTDRAWINFO g_DirectDrawInfo = {0,};
  69. CHARACTERLIST g_CharacterList;
  70.  
  71.  
  72. POINT g_pointMouse, g_pointFuzz;
  73. long g_pointMouseX, g_pointMouseY;
  74. int g_nLButtonState, g_nRButtonState;
  75. int g_nLDButtonState, g_nRDButtonState;
  76. int g_nOldLButtonState, g_nOldRButtonState;
  77. int g_nSensitivity = 0; // ¸¶¿ì½º°¨µµ¸¦ SettingÇÑ´Ù.
  78. int LButtonDownIng, RButtonDownIng;
  79.  
  80. DWORD g_CurrentTime; // ¼­¹ö¿¡¼­ ¾Ë·ÁÁØ ÇöÀç ½Ã°£.
  81. DWORD g_ClientTime; // GameProc()¿¡¼­ °è¼ÓÀûÀ¸·Î Check ÇÑ´Ù.
  82. DWORD g_ServerClientTimeGap;
  83.  
  84. DWORD g_curr_time; // ¼­¹ö¿¡¼­º¸³»ÁÖ´Â ÇöÀçÀÇ ½Ã°£. ÃÊ´ÜÀ§..
  85. DWORD g_packet_recv_send_checktime;
  86.  
  87. ///////////////// 0311 lkh Ãß°¡ /////////////////
  88. int g_Operator_Function; //¿î¿µÀÚ¿ë È¿°ú ±¸ÇöÀ» À§ÇÑ ½ºÀ§Äª º¯¼ö
  89.  
  90.  
  91.  
  92. char IIDD[MAX_PATH]= {0,};
  93. char PPWW[MAX_PATH]= {0,};
  94.  
  95.  
  96. int CheckSumError;
  97.  
  98. // ------------------- khs 0804
  99. char *g_DestBackBuf, *g_OldDestBackBuf;
  100. int Mox, Moy; // ¸¶¿ì½ºÀÇ MapÀÇ Àý´ëÁÂÇ¥.
  101. int Mapx, Mapy; // ÇöÀ纸¿©Áö´Â ¸ÊÀÇ ½ÃÀÛÀý´ëÁÂÇ¥.
  102. int MapTx, MapTy; // ÇöÀ纸¿©Áö´Â ¸ÊÀÇ ½ÃÀÛÀý´ëÁÂÇ¥.
  103. LPCHARACTER Hero = NULL; // ÁÖÀΰøÀÇ Point..
  104. //------------------------------
  105. int QuitFlag = false;
  106.  
  107. DWORD g_RecvBytes, g_SendBytes;
  108.  
  109. bool MouseCursorOnOff = true;
  110. DWORD g_Inside;
  111.  
  112. int NowLoading;
  113.  
  114.  
  115.  
  116. ///////////////////////////////////////////////////////////////////////////////
  117. // Function prototypes.
  118. ATOM MyRegisterClass( HINSTANCE );
  119. BOOL InitInstance( HINSTANCE, int );
  120. BOOL InitApplication( HINSTANCE, LPSTR );
  121. void ExitApplication( void );
  122. void ParseCommandLine( LPSTR );
  123.  
  124. void SetCurrentWorkingDirectory( void );
  125. char* GetCurrentWorkingDirectory( void );
  126. void SetInfoFile( void );
  127. char* GetInfoFile( void );
  128. char* EatFrontWhiteChar( ch].,ar* );
  129. char* EatRearWhiteChar( char* );
  130. BOOL ShowErrorMessage( char* lpszMessage );
  131.  
  132. BOOL LoadGameInfo( void );
  133.  
  134. LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
  135. void CALLBACK TimerProc(HWND hWnd, UINT nMsg, UINT nTimerid, DWORD dwTime); // CSD-CN-031215
  136.  
  137. /////////////// 0128 À̱ÔÈÆ /////////////////
  138. bool g_Volume_Off=0;
  139.  
  140. /////////////// 0126 À̱ÔÈÆ /////////////////
  141. short int g_Current_Volume=100; //ÇöÀçÀÇ »ç¿îµå º¼·ý(0~100»çÀÌ°ª)
  142. short int g_To_Volume =100; //º¯È¯µÇ¾î¾ß ÇÏ´Â (ÃÖÁ¾ÀûÀ¸·Î) ¸ñÇ¥ »ç¿îµå º¼·ý
  143. short int g_Change_Volume =0; //º¼·ý ¼öÄ¡ º¯È¯Ä¡(-+ º¯È­°ª->Fade Out/In)
  144.  
  145. extern void InitMoveVariablesSetting( void );
  146. extern void ItemRead();
  147. extern void PutStartLodingImg( ); // 0127 YGI
  148.  
  149. #include "Path.h"
  150.  
  151. char nOldVal[MAX_PATH];
  152.  
  153.  
  154. int recvAttackResultCount;
  155. FILE *keyplayfp;
  156. FILE *keykeyplayfp;
  157.  
  158.  
  159. bool g_bIsChristmas = false;
  160.  
  161. ///////////////////////////////////////////////////////////////////////////////
  162. // Functions.
  163.  
  164. //lsw
  165. extern char explain_tactics[13][20];
  166. extern char FightTeam[5][13];
  167. extern char NationName[8][20]; // 010227 YGI
  168. // thai2 YGI
  169. extern char subFarmType[20][25];
  170. extern char subMineType[20][25];
  171. extern char subHubType[20][25];
  172.  
  173. //________________________ // 010904 LTS
  174. extern bool InitNation();
  175. extern void CloseNation();
  176. extern void InitHorseAniTable(); // LTS HORSERIDER
  177. //________________________ // 010904 LTS
  178.  
  179.  
  180. static int FirstCheck = 0;
  181. static char s_szCheckCode[] = "87021595-E214-4061-8E40-98BD9AAED844"; // CSD-CN-031215
  182.  
  183. HWND g_hMultiDlg = NULL;
  184. CSecuritySystem g_sysSecurity; // CSD-CN-031215
  185. UINT g_idSafeTimer = 0; // CSD-CN-031215
  186.  
  187. //---------------------------------------------------------------------------------------------
  188. // °ÔÀÓÀ» ½ÇÇàÇϱâÀü È­ÀÏÀ̸§ÀÇ º¯µ¿À̶óµç°¡ ÀÚµ¿ÆÐÄ¡·Î ¸øÇÏ°í ÇÁ·Î±×·¥ÀûÀ¸·Î
  189. // ó¸®ÇØ¾ß ÇÏ´Â °ÍÀ» ¿©±â¼­ ó¸®ÇÑ´Ù.
  190. //---------------------------------------------------------------------------------------------
  191. void BeforeExe( LPSTR lpCmdLine ) // thai2 YGI
  192. { //< CSD-030324
  193.  
  194. int i,j;
  195. int c = 0;
  196.  
  197. if( !FirstCheck)
  198. {
  199. for(int ii=0;ii<13; ii++)
  200. {
  201. char *temp = lan->OutputMessage(9,ii+451);
  202. if( strlen( temp ) >= 20 ) JustMsg( "1 : %d", strlen( temp ) );
  203. sprintf(explain_tactics[ii],"%s",lan->OutputMessage(9,ii+451));
  204. }
  205.  
  206. for(ii=0;ii<5; ii++)
  207. {
  208. char *temp = lan->OutputMessage(9,ii+441);
  209. if( strlen( temp ) >= 13 ) JustMsg( "2: %d", strlen( temp ) );
  210.  
  211. sprintf(FightTeam[ii],"%s",lan->OutputMessage(9,ii+441));
  212. }
  213.  
  214. for(ii=0;ii<8; ii++)
  215. {
  216. char *temp = lan->OutputMessage(9,ii+421);
  217. if( strlen( temp ) >= 20 ) JustMsg( "3: %d", strlen( temp ) );
  218. sprintf(NationName[ii],"%s",lan->OutputMessage(9,ii+421));
  219. }
  220. // 010314 KHS
  221. for (ii = 0; ii < MAX_CHARACTER_SPRITE_; ++ii)
  222. { //< CSD-030419
  223. char* temp = lan->OutputMessage(4, ii + 201);
  224. if (strlen(temp) >= 40)
  225. {
  226. JustMsg("4: %d", strlen(temp));
  227. }
  228.  
  229. sprintf(g_infNpc[ii].szName, "%s", lan->OutputMessage(4, ii + 201));
  230. } //> CSD-030419
  231.  
  232. for(ii=0;ii<20; ii++)
  233. {
  234. char *temp = lan->OutputMessage(4,ii+401);
  235. if( strlen( temp ) >= 25 ) JustMsg( "5: %d", strlen( temp ) );
  236. sprintf(subFarmType[ii],"%s",lan->OutputMessage(4,ii+401));
  237. }
  238.  
  239.  
  240. for(ii=0;ii<8; ii++)
  241. {
  242. char *temp = lan->OutputMessage(4,ii+421);
  243. if( strlen( temp ) >= 25 ) JustMsg( "6: %d", strlen( temp ) );
  244. sprintf(subMineType[ii],"%s",lan->OutputMessage(4,ii+421));
  245. }
  246.  
  247.  
  248. for(ii=0;ii<11; ii++)
  249. {
  250. char *temp = lan->OutputMessage(4,ii+121);
  251. if( strlen( temp ) >= 25 ) JustMsg( "7: %d", strlen( temp ) );
  252. sprintf(subHubType[ii],"%s",lan->OutputMessage(4,ii+121));
  253. }
  254.  
  255. for(int j=0;j<MAX_LINE_COMMAND_; j++)//010216 lsw ¶óÀÎ Ä¿¸àµå / µÚ¿¡ ¸í·É¾îµé 501 ¹øºÎÅÍ ½ÃÀÛ
  256. {
  257. char *temp = lan->OutputMessage(9,j+501);
  258. if( strlen( temp ) >= 35 ) JustMsg( "8: %d, %d", strlen( temp ), j );
  259. sprintf(LC[j].reserved,"%s" ,lan->OutputMessage(9,j+501));
  260. }
  261. FirstCheck = 1;
  262. }
  263.  
  264. g_pBill = new CClientBill(lpCmdLine);
  265.  
  266. #ifdef _DEBUG//À̺κÐÀº µð¹ö±ë ¿ëÀ¸·Î ¾î¶² ÀÎÀÚ°ªÀÌ ³Ñ¾î ¿Ô´ÂÁö º¸¿©ÁÝ´Ï´Ù. ¹°·Ð ¹èÆ÷ÇÒ¶§´Â »©¾ß ÇÕ´Ï´Ù
  267. g_pBill->DisplayAllCommand();
  268. #endif
  269.  
  270. #ifdef _MAPOBJECT_DIRECTORY_CHANGE_
  271.  
  272. _mkdir("./object/0" );
  273. _mkdir("./object/2" );
  274. _mkdir("./object/3" );
  275. _mkdir("./object/4" );
  276. _mkdir("./object/5" );
  277. _mkdir("./object/6" );
  278. _mkdir("./object/7" );
  279.  
  280. c = ReturnFileNumber("./object/Sung_Tile_00/" );
  281. c += ReturnFileNumber("./object/K_Sung2/" );
  282. c += ReturnFileNumber("./object/Ma-In/" );
  283. c += ReturnFileNumber("./object/Source/" );
  284. c += ReturnFileNumber("./object/Ice-w01/" );
  285. c += ReturnFileNumber("./object/Firedun1/" );
  286. c += ReturnFileNumber("./object/ManDun1/" );
  287.  
  288. if( c )
  289. {
  290. JustMsg(lan->OutputMessage(6,1) );//010215 lsw
  291. JustMsg( lan->OutputMessage(6,2) );//010215 lsw
  292. }
  293.  
  294. Dir2DirCopy("./object/Sung_Tile_00/", "./object/2/" );
  295. Dir2DirCopy("./object/K_Sung2/", "./object/7/" );
  296. Dir2DirCopy("./object/Ma-In/", "./object/0/" );
  297. Dir2DirCopy("./object/Source/", "./object/6/" );
  298. Dir2DirCopy("./object/Ice-w01/", "./object/3/" );
  299. Dir2DirCopy("./object/Firedun1/", "./object/4/" );
  300. Dir2DirCopy("./object/ManDun1/", "./object/5/" );
  301.  
  302. if( c )
  303. {
  304. JustMsg( lan->OutputMessage(6,3) );//010215 lsw
  305. }
  306.  
  307. FILE *fp = Fopen( "./object/7/0277.csp", "rb" );
  308. if( fp )
  309. {
  310. fclose(fp);
  311. JustMsg( lan->OutputMessage(6,4) );//010215 lsw
  312. for( i = 277 ; i <= 798 ; i ++)
  313. {
  314. char temp[ FILENAME_MAX];
  315. char temp1[ FILENAME_MAX];
  316.  
  317. for( j = 0 ; j < 10 ; j ++)
  318. {
  319. if( j == 0 )
  320. {
  321. sprintf( temp, "./object/7/%04d.csp", i );
  322. sprintf( temp1, "./object/7/%04d.csp", i+7000 );
  323. }
  324. else
  325. {
  326. sprintf( temp, "./object/7/%04d%02d.csp", i,j );
  327. sprintf( temp1, "./object/7/%04d%02d.csp", i+7000,j );
  328. }
  329. rename( temp, temp1 );
  330. }
  331. }
  332. }
  333. #endif
  334. }
  335.  
  336. extern int LoadHackingToolName();
  337. int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow )
  338. {
  339. ::Sleep(1000);//¿ÀÅäÆÐÄ¡ÀÇ ÆÐÄ¡ ¶§¹®¿¡ 1ÃÊ Á¤µµÀÇ µô·¹À̸¦ ÁÝ´Ï´Ù.
  340.  
  341. #ifndef _DEBUG
  342. if (g_sysSecurity.GetDragonHwnd() != NULL)
  343. { //< PowerZ-030116
  344. MessageBox(NULL, "Can Not Run Program", "Run Error", NULL);
  345. return FALSE;
  346. } //> PowerZ-030116
  347. #endif
  348.  
  349. MSG msg = {0,};
  350. #ifndef _DEBUG // 031110 YGI
  351. EXCEPTION_POINTERS* pException = NULL;//020508 lsw
  352. __try //020514 lsw
  353. {
  354. #endif
  355.  
  356. g_CrashLog.Init(OUTPUT_JUST_FILE,"ClientCrash");//¸ðµå ¼ÂÆà ±â·Ï µÉ ÆÄÀÏÀÇ °íÀ¯ À̸§ÀÔ´Ï´Ù.
  357. g_DBGLog.Init(OUTPUT_JUST_FILE,"CustomerService");//¸ðµå ¼ÂÆà ±â·Ï µÉ ÆÄÀÏÀÇ °íÀ¯ À̸§ÀÔ´Ï´Ù.
  358.  
  359. CrackMgr.SetInitClock();//030319 lsw
  360. CrackMgr.InitCrackMgr();
  361.  
  362. if(!CrackMgr.StartCrackThread())
  363. {
  364. MessageBox(NULL,"Can Not Run Program. Call to A/S Center","Init Error",NULL);
  365. return false;
  366. }
  367.  
  368. if(!LoadLanguageText())
  369. {
  370. MessageBox(NULL,"Loading Language Pack Error","LanguagePack",NULL);
  371. return false;
  372. }
  373.  
  374. if(!LoadHackingToolName())
  375. {
  376. g_DBGLog.Log(LOG_LV1,"Can't Load Hacking Tool Check File");
  377. return false;
  378. }
  379. //< CSD-CN031215
  380. FILE *fpAP = Fopen("DragonRaja.b", "rb" );
  381.  
  382. if (fpAP != NULL)
  383. {
  384. fclose(fpAP);
  385. Sleep(300);
  386. remove("DragonRaja.exe");
  387. Sleep(300);
  388. rename("DragonRaja.b", "DragonRaja.exe");
  389. MessageBox( NULL, lan->OutputMessage(6,6), "DragonRaja", MB_OK );//010215 lsw
  390. ExitApplication(EA_BEFORE_EXE2);
  391. return false;
  392. }
  393. //> CSD-CN031215
  394. if ( !InitApplication( hInstance, lpCmdLine ) )
  395. {
  396. g_DBGLog.Log(LOG_LV1,"Application Init Failed");
  397. return FALSE;
  398. }
  399. if ( !InitInstance( hInstance, nCmdShow ) )
  400. {
  401. g_DBGLog.Log(LOG_LV1,"Instance Init Failed");
  402. return FALSE;
  403. }
  404. //< CSD-040224
  405. #ifndef _DEBUG
  406. #if defined (KOREA_LOCALIZING_)
  407. if (!g_sysSecurity.CheckFileName("dragonraja.bin"))
  408. {
  409. ExitWindows(EWX_SHUTDOWN, 0);
  410. return FALSE;
  411. }
  412. #endif
  413. /*
  414. #ifndef KOREA_LOCALIZING_
  415. const int nError = g_sysSecurity.Connect(g_hwndMain);
  416.  
  417. if (nError != 1)
  418. {
  419. MessageBox(NULL, VA("Connect Error!\nERR.CODE.00%d!", nError), "Run Error", NULL);
  420. return FALSE;
  421. }
  422.  
  423. g_idSafeTimer = SetTimer(g_hwndMain, 24, 1000, TimerProc);
  424.  
  425. if (g_idSafeTimer == 0)
  426. {
  427. return FALSE;
  428. }
  429. #endif
  430. */
  431. #endif
  432. //> CSD-040224
  433. //< CSD-TEST : SafeMeme Å×½ºÆ®
  434. /*
  435. const int nError = g_sysSecurity.Connect(g_hwndMain);
  436.  
  437. if (nError != 1)
  438. {
  439. MessageBox(NULL, VA("Connect Error!\nERR.CODE.00%d!", nError), "Run Error", NULL);
  440. return FALSE;
  441. }
  442.  
  443. g_idSafeTimer = SetTimer(g_hwndMain, 24, 1000, TimerProc);
  444.  
  445. if (g_idSafeTimer == 0)
  446. {
  447. return FALSE;
  448. }
  449. */
  450. //> CSD-TEST
  451. BeforeExe(lpCmdLine);
  452.  
  453. if ( !InitDirectDraw( g_hwndMain, &g_DirectDrawInfo ) )
  454. {
  455. g_DBGLog.Log(LOG_LV1,"DDraw Init Failed");
  456. return FALSE;
  457. }
  458. if ( InitDirectInput( g_hwndMain, g_hInstance, g_bIsActive ) != DI_OK )
  459. {
  460. g_DBGLog.Log(LOG_LV1,"DInput Init Failed");
  461. return FALSE;
  462. }
  463. if ( !EWndMgr.InitEditWnd())//021001 lsw
  464. {
  465. g_DBGLog.Log(LOG_LV1,"EditWnd Init Failed");
  466. return FALSE;
  467. }
  468.  
  469. InitSpriteTransTable( g_DirectDrawInfo.lpDirectDrawSurfacePrimary );
  470.  
  471. g_DestBackBuf = GetSurfacePointer( g_DirectDrawInfo.lpDirectDrawSurfaceBack );
  472. EraseScreen( &g_DirectDrawInfo, (WORD)RGB( 0xff, 0xff, 0xff ) );
  473. PutStartLodingImg( );
  474. FlipScreen( &g_DirectDrawInfo );
  475.  
  476. LoadSoundList();
  477. RenameSoundFile();
  478.  
  479. if( SysInfo.effect )
  480. if ( !InitSfx( g_hwndMain ) )
  481. {
  482. //return FALSE;
  483. }
  484.  
  485. LoadConditionTable();
  486.  
  487. if (!LoadEffect())
  488. {
  489. MessageBox(NULL,"Loading Effect Error","Effect Data", NULL);
  490. return false;
  491. }
  492.  
  493. if (!LoadMagicTable2())
  494. {
  495. MessageBox(NULL,"Loading Magic Error","Magic Data", NULL);
  496. return false;
  497. }
  498. ////////////////////// SoundUp LKH Ãß°¡ ////////////////////////
  499. LoadBGESoundTable(); //¹è°æ È¿°ú ÀÌÆåÆ®À½ Å×À̺í ÀÐ¾î ¿À±â
  500.  
  501. LoadSmallMapBack();
  502.  
  503. ViewTipsLoad( 0 );
  504.  
  505. HangulOutputArea( 0, SCREEN_WIDTH-1, 0, SCREEN_HEIGHT-1 );
  506. LoadHangulEnglishFont( "./data/han.fnt", "./data/eng.fnt" );
  507. MakergbTable();
  508. LoadLevelExpTable();
  509. LoadCursorAni();
  510. LoadMouseCursor( "Cursor.Spr" );
  511.  
  512. //010928 lsw
  513. LoadChatImage();
  514.  
  515. if(!LoadItemTableData())//021111 lsw
  516. {
  517. g_DBGLog.Log(LOG_LV1,"ItemTableData Init Failed");
  518. return false;
  519. }
  520.  
  521. if (checkbeta=='1')
  522. { //< CSD-031030
  523. if (!g_mgrLimit.Load("./data_b5/AbilityLimit.bin"))
  524. {
  525. if (!g_mgrLimit.Load("./data/AbilityLimit.bin"))
  526. {
  527. MessageBox(NULL,"Loading LimitData Error","Limit Data", NULL);
  528. return false;
  529. }
  530. }
  531. } //> CSD-031030
  532. else
  533. {
  534. if (!g_mgrLimit.Load("./data/AbilityLimit.bin"))
  535. {
  536. MessageBox(NULL,"Loading LimitData Error","Limit Data", NULL);
  537. return false;
  538. }
  539. }
  540. //> CSD-021015
  541. if (!InitNation())
  542. {
  543. MessageBox(NULL,"Loading NationData Error","Nation Data",NULL);
  544. return false;
  545. }
  546. //________________________________________________________________ // 010904 LTS
  547.  
  548. #ifdef USE_PROFILER // 031013 kyo
  549. g_ProFileMgr.Init();
  550. g_ProFileMgr.AddCounter("GameProc", "GameProc" );
  551. g_ProFileMgr.AddCounter("GameProc", "Protocol" );
  552. g_ProFileMgr.AddCounter("GameProc", "Input" );
  553. #endif
  554.  
  555. #ifndef LIGHT_VERSION_
  556. InitHorseAniTable(); // LTS HORSERIDER
  557. #endif
  558.  
  559. MAIN_MENU_:
  560.  
  561. LoadMenuData( 0 );
  562. LoadMenuData( 4 );
  563. StartMenuSetting(); //°ÔÀÓÀ» ½ÃÀÛÇϱâ Àü¿¡ ¸Þ´º ±¸Á¶Ã¼µéÀ» ÃʱâÈ­ GamePorc() Àü¿¡ È£ÃâMenuSetting(); //°ÔÀÓÀ» ½ÃÀÛÇϱâ Àü¿¡ ¸Þ´º ±¸Á¶Ã¼µéÀ» ÃʱâÈ­ GamePorc() Àü¿¡ È£Ãâ
  564.  
  565. PlayBackMusic( g_hwndMain, 0 );
  566.  
  567. CursorNo( 1 );
  568.  
  569. struct tm *today;
  570. time_t lTime;
  571. time( &lTime );
  572. today = localtime( &lTime );
  573. //Log( "Packet¹ÞÀ½.txt", "%02d:%02d %d", today->tm_min, today->tm_sec, addlen );
  574. if( today->tm_mon == 11 && ( today->tm_mday == 24 || today->tm_mday == 25 ))
  575. {
  576. g_bIsChristmas = true;
  577. }
  578.  
  579. // 0811 NPC KHS
  580. LoadNPCAccessTable();
  581. g_FrameMgr.InitTime();
  582. while( TRUE )
  583. {
  584. if (PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE))
  585. {
  586. if (!GetMessage(&msg, NULL, 0, 0 )){break;}
  587.  
  588. // soto-030602 ÀÚ½Ä ´ëÈ­»óÀÚ¿¡. TabÅ°¸¦ ¸ÔÀÌÀÚ.
  589. if(g_hMultiDlg)
  590. {
  591. if ( IsDialogMessage(g_hMultiDlg, &msg) == FALSE )
  592. {
  593. TranslateMessage(&msg);
  594. DispatchMessage(&msg);
  595. }
  596. }
  597. else
  598. {
  599. TranslateMessage(&msg);
  600. DispatchMessage(&msg);
  601. }
  602. }
  603. else
  604. {
  605. #ifdef ALT_TAB_BLOCK
  606. if (g_DirectDrawInfo.lpDirectDraw==NULL) // ¿¢Æ¼ºê´Â µÇ¾úÁö¸¸ ¼­ÆäÀ̽º°¡ ¾ø´Ù // LTS 020725
  607. {
  608. SetFocus2(HWND_GAME_MAIN);//021001 lsw
  609. ShowWindow(g_hwndMain,SW_RESTORE);
  610. UpdateWindow(g_hwndMain);
  611. }
  612. #endif
  613. if( !StartMenuProc( &g_DirectDrawInfo ))
  614. {
  615. PostMessage(g_hwndMain, WM_CLOSE, 0, 0);
  616. goto END_;
  617. }
  618.  
  619. if (QuitFlag == SWD_QUIT || QuitFlag == SWD_LOGON)
  620. {
  621. goto END_;
  622. }
  623. if( SMenu[MN_MAININTERFACE].bActive == TRUE )
  624. {
  625. goto START_GAME_;
  626. }
  627. }
  628. }
  629. goto END_;
  630.  
  631. START_GAME_:
  632.  
  633. MenuSetting();
  634. SendAllReady();
  635. // ÆÁº¸±â Àú·¦Àº ±âº»À¸·Î º¸ÀÌ°Ô ÇÑ´Ù. 0818 khs
  636. // 010205 KHS
  637. if( SCharacterData.nLevel < 8 ) ViewTipToggle = 1;
  638.  
  639. double StartTime, Duration;
  640. StartTime = timeGetTime( );
  641. ListenCommand = CMD_NONE;
  642. while( 1 )
  643. {
  644. Duration = timeGetTime( ) - StartTime; // 5Ãʸ¦ ±â´Ù¸°´Ù.
  645. if ( Duration > 1000 )
  646. {
  647. break;
  648. }
  649.  
  650. if ( ProtocolProc( &connections ) < 0 ) break;
  651. }
  652.  
  653. InitBytesRoutine(); //
  654. YouCanHeroActionProc =0; YouCanViewTipsCheck = 0;
  655.  
  656. CLottoMgr::Create();//soto-030501
  657. g_FrameMgr.InitTime();
  658.  
  659.  
  660. while( TRUE )
  661. {
  662. if (PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE ))//PM_NOREMOVE
  663. {
  664. if (!GetMessage(&msg, NULL, 0, 0 )){break;}
  665. TranslateMessage(&msg);
  666. DispatchMessage(&msg);
  667. }
  668. else
  669. {
  670.  
  671. #ifdef ALT_TAB_BLOCK
  672. if (g_DirectDrawInfo.lpDirectDraw==NULL) // ¿¢Æ¼ºê´Â µÇ¾úÁö¸¸ ¼­ÆäÀ̽º°¡ ¾ø´Ù // LTS 020725
  673. {
  674. SetFocus2(HWND_GAME_MAIN);//021001 lsw
  675. ShowWindow(g_hwndMain,SW_RESTORE);
  676. UpdateWindow(g_hwndMain);
  677. }
  678. #endif
  679. if (!GameProc(&g_DirectDrawInfo))
  680. {
  681. PostMessage(g_hwndMain, WM_CLOSE, 0, 0);
  682. goto END_;
  683. }
  684.  
  685. if (QuitFlag == SWD_QUIT || QuitFlag == SWD_LOGON)
  686. {
  687. goto GOTO_MAIN_MENU_; //0201 YGI
  688. }
  689. }
  690. }
  691.  
  692.  
  693. goto END_;
  694.  
  695. GOTO_MAIN_MENU_:
  696. ReStartMenu( );
  697. pMusic->Stop();
  698. Release( &connections ); // Release()È£Ãâ..
  699. FreeTOI();
  700. DestroyRoofHeader( &g_RoofHeader );
  701. DestroyEventList();
  702. FreeMapSource();
  703. DestroyItemList();
  704. FreeCharacterSpriteDataAll( 0, MAX_CHARACTER_SPRITE_ );
  705. DestroyCharacterListExceptHero();
  706.  
  707. CLottoMgr::Destroy();//soto-030501
  708.  
  709. goto MAIN_MENU_;
  710.  
  711. #ifndef _DEBUG // 031110 YGI
  712. }
  713. __except(pException = GetExceptionInformation())//020508 lsw
  714. {
  715. ::DumpException( pException, "Exception Raised on WinMain()");
  716. }
  717. #endif
  718.  
  719. END_:
  720. CloseNation(); // 010904 LTS //¸ÞÀθ޴º¿¡ À§Ä¡ÇÏ°Ô µÇ¸é ClosenationÀÌ °è¼ÓÈ£ÃâµÈ´Ù..
  721. //g_pNationÀÌ °è¼Ó Áö¿öÁø´Ù.
  722. ExitApplication(EA_NORMAL);
  723. return msg.wParam;
  724. }
  725.  
  726. ATOM
  727. MyRegisterClass( HINSTANCE hInstance )
  728. {
  729. WNDCLASSEX wcex;
  730.  
  731. wcex.cbSize = sizeof( WNDCLASSEX );
  732. wcex.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS;
  733. wcex.lpfnWndProc = ( WNDPROC )WndProc;
  734. wcex.cbClsExtra = 0;
  735. wcex.cbWndExtra = 0;
  736. wcex.hInstance = hInstance;
  737. wcex.hIcon = LoadIcon( hInstance, ( LPCTSTR )IDI_DRAGON );
  738. wcex.hCursor = NULL;// LoadCursor( NULL, IDC_ARROW );
  739. wcex.hbrBackground = ( HBRUSH )( COLOR_WINDOW + 1 );
  740.  
  741. //acer7
  742. if( SysInfo.enable_menu )
  743. {
  744. if( SysInfo.notdead )
  745. {
  746. wcex.lpszMenuName = ( LPCSTR )IDC_DRAGON;
  747. }
  748. else
  749. {
  750. wcex.lpszMenuName = ( LPCSTR )IDR_GM;
  751. }
  752. }
  753. else
  754. {
  755. wcex.lpszMenuName = NULL;
  756. }
  757.  
  758. wcex.lpszClassName = g_szWindowClass;
  759. wcex.hIconSm = LoadIcon( wcex.hInstance, ( LPCTSTR )IDI_SMALL );
  760.  
  761. return RegisterClassEx( &wcex );
  762. }
  763.  
  764. BOOL
  765. InitInstance( HINSTANCE hInstance, int nCmdShow )
  766. {
  767. HWND hWnd;
  768. int cx, cy;
  769. int nStyle = 0;
  770.  
  771. g_hInstance = hInstance;
  772.  
  773. cx = SCREEN_WIDTH + GetSystemMetrics( SM_CXSIZEFRAME ) * 2;
  774. cy = SCREEN_HEIGHT + GetSystemMetrics( SM_CYSIZEFRAME ) * 2 + GetSystemMetrics( SM_CYMENU );
  775.  
  776.  
  777. switch( SysInfo.dx )
  778. {
  779. case 0 : nStyle = WS_OVERLAPPEDWINDOW; break;
  780. case 1 : nStyle = WS_POPUP; break;
  781. }
  782.  
  783. if( GetSysInfo( SI_GAME_MAKE_MODE ) == 0 )
  784. if(FindWindow("DRAGONRAJA_CLASS","DragonRaja Online")){ return FALSE; }
  785.  
  786. hWnd = CreateWindow( g_szWindowClass,
  787. g_szTitle,
  788. nStyle,
  789. 0,0,
  790. cx,
  791. cy,
  792. NULL,
  793. NULL,
  794. hInstance,
  795. NULL );
  796. if ( !hWnd )
  797. {
  798. return FALSE;
  799. }
  800.  
  801. g_hwndMain = hWnd;
  802.  
  803. ShowWindow( hWnd, nCmdShow );
  804. UpdateWindow( hWnd );
  805.  
  806. return TRUE;
  807. }
  808.  
  809. BOOL
  810. InitApplication( HINSTANCE hInstance, LPSTR lpCmdLine )
  811. {
  812. ModeSetting( g_hwndMain, hInstance);
  813. if( SysInfo.result == 999 ) return FALSE;
  814.  
  815. MakeSizeofSOU2();
  816.  
  817.  
  818. LoadString( hInstance, IDS_APP_TITLE, g_szTitle, MAX_LOADSTRING);
  819. LoadString( hInstance, IDC_DRAGONRAJA_CLASS, g_szWindowClass, MAX_LOADSTRING );
  820. MyRegisterClass( hInstance );
  821.  
  822. // ParseCommandLine( lpCmdLine );
  823. srand( ::timeGetTime() );
  824.  
  825. SetCurrentWorkingDirectory();
  826. SetInfoFile();
  827.  
  828. if ( !LoadGameInfo( ) )
  829. {
  830. return FALSE;
  831. }
  832.  
  833. pMusic->Stop();
  834.  
  835. CoInitialize( NULL );
  836. if ( !::Initialize() )
  837. {
  838. return FALSE;
  839. }
  840. g_pointMouseX = SCREEN_WIDTH / 2;
  841. g_pointMouseY = SCREEN_HEIGHT / 2;
  842. g_nLButtonState = g_nRButtonState = g_nOldLButtonState = g_nOldRButtonState = STATE_BUTTON_RELEASED;
  843. g_nSensitivity = 0;
  844.  
  845. return TRUE;
  846. }
  847.  
  848. void ExitApplication( const eExitAppType eEAType )
  849. {
  850. CrackMgr.StopCrackThread();
  851.  
  852. SendLogOut();
  853. GameEndFree();
  854.  
  855. ::Release( &connections );
  856.  
  857. EndLoadCharSpriteDataThread();
  858. DestroyCharacterList( &g_CharacterList );
  859. CleanupDirectDraw( &g_DirectDrawInfo );
  860. StopBackMusic( g_hwndMain );
  861. FreeSfx();
  862. CoUninitialize( );
  863. FreeAllOfMenu(); // 0927 YGI
  864. DeleteAllSkillData();
  865. pMusic->Stop();
  866. if(EA_NORMAL != eEAType)
  867. {
  868. g_DBGLog.Log(LOG_LV1,"ExitApplication Call(%d)",eEAType);
  869. }
  870.  
  871. if( CheckSumError )
  872. {
  873. JustMsg( "Found corrupted or tampered files while loading. \nExiting program. [%d]", CheckSumError);
  874. }
  875.  
  876. FreeItemTable();
  877.  
  878. delete g_pBill;
  879. delete lan;
  880.  
  881. exit(0);
  882. }
  883.  
  884. void ParseCommandLine( LPSTR lpCmdLine )
  885. {
  886. while ( lpCmdLine[ 0 ] == '-' || lpCmdLine[ 0 ] == '/' )
  887. {
  888. lpCmdLine++;
  889.  
  890. switch ( *lpCmdLine++ )
  891. {
  892. case 'f':
  893. case 'F':
  894. g_DirectDrawInfo.bFullscreen = FALSE; // LTS TEST
  895. break;
  896. }
  897.  
  898. lpCmdLine = EatFrontWhiteChar( lpCmdLine );
  899. }
  900. }
  901. void SetCurrentWorkingDirectory( void )
  902. {
  903. char* ptr;
  904.  
  905. GetModuleFileName( g_hInstance, g_szCWD, sizeof( g_szCWD ) );
  906. ptr = strrchr( g_szCWD, '\\' );
  907. *ptr = 0;
  908. }
  909.  
  910. char*
  911. GetCurrentWorkingDirectory( void )
  912. {
  913. return g_szCWD;
  914. }
  915.  
  916. void SetInfoFile( void )
  917. {
  918. wsprintf( g_szInfoFile, "%s/dragon.ini", g_szCWD );
  919. }
  920.  
  921. char*
  922. GetInfoFile( void )
  923. {
  924. return g_szInfoFile;
  925. }
  926.  
  927. char*
  928. EatFrontWhiteChar( char* pStr )
  929. {
  930. char* szWhite = " \t\n\r";
  931.  
  932. if ( pStr )
  933. {
  934. while ( *pStr )
  935. {
  936. if ( strchr( szWhite, *pStr ) )
  937. {
  938. pStr++;
  939. }
  940. else
  941. {
  942. break;
  943. }
  944. }
  945. }
  946.  
  947. return pStr;
  948. }
  949.  
  950. char*
  951. EatRearWhiteChar( char* pStr )
  952. {
  953. char* szWhite = " \t\n\r";
  954. char* pRear;
  955.  
  956. pRear = pStr + strlen( pStr ) - 1;
  957. if ( pRear )
  958. {
  959. while ( pStr <= pRear )
  960. {
  961. if ( strchr( szWhite, *pRear ) )
  962. {
  963. *pRear-- = 0;
  964. }
  965. else
  966. {
  967. break;
  968. }
  969. }
  970. }
  971.  
  972. return pStr;
  973. }
  974.  
  975. BOOL
  976. ShowErrorMessage( char* lpszMessage )
  977. {
  978. MessageBox( g_hwndMain, lpszMessage, "Dragon Raja Online", MB_OK );
  979. return FALSE;
  980. }
  981.  
  982.  
  983.  
  984.  
  985.  
  986.  
  987. ///////////////////////////////////////////////////////////////////////////////
  988. // window procedure
  989.  
  990. void MouseProcess( UINT message, WPARAM wParam, LPARAM lParam)
  991. {
  992. int x, y;
  993.  
  994. switch( message )
  995. {
  996. case WM_LBUTTONUP : g_nLButtonState = STATE_BUTTON_RELEASED; LButtonDownIng= 0; tool_MyHouseLBU( wParam, lParam ); ReleaseCapture(); break;
  997. case WM_LBUTTONDOWN : YouCanHeroActionProc = 1; YouCanViewTipsCheck = 1;g_nLButtonState = STATE_BUTTON_PRESSED; LButtonDownIng= 1; tool_MyHouseLBD( wParam, lParam ); SetCapture( g_hwndMain); break;
  998. case WM_RBUTTONUP : g_nRButtonState = STATE_BUTTON_RELEASED; RButtonDownIng= 0; ReleaseCapture(); break;
  999. case WM_RBUTTONDOWN : g_nRButtonState = STATE_BUTTON_PRESSED; RButtonDownIng= 1; SetCapture( g_hwndMain); break;
  1000. case WM_LBUTTONDBLCLK : g_nLDButtonState = STATE_BUTTON_DOUBLECLICK; SetCapture( g_hwndMain); break;
  1001. case WM_RBUTTONDBLCLK : g_nRDButtonState = STATE_BUTTON_DOUBLECLICK; SetCapture( g_hwndMain); break;
  1002. }
  1003.  
  1004. x = LOWORD( lParam );
  1005. y = HIWORD( lParam );
  1006.  
  1007. #ifdef _DEBUG
  1008. y += ::GetSystemMetrics(SM_CYMENUSIZE);
  1009. #endif
  1010.  
  1011. if(LButtonDownIng==1 )
  1012. {
  1013. g_DragMouse.ex=x+Mapx; //¸¶¿ì½ºÀÇ È­¸éÁÂÇ¥¿¡ ¸ÊÀÇ Àý´ë ÁÂÇ¥¸¦ ´õÇÔ
  1014. g_DragMouse.ey=y+Mapy;
  1015. }
  1016.  
  1017.  
  1018. AdjustSkillMouseCursor( &x, &y );
  1019.  
  1020.  
  1021. // ÇöÀç ³ë°¡´Ù ±â¼úÀ» ÇÏ´Â ÁßÀÌ¸é ¸¶¿ì½º´Â ±× ¹Ú½º¾È¿¡ ÀÖ¾î¾ß ÇÑ´Ù.
  1022. g_pointMouseY = g_pointMouse.y = y;
  1023. g_pointMouseX = g_pointMouse.x = x;
  1024. Mox = Mapx + g_pointMouseX; Moy = Mapy + g_pointMouseY;
  1025.  
  1026. /*int SkillNo;
  1027. int SkillStatus;
  1028. Spr *SkillIcon;
  1029. int SkillItemNo; // ±â¼ú¿¡ »ç¿ëµÉ ItemÀÇ ¹øÈ£.
  1030. POS SkillItemPOS; // ±â¼ú¿¡ »ç¿ëµÉ ItemÀÇ À§Ä¡°ª.
  1031.  
  1032.  
  1033.  
  1034. bool SkillMouseDontMoveFlag; // ³ë°¡´Ù¸¦ ÇØ¾ß ÇÏ´Â ±â¼úÀº Çѹø ±×°÷À» ¼±ÅÃÇÏ¸é ¿À¸¥Âʸ¶¿ì½º·Î Ãë¼ÒÇϵ簡 NogadaCount°¡ Max°¡ µÉ¶§±îÁö ±â´Ù·Á¾ß ÇÑ´Ù.
  1035. DWORD SkillRetryTime;
  1036. int SkillDontMoveSx,SkillDontMoveSy,SkillDontMoveEx,SkillDontMoveEy;
  1037. bool YouCanNogadaFlag;
  1038. */
  1039.  
  1040. }
  1041.  
  1042. //1206 zhh
  1043. //#include "Language.h" //010215 lsw ÁÖ¼®Ã³¸®.
  1044.  
  1045.  
  1046. // 10505 KHS //010605 lms
  1047. bool chinese_input;
  1048. void CheckChineseInput( HWND hwnd, LPARAM lParam )
  1049. {
  1050. if( ( lParam & 0x00ff ) == 0x0004 )
  1051. {
  1052. HRESULT hResult;
  1053.  
  1054. chinese_input = true;
  1055.  
  1056. if( g_DirectDrawInfo.lpClipper )
  1057. {
  1058. g_DirectDrawInfo.lpClipper->Release();
  1059. g_DirectDrawInfo.lpClipper = NULL;
  1060. }
  1061.  
  1062. hResult = g_DirectDrawInfo.lpDirectDraw->CreateClipper( 0, &g_DirectDrawInfo.lpClipper, NULL );
  1063. if( hResult == DD_OK )
  1064. g_DirectDrawInfo.lpClipper->SetHWnd( 0, g_hwndMain );
  1065. }
  1066. else
  1067. {
  1068. chinese_input = false;
  1069.  
  1070. if( g_DirectDrawInfo.lpClipper )
  1071. {
  1072. g_DirectDrawInfo.lpClipper->Release();
  1073. g_DirectDrawInfo.lpClipper = NULL;
  1074. }
  1075. }
  1076. }
  1077.  
  1078. LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
  1079. {
  1080. PAINTSTRUCT ps;
  1081. HDC hDC;
  1082. MINMAXINFO* pMinMax = NULL;
  1083.  
  1084. if (EWndMgr.CheckSysKey( message, wParam ) == 0)
  1085. { //021001 lsw
  1086. return 0;
  1087. }
  1088.  
  1089. switch (message)
  1090. {
  1091. case WM_INPUTLANGCHANGE:
  1092. {
  1093. CheckChineseInput( hWnd, lParam );
  1094. break;
  1095. }
  1096. case WM_COMMAND:
  1097. {
  1098. SystemMenuProcess ( wParam );
  1099. break;
  1100. }
  1101. case WM_INITMENU:
  1102. { //soto 030307
  1103. #ifdef _DEBUG
  1104. MainMenuSelected(wParam,lParam);
  1105. #endif
  1106. break;
  1107. } //soto End.
  1108. case WM_CREATE:
  1109. {
  1110. SetCursor( NULL );
  1111. SetTimer( hWnd, 13, 1000, NULL);
  1112. break;
  1113. }
  1114. case WM_TIMER:
  1115. {
  1116. if (wParam == 13)
  1117. {
  1118. g_curr_time++;
  1119. g_packet_recv_send_checktime++;
  1120. }
  1121.  
  1122. break;
  1123. }
  1124. case WM_ACTIVATE:
  1125. case WM_ACTIVATEAPP:
  1126. {
  1127. switch (LOWORD(wParam))
  1128. {
  1129. case WA_CLICKACTIVE:
  1130. {
  1131. g_bIsActive = TRUE;
  1132. g_FrameMgr.InitTime();
  1133.  
  1134. if (g_DirectDrawInfo.lpDirectDraw == NULL)
  1135. {
  1136. if (!InitDirectDraw(g_hwndMain, &g_DirectDrawInfo))
  1137. {
  1138. return 0;
  1139. }
  1140.  
  1141. EraseScreen(&g_DirectDrawInfo, RGB(0,0,0));
  1142. }
  1143.  
  1144. break;
  1145. }
  1146. case WA_INACTIVE:
  1147. {
  1148. g_bIsActive = FALSE;
  1149. g_FrameMgr.InitTime();
  1150.  
  1151. if (g_DirectDrawInfo.lpDirectDraw != NULL)
  1152. {
  1153. CleanupDirectDraw(&g_DirectDrawInfo);
  1154. }
  1155.  
  1156. break;
  1157. }
  1158. case WA_ACTIVE:
  1159. {
  1160. g_bIsActive = TRUE;
  1161.  
  1162. if (g_DirectDrawInfo.lpDirectDraw == NULL)
  1163. {
  1164. if (!InitDirectDraw(g_hwndMain, &g_DirectDrawInfo))
  1165. {
  1166. return 0;
  1167. }
  1168.  
  1169. EraseScreen(&g_DirectDrawInfo, RGB(0,0,0));
  1170.  
  1171. SetCursor(NULL);
  1172. }
  1173.  
  1174. break;
  1175. }
  1176. }
  1177.  
  1178. SetAcquire(g_bIsActive);
  1179. CheckingAccelator_Sub1();
  1180. break;
  1181. }
  1182. case WM_GETMINMAXINFO:
  1183. {
  1184. pMinMax = (MINMAXINFO*)lParam;
  1185. pMinMax->ptMinTrackSize.x = SCREEN_WIDTH + GetSystemMetrics(SM_CXSIZEFRAME) * 2;
  1186. pMinMax->ptMinTrackSize.y = SCREEN_HEIGHT + GetSystemMetrics(SM_CYSIZEFRAME) * 2 + GetSystemMetrics(SM_CYMENU);
  1187. pMinMax->ptMaxTrackSize.x = pMinMax->ptMinTrackSize.x;
  1188. pMinMax->ptMaxTrackSize.y = pMinMax->ptMinTrackSize.y;
  1189. break;
  1190. }
  1191. case WM_MOVE:
  1192. case WM_SIZE:
  1193. {
  1194. if (g_bIsActive)
  1195. {
  1196. if (g_DirectDrawInfo.bFullscreen)
  1197. {
  1198. SetRect(&g_DirectDrawInfo.rectPrimarySurface, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN));
  1199. }
  1200. else
  1201. {
  1202. GetClientRect(hWnd, &g_DirectDrawInfo.rectPrimarySurface);
  1203. ClientToScreen(hWnd, (LPPOINT)&g_DirectDrawInfo.rectPrimarySurface);
  1204. ClientToScreen(hWnd, (LPPOINT)&g_DirectDrawInfo.rectPrimarySurface + 1);
  1205. }
  1206. }
  1207.  
  1208. break;
  1209. }
  1210. case WM_PAINT:
  1211. {
  1212. if (g_bIsActive)
  1213. {
  1214. hDC = BeginPaint(hWnd, &ps);
  1215. EndPaint(hWnd, &ps);
  1216. }
  1217.  
  1218. break;
  1219. }
  1220. case WM_KEYDOWN:
  1221. {
  1222. DoSomeThingWithKey( wParam, lParam ); // tool.cpp
  1223. CheckCharacterFrameOrder( wParam, lParam ); // tool.cpp
  1224.  
  1225. switch (wParam)
  1226. {
  1227. case VK_RETURN:
  1228. {
  1229. if (!IsChatBoxActive()) // 0601 YGI
  1230. {
  1231. SetChatMode(CM_MESSAGE);
  1232. }
  1233.  
  1234. break;
  1235. }
  1236. }
  1237.  
  1238. break;
  1239. }
  1240. case WM_CHAR:
  1241. {
  1242. switch (wParam)
  1243. {
  1244. case VK_RETURN:
  1245. case VK_TAB:
  1246. {
  1247. return 0;
  1248. }
  1249. }
  1250.  
  1251. break;
  1252. }
  1253. case WM_KEYUP://021008 lsw
  1254. {
  1255. const int nVirtKey = (int)wParam; // virtual-key code
  1256. LPARAM lKeyData = lParam; // key data
  1257.  
  1258. switch (nVirtKey)
  1259. {
  1260. case VK_F1:
  1261. case VK_F2:
  1262. case VK_F3:
  1263. case VK_F4:
  1264. case VK_F5:
  1265. case VK_F6:
  1266. case VK_F7:
  1267. case VK_F8:
  1268. {
  1269. ::DoQuickmemoryByKeyInput(nVirtKey,false);
  1270. return 0;
  1271. }
  1272. }
  1273.  
  1274. break;
  1275. }
  1276. case WM_LBUTTONDOWN:
  1277. case WM_LBUTTONUP:
  1278. case WM_RBUTTONDOWN:
  1279. case WM_RBUTTONUP:
  1280. case WM_LBUTTONDBLCLK:
  1281. case WM_RBUTTONDBLCLK:
  1282. {
  1283. MouseProcess( message, wParam, lParam);
  1284. break;
  1285. }
  1286. case WM_MOUSEMOVE:
  1287. {
  1288. MouseProcess( message, wParam, lParam);
  1289. break;
  1290. }
  1291. case MM_MCINOTIFY: // MCI ÅëÁö ¸Þ½ÃÁö¸¦ ¹Þ´Â´Ù.
  1292. {
  1293. if (wParam == MCI_NOTIFY_SUCCESSFUL) // ¿¬ÁÖ°¡ ³¡³µÀ»¶§.
  1294. {
  1295. PlayBackMusic(g_hwndMain, CurMidi);
  1296. }
  1297. else if (CurMidi >= 0)
  1298. {
  1299. PlayBackMusic(g_hwndMain, CurMidi);
  1300. }
  1301.  
  1302. break;
  1303. }
  1304. case WM_DESTROY:
  1305. {
  1306. PostQuitMessage( 0 );
  1307. break;
  1308. }
  1309. }
  1310.  
  1311. return DefWindowProc( hWnd, message, wParam, lParam );
  1312. }
  1313.  
  1314. void CALLBACK TimerProc(HWND hWnd, UINT nMsg, UINT nTimerid, DWORD dwTime)
  1315. { //< CSD-CN-031215
  1316. if (nTimerid == g_idSafeTimer)
  1317. { //< PowerZ-030116
  1318. HWND hSafeWnd = g_sysSecurity.GetSafeWindowHandle();
  1319.  
  1320. if (!IsWindow(hSafeWnd))
  1321. {
  1322. KillTimer(hWnd, g_idSafeTimer);
  1323. PostMessage(hWnd, WM_CLOSE, 0, 0);
  1324. }
  1325. } //> PowerZ-030116
  1326. } //> CSD-CN-031215
  1327.  
  1328. BOOL LoadGameInfo( void )
  1329. {
  1330. GetPrivateProfileString( "network", "host1", "", g_GameInfo.proxy_ip[0], sizeof( g_GameInfo.proxy_ip[0] ), g_szInfoFile );
  1331. if ( g_GameInfo.proxy_ip[0][0]== 0 )
  1332. {
  1333. return FALSE;
  1334. }
  1335. GetPrivateProfileString( "network", "host2", "", g_GameInfo.proxy_ip[1], sizeof( g_GameInfo.proxy_ip[1] ), g_szInfoFile );
  1336. if ( g_GameInfo.proxy_ip[1][0]== 0 )
  1337. {
  1338. return FALSE;
  1339. }
  1340. g_GameInfo.version = GetPrivateProfileInt( "network", "ver", 0, g_szInfoFile );
  1341. if ( g_GameInfo.version == 0 )
  1342. {
  1343. return FALSE;
  1344. }
  1345. else
  1346. {
  1347. // char temp[ MAX_PATH];
  1348. // sprintf( temp, "%d", 400 );
  1349. // WritePrivateProfileString( "network", "ver", temp, "dragon.ini" );
  1350. }
  1351.  
  1352. // 010711 YGI
  1353. g_SelectServerIndex = GetPrivateProfileInt( "network", "ServerSet", 0, g_szInfoFile );
  1354.  
  1355. //< kjy-040325
  1356. // ÀϽº ¼±Åà ¹æÁö Ç÷¡±×¸¦ dragon.iniÆÄÀϷκÎÅÍ ÀԷ¹޴´Ù.
  1357. char szKeySelectYilse[50];
  1358. memset( szKeySelectYilse, '\0', 50 );
  1359. sprintf( szKeySelectYilse, "name%d_prevent_select_yilse", g_SelectServerIndex+1 );
  1360. g_GameInfo.preventSelectYilse = GetPrivateProfileInt( "network", szKeySelectYilse, 0, g_szInfoFile );
  1361. //> kjy-040325
  1362.  
  1363.  
  1364. //< CSD-040127
  1365. //#ifdef KOREA_LOCALIZING_
  1366. g_GameInfo.proxy_port = 39204;
  1367. //#else
  1368. // g_GameInfo.proxy_port = 9000;
  1369. //#endif
  1370. g_GameInfo.agent_port = 39201;
  1371. //> CSD-040127
  1372. return TRUE;
  1373. }
  1374.  
  1375. int LoadingGameData()
  1376. { // eLoadingGameDataStep ¸¦ »ç¿ë
  1377. static int s_iLoadingPos = LGDS_FIRST;
  1378.  
  1379. switch (s_iLoadingPos)
  1380. {
  1381. case LGDS_FIRST:
  1382. {
  1383. LoadAttackRangeTable(0);
  1384. LoadAttackRangeTable(1);
  1385.  
  1386. if (SysInfo.notconectserver)
  1387. {
  1388. s_iLoadingPos = LGDS_STEP1;
  1389. return s_iLoadingPos;
  1390. }
  1391.  
  1392. DWORD StartTime = ::timeGetTime();
  1393. ListenCommand = CMD_NONE;
  1394.  
  1395. while (true)
  1396. {
  1397. DWORD Duration = ::timeGetTime( ) - StartTime;
  1398.  
  1399. if (Duration > WAIT_TIME_RESPONSE_DURATION) // 030930 kyo
  1400. {
  1401. s_iLoadingPos = LGDS_FIRST;
  1402. return -1;
  1403. }
  1404.  
  1405. if (HandleRunning(&connections) <= 0)
  1406. {
  1407. Release(&connections);
  1408. s_iLoadingPos = LGDS_FIRST;
  1409. return -2;
  1410. }
  1411.  
  1412. if (ListenCommand == CONNECT_REFUSE)
  1413. {
  1414. s_iLoadingPos = LGDS_FIRST;
  1415. return -3;
  1416. }
  1417.  
  1418. if (ListenCommand == CMD_CONNECT_INFO)
  1419. {
  1420. s_iLoadingPos = LGDS_STEP1;
  1421. return s_iLoadingPos;
  1422. }
  1423. }
  1424.  
  1425. break;
  1426. }
  1427. case LGDS_STEP1:
  1428. {
  1429. HandleRunning(&connections);
  1430. g_Volume_Off = 1; // ·ÎµùÀÌ ³¡³¯ ¶§±îÁö ¹è°æÀ½¾Ç ÀÌ¿ÜÀÇ ¼Ò¸® ¾È³ª¿À°Ô
  1431.  
  1432. if (SysInfo.notconectserver)
  1433. {
  1434. if (!BuildCharacterList(&g_CharacterList))
  1435. {
  1436. JustMsg(lan->OutputMessage(6, 8)); //010215 lsw
  1437. }
  1438. }
  1439.  
  1440. s_iLoadingPos = LGDS_STEP2;
  1441. break;
  1442. }
  1443. case LGDS_STEP2:
  1444. {
  1445. MapBuild(&g_Map, MapName); // map
  1446.  
  1447. if (HandleRunning(&connections) <= 0)
  1448. {
  1449. Release(&connections);
  1450. return -2;
  1451. }
  1452.  
  1453. s_iLoadingPos = LGDS_STEP3;
  1454. break;
  1455. }
  1456. case LGDS_STEP3 :
  1457. {
  1458. LoadTOI(MapName);
  1459. HandleRunning(&connections );
  1460. BuildRoofHeader(&g_RoofHeader, MapName); // rof
  1461. HandleRunning(&connections);
  1462. BuildEventList(MapName); // ent
  1463. HandleRunning(&connections);
  1464.  
  1465. ReqTacSkillExp(); // Àüü ÅÃƽ ¼öÄ¡ °¡Á®¿À±â
  1466. HandleRunning(&connections);
  1467. AllReqSkillExp(); // Àüü ½ºÅ³ °æÇèÄ¡ °¡Á®¿À±â
  1468. HandleRunning(&connections);
  1469. s_iLoadingPos = LGDS_STEP4;
  1470. break;
  1471. }
  1472. case LGDS_STEP4:
  1473. {
  1474. LoadMapSource2( MapName ); // sou
  1475. HandleRunning( &connections);
  1476. s_iLoadingPos = LGDS_STEP5;
  1477. break;
  1478. }
  1479. case LGDS_STEP5:
  1480. {
  1481. LoadCharSpriteData( "./char/000000.spr", &CharBuf[0], &CharBufLength[0], &CharSpr[0], LD_CHAR_SPRITE_ALL_LOAD);
  1482. HandleRunning(&connections);
  1483. s_iLoadingPos= LGDS_STEP6;
  1484. break;
  1485. }
  1486. case LGDS_STEP6:
  1487. {
  1488. LoadCharSpriteData( "./char/001000.spr", &CharBuf[1], &CharBufLength[1], &CharSpr[1], LD_CHAR_SPRITE_ALL_LOAD);
  1489. LoadHeroClothAccessoryData( 104, 107 );
  1490.  
  1491. char tempfilename[FILENAME_MAX];
  1492. const int preloadcharsprite[21] = {29,30,37,38,46,72,79,1005,1006,1017,1018,1019,1020,1027,1028,1041,1060,1061,1075,1083,1092 };
  1493.  
  1494. for (int i = 0; i < 21; ++i)
  1495. {
  1496. int tt = preloadcharsprite[i];
  1497. sprintf(tempfilename, "./char/%06d.spr", tt);
  1498. LoadCharSpriteData(tempfilename, &CharAccessoryBuf[tt/1000][tt%1000], &CharAccessoryBufLength[ tt/1000][tt%1000], &CharAccessorySpr[tt/1000][tt%1000], LD_CHAR_SPRITE_ALL_LOAD);
  1499. HandleRunning(&connections);
  1500. }
  1501.  
  1502. HandleRunning(&connections);
  1503. s_iLoadingPos = LGDS_STEP7;
  1504. break;
  1505. }
  1506. case LGDS_STEP7:
  1507. {
  1508. LoadClothOrderData();
  1509. HandleRunning(&connections);
  1510. s_iLoadingPos = LGDS_STEP8;
  1511. break;
  1512. }
  1513. case LGDS_STEP8 :
  1514. {
  1515. LoadBrightData();
  1516. HandleRunning(&connections);
  1517. s_iLoadingPos = LGDS_STEP9;
  1518. break;
  1519. }
  1520. case LGDS_STEP9:
  1521. {
  1522. StartSetView(Hero);
  1523. HandleRunning(&connections);
  1524. s_iLoadingPos = LGDS_STEP10;
  1525. break;
  1526. }
  1527. case LGDS_STEP10:
  1528. {
  1529. LoadMenuData(1);
  1530. HandleRunning(&connections);
  1531. s_iLoadingPos = LGDS_STEP11;
  1532. break;
  1533. }
  1534. case LGDS_STEP11:
  1535. {
  1536. LoadMenuData(2);
  1537. HandleRunning(&connections);
  1538. s_iLoadingPos = LGDS_STEP12;
  1539. break;
  1540. }
  1541. case LGDS_STEP12:
  1542. {
  1543. LoadHongSkillTable();
  1544. HandleRunning(&connections);
  1545. LoadMenuData(5);
  1546. HandleRunning(&connections);
  1547.  
  1548. if (CurOpenHouse >= 0)
  1549. {
  1550. RecvRoofOpen(CurOpenHouse);
  1551. }
  1552.  
  1553. InitHpUpDown();
  1554. HandleRunning(&connections);
  1555. s_iLoadingPos = LGDS_FIRST;
  1556. return LGDS_END; // À̰͸¸ ¿¹¿Ü ó¸®
  1557. }
  1558. }
  1559.  
  1560. return s_iLoadingPos;
  1561. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement