Merge branch 'master' into newrenderer2

This commit is contained in:
Christoph Oelckers 2021-04-06 16:14:21 +02:00
commit 0b79649dc2
8 changed files with 117 additions and 12 deletions

View file

@ -18,6 +18,7 @@
#include "palettecontainer.h" #include "palettecontainer.h"
#include "mapinfo.h" #include "mapinfo.h"
#include "hw_voxels.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 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); int tileSetSkybox(int picnum, int palnum, const char** facenames, int flags);
@ -646,15 +647,9 @@ static int32_t defsparser(scriptfile *script)
break; break;
} }
case T_ANIMTILERANGE: case T_ANIMTILERANGE:
{ parseAnimTileRange(*script, pos);
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);
break; break;
}
case T_TILEFROMTEXTURE: case T_TILEFROMTEXTURE:
{ {
auto texturepos = scriptfile_getposition(script); auto texturepos = scriptfile_getposition(script);

View file

@ -696,6 +696,12 @@ void ReadBindings(int lump, bool override)
dest = &AutomapBindings; dest = &AutomapBindings;
sc.MustGetString(); sc.MustGetString();
} }
else if (sc.Compare("unbind"))
{
sc.MustGetString();
dest->UnbindKey(sc.String);
continue;
}
key = GetConfigKeyFromName(sc.String); key = GetConfigKeyFromName(sc.String);
sc.MustGetString(); sc.MustGetString();
dest->SetBind(key, sc.String, override); dest->SetBind(key, sc.String, override);

View file

@ -113,6 +113,13 @@ public:
void MustGetNumber(bool evaluate = false); void MustGetNumber(bool evaluate = false);
bool CheckNumber(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); bool GetFloat(bool evaluate = false);
void MustGetFloat(bool evaluate = false); void MustGetFloat(bool evaluate = false);
bool CheckFloat(bool evaluate = false); bool CheckFloat(bool evaluate = false);

View file

@ -233,12 +233,14 @@ bool FZipFile::Open(bool quiet, LumpFilterInfo* filter)
} }
name.ToLower(); name.ToLower();
if (name.IndexOf("__macosx") == 0)
continue; // skip Apple garbage. At this stage only the root folder matters,
if (i == 0) if (i == 0)
{ {
// check for special names, if one of these gets found this must be treated as a normal zip. // 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()); bool isspecial = name.IndexOf("/") < 0 || (filter && filter->reservedFolders.Find(name) < filter->reservedFolders.Size());
if (isspecial) break; if (isspecial) break;
name0 = name; name0 = name.Left(name.LastIndexOf("/")+1);
} }
else else
{ {
@ -252,7 +254,7 @@ bool FZipFile::Open(bool quiet, LumpFilterInfo* filter)
// at least one of the more common definition lumps must be present. // at least one of the more common definition lumps must be present.
for (auto &p : filter->requiredPrefixes) 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; foundspeciallump = true;
break; break;
@ -272,7 +274,6 @@ bool FZipFile::Open(bool quiet, LumpFilterInfo* filter)
int len = LittleShort(zip_fh->NameLength); int len = LittleShort(zip_fh->NameLength);
FString name(dirptr + sizeof(FZipCentralDirectoryInfo), len); FString name(dirptr + sizeof(FZipCentralDirectoryInfo), len);
if (name0.IsNotEmpty()) name = name.Mid(name0.Len());
dirptr += sizeof(FZipCentralDirectoryInfo) + dirptr += sizeof(FZipCentralDirectoryInfo) +
LittleShort(zip_fh->NameLength) + LittleShort(zip_fh->NameLength) +
LittleShort(zip_fh->ExtraLength) + 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()); if (!quiet) Printf(TEXTCOLOR_RED "\n%s: Central directory corrupted.", FileName.GetChars());
return false; 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 // skip Directories
if (name.IsEmpty() || (name.Back() == '/' && LittleLong(zip_fh->UncompressedSize) == 0)) if (name.IsEmpty() || (name.Back() == '/' && LittleLong(zip_fh->UncompressedSize) == 0))
{ {

View file

@ -274,6 +274,18 @@ static void DeleteStuff(FileSystem &fileSystem, const TArray<FString>& 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<GrpEntry>& groups) void InitFileSystem(TArray<GrpEntry>& groups)
{ {
@ -374,6 +386,8 @@ void InitFileSystem(TArray<GrpEntry>& groups)
} }
todelete.Append(userConfig.toBeDeleted); todelete.Append(userConfig.toBeDeleted);
LumpFilterInfo lfi; 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; lfi.dotFilter = LumpFilter;

48
source/core/parsefuncs.h Normal file
View file

@ -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);
}

View file

@ -115,6 +115,28 @@ void levelLoadMapInfo(IniFile *pIni, MapRecord *pLevelInfo, const char *pzSectio
static const char* DefFile(void) 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. // The command line parser stores this in the CON field.
return userConfig.DefaultCon.IsNotEmpty() ? userConfig.DefaultCon.GetChars() : "blood.ini"; return userConfig.DefaultCon.IsNotEmpty() ? userConfig.DefaultCon.GetChars() : "blood.ini";
} }

View file

@ -8,3 +8,8 @@ X "+Alt_Fire"
J "useitem 4" J "useitem 4"
M "useitem 1" M "useitem 1"
Mouse2 "+Alt_Fire" Mouse2 "+Alt_Fire"
unbind KP0
unbind KP.
unbind DEL
unbind INS