From 59700406729fb35c802dbe9791dfcf335d5cdda6 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 18 Feb 2019 00:43:40 +0100 Subject: [PATCH] - fixed: The wbstartstruct that gets passed to the level summary screen needs to be static This variable is needed long after the function which sets it up will be exited. So this either needs to be dynamically allocated or static, and in this case using a static variable is simpler. However, unlike before, it is only being accessed in the one function that needs to initialize it and pass to the summary screen and nowhere else. --- src/g_level.cpp | 16 +++++++++++----- src/wi_stuff.h | 1 + 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/g_level.cpp b/src/g_level.cpp index d86618ebeb..8d30c05385 100644 --- a/src/g_level.cpp +++ b/src/g_level.cpp @@ -754,6 +754,7 @@ void FLevelLocals::SecretExitLevel (int position) // // //========================================================================== +static wbstartstruct_t staticWmInfo; void G_DoCompleted (void) { @@ -780,9 +781,7 @@ void G_DoCompleted (void) // Close the conversation menu if open. P_FreeStrifeConversations (); - wbstartstruct_t wminfo; // parms for world map / intermission - - if (primaryLevel->DoCompleted(nextlevel, wminfo)) + if (primaryLevel->DoCompleted(nextlevel, staticWmInfo)) { gamestate = GS_INTERMISSION; viewactive = false; @@ -792,10 +791,16 @@ void G_DoCompleted (void) // if (statcopy) // memcpy (statcopy, &wminfo, sizeof(wminfo)); - WI_Start (&wminfo); + WI_Start (&staticWmInfo); } } +//========================================================================== +// +// Prepare the level to be exited and +// set up the wminfo struct for the coming intermission screen +// +//========================================================================== bool FLevelLocals::DoCompleted (FString nextlevel, wbstartstruct_t &wminfo) { @@ -817,6 +822,7 @@ bool FLevelLocals::DoCompleted (FString nextlevel, wbstartstruct_t &wminfo) { wminfo.next = MapName; wminfo.LName1 = wminfo.LName0; + wminfo.nextname = wminfo.thisname; } else { @@ -831,7 +837,7 @@ bool FLevelLocals::DoCompleted (FString nextlevel, wbstartstruct_t &wminfo) { wminfo.next = nextinfo->MapName; wminfo.LName1 = TexMan.CheckForTexture(nextinfo->PName, ETextureType::MiscPatch); - wminfo.nextname = info->LookupLevelName(&langtable[1]); + wminfo.nextname = nextinfo->LookupLevelName(&langtable[1]); } } diff --git a/src/wi_stuff.h b/src/wi_stuff.h index 6f06037811..3ff4828b1b 100644 --- a/src/wi_stuff.h +++ b/src/wi_stuff.h @@ -76,6 +76,7 @@ struct wbstartstruct_t int pnum; wbplayerstruct_t plyr[MAXPLAYERS]; + }; // Intermission stats.