- proper handling for running an end-of-game intermission.

This commit is contained in:
Christoph Oelckers 2022-04-26 19:26:36 +02:00
parent ce59b47e93
commit 9b0b44d83b
5 changed files with 16 additions and 20 deletions

View file

@ -904,7 +904,6 @@ DIntermissionController* FLevelLocals::CreateIntermission()
ext->mDefined & FExitText::DEF_LOOKUP, ext->mDefined & FExitText::DEF_LOOKUP,
false); false);
} }
if (controller) controller->mEndGame = false;
return controller; return controller;
} }
@ -936,14 +935,11 @@ DIntermissionController* FLevelLocals::CreateIntermission()
} }
} }
} }
if (controller) controller->mEndGame = endgame;
return controller; return controller;
} }
void RunIntermission(DIntermissionController* intermissionScreen, DObject* statusScreen, std::function<void(bool)> completionf) void RunIntermission(DIntermissionController* intermissionScreen, DObject* statusScreen, std::function<void(bool)> completionf)
{ {
D_StartTitle();
if (!intermissionScreen && !statusScreen) if (!intermissionScreen && !statusScreen)
{ {
completionf(false); completionf(false);
@ -1014,12 +1010,12 @@ void G_DoCompleted (void)
statusScreen = WI_Start (&staticWmInfo); statusScreen = WI_Start (&staticWmInfo);
} }
bool endgame = intermissionScreen && intermissionScreen->mEndGame; bool endgame = strncmp(nextlevel, "enDSeQ", 6) == 0;
intermissionScreen = primaryLevel->CreateIntermission(); intermissionScreen = primaryLevel->CreateIntermission();
RunIntermission(intermissionScreen, statusScreen, [=](bool) RunIntermission(intermissionScreen, statusScreen, [=](bool)
{ {
if (!endgame) primaryLevel->WorldDone(); if (!endgame) primaryLevel->WorldDone();
else if (!intermissionScreen) D_StartTitle(); else D_StartTitle();
}); });
} }

View file

@ -834,7 +834,7 @@ void DIntermissionScreenScroller::Drawer ()
// //
//========================================================================== //==========================================================================
DIntermissionController::DIntermissionController(FIntermissionDescriptor *Desc, bool DeleteDesc) DIntermissionController::DIntermissionController(FIntermissionDescriptor *Desc, bool DeleteDesc, bool ending)
{ {
mDesc = Desc; mDesc = Desc;
mDeleteDesc = DeleteDesc; mDeleteDesc = DeleteDesc;
@ -843,6 +843,7 @@ DIntermissionController::DIntermissionController(FIntermissionDescriptor *Desc,
mSentAdvance = false; mSentAdvance = false;
mScreen = nullptr; mScreen = nullptr;
mFirst = true; mFirst = true;
mEndGame = ending;
} }
bool DIntermissionController::NextPage () bool DIntermissionController::NextPage ()
@ -852,8 +853,8 @@ bool DIntermissionController::NextPage ()
if (mIndex == (int)mDesc->mActions.Size() && mDesc->mLink == NAME_None) if (mIndex == (int)mDesc->mActions.Size() && mDesc->mLink == NAME_None)
{ {
// last page // last page (must block when ending the game.)
return false; return mEndGame;
} }
bg.SetInvalid(); bg.SetInvalid();
@ -872,7 +873,7 @@ again:
} }
else if (action->mClass == TITLE_ID) else if (action->mClass == TITLE_ID)
{ {
continue; return false;
} }
else else
{ {
@ -950,7 +951,7 @@ bool DIntermissionController::Ticker ()
mAdvance = false; mAdvance = false;
if (!NextPage()) if (!NextPage())
{ {
return false; return !false;
} }
} }
return true; return true;
@ -980,14 +981,14 @@ void DIntermissionController::OnDestroy ()
// //
//========================================================================== //==========================================================================
DIntermissionController* F_StartIntermission(FIntermissionDescriptor *desc, bool deleteme) DIntermissionController* F_StartIntermission(FIntermissionDescriptor *desc, bool deleteme, bool ending)
{ {
ScaleOverrider s(twod); ScaleOverrider s(twod);
S_StopAllChannels (); S_StopAllChannels ();
gameaction = ga_nothing; gameaction = ga_nothing;
gamestate = GS_FINALE; gamestate = GS_FINALE;
//if (state == FSTATE_InLevel) wipegamestate = GS_FINALE; // don't wipe when within a level. //if (state == FSTATE_InLevel) wipegamestate = GS_FINALE; // don't wipe when within a level.
auto CurrentIntermission = Create<DIntermissionController>(desc, deleteme); auto CurrentIntermission = Create<DIntermissionController>(desc, deleteme, ending);
// If the intermission finishes straight away then cancel the wipe. // If the intermission finishes straight away then cancel the wipe.
if (!CurrentIntermission->NextPage()) if (!CurrentIntermission->NextPage())

View file

@ -301,7 +301,7 @@ class DIntermissionController : public DObject
public: public:
bool mEndGame; bool mEndGame;
DIntermissionController(FIntermissionDescriptor *mDesc = NULL, bool mDeleteDesc = false); DIntermissionController(FIntermissionDescriptor *mDesc = NULL, bool mDeleteDesc = false, bool ending = false);
bool Responder (FInputEvent *ev); bool Responder (FInputEvent *ev);
bool Ticker (); bool Ticker ();
void Drawer (); void Drawer ();
@ -313,7 +313,7 @@ public:
// Interface for main loop // Interface for main loop
DIntermissionController* F_StartIntermission(FIntermissionDescriptor *desc, bool deleteme); DIntermissionController* F_StartIntermission(FIntermissionDescriptor *desc, bool deleteme, bool ending = false);
DIntermissionController* F_StartIntermission(FName desc); DIntermissionController* F_StartIntermission(FName desc);
// Create an intermission from old cluster data // Create an intermission from old cluster data

View file

@ -911,14 +911,14 @@ DIntermissionController* F_StartFinale (const char *music, int musicorder, int c
desc->mActions.Push(wiper); desc->mActions.Push(wiper);
} }
return F_StartIntermission(desc, true); return F_StartIntermission(desc, true, ending && endsequence != NAME_None);
} }
else if (ending) else if (ending)
{ {
FIntermissionDescriptor **pdesc = IntermissionDescriptors.CheckKey(endsequence); FIntermissionDescriptor **pdesc = IntermissionDescriptors.CheckKey(endsequence);
if (pdesc != NULL) if (pdesc != NULL)
{ {
return F_StartIntermission(*pdesc, false); return F_StartIntermission(*pdesc, false, ending);
} }
} }
return nullptr; return nullptr;

View file

@ -681,7 +681,6 @@ class StatusScreen : ScreenJob abstract version("2.5")
if (cnt == 0) if (cnt == 0)
{ {
End(); End();
Level.WorldDone();
} }
} }
@ -693,11 +692,11 @@ class StatusScreen : ScreenJob abstract version("2.5")
protected virtual void initShowNextLoc () protected virtual void initShowNextLoc ()
{ {
Console.Printf("Next m ap = %s", wbs.next);
if (wbs.next == "") if (wbs.next == "")
{ {
// Last map in episode - there is no next location! // Last map in episode - there is no next location!
End(); jobstate = finished;
Level.WorldDone();
return; return;
} }