From 83072f093d2231130a33800d592b101ffbb9df8a Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Thu, 11 Sep 2008 22:17:03 +0000 Subject: Remove duplicate w_wad.c from hexen/ and DevMaps option. Subversion-branch: /branches/raven-branch Subversion-revision: 1225 --- src/hexen/Makefile.am | 1 - src/hexen/h2_main.c | 42 ---- src/hexen/h2def.h | 26 +-- src/hexen/mn_menu.c | 2 +- src/hexen/p_setup.c | 27 --- src/hexen/sb_bar.c | 27 +-- src/hexen/w_wad.c | 601 -------------------------------------------------- src/hexen/xddefs.h | 7 +- 8 files changed, 8 insertions(+), 725 deletions(-) delete mode 100644 src/hexen/w_wad.c diff --git a/src/hexen/Makefile.am b/src/hexen/Makefile.am index a9ab0022..a43125f3 100644 --- a/src/hexen/Makefile.am +++ b/src/hexen/Makefile.am @@ -57,7 +57,6 @@ st_start.c st_start.h \ sv_save.c \ textdefs.h \ v_video.c \ -w_wad.c \ xddefs.h EXTRA_DIST= \ diff --git a/src/hexen/h2_main.c b/src/hexen/h2_main.c index 4a3f31c2..2313b463 100644 --- a/src/hexen/h2_main.c +++ b/src/hexen/h2_main.c @@ -81,7 +81,6 @@ static void AddWADFile(char *file); static void DrawAndBlit(void); static void ExecOptionFILE(char **args, int tag); static void ExecOptionSCRIPTS(char **args, int tag); -static void ExecOptionDEVMAPS(char **args, int tag); static void ExecOptionSKILL(char **args, int tag); static void ExecOptionPLAYDEMO(char **args, int tag); static void ExecOptionMAXZONE(char **args, int tag); @@ -101,8 +100,6 @@ extern char *SavePath; // PUBLIC DATA DEFINITIONS ------------------------------------------------- -boolean DevMaps; // true = Map development mode -char *DevMapsDir = ""; // development maps directory boolean shareware; // true if only episode 1 present boolean nomonsters; // checkparm of -nomonsters boolean respawnparm; // checkparm of -respawn @@ -142,7 +139,6 @@ static char *wadfiles[MAXWADFILES] = { static execOpt_t ExecOptions[] = { {"-file", ExecOptionFILE, 1, 0}, {"-scripts", ExecOptionSCRIPTS, 1, 0}, - {"-devmaps", ExecOptionDEVMAPS, 1, 0}, {"-skill", ExecOptionSKILL, 1, 0}, {"-playdemo", ExecOptionPLAYDEMO, 1, 0}, {"-timedemo", ExecOptionPLAYDEMO, 1, 0}, @@ -433,44 +429,6 @@ static void ExecOptionSCRIPTS(char **args, int tag) sc_ScriptsDir = args[1]; } -//========================================================================== -// -// ExecOptionDEVMAPS -// -//========================================================================== - -static void ExecOptionDEVMAPS(char **args, int tag) -{ - DevMaps = true; - ST_Message("Map development mode enabled:\n"); - ST_Message("[config ] = %s\n", args[1]); - SC_OpenFileCLib(args[1]); - SC_MustGetStringName("mapsdir"); - SC_MustGetString(); - ST_Message("[mapsdir ] = %s\n", sc_String); - DevMapsDir = malloc(strlen(sc_String) + 1); - strcpy(DevMapsDir, sc_String); - SC_MustGetStringName("scriptsdir"); - SC_MustGetString(); - ST_Message("[scriptsdir] = %s\n", sc_String); - sc_FileScripts = true; - sc_ScriptsDir = malloc(strlen(sc_String) + 1); - strcpy(sc_ScriptsDir, sc_String); - while (SC_GetString()) - { - if (SC_Compare("file")) - { - SC_MustGetString(); - AddWADFile(sc_String); - } - else - { - SC_ScriptError(NULL); - } - } - SC_Close(); -} - long superatol(char *s) { diff --git a/src/hexen/h2def.h b/src/hexen/h2def.h index 416591aa..fa90f6dd 100644 --- a/src/hexen/h2def.h +++ b/src/hexen/h2def.h @@ -901,33 +901,9 @@ long LongSwap(long); #endif +#include "w_wad.h" #include "z_zone.h" -//------- -//WADFILE -//------- -typedef struct -{ - char name[8]; - int handle, position, size; -} lumpinfo_t; - -extern lumpinfo_t *lumpinfo; -extern int numlumps; - -void W_InitMultipleFiles(char **filenames); -void W_OpenAuxiliary(char *filename); -void W_CloseAuxiliaryFile(void); -void W_CloseAuxiliary(void); -void W_UsePrimary(void); -void W_UseAuxiliary(void); -int W_CheckNumForName(char *name); -int W_GetNumForName(char *name); -int W_LumpLength(int lump); -void W_ReadLump(int lump, void *dest); -void *W_CacheLumpNum(int lump, int tag); -void *W_CacheLumpName(char *name, int tag); - //---------- //BASE LEVEL //---------- diff --git a/src/hexen/mn_menu.c b/src/hexen/mn_menu.c index 36fcfacc..aa5decd8 100644 --- a/src/hexen/mn_menu.c +++ b/src/hexen/mn_menu.c @@ -1429,7 +1429,7 @@ boolean MN_Responder(event_t * event) false); return true; case KEY_F12: // F12 - reload current map (devmaps mode) - if (netgame || DevMaps == false) + if (netgame) { return false; } diff --git a/src/hexen/p_setup.c b/src/hexen/p_setup.c index 02f88737..abcab748 100644 --- a/src/hexen/p_setup.c +++ b/src/hexen/p_setup.c @@ -288,9 +288,6 @@ void P_LoadSectors(int lump) ms = (mapsector_t *) data; ss = sectors; - // Make sure primary lumps are used for flat searching - W_UsePrimary(); - for (i = 0; i < numsectors; i++, ss++, ms++) { ss->floorheight = SHORT(ms->floorheight) << FRACBITS; @@ -303,10 +300,6 @@ void P_LoadSectors(int lump) ss->thinglist = NULL; ss->seqType = SEQTYPE_STONE; // default seqType } - if (DevMaps) - { - W_UseAuxiliary(); - } Z_Free(data); } @@ -513,9 +506,6 @@ void P_LoadSideDefs(int lump) msd = (mapsidedef_t *) data; sd = sides; - // Make sure primary lumps are used for texture searching - W_UsePrimary(); - for (i = 0; i < numsides; i++, msd++, sd++) { sd->textureoffset = SHORT(msd->textureoffset) << FRACBITS; @@ -525,10 +515,6 @@ void P_LoadSideDefs(int lump) sd->midtexture = R_TextureNumForName(msd->midtexture); sd->sector = §ors[SHORT(msd->sector)]; } - if (DevMaps) - { - W_UseAuxiliary(); - } Z_Free(data); } @@ -694,11 +680,6 @@ void P_SetupLevel(int episode, int map, int playermask, skill_t skill) P_InitThinkers(); leveltime = 0; - if (DevMaps) - { - sprintf(auxName, "%sMAP%02d.WAD", DevMapsDir, map); - W_OpenAuxiliary(auxName); - } sprintf(lumpname, "MAP%02d", map); lumpnum = W_GetNumForName(lumpname); // @@ -724,14 +705,6 @@ void P_SetupLevel(int episode, int map, int playermask, skill_t skill) // // End of map lump processing // - if (DevMaps) - { - // Close the auxiliary file, but don't free its loaded lumps. - // The next call to W_OpenAuxiliary() will do a full shutdown - // of the current auxiliary WAD (free lumps and info lists). - W_CloseAuxiliaryFile(); - W_UsePrimary(); - } // If deathmatch, randomly spawn the active players TimerGame = 0; diff --git a/src/hexen/sb_bar.c b/src/hexen/sb_bar.c index 6245c357..77f7bfad 100644 --- a/src/hexen/sb_bar.c +++ b/src/hexen/sb_bar.c @@ -1999,28 +1999,11 @@ static void CheatWarpFunc(player_t * player, Cheat_t * cheat) P_SetMessage(player, TXT_CHEATBADINPUT, true); return; } - if (DevMaps) - { // Search map development directory - sprintf(auxName, "%sMAP%02d.WAD", DevMapsDir, map); - fp = fopen(auxName, "rb"); - if (fp) - { - fclose(fp); - } - else - { // Can't find - P_SetMessage(player, TXT_CHEATNOMAP, true); - return; - } - } - else - { // Search primary lumps - sprintf(mapName, "MAP%02d", map); - if (W_CheckNumForName(mapName) == -1) - { // Can't find - P_SetMessage(player, TXT_CHEATNOMAP, true); - return; - } + sprintf(mapName, "MAP%02d", map); + if (W_CheckNumForName(mapName) == -1) + { // Can't find + P_SetMessage(player, TXT_CHEATNOMAP, true); + return; } P_SetMessage(player, TXT_CHEATWARP, true); G_TeleportNewMap(map, 0); diff --git a/src/hexen/w_wad.c b/src/hexen/w_wad.c deleted file mode 100644 index 9155d9cf..00000000 --- a/src/hexen/w_wad.c +++ /dev/null @@ -1,601 +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. -// -//----------------------------------------------------------------------------- - - -// HEADER FILES ------------------------------------------------------------ - -#include -#include -#include -#include - -#include "h2def.h" - -// MACROS ------------------------------------------------------------------ - -#ifndef O_BINARY -#define O_BINARY 0 -#endif - -// TYPES ------------------------------------------------------------------- - -typedef struct -{ - char identification[4]; - int numlumps; - int infotableofs; -} wadinfo_t; - -typedef struct -{ - int filepos; - int size; - char name[8]; -} filelump_t; - -// EXTERNAL FUNCTION PROTOTYPES -------------------------------------------- - -// PUBLIC FUNCTION PROTOTYPES ---------------------------------------------- - -// PRIVATE FUNCTION PROTOTYPES --------------------------------------------- - -// EXTERNAL DATA DECLARATIONS ---------------------------------------------- - -// PUBLIC DATA DEFINITIONS ------------------------------------------------- - -lumpinfo_t *lumpinfo; -int numlumps; -void **lumpcache; - -// PRIVATE DATA DEFINITIONS ------------------------------------------------ - -static lumpinfo_t *PrimaryLumpInfo; -static int PrimaryNumLumps; -static void **PrimaryLumpCache; -static lumpinfo_t *AuxiliaryLumpInfo; -static int AuxiliaryNumLumps; -static void **AuxiliaryLumpCache; -static int AuxiliaryHandle = 0; -boolean AuxiliaryOpened = false; - -// CODE -------------------------------------------------------------------- - -#ifdef NeXT -//========================================================================== -// -// strupr -// -//========================================================================== - -void strupr(char *s) -{ - while (*s) - *s++ = toupper(*s); -} - -//========================================================================== -// -// filelength -// -//========================================================================== - -int filelength(int handle) -{ - struct stat fileinfo; - - if (fstat(handle, &fileinfo) == -1) - { - I_Error("Error fstating"); - } - return fileinfo.st_size; -} -#endif - -//========================================================================== -// -// W_AddFile -// -// Files with a .wad extension are wadlink files with multiple lumps, -// other files are single lumps with the base filename for the lump name. -// -//========================================================================== - -void W_AddFile(char *filename) -{ - wadinfo_t header; - lumpinfo_t *lump_p; - unsigned i; - int handle, length; - int startlump; - filelump_t *fileinfo, singleinfo; - filelump_t *freeFileInfo; - - if ((handle = open(filename, O_RDONLY | O_BINARY)) == -1) - { // Didn't find file - return; - } - startlump = numlumps; - if (strcmpi(filename + strlen(filename) - 3, "wad")) - { // Single lump file - fileinfo = &singleinfo; - freeFileInfo = NULL; - singleinfo.filepos = 0; - singleinfo.size = LONG(filelength(handle)); - M_ExtractFileBase(filename, singleinfo.name); - numlumps++; - } - else - { // WAD file - read(handle, &header, sizeof(header)); - if (strncmp(header.identification, "IWAD", 4)) - { - if (strncmp(header.identification, "PWAD", 4)) - { // Bad file id - I_Error("Wad file %s doesn't have IWAD or PWAD id\n", - filename); - } - } - header.numlumps = LONG(header.numlumps); - header.infotableofs = LONG(header.infotableofs); - length = header.numlumps * sizeof(filelump_t); -// fileinfo = alloca(length); - if (!(fileinfo = malloc(length))) - { - I_Error("W_AddFile: fileinfo malloc failed\n"); - } - freeFileInfo = fileinfo; - lseek(handle, header.infotableofs, SEEK_SET); - read(handle, fileinfo, length); - numlumps += header.numlumps; - } - - // Fill in lumpinfo - lumpinfo = realloc(lumpinfo, numlumps * sizeof(lumpinfo_t)); - if (!lumpinfo) - { - I_Error("Couldn't realloc lumpinfo"); - } - lump_p = &lumpinfo[startlump]; - for (i = startlump; i < numlumps; i++, lump_p++, fileinfo++) - { - lump_p->handle = handle; - lump_p->position = LONG(fileinfo->filepos); - lump_p->size = LONG(fileinfo->size); - strncpy(lump_p->name, fileinfo->name, 8); - } - if (freeFileInfo) - { - free(freeFileInfo); - } -} - -//========================================================================== -// -// W_InitMultipleFiles -// -// Pass a null terminated list of files to use. All files are optional, -// but at least one file must be found. Lump names can appear multiple -// times. The name searcher looks backwards, so a later file can -// override an earlier one. -// -//========================================================================== - -void W_InitMultipleFiles(char **filenames) -{ - int size; - - // Open all the files, load headers, and count lumps - numlumps = 0; - lumpinfo = malloc(1); // Will be realloced as lumps are added - - for (; *filenames; filenames++) - { - W_AddFile(*filenames); - } - if (!numlumps) - { - I_Error("W_InitMultipleFiles: no files found"); - } - - // Set up caching - size = numlumps * sizeof(*lumpcache); - lumpcache = malloc(size); - if (!lumpcache) - { - I_Error("Couldn't allocate lumpcache"); - } - memset(lumpcache, 0, size); - - PrimaryLumpInfo = lumpinfo; - PrimaryLumpCache = lumpcache; - PrimaryNumLumps = numlumps; -} - -//========================================================================== -// -// W_InitFile -// -// Initialize the primary from a single file. -// -//========================================================================== - -void W_InitFile(char *filename) -{ - char *names[2]; - - names[0] = filename; - names[1] = NULL; - W_InitMultipleFiles(names); -} - -//========================================================================== -// -// W_OpenAuxiliary -// -//========================================================================== - -void W_OpenAuxiliary(char *filename) -{ - int i; - int size; - wadinfo_t header; - int handle; - int length; - filelump_t *fileinfo; - filelump_t *sourceLump; - lumpinfo_t *destLump; - - if (AuxiliaryOpened) - { - W_CloseAuxiliary(); - } - if ((handle = open(filename, O_RDONLY | O_BINARY)) == -1) - { - I_Error("W_OpenAuxiliary: %s not found.", filename); - return; - } - AuxiliaryHandle = handle; - read(handle, &header, sizeof(header)); - if (strncmp(header.identification, "IWAD", 4)) - { - if (strncmp(header.identification, "PWAD", 4)) - { // Bad file id - I_Error("Wad file %s doesn't have IWAD or PWAD id\n", filename); - } - } - header.numlumps = LONG(header.numlumps); - header.infotableofs = LONG(header.infotableofs); - length = header.numlumps * sizeof(filelump_t); - fileinfo = Z_Malloc(length, PU_STATIC, 0); - lseek(handle, header.infotableofs, SEEK_SET); - read(handle, fileinfo, length); - numlumps = header.numlumps; - - // Init the auxiliary lumpinfo array - lumpinfo = Z_Malloc(numlumps * sizeof(lumpinfo_t), PU_STATIC, 0); - sourceLump = fileinfo; - destLump = lumpinfo; - for (i = 0; i < numlumps; i++, destLump++, sourceLump++) - { - destLump->handle = handle; - destLump->position = LONG(sourceLump->filepos); - destLump->size = LONG(sourceLump->size); - strncpy(destLump->name, sourceLump->name, 8); - } - Z_Free(fileinfo); - - // Allocate the auxiliary lumpcache array - size = numlumps * sizeof(*lumpcache); - lumpcache = Z_Malloc(size, PU_STATIC, 0); - memset(lumpcache, 0, size); - - AuxiliaryLumpInfo = lumpinfo; - AuxiliaryLumpCache = lumpcache; - AuxiliaryNumLumps = numlumps; - AuxiliaryOpened = true; -} - -//========================================================================== -// -// W_CloseAuxiliary -// -//========================================================================== - -void W_CloseAuxiliary(void) -{ - int i; - - if (AuxiliaryOpened) - { - W_UseAuxiliary(); - for (i = 0; i < numlumps; i++) - { - if (lumpcache[i]) - { - Z_Free(lumpcache[i]); - } - } - Z_Free(AuxiliaryLumpInfo); - Z_Free(AuxiliaryLumpCache); - W_CloseAuxiliaryFile(); - AuxiliaryOpened = false; - } - W_UsePrimary(); -} - -//========================================================================== -// -// W_CloseAuxiliaryFile -// -// WARNING: W_CloseAuxiliary() must be called before any further -// auxiliary lump processing. -// -//========================================================================== - -void W_CloseAuxiliaryFile(void) -{ - if (AuxiliaryHandle) - { - close(AuxiliaryHandle); - AuxiliaryHandle = 0; - } -} - -//========================================================================== -// -// W_UsePrimary -// -//========================================================================== - -void W_UsePrimary(void) -{ - lumpinfo = PrimaryLumpInfo; - numlumps = PrimaryNumLumps; - lumpcache = PrimaryLumpCache; -} - -//========================================================================== -// -// W_UseAuxiliary -// -//========================================================================== - -void W_UseAuxiliary(void) -{ - if (AuxiliaryOpened == false) - { - I_Error("W_UseAuxiliary: WAD not opened."); - } - lumpinfo = AuxiliaryLumpInfo; - numlumps = AuxiliaryNumLumps; - lumpcache = AuxiliaryLumpCache; -} - -//========================================================================== -// -// W_NumLumps -// -//========================================================================== - -int W_NumLumps(void) -{ - return numlumps; -} - -//========================================================================== -// -// W_CheckNumForName -// -// Returns -1 if name not found. -// -//========================================================================== - -int W_CheckNumForName(char *name) -{ - char name8[9]; - int v1, v2; - lumpinfo_t *lump_p; - - // Make the name into two integers for easy compares - strncpy(name8, name, 8); - name8[8] = 0; // in case the name was a full 8 chars - strupr(name8); // case insensitive - v1 = *(int *) name8; - v2 = *(int *) &name8[4]; - - // Scan backwards so patch lump files take precedence - lump_p = lumpinfo + numlumps; - while (lump_p-- != lumpinfo) - { - if (*(int *) lump_p->name == v1 && *(int *) &lump_p->name[4] == v2) - { - return lump_p - lumpinfo; - } - } - return -1; -} - -//========================================================================== -// -// W_GetNumForName -// -// Calls W_CheckNumForName, but bombs out if not found. -// -//========================================================================== - -int W_GetNumForName(char *name) -{ - int i; - - i = W_CheckNumForName(name); - if (i != -1) - { - return i; - } - I_Error("W_GetNumForName: %s not found!", name); - return -1; -} - -//========================================================================== -// -// W_LumpLength -// -// Returns the buffer size needed to load the given lump. -// -//========================================================================== - -int W_LumpLength(int lump) -{ - if (lump >= numlumps) - { - I_Error("W_LumpLength: %i >= numlumps", lump); - } - return lumpinfo[lump].size; -} - -//========================================================================== -// -// W_ReadLump -// -// Loads the lump into the given buffer, which must be >= W_LumpLength(). -// -//========================================================================== - -void W_ReadLump(int lump, void *dest) -{ - int c; - lumpinfo_t *l; - - if (lump >= numlumps) - { - I_Error("W_ReadLump: %i >= numlumps", lump); - } - l = lumpinfo + lump; - //I_BeginRead(); - lseek(l->handle, l->position, SEEK_SET); - c = read(l->handle, dest, l->size); - if (c < l->size) - { - I_Error("W_ReadLump: only read %i of %i on lump %i", - c, l->size, lump); - } - //I_EndRead(); -} - -//========================================================================== -// -// W_CacheLumpNum -// -//========================================================================== - -void *W_CacheLumpNum(int lump, int tag) -{ - byte *ptr; - - if ((unsigned) lump >= numlumps) - { - I_Error("W_CacheLumpNum: %i >= numlumps", lump); - } - if (!lumpcache[lump]) - { // Need to read the lump in - ptr = Z_Malloc(W_LumpLength(lump), tag, &lumpcache[lump]); - W_ReadLump(lump, lumpcache[lump]); - } - else - { - Z_ChangeTag(lumpcache[lump], tag); - } - return lumpcache[lump]; -} - -//========================================================================== -// -// W_CacheLumpName -// -//========================================================================== - -void *W_CacheLumpName(char *name, int tag) -{ - return W_CacheLumpNum(W_GetNumForName(name), tag); -} - -//========================================================================== -// -// W_Profile -// -//========================================================================== - -// Ripped out for Heretic -/* -int info[2500][10]; -int profilecount; - -void W_Profile (void) -{ - int i; - memblock_t *block; - void *ptr; - char ch; - FILE *f; - int j; - char name[9]; - - - for (i=0 ; itag < PU_PURGELEVEL) - ch = 'S'; - else - ch = 'P'; - } - info[i][profilecount] = ch; - } - profilecount++; - - f = fopen ("waddump.txt","w"); - name[8] = 0; - for (i=0 ; i