Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stats: fix the game hanging if exited during the level stats, credits, or final stats #1777

Merged
merged 1 commit into from
Oct 31, 2024

Conversation

walkawayy
Copy link
Collaborator

@walkawayy walkawayy commented Oct 30, 2024

Checklist

  • I have read the coding conventions
  • I have added a changelog entry about what my pull request accomplishes, or it is an internal change

Description

Fix the game hanging if exited during the level stats, credits, or final stats.

The only caveat to this PR is that if you exit during the credit images (not the final stats), the game has to wait until the current credits picture timer ends before it will exit. I think this is due to the credit pictures being unskippable which is a separate issue. I hate to bug @rr-, but if we could get DisplayCredits decompiled, I think we could solve this delayed exit and unskippable credits in another PR. There is no rush on this though, so I don't mind marking this PR as draft until we have to time to decompile DisplayCredits.

@walkawayy walkawayy added OG bug A bug in original game TR2 labels Oct 30, 2024
@walkawayy walkawayy self-assigned this Oct 30, 2024
@walkawayy walkawayy requested review from a team as code owners October 30, 2024 01:15
@walkawayy walkawayy requested review from rr- and lahm86 and removed request for a team October 30, 2024 01:15
Copy link

github-actions bot commented Oct 30, 2024

@walkawayy walkawayy force-pushed the issue-1585-credits-exit branch from b8f5aa4 to 41988ba Compare October 30, 2024 01:17
@rr-
Copy link
Collaborator

rr- commented Oct 30, 2024

I can decompile the necessary functions after we merge #1768.

@rr-
Copy link
Collaborator

rr- commented Oct 30, 2024

@walkawayy actually you just need this:

diff --git a/src/tr2/decomp/decomp.c b/src/tr2/decomp/decomp.c
index 990a0e87..38cc00a3 100644
--- a/src/tr2/decomp/decomp.c
+++ b/src/tr2/decomp/decomp.c
@@ -560,7 +560,8 @@ void __cdecl Shell_Shutdown(void)
 {
     Console_Shutdown();
     WinInFinish();
-    RenderFinish(true);
+    BGND_Free();
+    RenderFinish(false);
     WinVidFinish();
     WinVidHideGameWindow();
     if (g_ErrorMessage[0]) {
@@ -3068,6 +3069,10 @@ void __cdecl S_Wait(int32_t frames, const BOOL input_check)
                 passed = Sync();
             } while (!passed);
             frames -= passed;
+
+            if (g_IsGameToExit) {
+                break;
+            }
         }
     }
 
@@ -3077,6 +3082,10 @@ void __cdecl S_Wait(int32_t frames, const BOOL input_check)
             break;
         }
 
+        if (g_IsGameToExit) {
+            break;
+        }
+
         int32_t passed;
         do {
             passed = Sync();

@walkawayy walkawayy force-pushed the issue-1585-credits-exit branch from 41988ba to 1a29a29 Compare October 30, 2024 21:22
@walkawayy walkawayy requested review from rr- and aredfan October 30, 2024 21:22
@walkawayy walkawayy linked an issue Oct 30, 2024 that may be closed by this pull request
Copy link
Collaborator

@lahm86 lahm86 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks for fixing, this was always an annoying bug.

@rr- rr- merged commit 11a7bad into LostArtefacts:develop Oct 31, 2024
6 checks passed
@walkawayy walkawayy deleted the issue-1585-credits-exit branch November 9, 2024 19:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OG bug A bug in original game TR2
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

OG bug: exiting during credits does not end process
4 participants