| 689 | } |
| 690 | |
| 691 | GameStatus DoGameLoop(int levelIndex) |
| 692 | { |
| 693 | int frameCount = LOOP_FRAME_COUNT; |
| 694 | auto& status = g_GameFlow->LastGameStatus; |
| 695 | |
| 696 | // Before entering actual game loop, GamePhase() must be called once to sort out |
| 697 | // various runtime shenanigangs (e.g. hair or freeze mode initialization). |
| 698 | status = GamePhase(false); |
| 699 | |
| 700 | g_Synchronizer.Init(); |
| 701 | bool legacy30FpsDoneDraw = false; |
| 702 | |
| 703 | while (DoTheGame) |
| 704 | { |
| 705 | g_Synchronizer.Sync(); |
| 706 | |
| 707 | if (g_VideoPlayer.Update()) |
| 708 | continue; |
| 709 | |
| 710 | while (g_Synchronizer.Synced()) |
| 711 | { |
| 712 | status = ControlPhase(false); |
| 713 | g_Synchronizer.Step(); |
| 714 | |
| 715 | legacy30FpsDoneDraw = false; |
| 716 | } |
| 717 | |
| 718 | if (g_VideoPlayer.IsBackgroundPlaybackQueued()) |
| 719 | continue; |
| 720 | |
| 721 | if (status != GameStatus::Normal) |
| 722 | break; |
| 723 | |
| 724 | if (g_GameFlow->LastFreezeMode != g_GameFlow->CurrentFreezeMode) |
| 725 | continue; |
| 726 | |
| 727 | if (!g_Configuration.EnableHighFramerate) |
| 728 | { |
| 729 | if (!legacy30FpsDoneDraw) |
| 730 | { |
| 731 | DrawPhase(!levelIndex, 0.0f); |
| 732 | legacy30FpsDoneDraw = true; |
| 733 | } |
| 734 | } |
| 735 | else |
| 736 | { |
| 737 | DrawPhase(!levelIndex, g_Synchronizer.GetInterpolationFactor()); |
| 738 | } |
| 739 | } |
| 740 | |
| 741 | EndGameLoop(levelIndex, DoTheGame ? status : GameStatus::ExitGame); |
| 742 | |
| 743 | return status; |
| 744 | } |
| 745 | |
| 746 | void EndGameLoop(int levelIndex, GameStatus reason) |
| 747 | { |
no test coverage detected