winWindow.cpp 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2012 GarageGames, LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to
  6. // deal in the Software without restriction, including without limitation the
  7. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8. // sell copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  20. // IN THE SOFTWARE.
  21. //-----------------------------------------------------------------------------
  22. #include "platform/platform.h"
  23. #include "platformWin32/platformWin32.h"
  24. #include "platformWin32/winConsole.h"
  25. #include "platformWin32/winDirectInput.h"
  26. #include "windowManager/win32/win32Window.h"
  27. #include "console/console.h"
  28. #include "console/engineAPI.h"
  29. #include "math/mRandom.h"
  30. #include "core/stream/fileStream.h"
  31. #include "T3D/resource.h"
  32. #include <d3d9.h>
  33. #include "gfx/gfxInit.h"
  34. #include "gfx/gfxDevice.h"
  35. #include "core/strings/unicode.h"
  36. #include "gui/core/guiCanvas.h"
  37. extern void createFontInit();
  38. extern void createFontShutdown();
  39. extern void installRedBookDevices();
  40. extern void handleRedBookCallback(U32, U32);
  41. static MRandomLCG sgPlatRandom;
  42. static bool sgQueueEvents;
  43. // is keyboard input a standard (non-changing) VK keycode
  44. #define dIsStandardVK(c) (((0x08 <= (c)) && ((c) <= 0x12)) || \
  45. ((c) == 0x1b) || \
  46. ((0x20 <= (c)) && ((c) <= 0x2e)) || \
  47. ((0x30 <= (c)) && ((c) <= 0x39)) || \
  48. ((0x41 <= (c)) && ((c) <= 0x5a)) || \
  49. ((0x70 <= (c)) && ((c) <= 0x7B)))
  50. extern InputObjectInstances DIK_to_Key( U8 dikCode );
  51. // static helper variables
  52. static HANDLE gMutexHandle = NULL;
  53. static bool sgDoubleByteEnabled = false;
  54. // track window states
  55. Win32PlatState winState;
  56. //-----------------------------------------------------------------------------------------------------------------------------------------------------------
  57. //
  58. // Microsoft Layer for Unicode
  59. // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/mslu/winprog/compiling_your_application_with_the_microsoft_layer_for_unicode.asp
  60. //
  61. //-----------------------------------------------------------------------------------------------------------------------------------------------------------
  62. #ifdef UNICODE
  63. HMODULE LoadUnicowsProc(void)
  64. {
  65. return(LoadLibraryA("unicows.dll"));
  66. }
  67. #ifdef _cplusplus
  68. extern "C" {
  69. #endif
  70. extern FARPROC _PfnLoadUnicows = (FARPROC) &LoadUnicowsProc;
  71. #ifdef _cplusplus
  72. }
  73. #endif
  74. #endif
  75. //--------------------------------------
  76. Win32PlatState::Win32PlatState()
  77. {
  78. log_fp = NULL;
  79. hinstOpenGL = NULL;
  80. hinstGLU = NULL;
  81. hinstOpenAL = NULL;
  82. appDC = NULL;
  83. appInstance = NULL;
  84. currentTime = 0;
  85. processId = 0;
  86. }
  87. //--------------------------------------
  88. bool Platform::excludeOtherInstances(const char *mutexName)
  89. {
  90. #ifdef UNICODE
  91. UTF16 b[512];
  92. convertUTF8toUTF16((UTF8 *)mutexName, b, sizeof(b));
  93. gMutexHandle = CreateMutex(NULL, true, b);
  94. #else
  95. gMutexHandle = CreateMutex(NULL, true, mutexName);
  96. #endif
  97. if(!gMutexHandle)
  98. return false;
  99. if(GetLastError() == ERROR_ALREADY_EXISTS)
  100. {
  101. CloseHandle(gMutexHandle);
  102. gMutexHandle = NULL;
  103. return false;
  104. }
  105. return true;
  106. }
  107. void Platform::restartInstance()
  108. {
  109. STARTUPINFO si;
  110. PROCESS_INFORMATION pi;
  111. ZeroMemory( &si, sizeof(si) );
  112. si.cb = sizeof(si);
  113. ZeroMemory( &pi, sizeof(pi) );
  114. TCHAR cen_buf[2048];
  115. GetModuleFileName( NULL, cen_buf, 2047);
  116. // Start the child process.
  117. if( CreateProcess( cen_buf,
  118. NULL, // Command line
  119. NULL, // Process handle not inheritable
  120. NULL, // Thread handle not inheritable
  121. FALSE, // Set handle inheritance to FALSE
  122. 0, // No creation flags
  123. NULL, // Use parent's environment block
  124. NULL, // Use parent's starting directory
  125. &si, // Pointer to STARTUPINFO structure
  126. &pi ) // Pointer to PROCESS_INFORMATION structure
  127. != false )
  128. {
  129. WaitForInputIdle( pi.hProcess, 5000 );
  130. CloseHandle( pi.hProcess );
  131. CloseHandle( pi.hThread );
  132. }
  133. }
  134. ///just check if the app's global mutex exists, and if so,
  135. ///return true - otherwise, false. Should be called before ExcludeOther
  136. /// at very start of app execution.
  137. bool Platform::checkOtherInstances(const char *mutexName)
  138. {
  139. #ifdef TORQUE_MULTITHREAD
  140. HANDLE pMutex = NULL;
  141. #ifdef UNICODE
  142. UTF16 b[512];
  143. convertUTF8toUTF16((UTF8 *)mutexName, b, sizeof(b));
  144. pMutex = CreateMutex(NULL, true, b);
  145. #else
  146. pMutex = CreateMutex(NULL, true, mutexName);
  147. #endif
  148. if(!pMutex)
  149. return false;
  150. if(GetLastError() == ERROR_ALREADY_EXISTS)
  151. {
  152. //another mutex of the same name exists
  153. //close ours
  154. CloseHandle(pMutex);
  155. pMutex = NULL;
  156. return true;
  157. }
  158. CloseHandle(pMutex);
  159. pMutex = NULL;
  160. #endif
  161. //we don;t care, always false
  162. return false;
  163. }
  164. #ifndef TORQUE_SDL
  165. //--------------------------------------
  166. void Platform::AlertOK(const char *windowTitle, const char *message)
  167. {
  168. ShowCursor(true);
  169. #ifdef UNICODE
  170. UTF16 m[1024], t[512];
  171. convertUTF8toUTF16((UTF8 *)windowTitle, t, sizeof(t));
  172. convertUTF8toUTF16((UTF8 *)message, m, sizeof(m));
  173. MessageBox(NULL, m, t, MB_ICONINFORMATION | MB_SETFOREGROUND | MB_TASKMODAL | MB_OK);
  174. #else
  175. MessageBox(NULL, message, windowTitle, MB_ICONINFORMATION | MB_SETFOREGROUND | MB_TASKMODAL | MB_OK);
  176. #endif
  177. }
  178. //--------------------------------------
  179. bool Platform::AlertOKCancel(const char *windowTitle, const char *message)
  180. {
  181. ShowCursor(true);
  182. #ifdef UNICODE
  183. UTF16 m[1024], t[512];
  184. convertUTF8toUTF16((UTF8 *)windowTitle, t, sizeof(t));
  185. convertUTF8toUTF16((UTF8 *)message, m, sizeof(m));
  186. return MessageBox(NULL, m, t, MB_ICONINFORMATION | MB_SETFOREGROUND | MB_TASKMODAL | MB_OKCANCEL) == IDOK;
  187. #else
  188. return MessageBox(NULL, message, windowTitle, MB_ICONINFORMATION | MB_SETFOREGROUND | MB_TASKMODAL | MB_OKCANCEL) == IDOK;
  189. #endif
  190. }
  191. //--------------------------------------
  192. bool Platform::AlertRetry(const char *windowTitle, const char *message)
  193. {
  194. ShowCursor(true);
  195. #ifdef UNICODE
  196. UTF16 m[1024], t[512];
  197. convertUTF8toUTF16((UTF8 *)windowTitle, t, sizeof(t));
  198. convertUTF8toUTF16((UTF8 *)message, m, sizeof(m));
  199. return (MessageBox(NULL, m, t, MB_ICONINFORMATION | MB_SETFOREGROUND | MB_TASKMODAL | MB_RETRYCANCEL) == IDRETRY);
  200. #else
  201. return (MessageBox(NULL, message, windowTitle, MB_ICONINFORMATION | MB_SETFOREGROUND | MB_TASKMODAL | MB_RETRYCANCEL) == IDRETRY);
  202. #endif
  203. }
  204. Platform::ALERT_ASSERT_RESULT Platform::AlertAssert(const char *windowTitle, const char *message)
  205. {
  206. #ifndef TORQUE_TOOLS
  207. ShowCursor(true);
  208. #endif // TORQUE_TOOLS
  209. #ifdef UNICODE
  210. UTF16 messageUTF[1024], title[512];
  211. convertUTF8toUTF16((UTF8 *)windowTitle, title, sizeof(title));
  212. convertUTF8toUTF16((UTF8 *)message, messageUTF, sizeof(messageUTF));
  213. #else
  214. const char* messageUTF = message;
  215. const char* title = windowTitle;
  216. #endif
  217. // TODO: Change this to a custom dialog that has Exit, Ignore, Ignore All, and Debug buttons
  218. ALERT_ASSERT_RESULT alertResult = ALERT_ASSERT_DEBUG;
  219. int result = MessageBox(winState.appWindow, messageUTF, title, MB_ABORTRETRYIGNORE | MB_ICONSTOP | MB_DEFBUTTON2 | MB_TASKMODAL | MB_SETFOREGROUND);
  220. switch( result )
  221. {
  222. case IDABORT:
  223. alertResult = ALERT_ASSERT_EXIT;
  224. break;
  225. case IDIGNORE:
  226. alertResult = ALERT_ASSERT_IGNORE;
  227. break;
  228. default:
  229. case IDRETRY:
  230. alertResult = ALERT_ASSERT_DEBUG;
  231. break;
  232. }
  233. return alertResult;
  234. }
  235. #endif
  236. //--------------------------------------
  237. HIMC gIMEContext;
  238. static void InitInput()
  239. {
  240. #ifndef TORQUE_LIB
  241. #ifdef UNICODE
  242. //gIMEContext = ImmGetContext(getWin32WindowHandle());
  243. //ImmReleaseContext( getWin32WindowHandle(), gIMEContext );
  244. #endif
  245. #endif
  246. }
  247. //--------------------------------------
  248. void Platform::init()
  249. {
  250. Con::printf("Initializing platform...");
  251. // Set the platform variable for the scripts
  252. Con::setVariable( "$platform", "windows" );
  253. WinConsole::create();
  254. if ( !WinConsole::isEnabled() )
  255. Input::init();
  256. InitInput(); // in case DirectInput falls through
  257. installRedBookDevices();
  258. sgDoubleByteEnabled = GetSystemMetrics( SM_DBCSENABLED );
  259. sgQueueEvents = true;
  260. Con::printf("Done");
  261. }
  262. //--------------------------------------
  263. void Platform::shutdown()
  264. {
  265. sgQueueEvents = false;
  266. if(gMutexHandle)
  267. CloseHandle(gMutexHandle);
  268. Input::destroy();
  269. GFXDevice::destroy();
  270. WinConsole::destroy();
  271. }
  272. extern bool LinkConsoleFunctions;
  273. #ifndef TORQUE_SHARED
  274. extern S32 TorqueMain(S32 argc, const char **argv);
  275. //--------------------------------------
  276. static S32 run(S32 argc, const char **argv)
  277. {
  278. // Console hack to ensure consolefunctions get linked in
  279. LinkConsoleFunctions=true;
  280. createFontInit();
  281. S32 ret = TorqueMain(argc, argv);
  282. createFontShutdown();
  283. return ret;
  284. }
  285. //--------------------------------------
  286. S32 main(S32 argc, const char **argv)
  287. {
  288. winState.appInstance = GetModuleHandle(NULL);
  289. return run(argc, argv);
  290. }
  291. //--------------------------------------
  292. #include "app/mainLoop.h"
  293. S32 PASCAL WinMain( HINSTANCE hInstance, HINSTANCE, LPSTR lpszCmdLine, S32)
  294. {
  295. Vector<char *> argv( __FILE__, __LINE__ );
  296. char moduleName[256];
  297. #ifdef TORQUE_UNICODE
  298. {
  299. TCHAR buf[ 256 ];
  300. GetModuleFileNameW( NULL, buf, sizeof( buf ) );
  301. convertUTF16toUTF8( buf, moduleName, sizeof( moduleName ) );
  302. }
  303. #else
  304. GetModuleFileNameA(NULL, moduleName, sizeof(moduleName));
  305. #endif
  306. argv.push_back(moduleName);
  307. for (const char* word,*ptr = lpszCmdLine; *ptr; )
  308. {
  309. // Eat white space
  310. for (; dIsspace(*ptr) && *ptr; ptr++)
  311. ;
  312. // Pick out the next word
  313. for (word = ptr; !dIsspace(*ptr) && *ptr; ptr++)
  314. ;
  315. // Add the word to the argument list.
  316. if (*word)
  317. {
  318. S32 len = ptr - word;
  319. char *arg = (char *) dMalloc(len + 1);
  320. dStrncpy(arg, word, len);
  321. arg[len] = 0;
  322. argv.push_back(arg);
  323. }
  324. }
  325. winState.appInstance = hInstance;
  326. S32 retVal = run(argv.size(), (const char **) argv.address());
  327. for(U32 j = 1; j < argv.size(); j++)
  328. dFree(argv[j]);
  329. return retVal;
  330. }
  331. #else //TORQUE_SHARED
  332. extern "C"
  333. {
  334. bool torque_engineinit(S32 argc, const char **argv);
  335. S32 torque_enginetick();
  336. S32 torque_getreturnstatus();
  337. bool torque_engineshutdown();
  338. };
  339. S32 TorqueMain(int argc, const char **argv)
  340. {
  341. if (!torque_engineinit(argc, argv))
  342. return 1;
  343. while(torque_enginetick())
  344. {
  345. }
  346. torque_engineshutdown();
  347. return torque_getreturnstatus();
  348. }
  349. extern "C" {
  350. S32 torque_winmain( HINSTANCE hInstance, HINSTANCE, LPSTR lpszCmdLine, S32)
  351. {
  352. Vector<char *> argv( __FILE__, __LINE__ );
  353. char moduleName[256];
  354. #ifdef TORQUE_UNICODE
  355. {
  356. TCHAR buf[ 256 ];
  357. GetModuleFileNameW( NULL, buf, sizeof( buf ) );
  358. convertUTF16toUTF8( buf, moduleName, sizeof( moduleName ) );
  359. }
  360. #else
  361. GetModuleFileNameA(NULL, moduleName, sizeof(moduleName));
  362. #endif
  363. argv.push_back(moduleName);
  364. for (const char* word,*ptr = lpszCmdLine; *ptr; )
  365. {
  366. // Eat white space
  367. for (; dIsspace(*ptr) && *ptr; ptr++)
  368. ;
  369. // Test for quotes
  370. bool withinQuotes = dIsquote(*ptr);
  371. if (!withinQuotes)
  372. {
  373. // Pick out the next word
  374. for (word = ptr; !dIsspace(*ptr) && *ptr; ptr++)
  375. ;
  376. }
  377. else
  378. {
  379. // Advance past the first quote. We don't want to include it.
  380. ptr++;
  381. // Pick out the next quote
  382. for (word = ptr; !dIsquote(*ptr) && *ptr; ptr++)
  383. ;
  384. }
  385. // Add the word to the argument list.
  386. if (*word)
  387. {
  388. S32 len = ptr - word;
  389. char *arg = (char *) dMalloc(len + 1);
  390. dStrncpy(arg, word, len);
  391. arg[len] = 0;
  392. argv.push_back(arg);
  393. }
  394. // If we had a quote, skip past it for the next arg
  395. if (withinQuotes && *ptr)
  396. {
  397. ptr++;
  398. }
  399. }
  400. winState.appInstance = hInstance;
  401. S32 retVal = TorqueMain(argv.size(), (const char **) argv.address());
  402. for(U32 j = 1; j < argv.size(); j++)
  403. dFree(argv[j]);
  404. return retVal;
  405. }
  406. } // extern "C"
  407. #endif
  408. //--------------------------------------
  409. F32 Platform::getRandom()
  410. {
  411. return sgPlatRandom.randF();
  412. }
  413. ////--------------------------------------
  414. /// Spawn the default Operating System web browser with a URL
  415. /// @param webAddress URL to pass to browser
  416. /// @return true if browser successfully spawned
  417. bool Platform::openWebBrowser( const char* webAddress )
  418. {
  419. static bool sHaveKey = false;
  420. static wchar_t sWebKey[512];
  421. char utf8WebKey[512];
  422. {
  423. HKEY regKey;
  424. DWORD size = sizeof( sWebKey );
  425. if ( RegOpenKeyEx( HKEY_CLASSES_ROOT, dT("\\http\\shell\\open\\command"), 0, KEY_QUERY_VALUE, &regKey ) != ERROR_SUCCESS )
  426. {
  427. Con::errorf( ConsoleLogEntry::General, "Platform::openWebBrowser - Failed to open the HKCR\\http registry key!!!");
  428. return( false );
  429. }
  430. if ( RegQueryValueEx( regKey, dT(""), NULL, NULL, (U8 *)sWebKey, &size ) != ERROR_SUCCESS )
  431. {
  432. Con::errorf( ConsoleLogEntry::General, "Platform::openWebBrowser - Failed to query the open command registry key!!!" );
  433. return( false );
  434. }
  435. RegCloseKey( regKey );
  436. sHaveKey = true;
  437. convertUTF16toUTF8(sWebKey,utf8WebKey,512);
  438. #ifdef UNICODE
  439. char *p = dStrstr((const char *)utf8WebKey, "%1");
  440. #else
  441. char *p = strstr( (const char *) sWebKey , "%1");
  442. #endif
  443. if (p) *p = 0;
  444. }
  445. STARTUPINFO si;
  446. dMemset( &si, 0, sizeof( si ) );
  447. si.cb = sizeof( si );
  448. char buf[1024];
  449. #ifdef UNICODE
  450. dSprintf( buf, sizeof( buf ), "%s %s", utf8WebKey, webAddress );
  451. UTF16 b[1024];
  452. convertUTF8toUTF16((UTF8 *)buf, b, sizeof(b));
  453. #else
  454. dSprintf( buf, sizeof( buf ), "%s %s", sWebKey, webAddress );
  455. #endif
  456. //Con::errorf( ConsoleLogEntry::General, "** Web browser command = %s **", buf );
  457. PROCESS_INFORMATION pi;
  458. dMemset( &pi, 0, sizeof( pi ) );
  459. CreateProcess( NULL,
  460. #ifdef UNICODE
  461. b,
  462. #else
  463. buf,
  464. #endif
  465. NULL,
  466. NULL,
  467. false,
  468. CREATE_NEW_CONSOLE | CREATE_NEW_PROCESS_GROUP,
  469. NULL,
  470. NULL,
  471. &si,
  472. &pi );
  473. return( true );
  474. }
  475. //--------------------------------------
  476. // Login password routines:
  477. //--------------------------------------
  478. #ifdef UNICODE
  479. static const UTF16* TorqueRegKey = dT("SOFTWARE\\GarageGames\\Torque");
  480. #else
  481. static const char* TorqueRegKey = "SOFTWARE\\GarageGames\\Torque";
  482. #endif
  483. const char* Platform::getLoginPassword()
  484. {
  485. HKEY regKey;
  486. char* returnString = NULL;
  487. if ( RegOpenKeyEx( HKEY_LOCAL_MACHINE, TorqueRegKey, 0, KEY_QUERY_VALUE, &regKey ) == ERROR_SUCCESS )
  488. {
  489. U8 buf[32];
  490. DWORD size = sizeof( buf );
  491. if ( RegQueryValueEx( regKey, dT("LoginPassword"), NULL, NULL, buf, &size ) == ERROR_SUCCESS )
  492. {
  493. returnString = Con::getReturnBuffer( size + 1 );
  494. dStrcpy( returnString, (const char*) buf );
  495. }
  496. RegCloseKey( regKey );
  497. }
  498. if ( returnString )
  499. return( returnString );
  500. else
  501. return( "" );
  502. }
  503. //--------------------------------------
  504. bool Platform::setLoginPassword( const char* password )
  505. {
  506. HKEY regKey;
  507. if ( RegOpenKeyEx( HKEY_LOCAL_MACHINE, TorqueRegKey, 0, KEY_WRITE, &regKey ) == ERROR_SUCCESS )
  508. {
  509. if ( RegSetValueEx( regKey, dT("LoginPassword"), 0, REG_SZ, (const U8*) password, dStrlen( password ) + 1 ) != ERROR_SUCCESS )
  510. Con::errorf( ConsoleLogEntry::General, "setLoginPassword - Failed to set the subkey value!" );
  511. RegCloseKey( regKey );
  512. return( true );
  513. }
  514. else
  515. Con::errorf( ConsoleLogEntry::General, "setLoginPassword - Failed to open the Torque registry key!" );
  516. return( false );
  517. }
  518. //--------------------------------------
  519. // Silly Korean registry key checker:
  520. //
  521. // NOTE: "Silly" refers to the nature of this hack, and is not intended
  522. // as commentary on Koreans as a nationality. Thank you for your
  523. // attention.
  524. //--------------------------------------
  525. DefineConsoleFunction( isKoreanBuild, bool, ( ), , "isKoreanBuild()")
  526. {
  527. HKEY regKey;
  528. bool result = false;
  529. if ( RegOpenKeyEx( HKEY_LOCAL_MACHINE, TorqueRegKey, 0, KEY_QUERY_VALUE, &regKey ) == ERROR_SUCCESS )
  530. {
  531. DWORD val;
  532. DWORD size = sizeof( val );
  533. if ( RegQueryValueEx( regKey, dT("Korean"), NULL, NULL, (U8*) &val, &size ) == ERROR_SUCCESS )
  534. result = ( val > 0 );
  535. RegCloseKey( regKey );
  536. }
  537. return( result );
  538. }