- 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,
false);
}
if (controller) controller->mEndGame = false;
return controller;
}
@ -936,14 +935,11 @@ DIntermissionController* FLevelLocals::CreateIntermission()
}
}
}
if (controller) controller->mEndGame = endgame;
return controller;
}
void RunIntermission(DIntermissionController* intermissionScreen, DObject* statusScreen, std::function<void(bool)> completionf)
{
D_StartTitle();
if (!intermissionScreen && !statusScreen)
{
completionf(false);
@ -1014,12 +1010,12 @@ void G_DoCompleted (void)
statusScreen = WI_Start (&staticWmInfo);
}
bool endgame = intermissionScreen && intermissionScreen->mEndGame;
bool endgame = strncmp(nextlevel, "enDSeQ", 6) == 0;
intermissionScreen = primaryLevel->CreateIntermission();
RunIntermission(intermissionScreen, statusScreen, [=](bool)
{
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;
mDeleteDesc = DeleteDesc;
@ -843,6 +843,7 @@ DIntermissionController::DIntermissionController(FIntermissionDescriptor *Desc,
mSentAdvance = false;
mScreen = nullptr;
mFirst = true;
mEndGame = ending;
}
bool DIntermissionController::NextPage ()
@ -852,8 +853,8 @@ bool DIntermissionController::NextPage ()
if (mIndex == (int)mDesc->mActions.Size() && mDesc->mLink == NAME_None)
{
// last page
return false;
// last page (must block when ending the game.)
return mEndGame;
}
bg.SetInvalid();
@ -872,7 +873,7 @@ again:
}
else if (action->mClass == TITLE_ID)
{
continue;
return false;
}
else
{
@ -950,7 +951,7 @@ bool DIntermissionController::Ticker ()
mAdvance = false;
if (!NextPage())
{
return false;
return !false;
}
}
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);
S_StopAllChannels ();
gameaction = ga_nothing;
gamestate = GS_FINALE;
//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 (!CurrentIntermission->NextPage())

View file

@ -301,7 +301,7 @@ class DIntermissionController : public DObject
public:
bool mEndGame;
DIntermissionController(FIntermissionDescriptor *mDesc = NULL, bool mDeleteDesc = false);
DIntermissionController(FIntermissionDescriptor *mDesc = NULL, bool mDeleteDesc = false, bool ending = false);
bool Responder (FInputEvent *ev);
bool Ticker ();
void Drawer ();
@ -313,7 +313,7 @@ public:
// 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);
// 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);
}
return F_StartIntermission(desc, true);
return F_StartIntermission(desc, true, ending && endsequence != NAME_None);
}
else if (ending)
{
FIntermissionDescriptor **pdesc = IntermissionDescriptors.CheckKey(endsequence);
if (pdesc != NULL)
{
return F_StartIntermission(*pdesc, false);
return F_StartIntermission(*pdesc, false, ending);
}
}
return nullptr;

View file

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