From 8da6b8796b539ddf4431b2ece5d503744e8aeedd Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 7 Jun 2020 13:35:23 +0200 Subject: [PATCH] - made presets work again. Two fixes: * fixed file system setup to mark the last main game resource. * unbind all keys before loading a preset. --- source/common/console/c_bind.cpp | 24 ++++++++----------- source/core/initfs.cpp | 1 + source/core/palette.cpp | 41 +++++++++++++++++++++++++------- 3 files changed, 44 insertions(+), 22 deletions(-) diff --git a/source/common/console/c_bind.cpp b/source/common/console/c_bind.cpp index 7dcabf96c..5e82f5bd0 100644 --- a/source/common/console/c_bind.cpp +++ b/source/common/console/c_bind.cpp @@ -716,13 +716,8 @@ void C_SetDefaultKeys(const char* baseconfig) while ((lump = fileSystem.FindLumpFullName(baseconfig, &lastlump)) != -1) { - if (fileSystem.GetFileContainer(lump) > 0) break; - // [SW] - We need to check to see the origin of the DEFBINDS... if it - // Comes from an IWAD/IPK3/IPK7 allow it to override the users settings... - // If it comes from a user mod however, don't. - if (fileSystem.GetFileContainer(lump) > fileSystem.GetMaxIwadNum()) - ReadBindings(lump, false); - else + // Read this only from the main game resources. + if (fileSystem.GetFileContainer(lump) <= fileSystem.GetMaxIwadNum()) ReadBindings(lump, true); } @@ -752,6 +747,13 @@ void C_BindDefaults() C_SetDefaultKeys(cl_defaultconfiguration == 1 ? "engine/origbinds.txt" : cl_defaultconfiguration == 2 ? "engine/leftbinds.txt" : "engine/defbinds.txt"); } +void C_SetDefaultBindings() +{ + C_UnbindAll(); + C_BindDefaults(); +} + + CCMD(controlpreset) { if (argv.argc() < 2) @@ -762,7 +764,7 @@ CCMD(controlpreset) int v = atoi(argv[1]); if (v < 0 || v > 2) return; cl_defaultconfiguration = v; - C_BindDefaults(); + C_SetDefaultBindings(); } CCMD(binddefaults) @@ -770,12 +772,6 @@ CCMD(binddefaults) C_BindDefaults(); } -void C_SetDefaultBindings() -{ - C_UnbindAll(); - C_BindDefaults(); -} - //============================================================================= // // diff --git a/source/core/initfs.cpp b/source/core/initfs.cpp index 0f75128c0..33b04446f 100644 --- a/source/core/initfs.cpp +++ b/source/core/initfs.cpp @@ -322,6 +322,7 @@ void InitFileSystem(TArray& groups) } i--; } + fileSystem.SetMaxIwadNum(Files.Size() - 1); D_AddConfigFiles(Files, "Global.Autoload", "*.grp", GameConfig); diff --git a/source/core/palette.cpp b/source/core/palette.cpp index 9ad401c6e..dfa4cbf79 100644 --- a/source/core/palette.cpp +++ b/source/core/palette.cpp @@ -1,10 +1,35 @@ -// "Build Engine & Tools" Copyright (c) 1993-1997 Ken Silverman -// Ken Silverman's official web site: "http://www.advsys.net/ken" -// See the included license file "BUILDLIC.TXT" for license info. -// -// This file has been modified from Ken Silverman's original release -// by Jonathon Fowler (jf@jonof.id.au) -// by the EDuke32 team (development@voidpoint.com) +/* +** palette.cpp +** +**--------------------------------------------------------------------------- +** Copyright 2019-2020 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. +**--------------------------------------------------------------------------- +** +*/ #include "build.h" #include "baselayer.h" @@ -325,7 +350,7 @@ void LookupTableInfo::makeTable(int palnum, const uint8_t *remapbuf, int r, int if (remapbuf == nullptr) { - if (r == 0 || g == 0 || b == 0) + if (r == 0 && g == 0 && b == 0) { clearTable(palnum); return;