From 62d036a63e12cdafb74ff617a5bd58444892284e Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Sun, 5 Apr 2015 20:24:49 -0500 Subject: [PATCH] Added gametype-based filter - For when IWADs are too specific, filter by the base gametype too. - Minor small edits to the sndinfo.txt files so that zipdir will notice the changes, since it doesn't check path names when checking for file differences. --- src/resourcefiles/resourcefile.cpp | 35 ++++++++++++++++++ src/resourcefiles/resourcefile.h | 1 + .../{doom => game-doomchex}/sndinfo.txt | 1 + .../{heretic => game-heretic}/sndinfo.txt | 1 + .../filter/{hexen => game-hexen}/sndinfo.txt | 1 + .../{strife => game-strife}/acs/strfhelp.o | Bin .../{strife => game-strife}/loadacs.txt | 0 .../{strife => game-strife}/sndinfo.txt | 1 + 8 files changed, 40 insertions(+) rename wadsrc/static/filter/{doom => game-doomchex}/sndinfo.txt (99%) rename wadsrc/static/filter/{heretic => game-heretic}/sndinfo.txt (99%) rename wadsrc/static/filter/{hexen => game-hexen}/sndinfo.txt (99%) rename wadsrc/static/filter/{strife => game-strife}/acs/strfhelp.o (100%) rename wadsrc/static/filter/{strife => game-strife}/loadacs.txt (100%) rename wadsrc/static/filter/{strife => game-strife}/sndinfo.txt (99%) diff --git a/src/resourcefiles/resourcefile.cpp b/src/resourcefiles/resourcefile.cpp index caeb1090f..d5ad659af 100644 --- a/src/resourcefiles/resourcefile.cpp +++ b/src/resourcefiles/resourcefile.cpp @@ -344,6 +344,7 @@ void FResourceFile::PostProcessArchive(void *lumps, size_t lumpsize) // in the ini file use. We reduce the maximum lump concidered after // each one so that we don't risk refiltering already filtered lumps. DWORD max = NumLumps; + max -= FilterLumpsByGameType(gameinfo.gametype, lumps, lumpsize, max); max -= FilterLumps(gameinfo.ConfigName, lumps, lumpsize, max); max -= FilterLumps(LumpFilterGroup, lumps, lumpsize, max); max -= FilterLumps(LumpFilterIWAD, lumps, lumpsize, max); @@ -406,6 +407,40 @@ int FResourceFile::FilterLumps(FString filtername, void *lumps, size_t lumpsize, return end - start; } +//========================================================================== +// +// FResourceFile :: FilterLumpsByGameType +// +// Matches any lumps that match "filter/game-/*". Includes +// inclusive gametypes like Raven. +// +//========================================================================== + +int FResourceFile::FilterLumpsByGameType(int type, void *lumps, size_t lumpsize, DWORD max) +{ + static const struct { int match; const char *name; } blanket[] = + { + { GAME_Raven, "game-Raven" }, + { GAME_DoomStrifeChex, "game-DoomStrifeChex" }, + { GAME_DoomChex, "game-DoomChex" }, + }; + if (type == 0) + { + return 0; + } + int count = 0; + for (int i = 0; i < countof(blanket); ++i) + { + if (type & blanket[i].match) + { + count += FilterLumps(blanket[i].name, lumps, lumpsize, max); + } + } + FString filter = "game-"; + filter += GameNames[type]; + return count + FilterLumps(filter, lumps, lumpsize, max); +} + //========================================================================== // // FResourceFile :: JunkLeftoverFilters diff --git a/src/resourcefiles/resourcefile.h b/src/resourcefiles/resourcefile.h index c62981ca7..e84967a24 100644 --- a/src/resourcefiles/resourcefile.h +++ b/src/resourcefiles/resourcefile.h @@ -72,6 +72,7 @@ private: DWORD FirstLump; int FilterLumps(FString filtername, void *lumps, size_t lumpsize, DWORD max); + int FilterLumpsByGameType(int gametype, void *lumps, size_t lumpsize, DWORD max); bool FindPrefixRange(FString filter, void *lumps, size_t lumpsize, DWORD max, DWORD &start, DWORD &end); void JunkLeftoverFilters(void *lumps, size_t lumpsize, DWORD max); diff --git a/wadsrc/static/filter/doom/sndinfo.txt b/wadsrc/static/filter/game-doomchex/sndinfo.txt similarity index 99% rename from wadsrc/static/filter/doom/sndinfo.txt rename to wadsrc/static/filter/game-doomchex/sndinfo.txt index 6028b11f0..c103f493c 100644 --- a/wadsrc/static/filter/doom/sndinfo.txt +++ b/wadsrc/static/filter/game-doomchex/sndinfo.txt @@ -1,3 +1,4 @@ + /****************************************************************************/ /* */ /* DOOM SOUNDS */ diff --git a/wadsrc/static/filter/heretic/sndinfo.txt b/wadsrc/static/filter/game-heretic/sndinfo.txt similarity index 99% rename from wadsrc/static/filter/heretic/sndinfo.txt rename to wadsrc/static/filter/game-heretic/sndinfo.txt index cb3fe1e73..b9f1fd7c3 100644 --- a/wadsrc/static/filter/heretic/sndinfo.txt +++ b/wadsrc/static/filter/game-heretic/sndinfo.txt @@ -1,3 +1,4 @@ + /****************************************************************************/ /* */ /* HERETIC SOUNDS */ diff --git a/wadsrc/static/filter/hexen/sndinfo.txt b/wadsrc/static/filter/game-hexen/sndinfo.txt similarity index 99% rename from wadsrc/static/filter/hexen/sndinfo.txt rename to wadsrc/static/filter/game-hexen/sndinfo.txt index 85d7a75dd..a1169dcb9 100644 --- a/wadsrc/static/filter/hexen/sndinfo.txt +++ b/wadsrc/static/filter/game-hexen/sndinfo.txt @@ -1,3 +1,4 @@ + /****************************************************************************/ /* */ /* HEXEN SOUNDS */ diff --git a/wadsrc/static/filter/strife/acs/strfhelp.o b/wadsrc/static/filter/game-strife/acs/strfhelp.o similarity index 100% rename from wadsrc/static/filter/strife/acs/strfhelp.o rename to wadsrc/static/filter/game-strife/acs/strfhelp.o diff --git a/wadsrc/static/filter/strife/loadacs.txt b/wadsrc/static/filter/game-strife/loadacs.txt similarity index 100% rename from wadsrc/static/filter/strife/loadacs.txt rename to wadsrc/static/filter/game-strife/loadacs.txt diff --git a/wadsrc/static/filter/strife/sndinfo.txt b/wadsrc/static/filter/game-strife/sndinfo.txt similarity index 99% rename from wadsrc/static/filter/strife/sndinfo.txt rename to wadsrc/static/filter/game-strife/sndinfo.txt index 877bba50a..22f9b8356 100644 --- a/wadsrc/static/filter/strife/sndinfo.txt +++ b/wadsrc/static/filter/game-strife/sndinfo.txt @@ -1,3 +1,4 @@ + /****************************************************************************/ /* */ /* STRIFE SOUNDS */