foxygit / doom Log in
commit 1670801dba930b9fa9d6a2b4a953091970dc180a
Author:     Simon Howard <fraggle@gmail.com>
AuthorDate: Wed Oct 8 19:34:09 2008 +0000
Commit:     Simon Howard <fraggle@gmail.com>
CommitDate: Wed Oct 8 19:34:09 2008 +0000

    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
---
 src/hexen/h2_main.c  | 56 +++++++++++++++++++++++-----------------------------
 src/hexen/h2def.h    | 18 +++++++----------
 src/hexen/mn_menu.c  |  2 +-
 src/hexen/r_draw.c   |  2 +-
 src/hexen/r_things.c |  2 +-
 5 files changed, 35 insertions(+), 45 deletions(-)

diff --git a/src/hexen/h2_main.c b/src/hexen/h2_main.c
index 4bdcc7d5..c6caf2e7 100644
--- 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 DrawMessage(void);
 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 @@ extern char *SavePath;

 // 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 WarpMap;
 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 @@ void D_DoomMain(void)
     autostart = false;
     startskill = sk_medium;
     startmap = 1;
-    shareware = false;          // Always false for Hexen
+    gamemode = commercial;

     // Initialize subsystems

@@ -212,8 +218,6 @@ void D_DoomMain(void)
     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 @@ void D_DoomMain(void)
     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 @@ static void ExecOptionFILE(char **args, int tag)
     p = M_CheckParm("-file");
     while (++p != myargc && myargv[p][0] != '-')
     {
-        AddWADFile(myargv[p]);
+        W_AddFile(myargv[p]);
     }
 }

@@ -432,7 +448,7 @@ static void ExecOptionPLAYDEMO(char **args, int tag)
     char file[256];

     sprintf(file, "%s.lmp", args[1]);
-    AddWADFile(file);
+    W_AddFile(file);
     ST_Message("Playing demo %s.lmp.\n", args[1]);
 }

@@ -795,28 +811,6 @@ static void CheckRecordFrom(void)
     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__
 /*
 void CleanExit(void)
diff --git a/src/hexen/h2def.h b/src/hexen/h2def.h
index 61ca87b9..a00d90bd 100644
--- 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,12 +649,13 @@ void NET_SendFrags(player_t * player);

 #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

diff --git a/src/hexen/mn_menu.c b/src/hexen/mn_menu.c
index df14e4d4..219cd139 100644
--- a/src/hexen/mn_menu.c
+++ b/src/hexen/mn_menu.c
@@ -1152,7 +1152,7 @@ boolean MN_Responder(event_t * event)
     key = event->data1;
     if (InfoType)
     {
-        if (shareware)
+        if (gamemode == shareware)
         {
             InfoType = (InfoType + 1) % 5;
         }
diff --git a/src/hexen/r_draw.c b/src/hexen/r_draw.c
index fb417995..da413ed3 100644
--- a/src/hexen/r_draw.c
+++ b/src/hexen/r_draw.c
@@ -517,7 +517,7 @@ void R_DrawTopBorder(void)
     if (scaledviewwidth == SCREENWIDTH)
         return;

-/*	if(shareware)
+/*	if(gamemode == shareware)
 	{
 		src = W_CacheLumpName ("FLOOR04", PU_CACHE);
 	}
diff --git a/src/hexen/r_things.c b/src/hexen/r_things.c
index b69e59d0..da8ed22e 100644
--- a/src/hexen/r_things.c
+++ b/src/hexen/r_things.c
@@ -209,7 +209,7 @@ void R_InitSpriteDefs(char **namelist)
         {
             //continue;
             sprites[i].numframes = 0;
-            if (shareware)
+            if (gamemode == shareware)
                 continue;
             I_Error("R_InitSprites: No lumps found for sprite %s",
                     namelist[i]);