From 8cae6e48779beb3dc8e95a5c32b422b2504b5722 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Tue, 30 Sep 2008 22:50:24 +0000 Subject: Move d_iwad.c into common code and update Heretic to use it on startup to locate the IWAD file. Subversion-branch: /branches/raven-branch Subversion-revision: 1308 --- src/doom/d_main.c | 238 ++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 233 insertions(+), 5 deletions(-) (limited to 'src/doom/d_main.c') diff --git a/src/doom/d_main.c b/src/doom/d_main.c index 1a778730..419e871c 100644 --- a/src/doom/d_main.c +++ b/src/doom/d_main.c @@ -586,8 +586,234 @@ void D_StartTitle (void) D_AdvanceDemo (); } +static iwad_t iwads[] = +{ + {"doom2.wad", doom2}, + {"plutonia.wad", pack_plut}, + {"tnt.wad", pack_tnt}, + {"doom.wad", doom}, + {"doom1.wad", doom}, + {"chex.wad", doom}, + {NULL, none}, +}; + +// Strings for dehacked replacements of the startup banner +// +// These are from the original source: some of them are perhaps +// not used in any dehacked patches + +static char *banners[] = +{ + // doom1.wad + " " + "DOOM Shareware Startup v%i.%i" + " ", + // doom.wad + " " + "DOOM Registered Startup v%i.%i" + " ", + // Registered DOOM uses this + " " + "DOOM System Startup v%i.%i" + " ", + // doom.wad (Ultimate DOOM) + " " + "The Ultimate DOOM Startup v%i.%i" + " ", + // doom2.wad + " " + "DOOM 2: Hell on Earth v%i.%i" + " ", + // tnt.wad + " " + "DOOM 2: TNT - Evilution v%i.%i" + " ", + // plutonia.wad + " " + "DOOM 2: Plutonia Experiment v%i.%i" + " ", +}; + +// +// Get game name: if the startup banner has been replaced, use that. +// Otherwise, use the name given +// + +static char *GetGameName(char *gamename) +{ + size_t i; + char *deh_sub; + + for (i=0; i 0) + { + // Ultimate Doom + + gamemode = retail; + } + else if (W_CheckNumForName("E3M1") > 0) + { + gamemode = registered; + } + else + { + gamemode = shareware; + } + } + else + { + // Doom 2 of some kind. + + gamemode = commercial; + } +} + +// Set the gamedescription string + +void D_SetGameDescription(void) +{ + gamedescription = "Unknown"; + + if (gamemission == doom) + { + // Doom 1. But which version? + + if (gamemode == retail) + { + // Ultimate Doom + + gamedescription = GetGameName("The Ultimate DOOM"); + } + else if (gamemode == registered) + { + gamedescription = GetGameName("DOOM Registered"); + } + else if (gamemode == shareware) + { + gamedescription = GetGameName("DOOM Shareware"); + } + } + else + { + // Doom 2 of some kind. But which mission? + + if (gamemission == doom2) + gamedescription = GetGameName("DOOM 2: Hell on Earth"); + else if (gamemission == pack_plut) + gamedescription = GetGameName("DOOM 2: Plutonia Experiment"); + else if (gamemission == pack_tnt) + gamedescription = GetGameName("DOOM 2: TNT - Evilution"); + } +} + +static void SetSaveGameDir(char *iwad_filename) +{ + char *sep; + char *basefile; + + // Extract the base filename + + sep = strrchr(iwad_filename, DIR_SEPARATOR); + + if (sep == NULL) + { + basefile = iwad_filename; + } + else + { + basefile = sep + 1; + } + + // eg. ~/.chocolate-doom/savegames/doom2.wad/ + + savegamedir = malloc(strlen(configdir) + strlen(basefile) + 10); + sprintf(savegamedir, "%ssavegames%c%s%c", + configdir, DIR_SEPARATOR, basefile, DIR_SEPARATOR); +} + +// Check if the IWAD file is the Chex Quest IWAD. +// Returns true if this is chex.wad. + +static boolean CheckChex(char *iwadname) +{ + char *chex_iwadname = "chex.wad"; + return (strlen(iwadname) > strlen(chex_iwadname) + && !strcasecmp(iwadname + strlen(iwadname) - strlen(chex_iwadname), + chex_iwadname)); +} // print title for every printed line char title[128]; @@ -711,9 +937,11 @@ static void InitGameVersion(void) { // Determine automatically - if (gameversion == exe_chex) + if (CheckChex(iwadfile)) { - // Already determined + // chex.exe - identified by iwad filename + + gameversion = exe_chex; } else if (gamemode == shareware || gamemode == registered) { @@ -833,7 +1061,7 @@ void D_DoomMain (void) if (M_CheckParm("-findiwads") > 0) { - D_FindInstalledIWADs(); + D_FindInstalledIWADs(iwads); } // print banner @@ -890,7 +1118,7 @@ void D_DoomMain (void) DEH_Init(); #endif - iwadfile = D_FindIWAD(); + iwadfile = D_FindIWAD(iwads, &gamemission); // None found? @@ -1259,7 +1487,7 @@ void D_DoomMain (void) InitGameVersion(); LoadChexDeh(); D_SetGameDescription(); - D_SetSaveGameDir(); + SetSaveGameDir(iwadfile); // Check for -file in shareware if (modifiedgame) -- cgit v1.2.3