From 8106d788f652a93c2a065e61a09aeff06205e06a Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 11 Aug 2021 10:28:21 +0200 Subject: [PATCH] - backend update from GZDoom. Fixes: * do not strip 'filter' as a directory prefix. * proper spacing for scaled sheet fonts. * fix of transparent color in BMF fonts. * fix restart button on error pane in Windows. * do not skip over empty 'if's with a condition that would error out. --- source/common/filesystem/file_zip.cpp | 2 ++ source/common/fonts/font.cpp | 2 +- source/common/fonts/singlelumpfont.cpp | 1 + source/common/platform/posix/cocoa/i_main.mm | 2 +- source/common/platform/posix/sdl/i_system.cpp | 2 +- source/common/platform/win32/i_main.cpp | 22 ++++++++++++++----- .../hwrenderer/data/hw_shadowmap.cpp | 3 ++- .../rendering/hwrenderer/data/hw_shadowmap.h | 5 +++++ .../rendering/hwrenderer/data/hw_vrmodes.cpp | 4 ++-- source/common/scripting/backend/codegen.cpp | 4 ++-- 10 files changed, 34 insertions(+), 13 deletions(-) diff --git a/source/common/filesystem/file_zip.cpp b/source/common/filesystem/file_zip.cpp index 0096507bf..b3acb8d13 100644 --- a/source/common/filesystem/file_zip.cpp +++ b/source/common/filesystem/file_zip.cpp @@ -234,6 +234,8 @@ bool FZipFile::Open(bool quiet, LumpFilterInfo* filter) } name.ToLower(); + if (name.IndexOf("filter/") == 0) + continue; // 'filter' is a reserved name of the file system. if (name.IndexOf("__macosx") == 0) continue; // skip Apple garbage. At this stage only the root folder matters. if (!foundprefix) diff --git a/source/common/fonts/font.cpp b/source/common/fonts/font.cpp index 3324a14e4..9663f4e1c 100644 --- a/source/common/fonts/font.cpp +++ b/source/common/fonts/font.cpp @@ -437,7 +437,7 @@ void FFont::ReadSheetFont(TArray &folderdata, int width, int height Chars[i].OriginalPic->CopySize(*lump, true); if (Chars[i].OriginalPic != *lump) TexMan.AddGameTexture(Chars[i].OriginalPic); } - Chars[i].XMove = width; + Chars[i].XMove = int(width / Scale.X); } if (map1252) diff --git a/source/common/fonts/singlelumpfont.cpp b/source/common/fonts/singlelumpfont.cpp index 5ba90b989..c4711d902 100644 --- a/source/common/fonts/singlelumpfont.cpp +++ b/source/common/fonts/singlelumpfont.cpp @@ -407,6 +407,7 @@ void FSingleLumpFont::LoadBMF(int lump, const uint8_t *data) count = LastChar - FirstChar + 1; Chars.Resize(count); // BMF palettes are only six bits per component. Fix that. + Palette[0] = 0; for (i = 0; i < ActiveColors; ++i) { int r = (data[17 + i * 3] << 2) | (data[17 + i * 3] >> 4); diff --git a/source/common/platform/posix/cocoa/i_main.mm b/source/common/platform/posix/cocoa/i_main.mm index a243bdbe5..ea7040ee5 100644 --- a/source/common/platform/posix/cocoa/i_main.mm +++ b/source/common/platform/posix/cocoa/i_main.mm @@ -131,7 +131,7 @@ static bool ReadSystemVersionFromPlist(NSOperatingSystemVersion& version) if (const char *patchVersionString = strstr(minorVersionString, ".")) { patchVersionString++; - plistVersion.patchVersion = atoi(minorVersionString); + plistVersion.patchVersion = atoi(patchVersionString); } } } diff --git a/source/common/platform/posix/sdl/i_system.cpp b/source/common/platform/posix/sdl/i_system.cpp index 03b96b8c3..922c228a3 100644 --- a/source/common/platform/posix/sdl/i_system.cpp +++ b/source/common/platform/posix/sdl/i_system.cpp @@ -204,7 +204,7 @@ void I_PrintStr(const char *cp) { // gray if (v < 0.33) attrib = 0x8; else if (v < 0.90) attrib = 0x7; - else attrib = 0x15; + else attrib = 0xF; } printData.AppendFormat("\033[%um",((attrib & 0x8) ? 90 : 30) + (attrib & 0x7)); diff --git a/source/common/platform/win32/i_main.cpp b/source/common/platform/win32/i_main.cpp index 7207717ea..acdfd2eb5 100644 --- a/source/common/platform/win32/i_main.cpp +++ b/source/common/platform/win32/i_main.cpp @@ -545,6 +545,20 @@ LRESULT CALLBACK LConProc (HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) // //========================================================================== +bool restartrequest; + +void CheckForRestart() +{ + if (restartrequest) + { + HMODULE hModule = GetModuleHandleW(NULL); + WCHAR path[MAX_PATH]; + GetModuleFileNameW(hModule, path, MAX_PATH); + ShellExecuteW(NULL, L"open", path, GetCommandLineW(), NULL, SW_SHOWNORMAL); + } + restartrequest = false; +} + INT_PTR CALLBACK ErrorPaneProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) @@ -559,11 +573,7 @@ INT_PTR CALLBACK ErrorPaneProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lPara { if (LOWORD(wParam) == IDC_BUTTON1) // we pressed the restart button, so run GZDoom again { - HMODULE hModule = GetModuleHandleW(NULL); - WCHAR path[MAX_PATH]; - GetModuleFileNameW(hModule, path, MAX_PATH); - - ShellExecuteW(NULL, L"open", path, GetCommandLineW(), NULL, SW_SHOWNORMAL); + restartrequest = true; } PostQuitMessage (0); return TRUE; @@ -969,6 +979,8 @@ int DoMain (HINSTANCE hInstance) atexit (UnCOM); int ret = GameMain (); + CheckForRestart(); + DestroyCustomCursor(); if (ret == 1337) // special exit code for 'norun'. { diff --git a/source/common/rendering/hwrenderer/data/hw_shadowmap.cpp b/source/common/rendering/hwrenderer/data/hw_shadowmap.cpp index cb5630594..bca545b3b 100644 --- a/source/common/rendering/hwrenderer/data/hw_shadowmap.cpp +++ b/source/common/rendering/hwrenderer/data/hw_shadowmap.cpp @@ -25,6 +25,7 @@ #include "hw_dynlightdata.h" #include "buffers.h" #include "shaderuniforms.h" +#include "g_cvars.h" #include "hwrenderer/postprocessing/hw_postprocess.h" /* @@ -98,7 +99,7 @@ bool IShadowMap::PerformUpdate() LightsProcessed = 0; LightsShadowmapped = 0; - if (gl_light_shadowmap && (screen->hwcaps & RFL_SHADER_STORAGE_BUFFER) && CollectLights != nullptr) + if (gl_lights && gl_light_shadowmap && (screen->hwcaps & RFL_SHADER_STORAGE_BUFFER) && CollectLights != nullptr) { UpdateCycles.Clock(); UploadAABBTree(); diff --git a/source/common/rendering/hwrenderer/data/hw_shadowmap.h b/source/common/rendering/hwrenderer/data/hw_shadowmap.h index f82e368b2..e755c0f59 100644 --- a/source/common/rendering/hwrenderer/data/hw_shadowmap.h +++ b/source/common/rendering/hwrenderer/data/hw_shadowmap.h @@ -57,6 +57,11 @@ public: mLights[index + 3] = r; } + bool Enabled() const + { + return mAABBTree != nullptr; + } + protected: // Upload the AABB-tree to the GPU void UploadAABBTree(); diff --git a/source/common/rendering/hwrenderer/data/hw_vrmodes.cpp b/source/common/rendering/hwrenderer/data/hw_vrmodes.cpp index 59f215e02..35b5eea06 100644 --- a/source/common/rendering/hwrenderer/data/hw_vrmodes.cpp +++ b/source/common/rendering/hwrenderer/data/hw_vrmodes.cpp @@ -33,10 +33,10 @@ #include "i_interface.h" // Set up 3D-specific console variables: -CVAR(Int, vr_mode, 0, CVAR_GLOBALCONFIG) +CVAR(Int, vr_mode, 0, CVAR_GLOBALCONFIG|CVAR_ARCHIVE) // switch left and right eye views -CVAR(Bool, vr_swap_eyes, false, CVAR_GLOBALCONFIG) +CVAR(Bool, vr_swap_eyes, false, CVAR_GLOBALCONFIG | CVAR_ARCHIVE) // intraocular distance in meters CVAR(Float, vr_ipd, 0.062f, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) // METERS diff --git a/source/common/scripting/backend/codegen.cpp b/source/common/scripting/backend/codegen.cpp index 6a551f1c6..17e148335 100644 --- a/source/common/scripting/backend/codegen.cpp +++ b/source/common/scripting/backend/codegen.cpp @@ -9823,6 +9823,8 @@ FxExpression *FxIfStatement::Resolve(FCompileContext &ctx) { CHECKRESOLVED(); + SAFE_RESOLVE(Condition, ctx); + if (WhenTrue == nullptr && WhenFalse == nullptr) { // We don't do anything either way, so disappear delete this; @@ -9830,8 +9832,6 @@ FxExpression *FxIfStatement::Resolve(FCompileContext &ctx) return new FxNop(ScriptPosition); } - SAFE_RESOLVE(Condition, ctx); - if (Condition->ValueType != TypeBool) { Condition = new FxBoolCast(Condition, false);