shithub: choc

Download patch

ref: 1670801dba930b9fa9d6a2b4a953091970dc180a
parent: 65404cbe64c2a708cd761befa1d828f6fbbee9bf
author: Simon Howard <[email protected]>
date: Wed Oct 8 15:34:09 EDT 2008

Replace hexen "shareware" variable with gamemode/gamemission. Use
d_iwad.c code to find the IWAD file. Remove AddWADFile and use the
w_wad.c API directly.

Subversion-branch: /branches/raven-branch
Subversion-revision: 1343

--- a/src/hexen/h2_main.c
+++ b/src/hexen/h2_main.c
@@ -37,6 +37,8 @@
 
 #include "h2def.h"
 #include "ct_chat.h"
+#include "d_iwad.h"
+#include "d_mode.h"
 #include "s_sound.h"
 #include "i_system.h"
 #include "m_argv.h"
@@ -85,7 +87,6 @@
 static void PageDrawer(void);
 static void HandleArgs(void);
 static void CheckRecordFrom(void);
-static void AddWADFile(char *file);
 static void DrawAndBlit(void);
 static void ExecOptionFILE(char **args, int tag);
 static void ExecOptionSCRIPTS(char **args, int tag);
@@ -107,7 +108,9 @@
 
 // PUBLIC DATA DEFINITIONS -------------------------------------------------
 
-boolean shareware;              // true if only episode 1 present
+GameMode_t gamemode;
+GameMission_t gamemission;
+char *iwadfile;
 boolean nomonsters;             // checkparm of -nomonsters
 boolean respawnparm;            // checkparm of -respawn
 boolean randomclass;            // checkparm of -randclass
@@ -132,9 +135,12 @@
 static int demosequence;
 static int pagetic;
 static char *pagename;
-static char *wadfiles[MAXWADFILES] = {
-    "hexen.wad"
+
+static iwad_t iwads[] = {
+    { "hexen.wad",        hexen },
+    { NULL,               none },
 };
+
 static execOpt_t ExecOptions[] = {
     {"-file", ExecOptionFILE, 1, 0},
     {"-scripts", ExecOptionSCRIPTS, 1, 0},
@@ -191,7 +197,7 @@
     autostart = false;
     startskill = sk_medium;
     startmap = 1;
-    shareware = false;          // Always false for Hexen
+    gamemode = commercial;
 
     // Initialize subsystems
 
@@ -212,8 +218,6 @@
     DoTimeBomb();
 #endif
 
-//    ST_Message("W_Init: Init WADfiles.\n");
-
     ST_Message("Z_Init: Init zone memory allocation daemon.\n");
     Z_Init();
 
@@ -222,6 +226,18 @@
     I_StartupJoystick();
 #endif
 
+    ST_Message("W_Init: Init WADfiles.\n");
+
+    iwadfile = D_FindIWAD(iwads, &gamemission);
+
+    if (iwadfile == NULL)
+    {
+        I_Error("Game mode indeterminate. No IWAD was found. Try specifying\n"
+                "one with the '-iwad' command line parameter.");
+    }
+
+    W_AddFile(iwadfile);
+
     HandleArgs();
 
     ST_Message("MN_Init: Init menu system.\n");
@@ -416,7 +432,7 @@
     p = M_CheckParm("-file");
     while (++p != myargc && myargv[p][0] != '-')
     {
-        AddWADFile(myargv[p]);
+        W_AddFile(myargv[p]);
     }
 }
 
@@ -432,7 +448,7 @@
     char file[256];
 
     sprintf(file, "%s.lmp", args[1]);
-    AddWADFile(file);
+    W_AddFile(file);
     ST_Message("Playing demo %s.lmp.\n", args[1]);
 }
 
@@ -793,28 +809,6 @@
     G_DoLoadGame();             // Load the gameskill etc info from savegame
     G_RecordDemo(gameskill, 1, gameepisode, gamemap, myargv[p + 2]);
     H2_GameLoop();              // Never returns
-}
-
-//==========================================================================
-//
-// AddWADFile
-//
-//==========================================================================
-
-static void AddWADFile(char *file)
-{
-    int i;
-    char *new;
-
-    ST_Message("Adding external file: %s\n", file);
-    i = 0;
-    while (wadfiles[i])
-    {
-        i++;
-    }
-    new = malloc(strlen(file) + 1);
-    strcpy(new, file);
-    wadfiles[i] = new;
 }
 
 #ifdef __WATCOMC__
--- a/src/hexen/h2def.h
+++ b/src/hexen/h2def.h
@@ -44,6 +44,10 @@
 
 #include "d_event.h"
 
+// gamemode/mission
+
+#include "d_mode.h"
+
 // for fixed_t:
 
 #include "m_fixed.h"
@@ -104,15 +108,6 @@
 
 typedef unsigned int uint;
 
-typedef enum
-{
-    sk_baby,
-    sk_easy,
-    sk_medium,
-    sk_hard,
-    sk_nightmare
-} skill_t;
-
 #define	BT_ATTACK		1
 #define	BT_USE			2
 #define	BT_CHANGE		4       // if true, the next 3 bits hold weapon num
@@ -654,11 +649,12 @@
 
 #define TELEFOGHEIGHT (32*FRACUNIT)
 
+extern GameMode_t gamemode;         // Always commercial
+extern GameMission_t gamemission;   // Always hexen
+
 extern gameaction_t gameaction;
 
 extern boolean paused;
-
-extern boolean shareware;       // true if other episodes not present
 
 extern boolean DevMaps;         // true = map development mode
 extern char *DevMapsDir;        // development maps directory
--- a/src/hexen/mn_menu.c
+++ b/src/hexen/mn_menu.c
@@ -1152,7 +1152,7 @@
     key = event->data1;
     if (InfoType)
     {
-        if (shareware)
+        if (gamemode == shareware)
         {
             InfoType = (InfoType + 1) % 5;
         }
--- a/src/hexen/r_draw.c
+++ b/src/hexen/r_draw.c
@@ -517,7 +517,7 @@
     if (scaledviewwidth == SCREENWIDTH)
         return;
 
-/*	if(shareware)
+/*	if(gamemode == shareware)
 	{
 		src = W_CacheLumpName ("FLOOR04", PU_CACHE);
 	}
--- a/src/hexen/r_things.c
+++ b/src/hexen/r_things.c
@@ -209,7 +209,7 @@
         {
             //continue;
             sprites[i].numframes = 0;
-            if (shareware)
+            if (gamemode == shareware)
                 continue;
             I_Error("R_InitSprites: No lumps found for sprite %s",
                     namelist[i]);