From cf7d8ab43b62b37c2a99ea96e7836d1e56591590 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 19 Jun 2006 15:31:10 +0000 Subject: [PATCH] - Removed the unused sfx_ variables for the chainsaw sounds. - Fixed map name checks in idclev, hxvisit, for +map and the titlemap. - Changed handling of Zips so that the patches/, graphics/, sounds/ and music/ subdirectories no longer are placed in the global namespace. Instead new namespaces are defined. These namespaces aren't merged, however and searching in them either returns a lump inside it or one from the global namespace when it doesn't come from a Zip file. Proper order of files is still observed though. As a result proper use of the directories inside Zips is strictly enforced now so that for example anything used as a patch must be in the patches/ directory and won't be found anywhere else. SVN r199 (trunk) --- docs/rh-log.txt | 12 ++++++++++ src/c_cmds.cpp | 10 +++++++-- src/d_main.cpp | 10 ++++++--- src/decallib.cpp | 2 +- src/g_level.cpp | 9 ++------ src/g_shared/shared_sbar.cpp | 4 ++-- src/m_menu.cpp | 4 ++-- src/oplsynth/opl_mus_player.cpp | 2 +- src/p_acs.cpp | 6 +---- src/r_data.cpp | 8 +++---- src/r_things.cpp | 4 ++-- src/s_advsound.cpp | 14 +++--------- src/s_sound.cpp | 6 +---- src/sound/altsound.cpp | 4 ++-- src/sound/fmodsound.cpp | 4 ++-- src/v_font.cpp | 6 ++--- src/v_video.cpp | 2 +- src/w_wad.cpp | 39 +++++++++++++++++++++++---------- src/w_wad.h | 14 +++++++++++- 19 files changed, 95 insertions(+), 65 deletions(-) diff --git a/docs/rh-log.txt b/docs/rh-log.txt index 97d2438e1..ec1158e22 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,3 +1,15 @@ +June 19, 2006 (Changes by Graf Zahl) +- Removed the unused sfx_ variables for the chainsaw sounds. +- Fixed map name checks in idclev, hxvisit, for +map and the titlemap. +- Changed handling of Zips so that the patches/, graphics/, sounds/ and + music/ subdirectories no longer are placed in the global namespace. Instead + new namespaces are defined. These namespaces aren't merged, however and + searching in them either returns a lump inside it or one from the global + namespace when it doesn't come from a Zip file. Proper order of files is + still observed though. As a result proper use of the directories inside Zips + is strictly enforced now so that for example anything used as a patch must be + in the patches/ directory and won't be found anywhere else. + June 18, 2006 (Changes by Graf Zahl) - Added another set of ACS inventory functions which take a tid for the actor and aren't limited to the script's activator. diff --git a/src/c_cmds.cpp b/src/c_cmds.cpp index 38300f104..50fd60e56 100644 --- a/src/c_cmds.cpp +++ b/src/c_cmds.cpp @@ -257,10 +257,13 @@ CCMD (idclev) // Catch invalid maps. mapname = CalcMapName (epsd, map); - if (Wads.CheckNumForName (mapname) == -1) + + MapData * mapd = P_OpenMapData(mapname); + if (mapd == NULL) return; // So be it. + delete mapd; Printf ("%s\n", GStrings("STSTR_CLEV")); G_DeferedInitNew (mapname); players[0].health = 0; // Force reset @@ -281,9 +284,12 @@ CCMD (hxvisit) if (CheckWarpTransMap (mapname, false)) { // Just because it's in MAPINFO doesn't mean it's in the wad. - if (Wads.CheckNumForName (mapname) != -1) + + MapData * map = P_OpenMapData(mapname); + if (map != NULL) { // So be it. + delete map; Printf ("%s\n", GStrings("STSTR_CLEV")); G_DeferedInitNew (mapname); return; diff --git a/src/d_main.cpp b/src/d_main.cpp index 130d95f57..252726b54 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -810,7 +810,7 @@ void D_DoStrifeAdvanceDemo () case 0: pagetic = 6 * TICRATE; pagename = "TITLEPIC"; - if (Wads.CheckNumForName ("d_logo") < 0) + if (Wads.CheckNumForName ("d_logo", ns_music) < 0) { // strife0.wad does not have d_logo S_StartMusic (""); } @@ -925,7 +925,9 @@ void D_DoAdvanceDemo (void) // [RH] If you want something more dynamic for your title, create a map // and name it TITLEMAP. That map will be loaded and used as the title. - if (Wads.CheckNumForName ("TITLEMAP") >= 0) + + MapData * map = P_OpenMapData("TITLEMAP"); + if (map != NULL) { G_InitNew ("TITLEMAP", true); return; @@ -2129,12 +2131,14 @@ void D_DoomMain (void) p = Args.CheckParm ("+map"); if (p && p < Args.NumArgs()-1) { - if (Wads.CheckNumForName (Args.GetArg (p+1)) == -1) + MapData * map = P_OpenMapData(Args.GetArg (p+1)); + if (map == NULL) { Printf ("Can't find map %s\n", Args.GetArg (p+1)); } else { + delete map; strncpy (startmap, Args.GetArg (p+1), 8); Args.GetArg (p)[0] = '-'; autostart = true; diff --git a/src/decallib.cpp b/src/decallib.cpp index 62f5970db..5cd4d1788 100644 --- a/src/decallib.cpp +++ b/src/decallib.cpp @@ -470,7 +470,7 @@ void FDecalLib::ParseDecal () case DECAL_PIC: SC_MustGetString (); picnum = TexMan.CheckForTexture (sc_String, FTexture::TEX_Any); - if (picnum < 0 && (picnum = Wads.CheckNumForName (sc_String)) >= 0) + if (picnum < 0 && (picnum = Wads.CheckNumForName (sc_String, ns_graphics)) >= 0) { picnum = TexMan.CreateTexture (picnum, FTexture::TEX_Decal); } diff --git a/src/g_level.cpp b/src/g_level.cpp index 5a5250efd..606724089 100644 --- a/src/g_level.cpp +++ b/src/g_level.cpp @@ -624,14 +624,9 @@ static void G_DoParseMapInfo (int lump) strcpy (levelinfo->skypic2, levelinfo->skypic1); } SetLevelNum (levelinfo, levelinfo->levelnum); // Wipe out matching levelnums from other maps. - if (levelinfo->pname[0] != 0 && TexMan.CheckForTexture (levelinfo->pname, FTexture::TEX_MiscPatch) < 0) + if (levelinfo->pname[0] != 0) { - int lumpnum = Wads.CheckNumForName (levelinfo->pname); - if (lumpnum >= 0) - { - TexMan.CreateTexture (lumpnum, FTexture::TEX_MiscPatch); - } - else + if (TexMan.AddPatch(levelinfo->pname) < 0) { levelinfo->pname[0] = 0; } diff --git a/src/g_shared/shared_sbar.cpp b/src/g_shared/shared_sbar.cpp index 91d24bcb4..3c27601cc 100644 --- a/src/g_shared/shared_sbar.cpp +++ b/src/g_shared/shared_sbar.cpp @@ -104,10 +104,10 @@ CUSTOM_CVAR (Int, crosshair, 0, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) } size = (SCREENWIDTH < 640) ? 'S' : 'B'; sprintf (name, "XHAIR%c%d", size, num); - if ((lump = Wads.CheckNumForName (name)) == -1) + if ((lump = Wads.CheckNumForName (name, ns_graphics)) == -1) { sprintf (name, "XHAIR%c1", size); - if ((lump = Wads.CheckNumForName (name)) == -1) + if ((lump = Wads.CheckNumForName (name, ns_graphics)) == -1) { strcpy (name, "XHAIRS1"); } diff --git a/src/m_menu.cpp b/src/m_menu.cpp index ced3fbb03..9eb54c11c 100644 --- a/src/m_menu.cpp +++ b/src/m_menu.cpp @@ -1381,11 +1381,11 @@ void M_DrawReadThis () { char name[9]; name[8] = 0; - Wads.GetLumpName (name, Wads.GetNumForName (gameinfo.info.indexed.basePage) + InfoType); + Wads.GetLumpName (name, Wads.GetNumForName (gameinfo.info.indexed.basePage, ns_graphics) + InfoType); tex = TexMan[name]; if (InfoType > 1) { - Wads.GetLumpName (name, Wads.GetNumForName (gameinfo.info.indexed.basePage) + InfoType - 1); + Wads.GetLumpName (name, Wads.GetNumForName (gameinfo.info.indexed.basePage, ns_graphics) + InfoType - 1); prevpic = TexMan[name]; } } diff --git a/src/oplsynth/opl_mus_player.cpp b/src/oplsynth/opl_mus_player.cpp index 02b8f5284..7a4e1a021 100644 --- a/src/oplsynth/opl_mus_player.cpp +++ b/src/oplsynth/opl_mus_player.cpp @@ -499,7 +499,7 @@ OPLmusicWriter::OPLmusicWriter (const char *songname, const char *filename) else { SharingData = false; - int lumpnum = Wads.CheckNumForName (songname); + int lumpnum = Wads.CheckNumForName (songname, ns_music); if (lumpnum == -1) { Printf ("Song %s is unknown.\n", songname); diff --git a/src/p_acs.cpp b/src/p_acs.cpp index ad5e2145b..6ec8971ed 100644 --- a/src/p_acs.cpp +++ b/src/p_acs.cpp @@ -1931,11 +1931,7 @@ void DLevelScript::DoSetFont (int fontnum) num = TexMan.CheckForTexture (fontname, FTexture::TEX_Any); if (num <= 0) { - num = Wads.CheckNumForName (fontname); - if (num > 0) - { - num = TexMan.CreateTexture (num); - } + num = TexMan.AddPatch(fontname); } if (num > 0) { diff --git a/src/r_data.cpp b/src/r_data.cpp index 71c30ea39..ffb945b22 100644 --- a/src/r_data.cpp +++ b/src/r_data.cpp @@ -241,7 +241,7 @@ int FTextureManager::CreateTexture (int lumpnum, int usetype) } first4bytes; // Must check the length of the lump. Zero length flat markers (F1_START etc.) will come through here. - // 13 is the minimum length of andthing valid (i.e a 1x1 pixel Doom patch.) + // 13 is the minimum length of anything valid (i.e a 1x1 pixel Doom patch.) if (lumpnum < 0 || Wads.LumpLength(lumpnum)<13) { return -1; @@ -426,7 +426,7 @@ int FTextureManager::AddPatch (const char *patchname, int namespc) { return lumpnum; } - lumpnum = Wads.CheckNumForName (patchname, namespc); + lumpnum = Wads.CheckNumForName (patchname, namespc==ns_global? ns_graphics:namespc); if (lumpnum < 0) { return -1; @@ -603,7 +603,7 @@ void FTextureManager::AddPatches (int lumpnum) if (CheckForTexture (name, FTexture::TEX_WallPatch, false) == -1) { - CreateTexture (Wads.CheckNumForName (name), FTexture::TEX_WallPatch); + CreateTexture (Wads.CheckNumForName (name, ns_patches), FTexture::TEX_WallPatch); } } @@ -1163,7 +1163,7 @@ void FPatchTexture::GetDimensions () if (dummy.width <= 0 || dummy.height <= 0 || dummy.width > 2048 || dummy.height > 2048) { delete lump; - lump = Wads.ReopenLumpNum ( Wads.GetNumForName("-BADPATC") ); + lump = Wads.ReopenLumpNum ( Wads.GetNumForName("-BADPATC", ns_graphics) ); (*lump) >> dummy.width >> dummy.height; } diff --git a/src/r_things.cpp b/src/r_things.cpp index 431acc4f7..0ef4e1c4a 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -512,7 +512,7 @@ void R_InitSkins (void) int lump = Wads.CheckNumForName (sc_String, skins[i].namespc); if (lump == -1) { - lump = Wads.CheckNumForName (sc_String); + lump = Wads.CheckNumForName (sc_String, ns_sounds); } if (lump != -1) { @@ -545,7 +545,7 @@ void R_InitSkins (void) sndlumps[j] = Wads.CheckNumForName (sc_String, skins[i].namespc); if (sndlumps[j] == -1) { // Replacement not found, try finding it in the global namespace - sndlumps[j] = Wads.CheckNumForName (sc_String); + sndlumps[j] = Wads.CheckNumForName (sc_String, ns_sounds); } } } diff --git a/src/s_advsound.cpp b/src/s_advsound.cpp index 0f6ca34b1..c65437587 100644 --- a/src/s_advsound.cpp +++ b/src/s_advsound.cpp @@ -440,7 +440,7 @@ int S_FindSoundTentative (const char *name) int S_AddSound (const char *logicalname, const char *lumpname) { return S_AddSound (logicalname, - lumpname ? Wads.CheckNumForName (lumpname) : -1); + lumpname ? Wads.CheckNumForName (lumpname, ns_sounds) : -1); } static int S_AddSound (const char *logicalname, int lumpnum) @@ -494,7 +494,7 @@ int S_AddPlayerSound (const char *pclass, int gender, int refid, const char *lumpname) { return S_AddPlayerSound (pclass, gender, refid, - lumpname ? Wads.CheckNumForName (lumpname) : -1); + lumpname ? Wads.CheckNumForName (lumpname, ns_sounds) : -1); } int S_AddPlayerSound (const char *pclass, int gender, int refid, int lumpnum, bool fromskin) @@ -648,15 +648,7 @@ void S_ParseSndInfo () S_ShrinkPlayerSoundLists (); - // [RH] Hack for pitch varying - sfx_sawup = S_FindSound ("weapons/sawup"); - sfx_sawidl = S_FindSound ("weapons/sawidle"); - sfx_sawful = S_FindSound ("weapons/sawfull"); - sfx_sawhit = S_FindSound ("weapons/sawhit"); - sfx_itemup = S_FindSound ("misc/i_pkup"); - sfx_tink = S_FindSound ("misc/chat2"); - - sfx_empty = Wads.CheckNumForName ("dsempty"); + sfx_empty = Wads.CheckNumForName ("dsempty", ns_sounds); } //========================================================================== diff --git a/src/s_sound.cpp b/src/s_sound.cpp index 7a1f8d0ff..1cb1abc88 100644 --- a/src/s_sound.cpp +++ b/src/s_sound.cpp @@ -152,10 +152,6 @@ static FPlayList *PlayList; // PUBLIC DATA DEFINITIONS ------------------------------------------------- -// [RH] Hacks for pitch variance -int sfx_sawup, sfx_sawidl, sfx_sawful, sfx_sawhit; -int sfx_itemup, sfx_tink; - int sfx_empty; int numChannels; @@ -1500,7 +1496,7 @@ bool S_ChangeMusic (const char *musicname, int order, bool looping, bool force) if (!FileExists (musicname)) { - if ((lumpnum = Wads.CheckNumForName (musicname)) == -1) + if ((lumpnum = Wads.CheckNumForName (musicname, ns_music)) == -1) { if ((lumpnum = Wads.CheckNumForFullName (musicname)) == -1) { diff --git a/src/sound/altsound.cpp b/src/sound/altsound.cpp index c4fe16b28..aaa61d06d 100644 --- a/src/sound/altsound.cpp +++ b/src/sound/altsound.cpp @@ -641,7 +641,7 @@ void AltSoundRenderer::LoadSound (sfxinfo_t *sfx) size = sfx->lumpnum >= 0 ? Wads.LumpLength (sfx->lumpnum) : 0; if (size == 0) { - sfx->lumpnum = Wads.GetNumForName ("dsempty"); + sfx->lumpnum = Wads.GetNumForName ("dsempty", ns_sounds); size = Wads.LumpLength (sfx->lumpnum); if (size == 0) { @@ -792,7 +792,7 @@ badwave: delete[] sfxdata; sfxdata = NULL; } - sfx->lumpnum = Wads.GetNumForName ("dsempty"); + sfx->lumpnum = Wads.GetNumForName ("dsempty", ns_sounds); LoadSound (sfx); } if (sfxdata != NULL) delete[] sfxdata; diff --git a/src/sound/fmodsound.cpp b/src/sound/fmodsound.cpp index ac47ed290..01f4b50e3 100644 --- a/src/sound/fmodsound.cpp +++ b/src/sound/fmodsound.cpp @@ -1054,7 +1054,7 @@ void FMODSoundRenderer::DoLoad (void **slot, sfxinfo_t *sfx) } if (errcount) - sfx->lumpnum = Wads.GetNumForName ("dsempty"); + sfx->lumpnum = Wads.GetNumForName ("dsempty", ns_sounds); size = Wads.LumpLength (sfx->lumpnum); if (size == 0) @@ -1187,7 +1187,7 @@ void FMODSoundRenderer::getsfx (sfxinfo_t *sfx) // If the sound doesn't exist, replace it with the empty sound. if (sfx->lumpnum == -1) { - sfx->lumpnum = Wads.GetNumForName ("dsempty"); + sfx->lumpnum = Wads.GetNumForName ("dsempty", ns_sounds); } // See if there is another sound already initialized with this lump. If so, diff --git a/src/v_font.cpp b/src/v_font.cpp index ec399566d..52a983fe7 100644 --- a/src/v_font.cpp +++ b/src/v_font.cpp @@ -193,15 +193,15 @@ FFont::FFont (const char *name, const char *nametemplate, int first, int count, for (i = 0; i < count; i++) { sprintf (buffer, nametemplate, i + start); - lump = Wads.CheckNumForName (buffer); + lump = Wads.CheckNumForName (buffer, ns_graphics); if (doomtemplate && lump >= 0 && i + start == 121) { // HACKHACK: Don't load STCFN121 in doom(2), because // it's not really a lower-case 'y' but an upper-case 'I'. // Because a lot of wads with their own font seem to foolishly // copy STCFN121 and make it an 'I' themselves, wads must // provide STCFN120 (x) and STCFN122 (z) for STCFN121 to load. - if (Wads.CheckNumForName ("STCFN120") == -1 || - Wads.CheckNumForName ("STCFN122") == -1) + if (Wads.CheckNumForName ("STCFN120", ns_graphics) == -1 || + Wads.CheckNumForName ("STCFN122", ns_graphics) == -1) { lump = -1; } diff --git a/src/v_video.cpp b/src/v_video.cpp index ee79c4079..5ddfe98fd 100644 --- a/src/v_video.cpp +++ b/src/v_video.cpp @@ -867,7 +867,7 @@ void V_Init (void) { SmallFont = new FFont ("SmallFont", "STCFN%.3d", HU_FONTSTART, HU_FONTSIZE, HU_FONTSTART); } - if (Wads.CheckNumForName ("STBFN033") >= 0) + if (Wads.CheckNumForName ("STBFN033", ns_graphics) >= 0) { SmallFont2 = new FFont ("SmallFont2", "STBFN%.3d", HU_FONTSTART, HU_FONTSIZE, HU_FONTSTART); } diff --git a/src/w_wad.cpp b/src/w_wad.cpp index 19e506c3e..c1a04a51f 100644 --- a/src/w_wad.cpp +++ b/src/w_wad.cpp @@ -97,7 +97,9 @@ struct FWadCollection::LumpRecord enum { LUMPF_BLOODCRYPT = 1, // Lump uses Blood-style encryption - LUMPF_COMPRESSED = 2 // Zip-compressed + LUMPF_COMPRESSED = 2, // Zip-compressed + LUMPF_ZIPFILE = 4, // Inside a Zip file - used to enforce use of special directories insize Zips + }; class FWadCollection::WadFileRecord : public FileReader @@ -592,6 +594,10 @@ void FWadCollection::AddFile (const char *filename, const char * data, int lengt lump_p->fullname = copystring(name); lump_p->position = LittleLong(zip_fh->dwFileOffset) + sizeof(FZipLocalHeader) + LittleShort(zip_fh->wFileNameSize); lump_p->size = zip_fh->dwSize; + + // Map some directories to WAD namespaces. + // Note that some of these namespaces don't exist in WADS. + // CheckNumForName will handle any request for these namespaces accordingly. lump_p->namespc = !strncmp(name, "flats/", 6) ? ns_flats : !strncmp(name, "textures/", 9) ? ns_newtextures : !strncmp(name, "hires/", 6) ? ns_hires : @@ -599,10 +605,10 @@ void FWadCollection::AddFile (const char *filename, const char * data, int lengt !strncmp(name, "colormaps/", 10) ? ns_colormaps : !strncmp(name, "acs/", 4) ? ns_acslibrary : !strncmp(name, "voices/", 7) ? ns_strifevoices : - !strncmp(name, "patches/", 8) ? ns_global : - !strncmp(name, "graphics/", 9) ? ns_global : - !strncmp(name, "sounds/", 7) ? ns_global : - !strncmp(name, "music/", 6) ? ns_global : + !strncmp(name, "patches/", 8) ? ns_patches : + !strncmp(name, "graphics/", 9) ? ns_graphics : + !strncmp(name, "sounds/", 7) ? ns_sounds : + !strncmp(name, "music/", 6) ? ns_music : !strchr(name, '/') ? ns_global : -1; // Anything that is not in one of these subdirectories or the main directory @@ -614,7 +620,8 @@ void FWadCollection::AddFile (const char *filename, const char * data, int lengt } lump_p->wadnum = (WORD)NumWads; - lump_p->flags = LittleShort(zip_fh->wCompression) == Z_DEFLATED? LUMPF_COMPRESSED : 0; + lump_p->flags = LittleShort(zip_fh->wCompression) == Z_DEFLATED? + LUMPF_COMPRESSED|LUMPF_ZIPFILE : LUMPF_ZIPFILE; lump_p->compressedsize = LittleLong(zip_fh->dwCompressedSize); // Since '\' can't be used as a file name's part inside a ZIP @@ -816,10 +823,20 @@ int FWadCollection::CheckNumForName (const char *name, int space) uppercopy (uname, name); i = FirstLumpIndex[LumpNameHash (uname) % NumLumps]; - while (i != NULL_INDEX && - (*(__int64 *)&LumpInfo[i].name != *(__int64 *)&uname || - LumpInfo[i].namespc != space)) + while (i != NULL_INDEX) { + if (*(__int64 *)&LumpInfo[i].name == *(__int64 *)&uname) + { + if (LumpInfo[i].namespc == space) break; + // If the lump is from one of the special namespaces exclusive to Zips + // the check has to be done differently: + // If we find a lump with this name in the global namespace that does not come + // from a Zip return that. WADs don't know these namespaces and single lumps must + // work as well. + if (space > ns_specialzipdirectory && + LumpInfo[i].namespc == ns_global && + !(LumpInfo[i].flags & LUMPF_ZIPFILE)) break; + } i = NextLumpIndex[i]; } @@ -858,11 +875,11 @@ int FWadCollection::CheckNumForName (const char *name, int space, int wadnum) // //========================================================================== -int FWadCollection::GetNumForName (const char *name) +int FWadCollection::GetNumForName (const char *name, int space) { int i; - i = CheckNumForName (name); + i = CheckNumForName (name, space); if (i == -1) I_Error ("W_GetNumForName: %s not found!", name); diff --git a/src/w_wad.h b/src/w_wad.h index b462495d5..05162ca40 100644 --- a/src/w_wad.h +++ b/src/w_wad.h @@ -74,6 +74,16 @@ typedef enum { ns_bloodmisc, ns_strifevoices, ns_hires, + + // These namespaces are only used to mark lumps in special subdirectories + // so that their contents doesn't interfere with the global namespace. + // searching for data in these namespaces works differently for lumps coming + // from Zips or other files. + ns_specialzipdirectory, + ns_sounds, + ns_patches, + ns_graphics, + ns_music, } namespace_t; // [RH] Copy an 8-char string and uppercase it. @@ -157,12 +167,14 @@ public: int CheckNumForName (const char *name, int namespc); int CheckNumForName (const char *name, int namespc, int wadfile); - int GetNumForName (const char *name); + int GetNumForName (const char *name, int namespc); inline int CheckNumForName (const byte *name) { return CheckNumForName ((const char *)name, ns_global); } inline int CheckNumForName (const char *name) { return CheckNumForName (name, ns_global); } inline int CheckNumForName (const byte *name, int ns) { return CheckNumForName ((const char *)name, ns); } + inline int GetNumForName (const char *name) { return GetNumForName (name, ns_global); } inline int GetNumForName (const byte *name) { return GetNumForName ((const char *)name); } + inline int GetNumForName (const byte *name, int ns) { return GetNumForName ((const char *)name, ns); } int CheckNumForFullName (const char *name); int CheckNumForFullName (const char *name, int wadfile);