shithub: choc

Download patch

ref: 1c78ab7f5f69f49114a150d28c0c7506b14198f1
parent: e80490d431d940f1e549c3a0426a5815d0be4dbf
author: Simon Howard <fraggle@gmail.com>
date: Mon May 18 14:30:49 EDT 2009

Fix A_BossDeath behavior in v1.9 emulation mode (thanks entryway)

Subversion-branch: /trunk/chocolate-doom
Subversion-revision: 1525

--- a/src/p_enemy.c
+++ b/src/p_enemy.c
@@ -1612,7 +1612,58 @@
     P_RadiusAttack(thingy, thingy->target, 128);
 }
 
+// Check whether the death of the specified monster type is allowed
+// to trigger the end of episode special action.
+//
+// This behavior changed in v1.9, the most notable effect of which
+// was to break uac_dead.wad
 
+static boolean CheckBossEnd(mobjtype_t motype)
+{
+    if (gameversion < exe_ultimate)
+    {
+        if (gamemap != 8)
+        {
+            return false;
+        }
+
+        // Baron death on later episodes is nothing special.
+
+        if (motype == MT_BRUISER && gameepisode != 1)
+        {
+            return false;
+        }
+
+        return true;
+    }
+    else
+    {
+        // New logic that appeared in Ultimate Doom.
+        // Looks like the logic was overhauled while adding in the
+        // episode 4 support.  Now bosses only trigger on their
+        // specific episode.
+
+	switch(gameepisode)
+	{
+            case 1:
+                return gamemap == 8 && motype == MT_BRUISER;
+
+            case 2:
+                return gamemap == 8 && motype == MT_CYBORG;
+
+            case 3:
+                return gamemap == 8 && motype == MT_SPIDER;
+
+	    case 4:
+                return (gamemap == 6 && motype == MT_CYBORG)
+                    || (gamemap == 8 && motype == MT_SPIDER);
+
+            default:
+                return gamemap == 8;
+	}
+    }
+}
+
 //
 // A_BossDeath
 // Possibly trigger special effects
@@ -1636,75 +1687,12 @@
     }
     else
     {
-	switch(gameepisode)
-	{
-	  case 1:
-	    if (gamemap != 8)
-		return;
-
-            // fraggle: disable this as it breaks uac_dead.wad.
-            // There is at least one version of Doom 1.9 which it is
-            // possible to play uac_dead through on.  I think this was
-            // added here for Ultimate Doom.
-            //
-            // See lmps/doom/ultimate/uac_dead.zip in idgames for
-            // an example of a demo which goes out of sync if this
-            // is left in here.
-            //
-            // For the time being, I'm making the assumption that 
-            // doing this is not going to break anything else.
-            //
-            // 2005/10/24: Modify this to test the gameversion setting
-
-            if (gameversion >= exe_ultimate && mo->type != MT_BRUISER)
-                return;
-	    break;
-	    
-	  case 2:
-	    if (gamemap != 8)
-		return;
-
-	    if (mo->type != MT_CYBORG)
-		return;
-	    break;
-	    
-	  case 3:
-	    if (gamemap != 8)
-		return;
-	    
-	    if (mo->type != MT_SPIDER)
-		return;
-	    
-	    break;
-	    
-	  case 4:
-	    switch(gamemap)
-	    {
-	      case 6:
-		if (mo->type != MT_CYBORG)
-		    return;
-		break;
-		
-	      case 8: 
-		if (mo->type != MT_SPIDER)
-		    return;
-		break;
-		
-	      default:
-		return;
-		break;
-	    }
-	    break;
-	    
-	  default:
-	    if (gamemap != 8)
-		return;
-	    break;
-	}
-		
+        if (!CheckBossEnd(mo->type))
+        {
+            return;
+        }
     }
 
-    
     // make sure there is a player alive for victory
     for (i=0 ; i<MAXPLAYERS ; i++)
 	if (playeringame[i] && players[i].health > 0)