Rev 54 | Rev 79 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 54 | Rev 77 | ||
|---|---|---|---|
| Line 28... | Line 28... | ||
| 28 | 28 | ||
| 29 | wchar_t widechar_buffer[256]; |
29 | wchar_t widechar_buffer[256]; |
| 30 | SYSTEM_INFO sysinfo; |
30 | SYSTEM_INFO sysinfo; |
| 31 | SECURITY_ATTRIBUTES saAttr; |
31 | SECURITY_ATTRIBUTES saAttr; |
| 32 | STARTUPINFO si; |
32 | STARTUPINFO si; |
| - | 33 | int try_index; |
|
| 33 | FILE *fp; |
34 | FILE *fp; |
| 34 | 35 | ||
| 35 | // reset stuff first |
36 | // reset stuff first |
| 36 | hChessEngineStdinRd = NULL; |
37 | hChessEngineStdinRd = NULL; |
| 37 | hChessEngineStdinWr = NULL; |
38 | hChessEngineStdinWr = NULL; |
| Line 73... | Line 74... | ||
| 73 | CREATE_NO_WINDOW | DETACHED_PROCESS | CREATE_NEW_PROCESS_GROUP, |
74 | CREATE_NO_WINDOW | DETACHED_PROCESS | CREATE_NEW_PROCESS_GROUP, |
| 74 | NULL, |
75 | NULL, |
| 75 | chessenginemodule_path, // process path |
76 | chessenginemodule_path, // process path |
| 76 | &si, // STARTUPINFO pointer |
77 | &si, // STARTUPINFO pointer |
| 77 | &PlayerEngine_pi)) // receives PROCESS_INFORMATION |
78 | &PlayerEngine_pi)) // receives PROCESS_INFORMATION |
| - | 79 | { |
|
| - | 80 | messagebox.hWndParent = hMainWnd; |
|
| - | 81 | wcscpy_s (messagebox.title, WCHAR_SIZEOF (messagebox.title), LOCALIZE (L"ImportantMessage")); |
|
| - | 82 | wcscpy_s (messagebox.text, WCHAR_SIZEOF (messagebox.text), LOCALIZE (L"Error_ChessEngineInitializationFailed")); |
|
| - | 83 | messagebox.flags = MB_ICONWARNING | MB_OK; |
|
| - | 84 | DialogBox_Message (&messagebox); // display a modeless error message box |
|
| - | 85 | ||
| - | 86 | PlayerEngine_Shutdown (player); // on error, shutdown the engine |
|
| - | 87 | return (false); |
|
| - | 88 | } |
|
| - | 89 | ||
| - | 90 | // wait for the engine process to display something (which will mean it's ready) |
|
| - | 91 | for (try_index = 0; try_index < 300; try_index++) |
|
| - | 92 | { |
|
| - | 93 | // read from pipe (non-blocking) |
|
| - | 94 | PlayerEngine_Recv (player); |
|
| - | 95 | if (player->recvbuffer[0] != 0) |
|
| - | 96 | break; // break as soon as we get something |
|
| - | 97 | Sleep (100); // next try in 100 milliseconds |
|
| - | 98 | } |
|
| - | 99 | ||
| - | 100 | // has the engine process not spoken yet ? |
|
| - | 101 | if (player->recvbuffer[0] == 0) |
|
| 78 | { |
102 | { |
| 79 | messagebox.hWndParent = hMainWnd; |
103 | messagebox.hWndParent = hMainWnd; |
| 80 | wcscpy_s (messagebox.title, WCHAR_SIZEOF (messagebox.title), LOCALIZE (L"ImportantMessage")); |
104 | wcscpy_s (messagebox.title, WCHAR_SIZEOF (messagebox.title), LOCALIZE (L"ImportantMessage")); |
| 81 | wcscpy_s (messagebox.text, WCHAR_SIZEOF (messagebox.text), LOCALIZE (L"Error_ChessEngineInitializationFailed")); |
105 | wcscpy_s (messagebox.text, WCHAR_SIZEOF (messagebox.text), LOCALIZE (L"Error_ChessEngineInitializationFailed")); |
| 82 | messagebox.flags = MB_ICONWARNING | MB_OK; |
106 | messagebox.flags = MB_ICONWARNING | MB_OK; |