summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Howard2008-10-30 02:10:50 +0000
committerSimon Howard2008-10-30 02:10:50 +0000
commit091f93809ee554571a6ed6145b8ac69f17814d91 (patch)
tree25e8e1f92ef66e95f5ab19f5d588562292a02785
parent8c045b4bfee2e859f800f8fbd76f5ae3d5d3f435 (diff)
downloadchocolate-doom-091f93809ee554571a6ed6145b8ac69f17814d91.tar.gz
chocolate-doom-091f93809ee554571a6ed6145b8ac69f17814d91.tar.bz2
chocolate-doom-091f93809ee554571a6ed6145b8ac69f17814d91.zip
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
-rw-r--r--src/d_mode.c63
-rw-r--r--src/d_mode.h2
-rw-r--r--src/heretic/Makefile.am1
-rw-r--r--src/heretic/d_main.c12
-rw-r--r--src/heretic/doomdef.h11
-rw-r--r--src/heretic/m_misc.c92
-rw-r--r--src/heretic/sb_bar.c2
-rw-r--r--src/hexen/Makefile.am1
-rw-r--r--src/hexen/a_action.c1
-rw-r--r--src/hexen/g_game.c1
-rw-r--r--src/hexen/h2_main.c48
-rw-r--r--src/hexen/h2def.h19
-rw-r--r--src/hexen/m_misc.c145
-rw-r--r--src/hexen/m_random.c81
-rw-r--r--src/hexen/p_acs.c1
-rw-r--r--src/hexen/p_anim.c1
-rw-r--r--src/hexen/p_enemy.c1
-rw-r--r--src/hexen/p_inter.c1
-rw-r--r--src/hexen/p_lights.c1
-rw-r--r--src/hexen/p_map.c1
-rw-r--r--src/hexen/p_mobj.c1
-rw-r--r--src/hexen/p_plats.c1
-rw-r--r--src/hexen/p_pspr.c1
-rw-r--r--src/hexen/p_telept.c1
-rw-r--r--src/hexen/p_user.c1
-rw-r--r--src/hexen/r_main.c1
-rw-r--r--src/hexen/s_sound.c1
-rw-r--r--src/hexen/sn_sonix.c1
-rw-r--r--src/hexen/xddefs.h13
-rw-r--r--src/m_argv.c2
-rw-r--r--src/m_misc.c48
-rw-r--r--src/m_misc.h3
-rw-r--r--src/w_wad.c28
33 files changed, 227 insertions, 360 deletions
diff --git a/src/d_mode.c b/src/d_mode.c
index 12b97e6a..435ce8d5 100644
--- 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.
@@ -59,6 +64,42 @@ boolean D_ValidGameMode(GameMission_t mission, GameMode_t mode)
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;
+}
+
// Table of valid versions
static struct {
diff --git a/src/d_mode.h b/src/d_mode.h
index b7214737..360ac2c1 100644
--- a/src/d_mode.h
+++ b/src/d_mode.h
@@ -85,6 +85,8 @@ typedef enum
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__ */
diff --git a/src/heretic/Makefile.am b/src/heretic/Makefile.am
index f5e620b6..4a539c47 100644
--- a/src/heretic/Makefile.am
+++ b/src/heretic/Makefile.am
@@ -16,7 +16,6 @@ f_finale.c \
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 \
diff --git a/src/heretic/d_main.c b/src/heretic/d_main.c
index 669d7b3d..70fd57c0 100644
--- a/src/heretic/d_main.c
+++ b/src/heretic/d_main.c
@@ -857,12 +857,18 @@ void D_DoomMain(void)
// -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 @@ void D_DoomMain(void)
// 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;
diff --git a/src/heretic/doomdef.h b/src/heretic/doomdef.h
index aac70e2f..e18f14f9 100644
--- a/src/heretic/doomdef.h
+++ b/src/heretic/doomdef.h
@@ -833,17 +833,6 @@ int R_CheckTextureNumForName(char *name);
//----
// 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);
//----------------------
diff --git a/src/heretic/m_misc.c b/src/heretic/m_misc.c
deleted file mode 100644
index 39674e4b..00000000
--- a/src/heretic/m_misc.c
+++ /dev/null
@@ -1,92 +0,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++;
- }
- }
-}
-
diff --git a/src/heretic/sb_bar.c b/src/heretic/sb_bar.c
index 3fefe54f..e21fc1c2 100644
--- a/src/heretic/sb_bar.c
+++ b/src/heretic/sb_bar.c
@@ -1237,7 +1237,7 @@ static void CheatWarpFunc(player_t * player, Cheat_t * cheat)
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);
diff --git a/src/hexen/Makefile.am b/src/hexen/Makefile.am
index c47e9746..e8ca8b98 100644
--- a/src/hexen/Makefile.am
+++ b/src/hexen/Makefile.am
@@ -17,6 +17,7 @@ h2_main.c \
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 \
diff --git a/src/hexen/a_action.c b/src/hexen/a_action.c
index fcecb5fd..29500618 100644
--- 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"
diff --git a/src/hexen/g_game.c b/src/hexen/g_game.c
index 22cc3e3d..abfd8d53 100644
--- 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"
diff --git a/src/hexen/h2_main.c b/src/hexen/h2_main.c
index 9d253575..15b6b1b6 100644
--- a/src/hexen/h2_main.c
+++ b/src/hexen/h2_main.c
@@ -214,6 +214,13 @@ static void D_HexenQuitMessage(void)
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 @@ void D_DoomMain(void)
"one with the '-iwad' command line parameter.");
}
- W_AddFile(iwadfile);
+ D_AddFile(iwadfile);
HandleArgs();
@@ -467,12 +474,15 @@ static void ExecOptionSKILL(char **args, int tag)
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);
}
}
@@ -505,40 +515,6 @@ static void ExecOptionSCRIPTS(char **args, int tag)
}
-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);
-}
-
-
//==========================================================================
//
// H2_GameLoop
diff --git a/src/hexen/h2def.h b/src/hexen/h2def.h
index a00d90bd..2a64dee0 100644
--- a/src/hexen/h2def.h
+++ b/src/hexen/h2def.h
@@ -237,9 +237,6 @@ typedef struct
fixed_t x, y, z;
} degenmobj_t;
-// Most damage defined using HITDICE
-#define HITDICE(a) ((1+(P_Random()&7))*a)
-
//
// frame flags
//
@@ -975,22 +972,6 @@ int R_CheckTextureNumForName(char *name);
//----
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);
//------------------------------
diff --git a/src/hexen/m_misc.c b/src/hexen/m_misc.c
index eb16b621..5382e3cb 100644
--- 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++;
- }
- }
-}
diff --git a/src/hexen/m_random.c b/src/hexen/m_random.c
new file mode 100644
index 00000000..b84f6d63
--- /dev/null
+++ b/src/hexen/m_random.c
@@ -0,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;
+}
+
diff --git a/src/hexen/p_acs.c b/src/hexen/p_acs.c
index b5e938d1..5e4988ac 100644
--- 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"
diff --git a/src/hexen/p_anim.c b/src/hexen/p_anim.c
index ca7685bf..ef56e811 100644
--- 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"
diff --git a/src/hexen/p_enemy.c b/src/hexen/p_enemy.c
index 41cc2fdd..ac73d1f3 100644
--- 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"
diff --git a/src/hexen/p_inter.c b/src/hexen/p_inter.c
index 1f57912e..92298f21 100644
--- 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"
diff --git a/src/hexen/p_lights.c b/src/hexen/p_lights.c
index 7ea7cf67..648f040c 100644
--- 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"
//============================================================================
diff --git a/src/hexen/p_map.c b/src/hexen/p_map.c
index 827670aa..16734325 100644
--- 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"
diff --git a/src/hexen/p_mobj.c b/src/hexen/p_mobj.c
index 4accc36b..db3078da 100644
--- 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"
diff --git a/src/hexen/p_plats.c b/src/hexen/p_plats.c
index 97795ead..4b2eeec3 100644
--- 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"
diff --git a/src/hexen/p_pspr.c b/src/hexen/p_pspr.c
index dad7f131..ddfb4601 100644
--- 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"
diff --git a/src/hexen/p_telept.c b/src/hexen/p_telept.c
index 5b7a0e45..538587fd 100644
--- 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"
diff --git a/src/hexen/p_user.c b/src/hexen/p_user.c
index d8db08b3..c86c19e1 100644
--- 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"
diff --git a/src/hexen/r_main.c b/src/hexen/r_main.c
index 05b5a0c7..426cbcc7 100644
--- 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"
diff --git a/src/hexen/s_sound.c b/src/hexen/s_sound.c
index 954bf817..5733c700 100644
--- 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"
diff --git a/src/hexen/sn_sonix.c b/src/hexen/sn_sonix.c
index 412791a3..2c136504 100644
--- 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"
diff --git a/src/hexen/xddefs.h b/src/hexen/xddefs.h
index f62ac4d4..6be289f4 100644
--- a/src/hexen/xddefs.h
+++ b/src/hexen/xddefs.h
@@ -193,17 +193,4 @@ typedef struct
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__
diff --git a/src/m_argv.c b/src/m_argv.c
index 63c86e26..acc15dfd 100644
--- a/src/m_argv.c
+++ b/src/m_argv.c
@@ -106,7 +106,7 @@ static void LoadResponseFile(int argv_index)
// needed.
file = malloc(size + 1);
- fread(file, size, 1, handle);
+ (void) fread(file, size, 1, handle);
fclose(handle);
// Create new arguments list array
diff --git a/src/m_misc.c b/src/m_misc.c
index a42d6b89..e493d58c 100644
--- a/src/m_misc.c
+++ b/src/m_misc.c
@@ -197,3 +197,51 @@ char *M_TempFile(char *s)
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);
+ }
+}
+
diff --git a/src/m_misc.h b/src/m_misc.h
index 0fea7e92..ec70a405 100644
--- a/src/m_misc.h
+++ b/src/m_misc.h
@@ -39,6 +39,9 @@ void M_MakeDirectory(char *dir);
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
diff --git a/src/w_wad.c b/src/w_wad.c
index 8fa46cd7..4f944fee 100644
--- a/src/w_wad.c
+++ b/src/w_wad.c
@@ -71,32 +71,6 @@ unsigned int numlumps = 0;
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 @@ wad_file_t *W_AddFile (char *filename)
// Name the lump after the base of the filename (without the
// extension).
- ExtractFileBase (filename, fileinfo->name);
+ M_ExtractFileBase (filename, fileinfo->name);
numlumps++;
}
else