shithub: choc

Download patch

ref: 6d773dce144d7037ae207d16ef98dab794b5cf3c
parent: 9eae89d3eb668df2ea218f3944d12996e3364000
author: James Canete <SmileTheory@gmail.com>
date: Mon Oct 14 00:03:03 EDT 2019

Detect v1.0/v1.1 IWADs.

--- a/src/d_mode.h
+++ b/src/d_mode.h
@@ -56,7 +56,8 @@
 
 typedef enum
 {
-    exe_doom_1_2,    // Doom 1.2: shareware and registered
+    exe_doom_1_1,    // Doom 1.0/1.1: shareware and registered
+    exe_doom_1_2,    // Doom 1.2: "
     exe_doom_1_666,  // Doom 1.666: for shareware, registered and commercial
     exe_doom_1_7,    // Doom 1.7/1.7a: "
     exe_doom_1_8,    // Doom 1.8: "
--- a/src/doom/d_main.c
+++ b/src/doom/d_main.c
@@ -959,6 +959,8 @@
     const char *cmdline;
     GameVersion_t version;
 } gameversions[] = {
+    {"Doom 1.0/1.1",         "1.1",        exe_doom_1_1},
+    {"Doom 1.2",             "1.2",        exe_doom_1_2},
     {"Doom 1.666",           "1.666",      exe_doom_1_666},
     {"Doom 1.7/1.7a",        "1.7",        exe_doom_1_7},
     {"Doom 1.8",             "1.8",        exe_doom_1_8},
@@ -986,9 +988,9 @@
     // @arg <version>
     // @category compat
     //
-    // Emulate a specific version of Doom.  Valid values are "1.666",
-    // "1.7", "1.8", "1.9", "ultimate", "final", "final2", "hacx" and
-    // "chex".
+    // Emulate a specific version of Doom.  Valid values are "1.1", "1.2", 
+    // "1.666", "1.7", "1.8", "1.9", "ultimate", "final", "final2", "hacx"
+    // and "chex".
     //
 
     p = M_CheckParmWithArgs("-gameversion", 1);
@@ -1079,6 +1081,12 @@
                         break;
                     }
                 }
+            }
+
+            // detect v1.0/v1.1 from missing D_INTROA
+            if (gameversion == exe_doom_1_2 && W_CheckNumForName("D_INTROA") < 0)
+            {
+                gameversion = exe_doom_1_1;
             }
         }
         else if (gamemode == retail)
--- a/src/doom/g_game.c
+++ b/src/doom/g_game.c
@@ -2052,6 +2052,8 @@
 {
     switch (gameversion)
     {
+        case exe_doom_1_1:
+            return 101;
         case exe_doom_1_2:
             return 102;
         case exe_doom_1_666:
@@ -2088,7 +2090,7 @@
     {
         *demo_p++ = DOOM_191_VERSION;
     }
-    else if (gameversion != exe_doom_1_2)
+    else if (gameversion > exe_doom_1_2)
     {
         *demo_p++ = G_VanillaVersionCode();
     }
@@ -2096,7 +2098,7 @@
     *demo_p++ = gameskill; 
     *demo_p++ = gameepisode; 
     *demo_p++ = gamemap; 
-    if (longtics || gameversion != exe_doom_1_2)
+    if (longtics || gameversion > exe_doom_1_2)
     {
         *demo_p++ = deathmatch; 
         *demo_p++ = respawnparm;
@@ -2130,6 +2132,10 @@
 
     switch (version)
     {
+        case 101:
+            return "v1.0/v1.1";
+        case 102:
+            return "v1.2";
         case 104:
             return "v1.4";
         case 105:
@@ -2151,7 +2157,7 @@
     // Unknown version.  Perhaps this is a pre-v1.4 IWAD?  If the version
     // byte is in the range 0-4 then it can be a v1.0-v1.2 demo.
 
-    if (version == 102 || (version >= 0 && version <= 4))
+    if (version >= 0 && version <= 4)
     {
         return "v1.0/v1.1/v1.2";
     }
@@ -2176,9 +2182,11 @@
 
     demoversion = *demo_p++;
 
-    if (demoversion < 102)
+    if (demoversion >= 0 && demoversion <= 4)
     {
-        demoversion = 102;
+        if (gameversion <= exe_doom_1_2)
+            demoversion = G_VanillaVersionCode();
+        
         demo_p--;
     }
 
@@ -2209,7 +2217,7 @@
     skill = *demo_p++; 
     episode = *demo_p++; 
     map = *demo_p++; 
-    if (demoversion != 102)
+    if (demoversion > 102)
     {
         deathmatch = *demo_p++;
         respawnparm = *demo_p++;
--- a/src/doom/p_enemy.c
+++ b/src/doom/p_enemy.c
@@ -176,7 +176,7 @@
     pl = actor->target;
     dist = P_AproxDistance (pl->x-actor->x, pl->y-actor->y);
 
-    if (gameversion == exe_doom_1_2)
+    if (gameversion <= exe_doom_1_2)
         range = MELEERANGE;
     else
         range = MELEERANGE-20*FRACUNIT+pl->info->radius;
@@ -672,7 +672,7 @@
     // modify target threshold
     if  (actor->threshold)
     {
-        if (gameversion != exe_doom_1_2 && 
+        if (gameversion > exe_doom_1_2 && 
             (!actor->target || actor->target->health <= 0))
 	{
 	    actor->threshold = 0;
@@ -933,7 +933,7 @@
 		
     A_FaceTarget (actor);
 
-    if (gameversion != exe_doom_1_2)
+    if (gameversion > exe_doom_1_2)
     {
         if (!P_CheckMeleeRange (actor))
             return;
@@ -941,7 +941,7 @@
 
     damage = ((P_Random()%10)+1)*4;
 
-    if (gameversion == exe_doom_1_2)
+    if (gameversion <= exe_doom_1_2)
         P_LineAttack(actor, actor->angle, MELEERANGE, 0, damage);
     else
         P_DamageMobj (actor->target, actor, actor, damage);
--- a/src/doom/p_floor.c
+++ b/src/doom/p_floor.c
@@ -303,7 +303,7 @@
 	    floor->speed = FLOORSPEED * 4;
 	    floor->floordestheight = 
 		P_FindHighestFloorSurrounding(sec);
-	    if (gameversion == exe_doom_1_2 ||
+	    if (gameversion <= exe_doom_1_2 ||
 	        floor->floordestheight != sec->floorheight)
 		floor->floordestheight += 8*FRACUNIT;
 	    break;
--- a/src/doom/p_inter.c
+++ b/src/doom/p_inter.c
@@ -382,7 +382,7 @@
 	
       case SPR_BON2:
 	player->armorpoints++;		// can go over 100%
-	if (player->armorpoints > deh_max_armor && gameversion != exe_doom_1_2)
+	if (player->armorpoints > deh_max_armor && gameversion > exe_doom_1_2)
 	    player->armorpoints = deh_max_armor;
         // deh_green_armor_class only applies to the green armor shirt;
         // for the armor helmets, armortype 1 is always used.
@@ -907,7 +907,7 @@
     target->reactiontime = 0;		// we're awake now...	
 
     if ( (!target->threshold || target->type == MT_VILE)
-	 && source && (source != target || gameversion == exe_doom_1_2)
+	 && source && (source != target || gameversion <= exe_doom_1_2)
 	 && source->type != MT_VILE)
     {
 	// if not intent on another player,
--- a/src/doom/p_map.c
+++ b/src/doom/p_map.c
@@ -1317,7 +1317,7 @@
     {
 	P_SetMobjState (thing, S_GIBS);
 
-    if (gameversion != exe_doom_1_2)
+    if (gameversion > exe_doom_1_2)
 	    thing->flags &= ~MF_SOLID;
 	thing->height = 0;
 	thing->radius = 0;
--- a/src/doom/p_sight.c
+++ b/src/doom/p_sight.c
@@ -375,7 +375,7 @@
     topslope = (t2->z+t2->height) - sightzstart;
     bottomslope = (t2->z) - sightzstart;
 	
-    if (gameversion == exe_doom_1_2)
+    if (gameversion <= exe_doom_1_2)
     {
         return P_PathTraverse(t1->x, t1->y, t2->x, t2->y,
                               PT_EARLYOUT | PT_ADDLINES, PTR_SightTraverse);
--- a/src/doom/p_spec.c
+++ b/src/doom/p_spec.c
@@ -509,7 +509,7 @@
 
     line = &lines[linenum];
     
-    if (gameversion == exe_doom_1_2)
+    if (gameversion <= exe_doom_1_2)
     {
         if (line->special > 98 && line->special != 104)
         {
--- a/src/doom/s_sound.c
+++ b/src/doom/s_sound.c
@@ -446,7 +446,7 @@
     }
 
     // substitute missing sounds in Doom 1.2
-    if (gameversion == exe_doom_1_2)
+    if (gameversion <= exe_doom_1_2)
     {
         switch(sfx_id)
         {
@@ -696,7 +696,7 @@
 
     if (musicnum == mus_intro && (snd_musicdevice == SNDDEVICE_ADLIB
                                || snd_musicdevice == SNDDEVICE_SB)
-        && W_CheckNumForName("D_INTROA") > 0)
+        && gameversion >= exe_doom_1_2)
     {
         musicnum = mus_introa;
     }
--- a/src/doom/st_stuff.c
+++ b/src/doom/st_stuff.c
@@ -1149,7 +1149,7 @@
     callback(namebuf, &faceback);
 
     // status bar background bits
-    if (W_CheckNumForName(DEH_String("STBAR")) > 0)
+    if (gameversion >= exe_doom_1_2)
     {
         callback(DEH_String("STBAR"), &sbar);
         sbarr = NULL;