foxygit / doom Log in
commit e1f113aec7399f5625d8dc9bfa1a8e9816695c19
Author:     Thomas A. Birkel <capnclever@gmail.com>
AuthorDate: Sun Nov 20 13:30:16 2016 -0500
Commit:     Thomas A. Birkel <capnclever@gmail.com>
CommitDate: Sun Nov 20 13:30:16 2016 -0500

    Emulate Doom2 map33 behavior

    On automap: TNT names are blank on map33-map35; Doom2 names are blank when
    not running via Final Doom
    On intermission: map name patch is ignored, partime value is blank. Partime
    value is set to zero to simulate intermission's timing, similar to Doom1
    E4's invisible counting of partimes from Doom2 spillage.

    Fix for #157
---
 NEWS.md             |  2 ++
 src/doom/g_game.c   | 25 ++++++++++++++++++++-----
 src/doom/hu_stuff.c | 11 +++++++++++
 src/doom/wi_stuff.c | 12 +++++++++---
 4 files changed, 42 insertions(+), 8 deletions(-)

diff --git a/NEWS.md b/NEWS.md
index dddf5105..3978044f 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -48,6 +48,8 @@
     temporary directory and reporting an error instead.  (thanks
     terrorcide)
   * Versions 1.666, 1.7, and 1.8 are emulated. (thanks Nuke.YKT)
+  * Map33 intermission screen and map33-map35 automap names are
+    emulated. (thanks CapnClever)

 ### Heretic
   * Added map names for Episode 6, fixing a crash after completing a
diff --git a/src/doom/g_game.c b/src/doom/g_game.c
index 424d87e1..7e6cff74 100644
--- a/src/doom/g_game.c
+++ b/src/doom/g_game.c
@@ -1455,15 +1455,30 @@ void G_DoCompleted (void)
     wminfo.maxsecret = totalsecret;
     wminfo.maxfrags = 0;

-    // Set par time. Doom episode 4 doesn't have a par time, so this
-    // overflows into the cpars array. It's necessary to emulate this
-    // for statcheck regression testing.
+    // Set par time. Exceptions are added for purposes of
+    // statcheck regression testing.
     if (gamemode == commercial)
-	wminfo.partime = TICRATE*cpars[gamemap-1];
+    {
+        // map33 has no official time: initialize to zero
+        if (gamemap == 33)
+        {
+            wminfo.partime = 0;
+        }
+        else
+        {
+            wminfo.partime = TICRATE*cpars[gamemap-1];
+        }
+    }
+    // Doom episode 4 doesn't have a par time, so this
+    // overflows into the cpars array.
     else if (gameepisode < 4)
-	wminfo.partime = TICRATE*pars[gameepisode][gamemap];
+    {
+        wminfo.partime = TICRATE*pars[gameepisode][gamemap];
+    }
     else
+    {
         wminfo.partime = TICRATE*cpars[gamemap];
+    }

     wminfo.pnum = consoleplayer;

diff --git a/src/doom/hu_stuff.c b/src/doom/hu_stuff.c
index a3d04428..fa7e6db3 100644
--- a/src/doom/hu_stuff.c
+++ b/src/doom/hu_stuff.c
@@ -335,6 +335,12 @@ char *mapnames_commercial[] =
     THUSTR_30,
     THUSTR_31,
     THUSTR_32
+
+    // Emulation: TNT maps 33-35 can be warped to and played if they exist
+    // so include blank names instead of spilling over
+    "",
+    "",
+    ""
 };

 void HU_Init(void)
@@ -393,6 +399,11 @@ void HU_Start(void)
 	break;
       case doom2:
 	 s = HU_TITLE2;
+         // Pre-Final Doom compatibility: map33-map35 names don't spill over
+         if (gameversion <= exe_doom_1_9 && gamemap >= 33)
+         {
+             s = "";
+         }
 	 break;
       case pack_plut:
 	s = HU_TITLEP;
diff --git a/src/doom/wi_stuff.c b/src/doom/wi_stuff.c
index 1d6466bb..cff0d9ac 100644
--- a/src/doom/wi_stuff.c
+++ b/src/doom/wi_stuff.c
@@ -430,7 +430,8 @@ void WI_drawLF(void)
     }
     else if (wbs->last == NUMCMAPS)
     {
-        // MAP33 - nothing is displayed!
+        // MAP33 - draw "Finished!" only
+        V_DrawPatch((SCREENWIDTH - SHORT(finished->width)) / 2, y, finished);
     }
     else if (wbs->last > NUMCMAPS)
     {
@@ -1472,8 +1473,13 @@ void WI_drawStats(void)

     if (wbs->epsd < 3)
     {
-	V_DrawPatch(SCREENWIDTH/2 + SP_TIMEX, SP_TIMEY, par);
-	WI_drawTime(SCREENWIDTH - SP_TIMEX, SP_TIMEY, cnt_par);
+        V_DrawPatch(SCREENWIDTH/2 + SP_TIMEX, SP_TIMEY, par);
+
+        // Emulation: don't draw partime value if map33
+        if (gamemode != commercial || wbs->last != NUMCMAPS)
+        {
+            WI_drawTime(SCREENWIDTH - SP_TIMEX, SP_TIMEY, cnt_par);
+        }
     }

 }