diff --git a/source/build/src/defs.cpp b/source/build/src/defs.cpp index f11d366a3..ab94457b0 100644 --- a/source/build/src/defs.cpp +++ b/source/build/src/defs.cpp @@ -18,6 +18,7 @@ #include "palettecontainer.h" #include "mapinfo.h" #include "hw_voxels.h" +#include "parsefuncs.h" int tileSetHightileReplacement(int picnum, int palnum, const char* filename, float alphacut, float xscale, float yscale, float specpower, float specfactor, uint8_t flags); int tileSetSkybox(int picnum, int palnum, const char** facenames, int flags); @@ -646,15 +647,9 @@ static int32_t defsparser(scriptfile *script) break; } case T_ANIMTILERANGE: - { - SetAnim set; - if (scriptfile_getsymbol(script,&set.tile1)) break; - if (scriptfile_getsymbol(script,&set.tile2)) break; - if (scriptfile_getsymbol(script,&set.speed)) break; - if (scriptfile_getsymbol(script,&set.type)) break; - processSetAnim("animtilerange", pos, set); + parseAnimTileRange(*script, pos); break; - } + case T_TILEFROMTEXTURE: { auto texturepos = scriptfile_getposition(script); diff --git a/source/common/console/c_bind.cpp b/source/common/console/c_bind.cpp index 1aad2d255..fa94d1e72 100644 --- a/source/common/console/c_bind.cpp +++ b/source/common/console/c_bind.cpp @@ -696,6 +696,12 @@ void ReadBindings(int lump, bool override) dest = &AutomapBindings; sc.MustGetString(); } + else if (sc.Compare("unbind")) + { + sc.MustGetString(); + dest->UnbindKey(sc.String); + continue; + } key = GetConfigKeyFromName(sc.String); sc.MustGetString(); dest->SetBind(key, sc.String, override); diff --git a/source/common/engine/sc_man.h b/source/common/engine/sc_man.h index 6c37806a8..3a894fcb3 100644 --- a/source/common/engine/sc_man.h +++ b/source/common/engine/sc_man.h @@ -113,6 +113,13 @@ public: void MustGetNumber(bool evaluate = false); bool CheckNumber(bool evaluate = false); + bool GetNumber(int& var, bool evaluate = false) + { + if (!GetNumber(evaluate)) return false; + var = Number; + return true; + } + bool GetFloat(bool evaluate = false); void MustGetFloat(bool evaluate = false); bool CheckFloat(bool evaluate = false); diff --git a/source/common/filesystem/file_zip.cpp b/source/common/filesystem/file_zip.cpp index 00de98cdc..2adca1160 100644 --- a/source/common/filesystem/file_zip.cpp +++ b/source/common/filesystem/file_zip.cpp @@ -233,12 +233,14 @@ bool FZipFile::Open(bool quiet, LumpFilterInfo* filter) } name.ToLower(); + if (name.IndexOf("__macosx") == 0) + continue; // skip Apple garbage. At this stage only the root folder matters, if (i == 0) { // check for special names, if one of these gets found this must be treated as a normal zip. bool isspecial = name.IndexOf("/") < 0 || (filter && filter->reservedFolders.Find(name) < filter->reservedFolders.Size()); if (isspecial) break; - name0 = name; + name0 = name.Left(name.LastIndexOf("/")+1); } else { @@ -252,7 +254,7 @@ bool FZipFile::Open(bool quiet, LumpFilterInfo* filter) // at least one of the more common definition lumps must be present. for (auto &p : filter->requiredPrefixes) { - if (name.IndexOf(name0 + p) == 0) + if (name.IndexOf(name0 + p) == 0 || name.LastIndexOf(p) == name.Len() - strlen(p)) { foundspeciallump = true; break; @@ -272,7 +274,6 @@ bool FZipFile::Open(bool quiet, LumpFilterInfo* filter) int len = LittleShort(zip_fh->NameLength); FString name(dirptr + sizeof(FZipCentralDirectoryInfo), len); - if (name0.IsNotEmpty()) name = name.Mid(name0.Len()); dirptr += sizeof(FZipCentralDirectoryInfo) + LittleShort(zip_fh->NameLength) + LittleShort(zip_fh->ExtraLength) + @@ -284,7 +285,14 @@ bool FZipFile::Open(bool quiet, LumpFilterInfo* filter) if (!quiet) Printf(TEXTCOLOR_RED "\n%s: Central directory corrupted.", FileName.GetChars()); return false; } - + + if (name.IndexOf("__macosx") == 0 || name.IndexOf("__MACOSX") == 0) + { + skipped++; + continue; // Weed out Apple's resource fork garbage right here because it interferes with safe operation. + } + if (name0.IsNotEmpty()) name = name.Mid(name0.Len()); + // skip Directories if (name.IsEmpty() || (name.Back() == '/' && LittleLong(zip_fh->UncompressedSize) == 0)) { diff --git a/source/core/initfs.cpp b/source/core/initfs.cpp index f18fd50d3..6910d2cdf 100644 --- a/source/core/initfs.cpp +++ b/source/core/initfs.cpp @@ -274,6 +274,18 @@ static void DeleteStuff(FileSystem &fileSystem, const TArray& deletelum // // //========================================================================== +const char* iwad_folders[13] = { "textures/", "hires/", "sounds/", "music/", "maps/" }; +const char* iwad_reserved_duke[12] = { ".map", ".con", "menudef", "gldefs", "zscript", "maps/", nullptr }; +const char* iwad_reserved_blood[12] = { ".map", ".ini", "menudef", "gldefs", "zscript", "maps/", nullptr }; +const char* iwad_reserved_sw[12] = { ".map", "swcustom.txt", "menudef", "gldefs", "zscript", "maps/", nullptr }; +const char* iwad_reserved_ex[12] = { ".map", "menudef", "gldefs", "zscript", "maps/", nullptr }; + +const char** iwad_reserved() +{ + return (g_gameType & GAMEFLAG_PSEXHUMED) ? iwad_reserved_ex : + (g_gameType & GAMEFLAG_SW) ? iwad_reserved_sw : + (g_gameType & GAMEFLAG_BLOOD) ? iwad_reserved_blood : iwad_reserved_duke; +} void InitFileSystem(TArray& groups) { @@ -374,6 +386,8 @@ void InitFileSystem(TArray& groups) } todelete.Append(userConfig.toBeDeleted); LumpFilterInfo lfi; + for (auto p : iwad_folders) lfi.reservedFolders.Push(p); + for (auto p = iwad_reserved(); *p; p++) lfi.requiredPrefixes.Push(*p); lfi.dotFilter = LumpFilter; diff --git a/source/core/parsefuncs.h b/source/core/parsefuncs.h new file mode 100644 index 000000000..05b3aa87b --- /dev/null +++ b/source/core/parsefuncs.h @@ -0,0 +1,48 @@ + +/* +** parsefuncs.h +** handlers for .def parser +** only to be included by the actual parser +** +**--------------------------------------------------------------------------- +** Copyright 2021 Christoph Oelckers +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +** +*/ + + +void parseAnimTileRange(FScanner& sc, FScriptPosition& pos) +{ + SetAnim set; + if (!sc.GetNumber(set.tile1, true)) return; + if (!sc.GetNumber(set.tile2, true)) return; + if (!sc.GetNumber(set.speed, true)) return; + if (!sc.GetNumber(set.type, true)) return; + processSetAnim("animtilerange", pos, set); +} + diff --git a/source/games/blood/src/levels.cpp b/source/games/blood/src/levels.cpp index ad1cd6ad9..462fbe316 100644 --- a/source/games/blood/src/levels.cpp +++ b/source/games/blood/src/levels.cpp @@ -115,6 +115,28 @@ void levelLoadMapInfo(IniFile *pIni, MapRecord *pLevelInfo, const char *pzSectio static const char* DefFile(void) { + int found = -1; + if (userConfig.DefaultCon.IsEmpty() || userConfig.DefaultCon.CompareNoCase("blood.ini") == 0) + { + int numlumps = fileSystem.GetNumEntries(); + for (int i = numlumps - 1; i >= 0; i--) + { + if (fileSystem.GetFileContainer(i) <= fileSystem.GetMaxIwadNum()) break; + FString fn = fileSystem.GetFileFullName(i, false); + FString ext = fn.Right(4); + if (ext.CompareNoCase(".ini") == 0) + { + if (fileSystem.CheckNumForFullName(fn) != i) continue; + if (found == -1) found = i; + else + { + found = -1; + break; + } + } + } + } + if (found >= 0) return fileSystem.GetFileFullName(found); // The command line parser stores this in the CON field. return userConfig.DefaultCon.IsNotEmpty() ? userConfig.DefaultCon.GetChars() : "blood.ini"; } diff --git a/wadsrc/static/filter/blood/engine/origbinds.txt b/wadsrc/static/filter/blood/engine/origbinds.txt index 85f93e3dc..e13f235d1 100644 --- a/wadsrc/static/filter/blood/engine/origbinds.txt +++ b/wadsrc/static/filter/blood/engine/origbinds.txt @@ -8,3 +8,8 @@ X "+Alt_Fire" J "useitem 4" M "useitem 1" Mouse2 "+Alt_Fire" + +unbind KP0 +unbind KP. +unbind DEL +unbind INS