shithub: choc

Download patch

ref: b295df80fe09802a774f9ef05d126f5139a383fa
parent: 3ac445e219bbfd2caa252a3896d65c8555bcf9d8
author: Simon Howard <fraggle@gmail.com>
date: Sat Mar 22 22:57:36 EDT 2014

doom: Add initial support for versions < v1.9.

Add -gameversion options for v1.666, v1.7, v1.8. Set demo and savegame
headers appropriately depending on version. Also add an enum entry for
Doom v1.2 but no code support for it yet.

--- a/src/d_mode.h
+++ b/src/d_mode.h
@@ -64,7 +64,11 @@
 
 typedef enum
 {
-    exe_doom_1_9,    // Doom 1.9: used for shareware, registered and commercial
+    exe_doom_1_2,    // Doom 1.2: shareware and registered
+    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: "
+    exe_doom_1_9,    // Doom 1.9: "
     exe_hacx,        // Hacx
     exe_ultimate,    // Ultimate Doom (retail)
     exe_final,       // Final Doom
--- a/src/doom/d_main.c
+++ b/src/doom/d_main.c
@@ -659,13 +659,15 @@
         
         if (deh_sub != banners[i])
         {
-            // Has been replaced
-            // We need to expand via printf to include the Doom version 
-            // number
+            int version;
+
+            // Has been replaced.
+            // We need to expand via printf to include the Doom version number
             // We also need to cut off spaces to get the basic name
 
             gamename = Z_Malloc(strlen(deh_sub) + 10, PU_STATIC, 0);
-            sprintf(gamename, deh_sub, DOOM_VERSION / 100, DOOM_VERSION % 100);
+            version = G_VanillaVersionCode();
+            sprintf(gamename, deh_sub, version / 100, version % 100);
 
             while (gamename[0] != '\0' && isspace(gamename[0]))
                 strcpy(gamename, gamename+1);
@@ -854,6 +856,9 @@
     char *cmdline;
     GameVersion_t version;
 } gameversions[] = {
+    {"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},
     {"Doom 1.9",             "1.9",        exe_doom_1_9},
     {"Hacx",                 "hacx",       exe_hacx},
     {"Ultimate Doom",        "ultimate",   exe_ultimate},
@@ -925,6 +930,8 @@
             // original
 
             gameversion = exe_doom_1_9;
+
+            // TODO: Detect IWADs earlier than Doom v1.9.
         }
         else if (gamemode == retail)
         {
--- a/src/doom/g_game.c
+++ b/src/doom/g_game.c
@@ -1961,8 +1961,26 @@
 	
     demorecording = true; 
 } 
- 
- 
+
+// Get the demo version code appropriate for the version set in gameversion.
+int G_VanillaVersionCode(void)
+{
+    switch (gameversion)
+    {
+        case exe_doom_1_2:
+            I_Error("Doom 1.2 does not have a version code!");
+        case exe_doom_1_666:
+            return 106;
+        case exe_doom_1_7:
+            return 107;
+        case exe_doom_1_8:
+            return 108;
+        case exe_doom_1_9:
+        default:  // All other versions are variants on v1.9:
+            return 109;
+    }
+}
+
 void G_BeginRecording (void) 
 { 
     int             i; 
@@ -1989,7 +2007,7 @@
     }
     else
     {
-        *demo_p++ = DOOM_VERSION;
+        *demo_p++ = G_VanillaVersionCode();
     }
 
     *demo_p++ = gameskill; 
@@ -2067,7 +2085,7 @@
 
     demoversion = *demo_p++;
 
-    if (demoversion == DOOM_VERSION)
+    if (demoversion == G_VanillaVersionCode())
     {
         longtics = false;
     }
@@ -2086,7 +2104,7 @@
                         "    See: http://doomworld.com/files/patches.shtml\n"
                         "    This appears to be %s.";
 
-        I_Error(message, demoversion, DOOM_VERSION,
+        I_Error(message, demoversion, G_VanillaVersionCode(),
                          DemoVersionDescription(demoversion));
     }
     
--- a/src/doom/g_game.h
+++ b/src/doom/g_game.h
@@ -80,6 +80,7 @@
 void G_ScreenShot (void);
 
 void G_DrawMouseSpeedBox(void);
+int G_VanillaVersionCode(void);
 
 extern int vanilla_savegame_limit;
 extern int vanilla_demo_limit;
--- a/src/doom/p_saveg.c
+++ b/src/doom/p_saveg.c
@@ -37,6 +37,7 @@
 
 // State.
 #include "doomstat.h"
+#include "g_game.h"
 #include "r_state.h"
 
 #define SAVEGAME_EOF 0x1d
@@ -1361,8 +1362,8 @@
     for (; i<SAVESTRINGSIZE; ++i)
         saveg_write8(0);
 
-    memset (name,0,sizeof(name)); 
-    sprintf (name,"version %i",DOOM_VERSION); 
+    memset(name, 0, sizeof(name));
+    sprintf(name, "version %i", G_VanillaVersionCode());
 
     for (i=0; i<VERSIONSIZE; ++i)
         saveg_write8(name[i]);
@@ -1398,11 +1399,11 @@
     for (i=0; i<VERSIONSIZE; ++i)
         read_vcheck[i] = saveg_read8();
 
-    memset (vcheck,0,sizeof(vcheck)); 
-    sprintf (vcheck,"version %i",DOOM_VERSION); 
+    memset(vcheck, 0, sizeof(vcheck));
+    sprintf(vcheck, "version %i", G_VanillaVersionCode());
     if (strcmp(read_vcheck, vcheck) != 0)
 	return false;				// bad version 
-			 
+
     gameskill = saveg_read8();
     gameepisode = saveg_read8();
     gamemap = saveg_read8();