From b295df80fe09802a774f9ef05d126f5139a383fa Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Sun, 23 Mar 2014 02:57:36 -0400 Subject: 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. --- src/doom/d_main.c | 15 +++++++++++---- src/doom/g_game.c | 28 +++++++++++++++++++++++----- src/doom/g_game.h | 1 + src/doom/p_saveg.c | 11 ++++++----- 4 files changed, 41 insertions(+), 14 deletions(-) (limited to 'src/doom') diff --git a/src/doom/d_main.c b/src/doom/d_main.c index e0bd1d26..5f7e2051 100644 --- a/src/doom/d_main.c +++ b/src/doom/d_main.c @@ -659,13 +659,15 @@ static char *GetGameName(char *gamename) 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 @@ static struct 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 @@ static void InitGameVersion(void) // original gameversion = exe_doom_1_9; + + // TODO: Detect IWADs earlier than Doom v1.9. } else if (gamemode == retail) { diff --git a/src/doom/g_game.c b/src/doom/g_game.c index 6ceb1cbb..4a814871 100644 --- a/src/doom/g_game.c +++ b/src/doom/g_game.c @@ -1961,8 +1961,26 @@ void G_RecordDemo (char *name) 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 @@ void G_BeginRecording (void) } else { - *demo_p++ = DOOM_VERSION; + *demo_p++ = G_VanillaVersionCode(); } *demo_p++ = gameskill; @@ -2067,7 +2085,7 @@ void G_DoPlayDemo (void) demoversion = *demo_p++; - if (demoversion == DOOM_VERSION) + if (demoversion == G_VanillaVersionCode()) { longtics = false; } @@ -2086,7 +2104,7 @@ void G_DoPlayDemo (void) " 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)); } diff --git a/src/doom/g_game.h b/src/doom/g_game.h index 46c80bd8..42cc5f64 100644 --- a/src/doom/g_game.h +++ b/src/doom/g_game.h @@ -80,6 +80,7 @@ boolean G_Responder (event_t* ev); void G_ScreenShot (void); void G_DrawMouseSpeedBox(void); +int G_VanillaVersionCode(void); extern int vanilla_savegame_limit; extern int vanilla_demo_limit; diff --git a/src/doom/p_saveg.c b/src/doom/p_saveg.c index 968120c0..7dd386a3 100644 --- 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 @@ void P_WriteSaveGameHeader(char *description) for (; i