From cddd5d3a4c7cdf5c2aad1644b481f82ded821100 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 11 Sep 2020 20:56:46 +0200 Subject: [PATCH] - Exhumed: added a white flash and fixed the accompanying sound when exiting a level. See #375 --- source/exhumed/src/exhumed.cpp | 34 +++++++++++++++++++++++++++------ source/exhumed/src/exhumed.h | 1 + source/exhumed/src/gameloop.cpp | 18 ++--------------- source/exhumed/src/object.cpp | 2 +- source/exhumed/src/player.cpp | 4 ++-- 5 files changed, 34 insertions(+), 25 deletions(-) diff --git a/source/exhumed/src/exhumed.cpp b/source/exhumed/src/exhumed.cpp index 9e68cf9c5..d7305f852 100644 --- a/source/exhumed/src/exhumed.cpp +++ b/source/exhumed/src/exhumed.cpp @@ -54,6 +54,7 @@ extern short bPlayerPan; extern short bLockPan; +static MapRecord* NextMap; void uploadCinemaPalettes(); int32_t registerosdcommands(void); @@ -457,16 +458,32 @@ void GameInterface::Ticker() else { // Wait for the end of level sound to play out, but stop updating the playsim. - EndLevel--; + if (EndLevel == 13) + PlayLocalSound(StaticSound[59], 0, true, CHANF_UI); + + if (EndLevel > 1) EndLevel--; r_NoInterpolate = false; - if (EndLevel == 0) - { - auto map = currentLevel->levelNumber == 20? nullptr : FindMapByLevelNum(currentLevel->levelNumber+1); // todo: Use the map record for progression - CompleteLevel(map); - } + int flash = 7 - abs(EndLevel - 7); + videoTintBlood(flash * 30, flash * 30, flash * 30); + if (EndLevel == 1) + { + if (!soundEngine->GetSoundPlayingInfo(SOURCE_None, nullptr, StaticSound[59] + 1)) + { + videoTintBlood(0, 0, 0); + CompleteLevel(NextMap); + NextMap = nullptr; + EndLevel = 0; + } + } } } +void LevelFinished() +{ + NextMap = currentLevel->levelNumber == 20 ? nullptr : FindMapByLevelNum(currentLevel->levelNumber + 1); // todo: Use the map record for progression + EndLevel = 13; +} + void ExitGame() { ShutDown(); @@ -682,4 +699,9 @@ void LoadTextureState() TileFiles.InvalidateTile(kEnergy2); } + +CCMD(endit) +{ + LevelFinished(); +} END_PS_NS diff --git a/source/exhumed/src/exhumed.h b/source/exhumed/src/exhumed.h index cc8574e1d..d4a5113ba 100644 --- a/source/exhumed/src/exhumed.h +++ b/source/exhumed/src/exhumed.h @@ -206,6 +206,7 @@ extern char g_modDir[BMAX_PATH]; void G_LoadGroupsInDir(const char* dirname); void G_DoAutoload(const char* dirname); void DrawRel(int tile, double x, double y, int shade = 0); +void LevelFinished(); // savegame. diff --git a/source/exhumed/src/gameloop.cpp b/source/exhumed/src/gameloop.cpp index 3c449ad16..dd73b7ab3 100644 --- a/source/exhumed/src/gameloop.cpp +++ b/source/exhumed/src/gameloop.cpp @@ -68,22 +68,8 @@ static void FinishLevel(int lnum, TArray &jobs) automapMode = am_off; STAT_Update(lnum == kMap20); - if (lnum != kMap20) - { - if (EndLevel == 13 && !netgame) - { - // There's really no choice but to enter an active wait loop here to make the sound play out. - PlayLocalSound(StaticSound[59], 0, true, CHANF_UI); - int nTicks = I_msTime() + 100; - while (nTicks > I_msTime()) - { - I_GetEvent(); - soundEngine->UpdateSounds(I_GetTime()); - } - Net_ClearFifo(); - } - } - else nPlayerLives[0] = 0; + if (lnum == kMap20) + nPlayerLives[0] = 0; DoAfterCinemaScene(lnum-1, jobs); } diff --git a/source/exhumed/src/object.cpp b/source/exhumed/src/object.cpp index f1aed4cb4..b058f1b71 100644 --- a/source/exhumed/src/object.cpp +++ b/source/exhumed/src/object.cpp @@ -1544,7 +1544,7 @@ void DoFinale() } else if (nFinaleStage == 3 && leveltime*4 >= nextstage) { - EndLevel = 13; + LevelFinished(); } } else diff --git a/source/exhumed/src/player.cpp b/source/exhumed/src/player.cpp index d2b050d1b..f13651971 100644 --- a/source/exhumed/src/player.cpp +++ b/source/exhumed/src/player.cpp @@ -1068,7 +1068,7 @@ void FuncPlayer(int a, int nDamage, int nRun) } else { - EndLevel = 13; + LevelFinished(); } return; @@ -2469,7 +2469,7 @@ do_default_b: { if (!bInDemo) { - EndLevel = 13; + LevelFinished(); } DestroyItemAnim(nValB);