Rev 119 | Rev 130 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 119 | Rev 124 | ||
|---|---|---|---|
| Line 41... | Line 41... | ||
| 41 | int index_line; |
41 | int index_line; |
| 42 | int index_column; |
42 | int index_column; |
| 43 | int part_index; |
43 | int part_index; |
| 44 | int part_color; |
44 | int part_color; |
| 45 | int viewer_index; |
45 | int viewer_index; |
| - | 46 | RECT rect; |
|
| 46 | 47 | ||
| 47 | // filter out the commonly used message values |
48 | // filter out the commonly used message values |
| 48 | wParam_hiword = HIWORD (wParam); |
49 | wParam_hiword = HIWORD (wParam); |
| 49 | wParam_loword = LOWORD (wParam); |
50 | wParam_loword = LOWORD (wParam); |
| - | 51 | ||
| - | 52 | // get current and opposite players and see if we're online |
|
| - | 53 | current_player = Player_GetCurrent (); |
|
| - | 54 | opposite_player = Player_GetOpposite (); |
|
| - | 55 | remote_player = Player_FindByType (PLAYER_INTERNET); |
|
| 50 | 56 | ||
| 51 | //////////////////////////////////////////////////////////////////////////////////////////////// |
57 | //////////////////////////////////////////////////////////////////////////////////////////////// |
| 52 | // has the window just been fired up ? |
58 | // has the window just been fired up ? |
| 53 | if (message == WM_CREATE) |
59 | if (message == WM_CREATE) |
| 54 | { |
60 | { |
| 55 | the_scene.gui.is_entering_text = false; // we are NOT entering text yet |
61 | the_scene.gui.is_entering_text = false; // we are NOT entering text yet |
| 56 | 62 | ||
| 57 | // call the default window message processing function to keep things going |
63 | // call the default window message processing function to keep things going |
| 58 | return (DefWindowProc (hWnd, message, wParam, lParam)); |
64 | return (DefWindowProc (hWnd, message, wParam, lParam)); |
| - | 65 | } |
|
| - | 66 | ||
| - | 67 | //////////////////////////////////////////////////////////////////////////////////////////////// |
|
| - | 68 | // else is the window being resized ? |
|
| - | 69 | else if ((message == WM_SIZE) || (message == WM_WINDOWPOSCHANGED)) |
|
| - | 70 | { |
|
| - | 71 | GetWindowRect (hMainWnd, &rect); // grab the current window size and update the options accordingly |
|
| - | 72 | options.want_maximized = (rect.right - rect.left > GetSystemMetrics (SM_CXMAXIMIZED) * 90 / 100) && (rect.bottom - rect.top > GetSystemMetrics (SM_CYMAXIMIZED) * 80 / 100); |
|
| - | 73 | if (!options.want_maximized) |
|
| - | 74 | { |
|
| - | 75 | options.window_width = max (rect.right - rect.left, 640); // min window width |
|
| - | 76 | options.window_height = max (rect.bottom - rect.top, 480); // min window height (only save them when the window is not maximized) |
|
| - | 77 | } |
|
| - | 78 | ||
| - | 79 | return (0); // don't let Windows do the default processing on this message |
|
| 59 | } |
80 | } |
| 60 | 81 | ||
| 61 | //////////////////////////////////////////////////////////////////////////////////////////////// |
82 | //////////////////////////////////////////////////////////////////////////////////////////////// |
| 62 | // else have we clicked on the close button ? |
83 | // else have we clicked on the close button ? |
| 63 | else if (message == WM_CLOSE) |
84 | else if (message == WM_CLOSE) |
| 64 | { |
85 | { |
| 65 | if ((the_board.game_state == STATE_PLAYING) && ((the_board.move_count > 1) || ( |
86 | if ((the_board.game_state == STATE_PLAYING) && ((the_board.move_count > 1) || (remote_player != NULL))) |
| 66 | DialogBox_Quit (); // if a game has started OR if we are online against somebody, ask for confirmation |
87 | DialogBox_Quit (); // if a game has started OR if we are online against somebody, ask for confirmation |
| 67 | else |
88 | else |
| 68 | is_dialogbox_quit_validated = true; // if game hasn't started yet, quit without question |
89 | is_dialogbox_quit_validated = true; // if game hasn't started yet, quit without question |
| 69 | 90 | ||
| 70 | return (0); // don't let Windows do the default processing on this message |
91 | return (0); // don't let Windows do the default processing on this message |
| Line 81... | Line 102... | ||
| 81 | 102 | ||
| 82 | /////////////// |
103 | /////////////// |
| 83 | // menu command |
104 | // menu command |
| 84 | else if (message == WM_COMMAND) |
105 | else if (message == WM_COMMAND) |
| 85 | { |
106 | { |
| - | 107 | // ANY menu choice makes the "new game" / "open game" front GUI button disappear |
|
| - | 108 | GUIBUTTON_DISABLE (the_scene.gui.newgamebutton); |
|
| - | 109 | GUIBUTTON_DISABLE (the_scene.gui.opengamebutton); |
|
| - | 110 | ||
| 86 | // game menu, new game |
111 | // game menu, new game |
| 87 | if (wParam_loword == MENUID_GAME_NEWGAME) |
112 | if (wParam_loword == MENUID_GAME_NEWGAME) |
| 88 | { |
113 | { |
| 89 | if ((the_board.game_state == STATE_PLAYING) && (the_board.move_count > 1)) |
114 | if ((the_board.game_state == STATE_PLAYING) && (the_board.move_count > 1)) |
| 90 | DialogBox_Resign (); // if a game is playing, ask to resign first |
115 | DialogBox_Resign (); // if a game is playing, ask to resign first |
| Line 159... | Line 184... | ||
| 159 | DialogBox_Options (); // fire up the options dialog box |
184 | DialogBox_Options (); // fire up the options dialog box |
| 160 | 185 | ||
| 161 | // game menu, quit |
186 | // game menu, quit |
| 162 | else if (wParam_loword == MENUID_GAME_QUIT) |
187 | else if (wParam_loword == MENUID_GAME_QUIT) |
| 163 | { |
188 | { |
| 164 | if ((the_board.game_state == STATE_PLAYING) && ((the_board.move_count > 1) || ( |
189 | if ((the_board.game_state == STATE_PLAYING) && ((the_board.move_count > 1) || (remote_player != NULL))) |
| 165 | DialogBox_Quit (); // if a game has started OR if we are online against somebody, ask for confirmation |
190 | DialogBox_Quit (); // if a game has started OR if we are online against somebody, ask for confirmation |
| 166 | else |
191 | else |
| 167 | is_dialogbox_quit_validated = true; // if game hasn't started yet, quit without question |
192 | is_dialogbox_quit_validated = true; // if game hasn't started yet, quit without question |
| 168 | } |
193 | } |
| 169 | 194 | ||
| Line 400... | Line 425... | ||
| 400 | else if (message == WM_LBUTTONDOWN) |
425 | else if (message == WM_LBUTTONDOWN) |
| 401 | { |
426 | { |
| 402 | // are we in animation OR are mouse commands NOT allowed ? |
427 | // are we in animation OR are mouse commands NOT allowed ? |
| 403 | if ((animation_endtime + 1.0f >= current_time) || (command_ignoretime >= current_time)) |
428 | if ((animation_endtime + 1.0f >= current_time) || (command_ignoretime >= current_time)) |
| 404 | return (DefWindowProc (hWnd, message, wParam, lParam)); // if so, call the default message proc to keep things going |
429 | return (DefWindowProc (hWnd, message, wParam, lParam)); // if so, call the default message proc to keep things going |
| - | 430 | ||
| - | 431 | // are we in board closeup mode OR are we online AND do we NOT have the right to select anything ? |
|
| - | 432 | if (((current_distance == CLOSEUP_VIEW_DISTANCE) && (current_pitch == CLOSEUP_VIEW_PITCH)) |
|
| - | 433 | || ((remote_player != NULL) && !remote_player->is_in_game)) |
|
| - | 434 | return (DefWindowProc (hWnd, message, wParam, lParam)); // if so, call the default window message processing function to keep things going |
|
| 405 | 435 | ||
| 406 | // is the ctrl key pressed (emulates a right click) ? |
436 | // is the ctrl key pressed (emulates a right click) ? |
| 407 | if (ctrl_pressed) |
437 | if (ctrl_pressed) |
| 408 | { |
438 | { |
| 409 | prevgui_x = GET_X_LPARAM (lParam); // remember mouse coordinates |
439 | prevgui_x = GET_X_LPARAM (lParam); // remember mouse coordinates |
| Line 451... | Line 481... | ||
| 451 | 481 | ||
| 452 | // get mouse coordinates |
482 | // get mouse coordinates |
| 453 | gui_x = GET_X_LPARAM (lParam); |
483 | gui_x = GET_X_LPARAM (lParam); |
| 454 | gui_y = GET_Y_LPARAM (lParam); |
484 | gui_y = GET_Y_LPARAM (lParam); |
| 455 | 485 | ||
| 456 | // is the |
486 | // is the "new game" button displayed AND is the mouse hovering it ? |
| 457 | if ((the_scene.gui. |
487 | if ((the_scene.gui.newgamebutton.state != 0) && Button_IsHovered (&the_scene.gui.newgamebutton, gui_x, gui_y)) |
| - | 488 | { |
|
| - | 489 | GUIBUTTON_DISABLE (the_scene.gui.newgamebutton); // hide the "new game" button |
|
| 458 |
|
490 | GUIBUTTON_DISABLE (the_scene.gui.opengamebutton); // hide the "open game" button |
| - | 491 | DialogBox_NewGame (); // fire up the "new game" dialog box |
|
| - | 492 | } |
|
| 459 | 493 | ||
| 460 | // is the |
494 | // is the "open game" button displayed AND is the mouse hovering it ? |
| 461 | if ((the_scene.gui. |
495 | if ((the_scene.gui.opengamebutton.state != 0) && Button_IsHovered (&the_scene.gui.opengamebutton, gui_x, gui_y)) |
| - | 496 | { |
|
| 462 |
|
497 | GUIBUTTON_DISABLE (the_scene.gui.newgamebutton); // hide the "new game" button |
| - | 498 | GUIBUTTON_DISABLE (the_scene.gui.opengamebutton); // hide the "open game" button |
|
| - | 499 | DialogBox_Load (); // fire up the "open game" dialog box |
|
| - | 500 | } |
|
| 463 | 501 | ||
| 464 | // is the chat button displayed AND is the mouse hovering it ? |
502 | // is the chat button displayed AND is the mouse hovering it ? |
| 465 | if ((the_scene.gui.chatbutton.state != 0) && Button_IsHovered (&the_scene.gui.chatbutton, gui_x, gui_y)) |
503 | if ((the_scene.gui.chatbutton.state != 0) && Button_IsHovered (&the_scene.gui.chatbutton, gui_x, gui_y)) |
| 466 | { |
504 | { |
| 467 | opposite_player = Player_FindByType (PLAYER_INTERNET); // get a hand on the remote player |
- | |
| 468 | - | ||
| 469 | // find or create the corresponding interlocutor structure and fire it up |
505 | // find or create the corresponding interlocutor structure and fire it up |
| 470 | if ( |
506 | if (remote_player != NULL) |
| 471 | Interlocutor_FindOrCreate ( |
507 | Interlocutor_FindOrCreate (remote_player->name); |
| 472 | } |
508 | } |
| 473 | 509 | ||
| 474 | // is the games button displayed AND is the mouse hovering it ? |
510 | // is the games button displayed AND is the mouse hovering it ? |
| 475 | if ((the_scene.gui.gamesbutton.state != 0) && Button_IsHovered (&the_scene.gui.gamesbutton, gui_x, gui_y)) |
511 | if ((the_scene.gui.gamesbutton.state != 0) && Button_IsHovered (&the_scene.gui.gamesbutton, gui_x, gui_y)) |
| 476 | Window_Sought (); // if so, display the sought games window |
512 | Window_Sought (); // if so, display the sought games window |
| 477 | 513 | ||
| 478 | // is the people button displayed AND is the mouse hovering it ? |
514 | // is the people button displayed AND is the mouse hovering it ? |
| 479 | if ((the_scene.gui.peoplebutton.state != 0) && Button_IsHovered (&the_scene.gui.peoplebutton, gui_x, gui_y)) |
515 | if ((the_scene.gui.peoplebutton.state != 0) && Button_IsHovered (&the_scene.gui.peoplebutton, gui_x, gui_y)) |
| 480 | Window_Opponents (); // if so, display the opponents window |
516 | Window_Opponents (); // if so, display the opponents window |
| - | 517 | ||
| - | 518 | // are we in board closeup mode OR are we online AND do we NOT have the right to select anything ? |
|
| - | 519 | if (((current_distance == CLOSEUP_VIEW_DISTANCE) && (current_pitch == CLOSEUP_VIEW_PITCH)) |
|
| - | 520 | || ((remote_player != NULL) && !remote_player->is_in_game)) |
|
| - | 521 | return (DefWindowProc (hWnd, message, wParam, lParam)); // if so, call the default window message processing function to keep things going |
|
| - | 522 | ||
| - | 523 | // is the left arrow displayed AND is the mouse hovering it ? |
|
| - | 524 | if ((the_scene.gui.larrow.state != 0) && Button_IsHovered (&the_scene.gui.larrow, gui_x, gui_y)) |
|
| - | 525 | SendMessage (hWnd, WM_COMMAND, MENUID_CHESSBOARD_PREVIOUSMOVE, NULL); // send a "previous move" event |
|
| - | 526 | ||
| - | 527 | // is the right arrow displayed AND is the mouse hovering it ? |
|
| - | 528 | if ((the_scene.gui.rarrow.state != 0) && Button_IsHovered (&the_scene.gui.rarrow, gui_x, gui_y)) |
|
| - | 529 | SendMessage (hWnd, WM_COMMAND, MENUID_CHESSBOARD_NEXTMOVE, NULL); // send a "next move" event |
|
| 481 | 530 | ||
| 482 | // is the parts selection line displayed AND is the mouse anywhere near it ? |
531 | // is the parts selection line displayed AND is the mouse anywhere near it ? |
| 483 | if (the_scene.gui.is_partspick_displayed && Render_IsMouseInBox (gui_x, gui_y, 0.0f, 0.0f, 100.0f, 11.0f)) |
532 | if (the_scene.gui.is_partspick_displayed && Render_IsMouseInBox (gui_x, gui_y, 0.0f, 0.0f, 100.0f, 11.0f)) |
| 484 | { |
533 | { |
| 485 | // for each selectable part, if the mouse is on it, mark it as selected |
534 | // for each selectable part, if the mouse is on it, mark it as selected |
| Line 489... | Line 538... | ||
| 489 | the_scene.gui.partspick_selectedpart = selectable_parts[part_index]; // mark it as selected |
538 | the_scene.gui.partspick_selectedpart = selectable_parts[part_index]; // mark it as selected |
| 490 | Audio_PlaySound (SOUNDTYPE_CLICK, 0.0f, 0.0f, 0.04f); // make a click sound at the center of the board |
539 | Audio_PlaySound (SOUNDTYPE_CLICK, 0.0f, 0.0f, 0.04f); // make a click sound at the center of the board |
| 491 | break; // no need to search further if one selection was found |
540 | break; // no need to search further if one selection was found |
| 492 | } |
541 | } |
| 493 | } |
542 | } |
| 494 | - | ||
| 495 | // get current player and see if we're online |
- | |
| 496 | current_player = Player_GetCurrent (); |
- | |
| 497 | remote_player = Player_FindByType (PLAYER_INTERNET); |
- | |
| 498 | 543 | ||
| 499 | // if we are not allowed to select anything, don't even try |
544 | // if we are not allowed to select anything, don't even try |
| 500 | if (is_paused || (current_player->type != PLAYER_HUMAN) || (the_board.viewed_move != the_board.move_count - 1) |
545 | if (is_paused || (current_player->type != PLAYER_HUMAN) || (the_board.viewed_move != the_board.move_count - 1) |
| 501 | || ((remote_player != NULL) && !remote_player->is_in_game)) |
546 | || ((remote_player != NULL) && !remote_player->is_in_game)) |
| 502 | { |
547 | { |
| Line 789... | Line 834... | ||
| 789 | gui_y = GET_Y_LPARAM (lParam); |
834 | gui_y = GET_Y_LPARAM (lParam); |
| 790 | 835 | ||
| 791 | // handle button update status |
836 | // handle button update status |
| 792 | the_scene.update |= Button_UpdateHoverState (&the_scene.gui.larrow, gui_x, gui_y); |
837 | the_scene.update |= Button_UpdateHoverState (&the_scene.gui.larrow, gui_x, gui_y); |
| 793 | the_scene.update |= Button_UpdateHoverState (&the_scene.gui.rarrow, gui_x, gui_y); |
838 | the_scene.update |= Button_UpdateHoverState (&the_scene.gui.rarrow, gui_x, gui_y); |
| - | 839 | the_scene.update |= Button_UpdateHoverState (&the_scene.gui.newgamebutton, gui_x, gui_y); |
|
| - | 840 | the_scene.update |= Button_UpdateHoverState (&the_scene.gui.opengamebutton, gui_x, gui_y); |
|
| 794 | the_scene.update |= Button_UpdateHoverState (&the_scene.gui.chatbutton, gui_x, gui_y); |
841 | the_scene.update |= Button_UpdateHoverState (&the_scene.gui.chatbutton, gui_x, gui_y); |
| 795 | the_scene.update |= Button_UpdateHoverState (&the_scene.gui.gamesbutton, gui_x, gui_y); |
842 | the_scene.update |= Button_UpdateHoverState (&the_scene.gui.gamesbutton, gui_x, gui_y); |
| 796 | the_scene.update |= Button_UpdateHoverState (&the_scene.gui.peoplebutton, gui_x, gui_y); |
843 | the_scene.update |= Button_UpdateHoverState (&the_scene.gui.peoplebutton, gui_x, gui_y); |
| 797 | 844 | ||
| 798 | // see if we're online |
- | |
| 799 |
|
845 | // are we in board closeup mode OR are we online AND do we NOT have the right to select anything ? |
| 800 | - | ||
| 801 |
|
846 | if (((current_distance == CLOSEUP_VIEW_DISTANCE) && (current_pitch == CLOSEUP_VIEW_PITCH)) |
| 802 |
|
847 | || ((remote_player != NULL) && !remote_player->is_in_game)) |
| 803 | return (DefWindowProc (hWnd, message, wParam, lParam)); // if so, call the default window message processing function to keep things going |
848 | return (DefWindowProc (hWnd, message, wParam, lParam)); // if so, call the default window message processing function to keep things going |
| 804 | 849 | ||
| 805 | // is the parts selection line displayed AND is the mouse anywhere in it ? |
850 | // is the parts selection line displayed AND is the mouse anywhere in it ? |
| 806 | if (the_scene.gui.is_partspick_displayed && Render_IsMouseInBox (gui_x, gui_y, 0.0f, 0.0f, 100.0f, 11.0f)) |
851 | if (the_scene.gui.is_partspick_displayed && Render_IsMouseInBox (gui_x, gui_y, 0.0f, 0.0f, 100.0f, 11.0f)) |
| 807 | { |
852 | { |
| Line 827... | Line 872... | ||
| 827 | } |
872 | } |
| 828 | } |
873 | } |
| 829 | } |
874 | } |
| 830 | else |
875 | else |
| 831 | the_scene.gui.partspick_hoveredpart = 0; // clear the hovered part |
876 | the_scene.gui.partspick_hoveredpart = 0; // clear the hovered part |
| 832 | - | ||
| 833 | // get current and opposite players |
- | |
| 834 | current_player = Player_GetCurrent (); |
- | |
| 835 | opposite_player = Player_GetOpposite (); |
- | |
| 836 | 877 | ||
| 837 | // if right button was clicked, compute new pitch and yaw |
878 | // if right button was clicked, compute new pitch and yaw |
| 838 | if (rbutton_pushed) |
879 | if (rbutton_pushed) |
| 839 | { |
880 | { |
| 840 | // cycle through both players and change their view angles EXCEPT the opponent if he's human |
881 | // cycle through both players and change their view angles EXCEPT the opponent if he's human |
| Line 842... | Line 883... | ||
| 842 | if ((the_board.players[viewer_index].type == PLAYER_COMPUTER) |
883 | if ((the_board.players[viewer_index].type == PLAYER_COMPUTER) |
| 843 | || (the_board.players[viewer_index].type == PLAYER_INTERNET) |
884 | || (the_board.players[viewer_index].type == PLAYER_INTERNET) |
| 844 | || (viewer_index == current_viewer)) |
885 | || (viewer_index == current_viewer)) |
| 845 | { |
886 | { |
| 846 | the_board.players[viewer_index].view_pitch += (gui_y - prevgui_y) * 0.3f; |
887 | the_board.players[viewer_index].view_pitch += (gui_y - prevgui_y) * 0.3f; |
| 847 | if (the_board.players[viewer_index].view_pitch < |
888 | if (the_board.players[viewer_index].view_pitch < MIN_VIEW_PITCH) |
| 848 | the_board.players[viewer_index].view_pitch = |
889 | the_board.players[viewer_index].view_pitch = MIN_VIEW_PITCH; // wrap angles around so that they |
| 849 | if (the_board.players[viewer_index].view_pitch > |
890 | if (the_board.players[viewer_index].view_pitch > MAX_VIEW_PITCH) |
| 850 | the_board.players[viewer_index].view_pitch = |
891 | the_board.players[viewer_index].view_pitch = MAX_VIEW_PITCH; // stay in the min-max pitch bounds |
| 851 | 892 | ||
| 852 | the_board.players[viewer_index].view_yaw += (gui_x - prevgui_x) * 0.3f; |
893 | the_board.players[viewer_index].view_yaw += (gui_x - prevgui_x) * 0.3f; |
| 853 | the_board.players[viewer_index].view_yaw = WrapAngle (the_board.players[viewer_index].view_yaw); |
894 | the_board.players[viewer_index].view_yaw = WrapAngle (the_board.players[viewer_index].view_yaw); |
| 854 | 895 | ||
| 855 | // save these as the new custom angles |
896 | // save these as the new custom angles |
| Line 920... | Line 961... | ||
| 920 | { |
961 | { |
| 921 | // are we in animation OR are mouse commands NOT allowed ? |
962 | // are we in animation OR are mouse commands NOT allowed ? |
| 922 | if ((animation_endtime + 1.0f >= current_time) || (command_ignoretime >= current_time)) |
963 | if ((animation_endtime + 1.0f >= current_time) || (command_ignoretime >= current_time)) |
| 923 | return (DefWindowProc (hWnd, message, wParam, lParam)); // if so, call the default message proc to keep things going |
964 | return (DefWindowProc (hWnd, message, wParam, lParam)); // if so, call the default message proc to keep things going |
| 924 | 965 | ||
| 925 | // see if we're online |
- | |
| 926 |
|
966 | // are we in board closeup mode OR are we online AND do we NOT have the right to select anything ? |
| 927 | - | ||
| 928 |
|
967 | if (((current_distance == CLOSEUP_VIEW_DISTANCE) && (current_pitch == CLOSEUP_VIEW_PITCH)) |
| 929 |
|
968 | || ((remote_player != NULL) && !remote_player->is_in_game)) |
| 930 | return (DefWindowProc (hWnd, message, wParam, lParam)); // if so, call the default window message processing function to keep things going |
969 | return (DefWindowProc (hWnd, message, wParam, lParam)); // if so, call the default window message processing function to keep things going |
| 931 | 970 | ||
| 932 | // scroll up / scroll down ? |
971 | // scroll up / scroll down ? |
| 933 | if (GET_WHEEL_DELTA_WPARAM (wParam) > 0) |
972 | if (GET_WHEEL_DELTA_WPARAM (wParam) > 0) |
| 934 | the_board.players[current_viewer].view_distance = max ( |
973 | the_board.players[current_viewer].view_distance = max (MIN_VIEW_DISTANCE, the_board.players[current_viewer].view_distance - 2.0f); |
| 935 | else if (GET_WHEEL_DELTA_WPARAM (wParam) < 0) |
974 | else if (GET_WHEEL_DELTA_WPARAM (wParam) < 0) |
| 936 | the_board.players[current_viewer].view_distance = min ( |
975 | the_board.players[current_viewer].view_distance = min (MAX_VIEW_DISTANCE, the_board.players[current_viewer].view_distance + 2.0f); |
| 937 | 976 | ||
| 938 | // save this as the new custom distance |
977 | // save this as the new custom distance |
| 939 | the_board.players[current_viewer].custom_distance = the_board.players[current_viewer].view_distance; |
978 | the_board.players[current_viewer].custom_distance = the_board.players[current_viewer].view_distance; |
| 940 | 979 | ||
| 941 | // when moving the table around, jump to ideal angles immediately |
980 | // when moving the table around, jump to ideal angles immediately |
| Line 956... | Line 995... | ||
| 956 | { |
995 | { |
| 957 | // is it the enter key ? if so, exit setup mode and start playing |
996 | // is it the enter key ? if so, exit setup mode and start playing |
| 958 | if (wParam == L'\r') |
997 | if (wParam == L'\r') |
| 959 | { |
998 | { |
| 960 | current_move = &the_board.moves[the_board.viewed_move]; // quick access to current move |
999 | current_move = &the_board.moves[the_board.viewed_move]; // quick access to current move |
| - | 1000 | ||
| - | 1001 | // make sure there is at least one king of each color (i.e. two kings) |
|
| - | 1002 | part_index = 0; |
|
| - | 1003 | for (line = 0; line < 8; line++) |
|
| - | 1004 | for (column = 0; column < 8; column++) |
|
| - | 1005 | if (current_move->slots[line][column].part == PART_KING) |
|
| - | 1006 | part_index++; // there's one king more on this board |
|
| - | 1007 | if (part_index != 2) |
|
| - | 1008 | return (DefWindowProc (hWnd, message, wParam, lParam)); // when at least one king is missing, we just can't leave edition mode |
|
| 961 | 1009 | ||
| 962 | // (in)validate the castling positions |
1010 | // (in)validate the castling positions |
| 963 | if ((current_move->slots[0][0].color == COLOR_WHITE) && (current_move->slots[0][0].part == PART_ROOK) |
1011 | if ((current_move->slots[0][0].color == COLOR_WHITE) && (current_move->slots[0][0].part == PART_ROOK) |
| 964 | && (current_move->slots[0][4].color == COLOR_WHITE) && (current_move->slots[0][4].part == PART_KING)) |
1012 | && (current_move->slots[0][4].color == COLOR_WHITE) && (current_move->slots[0][4].part == PART_KING)) |
| 965 | current_move->sides[COLOR_WHITE].longcastle_allowed = true; // white castling queenside allowed |
1013 | current_move->sides[COLOR_WHITE].longcastle_allowed = true; // white castling queenside allowed |
| Line 998... | Line 1046... | ||
| 998 | return (DefWindowProc (hWnd, message, wParam, lParam)); |
1046 | return (DefWindowProc (hWnd, message, wParam, lParam)); |
| 999 | } |
1047 | } |
| 1000 | } |
1048 | } |
| 1001 | 1049 | ||
| 1002 | // else are we in internet mode ? |
1050 | // else are we in internet mode ? |
| 1003 | else if ( |
1051 | else if (remote_player != NULL) |
| 1004 | { |
1052 | { |
| 1005 | entered_ccreply = &the_scene.gui.entered_ccreply; // quick access to entered ccreply |
1053 | entered_ccreply = &the_scene.gui.entered_ccreply; // quick access to entered ccreply |
| 1006 | local_player = Player_FindByType (PLAYER_HUMAN); // quick access to local player |
1054 | local_player = Player_FindByType (PLAYER_HUMAN); // quick access to local player |
| 1007 | if (local_player == NULL) |
1055 | if (local_player == NULL) |
| 1008 | return (DefWindowProc (hWnd, message, wParam, lParam)); // theoretically impossible condition, but better be sure |
1056 | return (DefWindowProc (hWnd, message, wParam, lParam)); // theoretically impossible condition, but better be sure |