foxygit / doom Log in
commit 6d773dce144d7037ae207d16ef98dab794b5cf3c
Author:     James Canete <SmileTheory@gmail.com>
AuthorDate: Mon Oct 14 04:03:03 2019 -0700
Commit:     James Canete <SmileTheory@gmail.com>
CommitDate: Mon Oct 14 04:03:03 2019 -0700

    Detect v1.0/v1.1 IWADs.
---
 src/d_mode.h        |  3 ++-
 src/doom/d_main.c   | 14 +++++++++++---
 src/doom/g_game.c   | 20 ++++++++++++++------
 src/doom/p_enemy.c  |  8 ++++----
 src/doom/p_floor.c  |  2 +-
 src/doom/p_inter.c  |  4 ++--
 src/doom/p_map.c    |  2 +-
 src/doom/p_sight.c  |  2 +-
 src/doom/p_spec.c   |  2 +-
 src/doom/s_sound.c  |  4 ++--
 src/doom/st_stuff.c |  2 +-
 11 files changed, 40 insertions(+), 23 deletions(-)

diff --git a/src/d_mode.h b/src/d_mode.h
index 7822a44a..04d2fab0 100644
--- a/src/d_mode.h
+++ b/src/d_mode.h
@@ -56,7 +56,8 @@ typedef enum

 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: "
diff --git a/src/doom/d_main.c b/src/doom/d_main.c
index bf42575d..036037d5 100644
--- a/src/doom/d_main.c
+++ b/src/doom/d_main.c
@@ -959,6 +959,8 @@ static struct
     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 @@ static void InitGameVersion(void)
     // @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);
@@ -1080,6 +1082,12 @@ static void InitGameVersion(void)
                     }
                 }
             }
+
+            // 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)
         {
diff --git a/src/doom/g_game.c b/src/doom/g_game.c
index 4420f655..50e7e85b 100644
--- a/src/doom/g_game.c
+++ b/src/doom/g_game.c
@@ -2052,6 +2052,8 @@ int G_VanillaVersionCode(void)
 {
     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 @@ void G_BeginRecording (void)
     {
         *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 @@ void G_BeginRecording (void)
     *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 @@ static const char *DemoVersionDescription(int version)

     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 @@ static const char *DemoVersionDescription(int version)
     // 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 @@ void G_DoPlayDemo (void)

     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 @@ void G_DoPlayDemo (void)
     skill = *demo_p++;
     episode = *demo_p++;
     map = *demo_p++;
-    if (demoversion != 102)
+    if (demoversion > 102)
     {
         deathmatch = *demo_p++;
         respawnparm = *demo_p++;
diff --git a/src/doom/p_enemy.c b/src/doom/p_enemy.c
index ca395310..0207ff8c 100644
--- a/src/doom/p_enemy.c
+++ b/src/doom/p_enemy.c
@@ -176,7 +176,7 @@ boolean P_CheckMeleeRange (mobj_t*	actor)
     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 @@ void A_Chase (mobj_t*	actor)
     // 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 @@ void A_SargAttack (mobj_t* actor)

     A_FaceTarget (actor);

-    if (gameversion != exe_doom_1_2)
+    if (gameversion > exe_doom_1_2)
     {
         if (!P_CheckMeleeRange (actor))
             return;
@@ -941,7 +941,7 @@ void A_SargAttack (mobj_t* actor)

     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);
diff --git a/src/doom/p_floor.c b/src/doom/p_floor.c
index 0e539bfc..2bf42e55 100644
--- a/src/doom/p_floor.c
+++ b/src/doom/p_floor.c
@@ -303,7 +303,7 @@ EV_DoFloor
 	    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;
diff --git a/src/doom/p_inter.c b/src/doom/p_inter.c
index 744dabbb..f827b02e 100644
--- a/src/doom/p_inter.c
+++ b/src/doom/p_inter.c
@@ -382,7 +382,7 @@ P_TouchSpecialThing

       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 @@ P_DamageMobj
     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,
diff --git a/src/doom/p_map.c b/src/doom/p_map.c
index bfb25149..2d980807 100644
--- a/src/doom/p_map.c
+++ b/src/doom/p_map.c
@@ -1317,7 +1317,7 @@ boolean PIT_ChangeSector (mobj_t*	thing)
     {
 	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;
diff --git a/src/doom/p_sight.c b/src/doom/p_sight.c
index 867c86a9..0598309a 100644
--- a/src/doom/p_sight.c
+++ b/src/doom/p_sight.c
@@ -375,7 +375,7 @@ P_CheckSight
     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);
diff --git a/src/doom/p_spec.c b/src/doom/p_spec.c
index 81addb7c..d6201e54 100644
--- a/src/doom/p_spec.c
+++ b/src/doom/p_spec.c
@@ -509,7 +509,7 @@ P_CrossSpecialLine

     line = &lines[linenum];

-    if (gameversion == exe_doom_1_2)
+    if (gameversion <= exe_doom_1_2)
     {
         if (line->special > 98 && line->special != 104)
         {
diff --git a/src/doom/s_sound.c b/src/doom/s_sound.c
index 2de5b0df..75ef929c 100644
--- a/src/doom/s_sound.c
+++ b/src/doom/s_sound.c
@@ -446,7 +446,7 @@ void S_StartSound(void *origin_p, int sfx_id)
     }

     // 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 @@ void S_ChangeMusic(int musicnum, int looping)

     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;
     }
diff --git a/src/doom/st_stuff.c b/src/doom/st_stuff.c
index 5aee4520..51603907 100644
--- a/src/doom/st_stuff.c
+++ b/src/doom/st_stuff.c
@@ -1149,7 +1149,7 @@ static void ST_loadUnloadGraphics(load_callback_t callback)
     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;