shithub: choc

Download patch

ref: 091f93809ee554571a6ed6145b8ac69f17814d91
parent: 8c045b4bfee2e859f800f8fbd76f5ae3d5d3f435
author: Simon Howard <[email protected]>
date: Wed Oct 29 22:10:50 EDT 2008

Factor out Heretic and Hexen versions of m_misc.c. Make -file for
Heretic and Hexen use WAD path lookup.

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

--- a/src/d_mode.c
+++ b/src/d_mode.c
@@ -25,21 +25,26 @@
 #include "doomtype.h"
 #include "d_mode.h"
 
-// Table of valid game modes
+// Valid game mode/mission combinations, with the number of
+// episodes/maps for each.
 
-static struct {
+static struct
+{
     GameMission_t mission;
     GameMode_t mode;
+    int episode;
+    int map;
 } valid_modes[] = {
-    { doom,        shareware },
-    { doom,        registered },
-    { doom,        retail },
-    { doom2,       commercial },
-    { pack_tnt,    commercial },
-    { pack_plut,   commercial },
-    { heretic,     shareware },
-    { heretic,     registered },
-    { hexen,       commercial },
+    { doom,      shareware,  1, 9 },
+    { doom,      registered, 3, 9 },
+    { doom,      retail,     4, 9 },
+    { doom2,     commercial, 1, 32 },
+    { pack_tnt,  commercial, 1, 32 },
+    { pack_plut, commercial, 1, 32 },
+    { heretic,   shareware,  1, 9 },
+    { heretic,   registered, 3, 9 },
+    { heretic,   retail,     5, 9 },
+    { hexen,     commercial, 1, 40 },
 };
 
 // Check that a gamemode+gamemission received over the network is valid.
@@ -55,6 +60,42 @@
             return true;
         }
     }
+
+    return false;
+}
+
+boolean D_ValidEpisodeMap(GameMission_t mission, GameMode_t mode,
+                          int episode, int map)
+{
+    int i;
+
+    // Hacks for Heretic secret episodes
+
+    if (mission == heretic)
+    {
+        if (mode == retail && episode == 6)
+        {
+            return map >= 1 && map <= 3;
+        }
+        else if (mode == registered && episode == 4)
+        {
+            return map == 1;
+        }
+    }
+
+    // Find the table entry for this mission/mode combination.
+
+    for (i=0; i<arrlen(valid_modes); ++i) 
+    {
+        if (mission == valid_modes[i].mission
+         && mode == valid_modes[i].mode)
+        {
+            return episode >= 1 && episode <= valid_modes[i].episode
+                && map >= 1 && map <= valid_modes[i].map;
+        }
+    }
+
+    // Unknown mode/mission combination
 
     return false;
 }
--- a/src/d_mode.h
+++ b/src/d_mode.h
@@ -85,6 +85,8 @@
 
 boolean D_ValidGameMode(GameMission_t mission, GameMode_t mode);
 boolean D_ValidGameVersion(GameMission_t mission, GameVersion_t version);
+boolean D_ValidEpisodeMap(GameMission_t mission, GameMode_t mode,
+                          int episode, int map);
 
 #endif /* #ifndef __D_MODE__ */
 
--- a/src/heretic/Makefile.am
+++ b/src/heretic/Makefile.am
@@ -16,7 +16,6 @@
 g_game.c                                             \
 info.c                 info.h                        \
 in_lude.c                                            \
-m_misc.c                                             \
 m_random.c             m_random.h                    \
 mn_menu.c                                            \
 p_ceilng.c                                           \
--- a/src/heretic/d_main.c
+++ b/src/heretic/d_main.c
@@ -857,12 +857,18 @@
     // -FILE [filename] [filename] ...
     // Add files to the wad list.
     p = M_CheckParm("-file");
+
     if (p)
-    {                           // the parms after p are wadfile/lump names, until end of parms
+    {
+        char *filename;
+
+        // the parms after p are wadfile/lump names, until end of parms
         // or another - preceded parm
+
         while (++p != myargc && myargv[p][0] != '-')
         {
-            D_AddFile(myargv[p]);
+            filename = D_FindWADByName(myargv[p]);
+            D_AddFile(filename);
         }
     }
 
@@ -1011,7 +1017,7 @@
     // Check valid episode and map
     if (autostart || netgame)
     {
-        if (M_ValidEpisodeMap(startepisode, startmap) == false)
+        if (!D_ValidEpisodeMap(gamemission, gamemode, startepisode, startmap))
         {
             startepisode = 1;
             startmap = 1;
--- a/src/heretic/doomdef.h
+++ b/src/heretic/doomdef.h
@@ -833,17 +833,6 @@
 //----
 // returns the position of the given parameter in the arg list (0 if not found)
 
-boolean M_ValidEpisodeMap(int episode, int map);
-// returns true if the episode/map combo is valid for the current
-// game configuration
-
-void M_ForceUppercase(char *text);
-// Changes a string to uppercase
-
-void M_LoadDefaults(void);
-
-void M_SaveDefaults(void);
-
 int M_DrawText(int x, int y, boolean direct, char *string);
 
 //----------------------
--- a/src/heretic/m_misc.c
+++ /dev/null
@@ -1,92 +1,0 @@
-// Emacs style mode select   -*- C++ -*- 
-//-----------------------------------------------------------------------------
-//
-// Copyright(C) 1993-1996 Id Software, Inc.
-// Copyright(C) 1993-2008 Raven Software
-//
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License
-// as published by the Free Software Foundation; either version 2
-// of the License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
-// 02111-1307, USA.
-//
-//-----------------------------------------------------------------------------
-
-// M_misc.c
-
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <fcntl.h>
-#include <stdlib.h>
-
-#include <ctype.h>
-
-#include "doomdef.h"
-#include "i_swap.h"
-#include "i_video.h"
-#include "m_argv.h"
-#include "s_sound.h"
-
-//---------------------------------------------------------------------------
-//
-// FUNC M_ValidEpisodeMap
-//
-//---------------------------------------------------------------------------
-
-boolean M_ValidEpisodeMap(int episode, int map)
-{
-    if (episode < 1 || map < 1 || map > 9)
-    {
-        return false;
-    }
-
-    switch (gamemode)
-    {
-        case shareware:
-            return episode == 1;
-
-        case retail:
-            return episode <= 5 || (episode == 6 && map <= 3);
-
-        case registered:
-            return episode <= 3 || (episode == 4 && map == 1);
-
-        default:
-            return false;
-    }
-}
-
-//---------------------------------------------------------------------------
-//
-// PROC M_ForceUppercase
-//
-// Change string to uppercase.
-//
-//---------------------------------------------------------------------------
-
-void M_ForceUppercase(char *text)
-{
-    char c;
-
-    while ((c = *text) != 0)
-    {
-        if (c >= 'a' && c <= 'z')
-        {
-            *text++ = c - ('a' - 'A');
-        }
-        else
-        {
-            text++;
-        }
-    }
-}
-
--- a/src/heretic/sb_bar.c
+++ b/src/heretic/sb_bar.c
@@ -1237,7 +1237,7 @@
 
     episode = args[0] - '0';
     map = args[1] - '0';
-    if (M_ValidEpisodeMap(episode, map))
+    if (D_ValidEpisodeMap(gamemission, gamemode, episode, map))
     {
         G_DeferedInitNew(gameskill, episode, map);
         P_SetMessage(player, TXT_CHEATWARP, false);
--- a/src/hexen/Makefile.am
+++ b/src/hexen/Makefile.am
@@ -17,6 +17,7 @@
 info.c              info.h            \
 in_lude.c                             \
 m_misc.c                              \
+m_random.c          m_random.h        \
 mn_menu.c                             \
 p_acs.c                               \
 p_anim.c                              \
--- a/src/hexen/a_action.c
+++ b/src/hexen/a_action.c
@@ -25,6 +25,7 @@
 // HEADER FILES ------------------------------------------------------------
 
 #include "h2def.h"
+#include "m_random.h"
 #include "p_local.h"
 #include "s_sound.h"
 
--- a/src/hexen/g_game.c
+++ b/src/hexen/g_game.c
@@ -23,6 +23,7 @@
 
 
 #include <string.h>
+#include "m_random.h"
 #include "h2def.h"
 #include "s_sound.h"
 #include "doomkeys.h"
--- a/src/hexen/h2_main.c
+++ b/src/hexen/h2_main.c
@@ -214,6 +214,13 @@
     printf("\nHexen: Beyond Heretic\n");
 }
 
+static void D_AddFile(char *filename)
+{
+    printf("  adding %s\n", filename);
+
+    W_AddFile(filename);
+}
+
 //==========================================================================
 //
 // H2_Main
@@ -275,7 +282,7 @@
                 "one with the '-iwad' command line parameter.");
     }
 
-    W_AddFile(iwadfile);
+    D_AddFile(iwadfile);
 
     HandleArgs();
 
@@ -467,12 +474,15 @@
 
 static void ExecOptionFILE(char **args, int tag)
 {
+    char *filename;
     int p;
 
     p = M_CheckParm("-file");
     while (++p != myargc && myargv[p][0] != '-')
     {
-        W_AddFile(myargv[p]);
+        filename = D_TryFindWADByName(myargv[p]);
+
+        D_AddFile(filename);
     }
 }
 
@@ -502,40 +512,6 @@
 {
     sc_FileScripts = true;
     sc_ScriptsDir = args[1];
-}
-
-
-long superatol(char *s)
-{
-    long int n = 0, r = 10, x, mul = 1;
-    char *c = s;
-
-    for (; *c; c++)
-    {
-        x = (*c & 223) - 16;
-
-        if (x == -3)
-        {
-            mul = -mul;
-        }
-        else if (x == 72 && r == 10)
-        {
-            n -= (r = n);
-            if (!r)
-                r = 16;
-            if (r < 2 || r > 36)
-                return -1;
-        }
-        else
-        {
-            if (x > 10)
-                x -= 39;
-            if (x >= r)
-                return -1;
-            n = (n * r) + x;
-        }
-    }
-    return (mul * n);
 }
 
 
--- a/src/hexen/h2def.h
+++ b/src/hexen/h2def.h
@@ -237,9 +237,6 @@
     fixed_t x, y, z;
 } degenmobj_t;
 
-// Most damage defined using HITDICE
-#define HITDICE(a) ((1+(P_Random()&7))*a)
-
 //
 // frame flags
 //
@@ -974,22 +971,6 @@
 //MISC
 //----
 extern int localQuakeHappening[MAXPLAYERS];
-
-void M_ExtractFileBase(char *path, char *dest);
-
-void M_ForceUppercase(char *text);
-// Changes a string to uppercase
-
-int M_Random(void);
-int P_Random(void);
-// returns a number from 0 to 255
-
-extern unsigned char rndtable[256];
-extern int prndindex;
-// as M_Random, but used only by the play simulation
-
-void M_ClearRandom(void);
-// fix randoms for demos
 
 int M_DrawText(int x, int y, boolean direct, char *string);
 
--- a/src/hexen/m_misc.c
+++ b/src/hexen/m_misc.c
@@ -24,150 +24,5 @@
 
 // HEADER FILES ------------------------------------------------------------
 
-#ifdef __NeXT__
-#include <libc.h>
-#else
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <fcntl.h>
-#include <stdlib.h>
-#endif
-#include <ctype.h>
 #include "h2def.h"
-#include "doomkeys.h"
-#include "i_system.h"
-#include "m_argv.h"
-#include "p_local.h"
-#include "s_sound.h"
-
-// MACROS ------------------------------------------------------------------
-
-#define MALLOC_CLIB 1
-#define MALLOC_ZONE 2
-
-// TYPES -------------------------------------------------------------------
-
-// EXTERNAL FUNCTION PROTOTYPES --------------------------------------------
-
-// PUBLIC FUNCTION PROTOTYPES ----------------------------------------------
-
-// PRIVATE FUNCTION PROTOTYPES ---------------------------------------------
-
-// EXTERNAL DATA DECLARATIONS ----------------------------------------------
-extern char *SavePath;
-
-// PUBLIC DATA DEFINITIONS -------------------------------------------------
-
-// PRIVATE DATA DEFINITIONS ------------------------------------------------
-
-// CODE --------------------------------------------------------------------
-
-//==========================================================================
-//
-// M_ExtractFileBase
-//
-//==========================================================================
-
-void M_ExtractFileBase(char *path, char *dest)
-{
-    char *src;
-    int length;
-
-    src = path + strlen(path) - 1;
-
-    // Back up until a \ or the start
-    while (src != path && *(src - 1) != '\\' && *(src - 1) != '/')
-    {
-        src--;
-    }
-
-    // Copy up to eight characters
-    memset(dest, 0, 8);
-    length = 0;
-    while (*src && *src != '.')
-    {
-        if (++length == 9)
-        {
-            I_Error("Filename base of %s > 8 chars", path);
-        }
-        *dest++ = toupper((int) *src++);
-    }
-}
-
-/*
-===============
-=
-= M_Random
-=
-= Returns a 0-255 number
-=
-===============
-*/
-
-
-// This is the new flat distribution table
-unsigned char rndtable[256] = {
-    201, 1, 243, 19, 18, 42, 183, 203, 101, 123, 154, 137, 34, 118, 10, 216,
-    135, 246, 0, 107, 133, 229, 35, 113, 177, 211, 110, 17, 139, 84, 251, 235,
-    182, 166, 161, 230, 143, 91, 24, 81, 22, 94, 7, 51, 232, 104, 122, 248,
-    175, 138, 127, 171, 222, 213, 44, 16, 9, 33, 88, 102, 170, 150, 136, 114,
-    62, 3, 142, 237, 6, 252, 249, 56, 74, 30, 13, 21, 180, 199, 32, 132,
-    187, 234, 78, 210, 46, 131, 197, 8, 206, 244, 73, 4, 236, 178, 195, 70,
-    121, 97, 167, 217, 103, 40, 247, 186, 105, 39, 95, 163, 99, 149, 253, 29,
-    119, 83, 254, 26, 202, 65, 130, 155, 60, 64, 184, 106, 221, 93, 164, 196,
-    112, 108, 179, 141, 54, 109, 11, 126, 75, 165, 191, 227, 87, 225, 156, 15,
-    98, 162, 116, 79, 169, 140, 190, 205, 168, 194, 41, 250, 27, 20, 14, 241,
-    50, 214, 72, 192, 220, 233, 67, 148, 96, 185, 176, 181, 215, 207, 172, 85,
-    89, 90, 209, 128, 124, 2, 55, 173, 66, 152, 47, 129, 59, 43, 159, 240,
-    239, 12, 189, 212, 144, 28, 200, 77, 219, 198, 134, 228, 45, 92, 125, 151,
-    5, 53, 255, 52, 68, 245, 160, 158, 61, 86, 58, 82, 117, 37, 242, 145,
-    69, 188, 115, 76, 63, 100, 49, 111, 153, 80, 38, 57, 174, 224, 71, 231,
-    23, 25, 48, 218, 120, 147, 208, 36, 226, 223, 193, 238, 157, 204, 146, 31
-};
-
-
-int rndindex = 0;
-int prndindex = 0;
-
-int P_Random(void)
-{
-    prndindex = (prndindex + 1) & 0xff;
-    return rndtable[prndindex];
-}
-
-int M_Random(void)
-{
-    rndindex = (rndindex + 1) & 0xff;
-    return rndtable[rndindex];
-}
-
-void M_ClearRandom(void)
-{
-    rndindex = prndindex = 0;
-}
-
-//---------------------------------------------------------------------------
-//
-// PROC M_ForceUppercase
-//
-// Change string to uppercase.
-//
-//---------------------------------------------------------------------------
-
-void M_ForceUppercase(char *text)
-{
-    char c;
-
-    while ((c = *text) != 0)
-    {
-        if (c >= 'a' && c <= 'z')
-        {
-            *text++ = c - ('a' - 'A');
-        }
-        else
-        {
-            text++;
-        }
-    }
-}
 
--- /dev/null
+++ b/src/hexen/m_random.c
@@ -1,0 +1,81 @@
+// Emacs style mode select   -*- C++ -*- 
+//-----------------------------------------------------------------------------
+//
+// Copyright(C) 1993-1996 Id Software, Inc.
+// Copyright(C) 1993-2008 Raven Software
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+// 02111-1307, USA.
+//
+//-----------------------------------------------------------------------------
+
+
+// HEADER FILES ------------------------------------------------------------
+
+#include "m_random.h"
+
+// This is the new flat distribution table
+
+static const unsigned char rndtable[256] = {
+    201, 1, 243, 19, 18, 42, 183, 203, 101, 123, 154, 137, 34, 118, 10, 216,
+    135, 246, 0, 107, 133, 229, 35, 113, 177, 211, 110, 17, 139, 84, 251, 235,
+    182, 166, 161, 230, 143, 91, 24, 81, 22, 94, 7, 51, 232, 104, 122, 248,
+    175, 138, 127, 171, 222, 213, 44, 16, 9, 33, 88, 102, 170, 150, 136, 114,
+    62, 3, 142, 237, 6, 252, 249, 56, 74, 30, 13, 21, 180, 199, 32, 132,
+    187, 234, 78, 210, 46, 131, 197, 8, 206, 244, 73, 4, 236, 178, 195, 70,
+    121, 97, 167, 217, 103, 40, 247, 186, 105, 39, 95, 163, 99, 149, 253, 29,
+    119, 83, 254, 26, 202, 65, 130, 155, 60, 64, 184, 106, 221, 93, 164, 196,
+    112, 108, 179, 141, 54, 109, 11, 126, 75, 165, 191, 227, 87, 225, 156, 15,
+    98, 162, 116, 79, 169, 140, 190, 205, 168, 194, 41, 250, 27, 20, 14, 241,
+    50, 214, 72, 192, 220, 233, 67, 148, 96, 185, 176, 181, 215, 207, 172, 85,
+    89, 90, 209, 128, 124, 2, 55, 173, 66, 152, 47, 129, 59, 43, 159, 240,
+    239, 12, 189, 212, 144, 28, 200, 77, 219, 198, 134, 228, 45, 92, 125, 151,
+    5, 53, 255, 52, 68, 245, 160, 158, 61, 86, 58, 82, 117, 37, 242, 145,
+    69, 188, 115, 76, 63, 100, 49, 111, 153, 80, 38, 57, 174, 224, 71, 231,
+    23, 25, 48, 218, 120, 147, 208, 36, 226, 223, 193, 238, 157, 204, 146, 31
+};
+
+
+int rndindex = 0;
+int prndindex = 0;
+
+/*
+===============
+=
+= M_Random
+=
+= Returns a 0-255 number
+=
+===============
+*/
+
+
+int P_Random(void)
+{
+    prndindex = (prndindex + 1) & 0xff;
+    return rndtable[prndindex];
+}
+
+int M_Random(void)
+{
+    rndindex = (rndindex + 1) & 0xff;
+    return rndtable[rndindex];
+}
+
+void M_ClearRandom(void)
+{
+    rndindex = prndindex = 0;
+}
+
--- a/src/hexen/p_acs.c
+++ b/src/hexen/p_acs.c
@@ -25,6 +25,7 @@
 // HEADER FILES ------------------------------------------------------------
 
 #include "h2def.h"
+#include "m_random.h"
 #include "s_sound.h"
 #include "i_swap.h"
 #include "i_system.h"
--- a/src/hexen/p_anim.c
+++ b/src/hexen/p_anim.c
@@ -25,6 +25,7 @@
 // HEADER FILES ------------------------------------------------------------
 
 #include "h2def.h"
+#include "m_random.h"
 #include "i_system.h"
 #include "p_local.h"
 #include "s_sound.h"
--- a/src/hexen/p_enemy.c
+++ b/src/hexen/p_enemy.c
@@ -23,6 +23,7 @@
 
 
 #include "h2def.h"
+#include "m_random.h"
 #include "i_system.h"
 #include "i_swap.h"
 #include "p_local.h"
--- a/src/hexen/p_inter.c
+++ b/src/hexen/p_inter.c
@@ -23,6 +23,7 @@
 
 
 #include "h2def.h"
+#include "m_random.h"
 #include "i_system.h"
 #include "p_local.h"
 #include "s_sound.h"
--- a/src/hexen/p_lights.c
+++ b/src/hexen/p_lights.c
@@ -23,6 +23,7 @@
 
 
 #include "h2def.h"
+#include "m_random.h"
 #include "p_local.h"
 
 //============================================================================
--- a/src/hexen/p_map.c
+++ b/src/hexen/p_map.c
@@ -23,6 +23,7 @@
 
 
 #include "h2def.h"
+#include "m_random.h"
 #include "i_system.h"
 #include "m_bbox.h"
 #include "p_local.h"
--- a/src/hexen/p_mobj.c
+++ b/src/hexen/p_mobj.c
@@ -25,6 +25,7 @@
 // HEADER FILES ------------------------------------------------------------
 
 #include "h2def.h"
+#include "m_random.h"
 #include "i_system.h"
 #include "p_local.h"
 #include "s_sound.h"
--- a/src/hexen/p_plats.c
+++ b/src/hexen/p_plats.c
@@ -23,6 +23,7 @@
 
 
 #include "h2def.h"
+#include "m_random.h"
 #include "i_system.h"
 #include "p_local.h"
 
--- a/src/hexen/p_pspr.c
+++ b/src/hexen/p_pspr.c
@@ -25,6 +25,7 @@
 // HEADER FILES ------------------------------------------------------------
 
 #include "h2def.h"
+#include "m_random.h"
 #include "p_local.h"
 #include "s_sound.h"
 
--- a/src/hexen/p_telept.c
+++ b/src/hexen/p_telept.c
@@ -25,6 +25,7 @@
 // HEADER FILES ------------------------------------------------------------
 
 #include "h2def.h"
+#include "m_random.h"
 #include "i_system.h"
 #include "p_local.h"
 #include "s_sound.h"
--- a/src/hexen/p_user.c
+++ b/src/hexen/p_user.c
@@ -23,6 +23,7 @@
 
 
 #include "h2def.h"
+#include "m_random.h"
 #include "i_system.h"
 #include "p_local.h"
 #include "s_sound.h"
--- a/src/hexen/r_main.c
+++ b/src/hexen/r_main.c
@@ -23,6 +23,7 @@
 
 
 #include <math.h>
+#include "m_random.h"
 #include "h2def.h"
 #include "m_bbox.h"
 #include "r_local.h"
--- a/src/hexen/s_sound.c
+++ b/src/hexen/s_sound.c
@@ -22,6 +22,7 @@
 //-----------------------------------------------------------------------------
 
 #include "h2def.h"
+#include "m_random.h"
 #include "i_cdmus.h"
 #include "i_sound.h"
 #include "i_system.h"
--- a/src/hexen/sn_sonix.c
+++ b/src/hexen/sn_sonix.c
@@ -25,6 +25,7 @@
 // HEADER FILES ------------------------------------------------------------
 
 #include <string.h>
+#include "m_random.h"
 #include "h2def.h"
 #include "i_system.h"
 #include "i_sound.h"
--- a/src/hexen/xddefs.h
+++ b/src/hexen/xddefs.h
@@ -193,17 +193,4 @@
     mappatch_t patches[1];
 } PACKEDATTR maptexture_t;
 
-//--------------------------------------------------------------------------
-//
-// Graphics
-//
-//--------------------------------------------------------------------------
-
-// a pic is an unmasked block of pixels
-typedef struct
-{
-    byte width, height;
-    byte data;
-} pic_t;
-
 #endif // __XDDEFS__
--- a/src/m_argv.c
+++ b/src/m_argv.c
@@ -106,7 +106,7 @@
     // needed.
 
     file = malloc(size + 1);
-    fread(file, size, 1, handle);
+    (void) fread(file, size, 1, handle);
     fclose(handle);
 
     // Create new arguments list array
--- a/src/m_misc.c
+++ b/src/m_misc.c
@@ -197,3 +197,51 @@
     return result;
 }
 
+void M_ExtractFileBase(char *path, char *dest)
+{
+    char*	src;
+    int		length;
+
+    src = path + strlen(path) - 1;
+
+    // back up until a \ or the start
+    while (src != path && *(src - 1) != DIR_SEPARATOR)
+    {
+	src--;
+    }
+
+    // copy up to eight characters
+    memset(dest, 0, 8);
+    length = 0;
+
+    while (*src != '\0' && *src != '.')
+    {
+        ++length;
+
+	if (length > 8)
+        {
+	    I_Error ("Filename base of %s >8 chars", path);
+        }
+
+	*dest++ = toupper((int)*src++);
+    }
+}
+
+//---------------------------------------------------------------------------
+//
+// PROC M_ForceUppercase
+//
+// Change string to uppercase.
+//
+//---------------------------------------------------------------------------
+
+void M_ForceUppercase(char *text)
+{
+    char *p;
+
+    for (p = text; *p != '\0'; ++p)
+    {
+        *p = toupper(*p);
+    }
+}
+
--- a/src/m_misc.h
+++ b/src/m_misc.h
@@ -39,6 +39,9 @@
 char *M_TempFile(char *s);
 boolean M_FileExists(char *file);
 long M_FileLength(FILE *handle);
+void M_ExtractFileBase(char *path, char *dest);
+void M_ForceUppercase(char *text);
+
 
 #endif
 
--- a/src/w_wad.c
+++ b/src/w_wad.c
@@ -71,32 +71,6 @@
 
 static lumpinfo_t **lumphash;
 
-static void ExtractFileBase(char *path, char *dest)
-{
-    char*	src;
-    int		length;
-
-    src = path + strlen(path) - 1;
-    
-    // back up until a \ or the start
-    while (src != path && *(src - 1) != DIR_SEPARATOR)
-    {
-	src--;
-    }
-    
-    // copy up to eight characters
-    memset (dest,0,8);
-    length = 0;
-    
-    while (*src && *src != '.')
-    {
-	if (++length == 9)
-	    I_Error ("Filename base of %s >8 chars",path);
-
-	*dest++ = toupper((int)*src++);
-    }
-}
-
 // Hash function used for lump names.
 
 unsigned int W_LumpNameHash(const char *s)
@@ -167,7 +141,7 @@
         // Name the lump after the base of the filename (without the
         // extension).
 
-	ExtractFileBase (filename, fileinfo->name);
+	M_ExtractFileBase (filename, fileinfo->name);
 	numlumps++;
     }
     else