| 725 | //========================================================================== |
| 726 | |
| 727 | void MainLoop () |
| 728 | { |
| 729 | int lasttic = 0; |
| 730 | |
| 731 | // Clamp the timer to TICRATE until the playloop has been entered. |
| 732 | r_NoInterpolate = true; |
| 733 | |
| 734 | if (userConfig.CommandMap.IsNotEmpty()) |
| 735 | { |
| 736 | auto maprecord = FindMapByName(userConfig.CommandMap.GetChars()); |
| 737 | if (maprecord == nullptr) |
| 738 | { |
| 739 | maprecord = SetupUserMap(userConfig.CommandMap.GetChars(), g_gameType & GAMEFLAG_DUKE? "dethtoll.mid" : nullptr); |
| 740 | } |
| 741 | userConfig.CommandMap = ""; |
| 742 | if (maprecord) |
| 743 | { |
| 744 | DeferredStartGame(maprecord, g_nextskill); |
| 745 | } |
| 746 | } |
| 747 | |
| 748 | for (;;) |
| 749 | { |
| 750 | try |
| 751 | { |
| 752 | // frame syncronous IO operations |
| 753 | if (gametic > lasttic) |
| 754 | { |
| 755 | lasttic = gametic; |
| 756 | I_StartFrame (); |
| 757 | } |
| 758 | I_SetFrameTime(); |
| 759 | |
| 760 | // update the scale factor for unsynchronised input here. |
| 761 | gameInput.UpdateInputScale(); |
| 762 | |
| 763 | TryRunTics (); // will run at least one tic |
| 764 | // Update display, next frame, with current state. |
| 765 | I_StartTic(); |
| 766 | |
| 767 | Display(); |
| 768 | Mus_UpdateMusic(); // must be at the end. |
| 769 | } |
| 770 | catch (CRecoverableError &error) |
| 771 | { |
| 772 | if (error.GetMessage ()) |
| 773 | { |
| 774 | Printf (PRINT_BOLD, "\n%s\n", error.GetMessage()); |
| 775 | } |
| 776 | gi->ErrorCleanup(); |
| 777 | M_ClearMenus(); |
| 778 | C_FullConsole(); |
| 779 | gameaction = ga_nothing; |
| 780 | } |
| 781 | catch (CVMAbortException &error) |
| 782 | { |
| 783 | error.MaybePrintMessage(); |
| 784 | Printf("%s", error.stacktrace.GetChars()); |
no test coverage detected