shithub: choc

Download patch

ref: 63e1c884911f9e3382936f84a388e941b29343e6
parent: 16eb65970747541102beb0b8343b158a740c75d0
author: Simon Howard <[email protected]>
date: Tue Oct 7 20:52:03 EDT 2014

Allow -warp to episodes beyond episode 4.

Vanilla Doom's -warp parameter allows warping to episodes beyond E4.
This didn't work in Chocolate Doom because of some changes made
to the G_InitNew code before the source release. Actual decompilation
of that function in Vanilla Doom shows that the episode/map sanity
checking is not present:

http://pastie.org/8140437

There is at least one known WAD (2002ado) that has a map on E5M1
that is playable in Vanilla, and this stops that map from being
possible to play. Comment out that code because it obviously
doesn't deserve to be there.

This fixes #426. Thanks plumsinus.

--- a/src/doom/g_game.c
+++ b/src/doom/g_game.c
@@ -1683,27 +1683,32 @@
 G_InitNew
 ( skill_t	skill,
   int		episode,
-  int		map ) 
-{ 
+  int		map )
+{
     char *skytexturename;
-    int             i; 
-	 
-    if (paused) 
-    { 
-	paused = false; 
-	S_ResumeSound (); 
-    } 
-	
+    int             i;
 
-    if (skill > sk_nightmare) 
-	skill = sk_nightmare;
+    if (paused)
+    {
+	paused = false;
+	S_ResumeSound ();
+    }
 
+    /*
+    // Note: This commented-out block of code was added at some point
+    // between the DOS version(s) and the Doom source release. It isn't
+    // found in disassemblies of the DOS version and causes IDCLEV and
+    // the -warp command line parameter to behave differently.
+    // This is left here for posterity.
 
+    if (skill > sk_nightmare)
+	skill = sk_nightmare;
+
     // This was quite messy with SPECIAL and commented parts.
     // Supposedly hacks to make the latest edition work.
     // It might not work properly.
     if (episode < 1)
-      episode = 1; 
+      episode = 1;
 
     if ( gamemode == retail )
     {
@@ -1712,64 +1717,62 @@
     }
     else if ( gamemode == shareware )
     {
-      if (episode > 1) 
+      if (episode > 1)
 	   episode = 1;	// only start episode 1 on shareware
-    }  
+    }
     else
     {
       if (episode > 3)
 	episode = 3;
     }
-    
+    */
 
-  
-    if (map < 1) 
+    if (map < 1)
 	map = 1;
-    
+
     if ( (map > 9)
 	 && ( gamemode != commercial) )
-      map = 9; 
-		 
-    M_ClearRandom (); 
-	 
+      map = 9;
+
+    M_ClearRandom ();
+
     if (skill == sk_nightmare || respawnparm )
 	respawnmonsters = true;
     else
 	respawnmonsters = false;
-		
+
     if (fastparm || (skill == sk_nightmare && gameskill != sk_nightmare) )
-    { 
-	for (i=S_SARG_RUN1 ; i<=S_SARG_PAIN2 ; i++) 
-	    states[i].tics >>= 1; 
-	mobjinfo[MT_BRUISERSHOT].speed = 20*FRACUNIT; 
-	mobjinfo[MT_HEADSHOT].speed = 20*FRACUNIT; 
-	mobjinfo[MT_TROOPSHOT].speed = 20*FRACUNIT; 
-    } 
-    else if (skill != sk_nightmare && gameskill == sk_nightmare) 
-    { 
-	for (i=S_SARG_RUN1 ; i<=S_SARG_PAIN2 ; i++) 
-	    states[i].tics <<= 1; 
-	mobjinfo[MT_BRUISERSHOT].speed = 15*FRACUNIT; 
-	mobjinfo[MT_HEADSHOT].speed = 10*FRACUNIT; 
-	mobjinfo[MT_TROOPSHOT].speed = 10*FRACUNIT; 
-    } 
-	 
-			 
-    // force players to be initialized upon first level load         
-    for (i=0 ; i<MAXPLAYERS ; i++) 
-	players[i].playerstate = PST_REBORN; 
- 
-    usergame = true;                // will be set false if a demo 
-    paused = false; 
-    demoplayback = false; 
-    automapactive = false; 
-    viewactive = true; 
-    gameepisode = episode; 
-    gamemap = map; 
-    gameskill = skill; 
- 
+    {
+	for (i=S_SARG_RUN1 ; i<=S_SARG_PAIN2 ; i++)
+	    states[i].tics >>= 1;
+	mobjinfo[MT_BRUISERSHOT].speed = 20*FRACUNIT;
+	mobjinfo[MT_HEADSHOT].speed = 20*FRACUNIT;
+	mobjinfo[MT_TROOPSHOT].speed = 20*FRACUNIT;
+    }
+    else if (skill != sk_nightmare && gameskill == sk_nightmare)
+    {
+	for (i=S_SARG_RUN1 ; i<=S_SARG_PAIN2 ; i++)
+	    states[i].tics <<= 1;
+	mobjinfo[MT_BRUISERSHOT].speed = 15*FRACUNIT;
+	mobjinfo[MT_HEADSHOT].speed = 10*FRACUNIT;
+	mobjinfo[MT_TROOPSHOT].speed = 10*FRACUNIT;
+    }
+
+    // force players to be initialized upon first level load
+    for (i=0 ; i<MAXPLAYERS ; i++)
+	players[i].playerstate = PST_REBORN;
+
+    usergame = true;                // will be set false if a demo
+    paused = false;
+    demoplayback = false;
+    automapactive = false;
     viewactive = true;
+    gameepisode = episode;
+    gamemap = map;
+    gameskill = skill;
 
+    viewactive = true;
+
     // Set the sky to use.
     //
     // Note: This IS broken, but it is how Vanilla Doom behaves.
@@ -1791,22 +1794,22 @@
     }
     else
     {
-        switch (gameepisode) 
-        { 
+        switch (gameepisode)
+        {
           default:
-          case 1: 
-            skytexturename = "SKY1"; 
-            break; 
-          case 2: 
-            skytexturename = "SKY2"; 
-            break; 
-          case 3: 
-            skytexturename = "SKY3"; 
-            break; 
+          case 1:
+            skytexturename = "SKY1";
+            break;
+          case 2:
+            skytexturename = "SKY2";
+            break;
+          case 3:
+            skytexturename = "SKY3";
+            break;
           case 4:        // Special Edition sky
             skytexturename = "SKY4";
             break;
-        } 
+        }
     }
 
     skytexturename = DEH_String(skytexturename);
@@ -1813,10 +1816,10 @@
 
     skytexture = R_TextureNumForName(skytexturename);
 
-    
-    G_DoLoadLevel (); 
-} 
- 
+
+    G_DoLoadLevel ();
+}
+
 
 //
 // DEMO RECORDING