Boss level ending not triggered if every player is dead

In a multiplayer game with monsters, killing the episode's final boss will end the level and a text screen will be displayed. The level's ending is normally triggered after the boss's death animation has completed.

Due to a bug, the ending will not be triggered if every player is dead while the boss's death animation finishes. Although this is normal in single player, in multiplayer the players are able to respawn. So, as a result, they remain stuck on the level. There is no way to restart the level unlike when in single player mode, where this happens when the player dies.

This bug does not affect the final boss found in Doom II: Hell on Earth, TNT: Evilution and The Plutonia Experiment. It also does not act as a soft lock condition in "Nightmare!" skill level or with use of the command line parameter.

Technical details
The code that handles the effects of a boss' death is found the file inside the function.

The relevant code is the following:

// make sure there is a player alive for victory for (i=0 ; i 0) break; if (i==MAXPLAYERS) return;	// no one left alive, so do not end game

This code cycles through every player and checks if they have health remaining. If at least one player is alive, the loop will break and the last condition shown here will not be met. In the other case, the function will return and the remaining portion of the function which calls will never be executed.

This logic would work correctly if the function was called repetitively after the boss is dead. It would also make sense if the players did not have the ability to respawn and if the level restarted once every player was dead. This behavior was probably coded before the ability to respawn was added into the game.