From 28f2d36732b4a0129e76040833015ddcd82a3c83 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 4 Aug 2021 08:00:49 +0200 Subject: [PATCH 01/39] - removed declaration for Screen.GetTextScreenSize. This function does not exist in GZDoom. --- wadsrc/static/zscript/engine/base.zs | 1 - 1 file changed, 1 deletion(-) diff --git a/wadsrc/static/zscript/engine/base.zs b/wadsrc/static/zscript/engine/base.zs index ad8dfb9e4..64f5921fe 100644 --- a/wadsrc/static/zscript/engine/base.zs +++ b/wadsrc/static/zscript/engine/base.zs @@ -412,7 +412,6 @@ struct Screen native native static Color PaletteColor(int index); native static int GetWidth(); native static int GetHeight(); - native static Vector2 GetTextScreenSize(); native static void Clear(int left, int top, int right, int bottom, Color color, int palcolor = -1); native static void Dim(Color col, double amount, int x, int y, int w, int h); From a067466dd8a851cf758abf6a38932cddf1ab4f43 Mon Sep 17 00:00:00 2001 From: Cacodemon345 Date: Wed, 4 Aug 2021 23:11:50 +0600 Subject: [PATCH 02/39] SDL2: Properly print white bold text to the screen --- src/common/platform/posix/sdl/i_system.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/platform/posix/sdl/i_system.cpp b/src/common/platform/posix/sdl/i_system.cpp index 03b96b8c3..922c228a3 100644 --- a/src/common/platform/posix/sdl/i_system.cpp +++ b/src/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)); From dcfd72c7666fa6b88457bfbf412d4a17f7fcb629 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Fri, 6 Aug 2021 15:02:00 +0300 Subject: [PATCH 03/39] - fixed crash after change level failure https://forum.zdoom.org/viewtopic.php?t=72890 --- src/g_game.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/g_game.cpp b/src/g_game.cpp index bfebb4f6b..fdbc18aa8 100644 --- a/src/g_game.cpp +++ b/src/g_game.cpp @@ -1014,7 +1014,7 @@ bool G_Responder (event_t *ev) { if (ST_Responder (ev)) return true; // status window ate it - if (!viewactive && primaryLevel->automap->Responder (ev, false)) + if (!viewactive && primaryLevel->automap && primaryLevel->automap->Responder (ev, false)) return true; // automap ate it } else if (gamestate == GS_FINALE) From a21c388dd6c7dd0f5630b2a582cbf99cdcfa46d7 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Fri, 6 Aug 2021 15:10:21 +0300 Subject: [PATCH 04/39] - destroyed stale thinkers after change level failure https://forum.zdoom.org/viewtopic.php?t=72890 --- src/g_level.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/g_level.cpp b/src/g_level.cpp index 0f85fc144..6468dd29d 100644 --- a/src/g_level.cpp +++ b/src/g_level.cpp @@ -378,6 +378,10 @@ void G_NewInit () if (primaryLevel->FraggleScriptThinker) primaryLevel->FraggleScriptThinker->Destroy(); primaryLevel->FraggleScriptThinker = nullptr; + // Destroy thinkers that may remain after change level failure + // Usually, the list contains just a sentinel when such error occurred + primaryLevel->Thinkers.DestroyThinkersInList(STAT_TRAVELLING); + G_ClearSnapshots (); netgame = false; multiplayer = multiplayernext; From 747c291ae164bd57da2ec0fe5dcc0347883c94cc Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Sat, 7 Aug 2021 12:37:18 +0300 Subject: [PATCH 05/39] - fixed patch version in compatibility implementation of macOS detection --- src/common/platform/posix/cocoa/i_main.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/platform/posix/cocoa/i_main.mm b/src/common/platform/posix/cocoa/i_main.mm index a243bdbe5..ea7040ee5 100644 --- a/src/common/platform/posix/cocoa/i_main.mm +++ b/src/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); } } } From cd5aa65fdab569bbc32a05ba9999e48929ec70aa Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 9 Aug 2021 18:50:50 +0200 Subject: [PATCH 06/39] - eliminate an unexpected slow path in the fragment shader. Apparently with checking uLightLevel the shader cannot discard the slow software lighting path entirely adding a significant amount of processing time. Changed to check the actual lightmode value, which re-enables the fast path again. --- wadsrc/static/shaders/glsl/main.fp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wadsrc/static/shaders/glsl/main.fp b/wadsrc/static/shaders/glsl/main.fp index 009427dd2..ba6e9190a 100644 --- a/wadsrc/static/shaders/glsl/main.fp +++ b/wadsrc/static/shaders/glsl/main.fp @@ -595,7 +595,7 @@ vec4 getLightColor(Material material, float fogdist, float fogfactor) { vec4 color = vColor; - if (uLightLevel >= 0.0) + if ((uPalLightLevels >> 16) >= 5) // gl_lightmode >= 5 are software lighting modes. { float newlightlevel = 1.0 - R_DoomLightingEquation(uLightLevel); color.rgb *= newlightlevel; From 39513cf7aef33dd0de3afd662815c64aafa870b5 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 9 Aug 2021 20:31:21 +0200 Subject: [PATCH 07/39] Revert "- eliminate an unexpected slow path in the fragment shader." This reverts commit cd5aa65fdab569bbc32a05ba9999e48929ec70aa. This does not work as expected, needs more investigation. --- wadsrc/static/shaders/glsl/main.fp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wadsrc/static/shaders/glsl/main.fp b/wadsrc/static/shaders/glsl/main.fp index ba6e9190a..009427dd2 100644 --- a/wadsrc/static/shaders/glsl/main.fp +++ b/wadsrc/static/shaders/glsl/main.fp @@ -595,7 +595,7 @@ vec4 getLightColor(Material material, float fogdist, float fogfactor) { vec4 color = vColor; - if ((uPalLightLevels >> 16) >= 5) // gl_lightmode >= 5 are software lighting modes. + if (uLightLevel >= 0.0) { float newlightlevel = 1.0 - R_DoomLightingEquation(uLightLevel); color.rgb *= newlightlevel; From 61739b408669f207fcc10a9df1156cbfca6e3d74 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 10 Aug 2021 18:00:14 +0200 Subject: [PATCH 08/39] - fixed BlockThingsIterator to not reset its list of processed actors when traversing portals. --- src/playsim/p_maputl.cpp | 7 ++++--- src/playsim/p_maputl.h | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/playsim/p_maputl.cpp b/src/playsim/p_maputl.cpp index 68ab182e3..6cd8de850 100644 --- a/src/playsim/p_maputl.cpp +++ b/src/playsim/p_maputl.cpp @@ -910,13 +910,13 @@ FBlockThingsIterator::FBlockThingsIterator(FLevelLocals *l, int _minx, int _miny Reset(); } -void FBlockThingsIterator::init(const FBoundingBox &box) +void FBlockThingsIterator::init(const FBoundingBox &box, bool clearhash) { maxy = Level->blockmap.GetBlockY(box.Top()); miny = Level->blockmap.GetBlockY(box.Bottom()); maxx = Level->blockmap.GetBlockX(box.Right()); minx = Level->blockmap.GetBlockX(box.Left()); - ClearHash(); + if (clearhash) ClearHash(); Reset(); } @@ -1139,7 +1139,7 @@ void FMultiBlockThingsIterator::startIteratorForGroup(int group) offset.X += checkpoint.X; offset.Y += checkpoint.Y; bbox.setBox(offset.X, offset.Y, checkpoint.Z); - blockIterator.init(bbox); + blockIterator.init(bbox, false); } //=========================================================================== @@ -1153,6 +1153,7 @@ void FMultiBlockThingsIterator::Reset() index = -1; portalflags = 0; startIteratorForGroup(basegroup); + blockIterator.ClearHash(); } //=========================================================================== diff --git a/src/playsim/p_maputl.h b/src/playsim/p_maputl.h index e293f317f..0c93ab445 100644 --- a/src/playsim/p_maputl.h +++ b/src/playsim/p_maputl.h @@ -319,7 +319,7 @@ public: Level = l; init(box); } - void init(const FBoundingBox &box); + void init(const FBoundingBox &box, bool clearhash = true); AActor *Next(bool centeronly = false); void Reset() { StartBlock(minx, miny); } }; From 4cee567b23969f27de558d1e5a706d26511b374c Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 10 Aug 2021 18:04:10 +0200 Subject: [PATCH 09/39] - fixed: P_RoughMonsterSearch did not pass the fov parameter to its worker functions. --- src/playsim/p_maputl.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/playsim/p_maputl.cpp b/src/playsim/p_maputl.cpp index 6cd8de850..4f3af3c85 100644 --- a/src/playsim/p_maputl.cpp +++ b/src/playsim/p_maputl.cpp @@ -1848,6 +1848,7 @@ AActor *P_RoughMonsterSearch(AActor *mo, int distance, bool onlyseekable, bool f { BlockCheckInfo info; info.onlyseekable = onlyseekable; + info.fov = fov; if ((info.frontonly = frontonly)) { info.frontline.x = mo->X(); From 61efe76ffdcca12dee9e6b8566d3899315a80e03 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 10 Aug 2021 18:18:44 +0200 Subject: [PATCH 10/39] - fixed: palette index 0 (transparent) was left uninitialized for BMF fonts. --- src/common/fonts/singlelumpfont.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/common/fonts/singlelumpfont.cpp b/src/common/fonts/singlelumpfont.cpp index 5ba90b989..c4711d902 100644 --- a/src/common/fonts/singlelumpfont.cpp +++ b/src/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); From 8747145c97e8ca98f8ea24d8156880c0ff8751f6 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 10 Aug 2021 18:46:23 +0200 Subject: [PATCH 11/39] - dim depleted inventory items in all games, not just Strife. --- wadsrc/static/zscript/ui/statusbar/doom_sbar.zs | 4 ++-- wadsrc/static/zscript/ui/statusbar/heretic_sbar.zs | 4 ++-- wadsrc/static/zscript/ui/statusbar/hexen_sbar.zs | 4 ++-- wadsrc/static/zscript/ui/statusbar/statusbar.zs | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/wadsrc/static/zscript/ui/statusbar/doom_sbar.zs b/wadsrc/static/zscript/ui/statusbar/doom_sbar.zs index f1a64acc4..39cad7adb 100644 --- a/wadsrc/static/zscript/ui/statusbar/doom_sbar.zs +++ b/wadsrc/static/zscript/ui/statusbar/doom_sbar.zs @@ -66,7 +66,7 @@ class DoomStatusBar : BaseStatusBar if (CPlayer.mo.InvSel != null && !Level.NoInventoryBar) { - DrawInventoryIcon(CPlayer.mo.InvSel, (160, 198)); + DrawInventoryIcon(CPlayer.mo.InvSel, (160, 198), DI_DIMDEPLETED); if (CPlayer.mo.InvSel.Amount > 1) { DrawString(mAmountFont, FormatNumber(CPlayer.mo.InvSel.Amount), (175, 198-mIndexFont.mFont.GetHeight()), DI_TEXT_ALIGN_RIGHT, Font.CR_GOLD); @@ -169,7 +169,7 @@ class DoomStatusBar : BaseStatusBar } if (!isInventoryBarVisible() && !Level.NoInventoryBar && CPlayer.mo.InvSel != null) { - DrawInventoryIcon(CPlayer.mo.InvSel, (-14, invY + 17)); + DrawInventoryIcon(CPlayer.mo.InvSel, (-14, invY + 17), DI_DIMDEPLETED); DrawString(mHUDFont, FormatNumber(CPlayer.mo.InvSel.Amount, 3), (-30, invY), DI_TEXT_ALIGN_RIGHT); } if (deathmatch) diff --git a/wadsrc/static/zscript/ui/statusbar/heretic_sbar.zs b/wadsrc/static/zscript/ui/statusbar/heretic_sbar.zs index 28eaf9db4..5c29e176f 100644 --- a/wadsrc/static/zscript/ui/statusbar/heretic_sbar.zs +++ b/wadsrc/static/zscript/ui/statusbar/heretic_sbar.zs @@ -127,7 +127,7 @@ class HereticStatusBar : BaseStatusBar //inventory box if (CPlayer.mo.InvSel != null) { - DrawInventoryIcon(CPlayer.mo.InvSel, (194, 175), DI_ARTIFLASH|DI_ITEM_CENTER, boxsize:(28, 28)); + DrawInventoryIcon(CPlayer.mo.InvSel, (194, 175), DI_ARTIFLASH|DI_ITEM_CENTER|DI_DIMDEPLETED, boxsize:(28, 28)); if (CPlayer.mo.InvSel.Amount > 1) { DrawString(mIndexFont, FormatNumber(CPlayer.mo.InvSel.Amount, 3), (209, 182), DI_TEXT_ALIGN_RIGHT); @@ -205,7 +205,7 @@ class HereticStatusBar : BaseStatusBar // This code was changed to always fit the item into the box, regardless of alignment or sprite size. // Heretic's ARTIBOX is 30x30 pixels. DrawImage("ARTIBOX", (-46, -1), 0, HX_SHADOW); - DrawInventoryIcon(CPlayer.mo.InvSel, (-46, -15), DI_ARTIFLASH|DI_ITEM_CENTER, boxsize:(28, 28)); + DrawInventoryIcon(CPlayer.mo.InvSel, (-46, -15), DI_ARTIFLASH|DI_ITEM_CENTER|DI_DIMDEPLETED, boxsize:(28, 28)); if (CPlayer.mo.InvSel.Amount > 1) { DrawString(mIndexFont, FormatNumber(CPlayer.mo.InvSel.Amount, 3), (-32, -2 - mIndexFont.mFont.GetHeight()), DI_TEXT_ALIGN_RIGHT); diff --git a/wadsrc/static/zscript/ui/statusbar/hexen_sbar.zs b/wadsrc/static/zscript/ui/statusbar/hexen_sbar.zs index 4b5d7189d..ce4d3dc89 100644 --- a/wadsrc/static/zscript/ui/statusbar/hexen_sbar.zs +++ b/wadsrc/static/zscript/ui/statusbar/hexen_sbar.zs @@ -83,7 +83,7 @@ class HexenStatusBar : BaseStatusBar // This code was changed to always fit the item into the box, regardless of alignment or sprite size. // Heretic's ARTIBOX is 30x30 pixels. DrawImage("ARTIBOX", (-66, -1), 0, HX_SHADOW); - DrawInventoryIcon(CPlayer.mo.InvSel, (-66, -15), DI_ARTIFLASH|DI_ITEM_CENTER, boxsize:(28, 28)); + DrawInventoryIcon(CPlayer.mo.InvSel, (-66, -15), DI_ARTIFLASH|DI_ITEM_CENTER|DI_DIMDEPLETED, boxsize:(28, 28)); if (CPlayer.mo.InvSel.Amount > 1) { DrawString(mIndexFont, FormatNumber(CPlayer.mo.InvSel.Amount, 3), (-52, -2 - mIndexFont.mFont.GetHeight()), DI_TEXT_ALIGN_RIGHT); @@ -146,7 +146,7 @@ class HexenStatusBar : BaseStatusBar //inventory box if (CPlayer.mo.InvSel != null) { - DrawInventoryIcon(CPlayer.mo.InvSel, (159.5, 177), DI_ARTIFLASH|DI_ITEM_CENTER, boxsize:(28, 28)); + DrawInventoryIcon(CPlayer.mo.InvSel, (159.5, 177), DI_ARTIFLASH|DI_ITEM_CENTER|DI_DIMDEPLETED, boxsize:(28, 28)); if (CPlayer.mo.InvSel.Amount > 1) { DrawString(mIndexFont, FormatNumber(CPlayer.mo.InvSel.Amount, 3), (174, 184), DI_TEXT_ALIGN_RIGHT); diff --git a/wadsrc/static/zscript/ui/statusbar/statusbar.zs b/wadsrc/static/zscript/ui/statusbar/statusbar.zs index b4d4f8a3d..75cbbe827 100644 --- a/wadsrc/static/zscript/ui/statusbar/statusbar.zs +++ b/wadsrc/static/zscript/ui/statusbar/statusbar.zs @@ -981,7 +981,7 @@ class BaseStatusBar : StatusBarCore native } else { - DrawInventoryIcon(item, itempos + (boxsize.X * i, 0), flags | DI_ITEM_CENTER ); + DrawInventoryIcon(item, itempos + (boxsize.X * i, 0), flags | DI_ITEM_CENTER | DI_DIMDEPLETED ); } } From a16088f4b46f42ac8d098ed0707dc605c1c31888 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 10 Aug 2021 18:51:44 +0200 Subject: [PATCH 12/39] - fixed two vr_* CVARs not getting archived. --- src/common/rendering/hwrenderer/data/hw_vrmodes.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/common/rendering/hwrenderer/data/hw_vrmodes.cpp b/src/common/rendering/hwrenderer/data/hw_vrmodes.cpp index 59f215e02..35b5eea06 100644 --- a/src/common/rendering/hwrenderer/data/hw_vrmodes.cpp +++ b/src/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 From 55520ed7d031fc3a749bf993d93b888b4c58f4f2 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 10 Aug 2021 18:57:31 +0200 Subject: [PATCH 13/39] - fixed exploding barrel animation duration. --- wadsrc/static/zscript/actors/doom/doommisc.zs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wadsrc/static/zscript/actors/doom/doommisc.zs b/wadsrc/static/zscript/actors/doom/doommisc.zs index c6d8af717..a761f94e0 100644 --- a/wadsrc/static/zscript/actors/doom/doommisc.zs +++ b/wadsrc/static/zscript/actors/doom/doommisc.zs @@ -26,7 +26,7 @@ class ExplosiveBarrel : Actor BEXP A 5 BRIGHT; BEXP B 5 BRIGHT A_Scream; BEXP C 5 BRIGHT; - BEXP D 5 BRIGHT A_Explode; + BEXP D 10 BRIGHT A_Explode; BEXP E 10 BRIGHT; TNT1 A 1050 BRIGHT A_BarrelDestroy; TNT1 A 5 A_Respawn; From 03b7324f717b7242f7c9489d3ff1d4dda238792e Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 10 Aug 2021 19:03:40 +0200 Subject: [PATCH 14/39] - reorder evaluation for 'if' statements to handle the condition first. Otherwise this won't emit errors if a bad condition is used with an empty conditional part. --- src/common/scripting/backend/codegen.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/common/scripting/backend/codegen.cpp b/src/common/scripting/backend/codegen.cpp index 6a551f1c6..17e148335 100644 --- a/src/common/scripting/backend/codegen.cpp +++ b/src/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); From f29eff5b4c88b5ff61917098f8f0e53c1a18c23c Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 10 Aug 2021 19:22:19 +0200 Subject: [PATCH 15/39] - fixed: the software scene drawer must be deleted before calling ST_Endoom. This contains render data that won't get deleted in time before taking down the render backend if not manually performed. --- src/menu/doommenu.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/menu/doommenu.cpp b/src/menu/doommenu.cpp index 1df0673a1..8a8e9cf8a 100644 --- a/src/menu/doommenu.cpp +++ b/src/menu/doommenu.cpp @@ -64,6 +64,7 @@ #include "gameconfigfile.h" #include "d_player.h" #include "teaminfo.h" +#include "hwrenderer/scene/hw_drawinfo.h" EXTERN_CVAR(Int, cl_gfxlocalization) EXTERN_CVAR(Bool, m_quickexit) @@ -295,6 +296,7 @@ CCMD (menu_quit) { // F10 if (m_quickexit) { + CleanSWDrawer(); ST_Endoom(); } @@ -326,6 +328,7 @@ CCMD (menu_quit) I_WaitVBL(105); } } + CleanSWDrawer(); ST_Endoom(); }); From 99c66071fb8b2be84eac674bf6c2b07a7bd574da Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 10 Aug 2021 21:08:26 +0200 Subject: [PATCH 16/39] - use original menu spacing for skill and episode menus if all elements are patches. --- src/menu/doommenu.cpp | 46 +++++++++++++++---- wadsrc/static/menudef.txt | 2 + .../static/zscript/engine/ui/menu/listmenu.zs | 30 ++++++++++++ .../zscript/engine/ui/menu/menuitembase.zs | 1 + 4 files changed, 69 insertions(+), 10 deletions(-) diff --git a/src/menu/doommenu.cpp b/src/menu/doommenu.cpp index 8a8e9cf8a..652530a64 100644 --- a/src/menu/doommenu.cpp +++ b/src/menu/doommenu.cpp @@ -571,8 +571,21 @@ void M_StartupEpisodeMenu(FNewGameStartup *gs) if (y < topy) topy = y; } + int spacing = ld->mLinespacing; + for (unsigned i = 0; i < AllEpisodes.Size(); i++) + { + if (AllEpisodes[i].mPicName.IsNotEmpty()) + { + FTextureID tex = GetMenuTexture(AllEpisodes[i].mPicName); + if (AllEpisodes[i].mEpisodeName.IsEmpty() || OkForLocalization(tex, AllEpisodes[i].mEpisodeName)) + continue; + } + if ((gameinfo.gametype & GAME_DoomStrifeChex) && spacing == 16) spacing = 18; + break; + } + // center the menu on the screen if the top space is larger than the bottom space - int totalheight = posy + AllEpisodes.Size() * ld->mLinespacing - topy; + int totalheight = posy + AllEpisodes.Size() * spacing - topy; if (totalheight < 190 || AllEpisodes.Size() == 1) { @@ -613,15 +626,15 @@ void M_StartupEpisodeMenu(FNewGameStartup *gs) { FTextureID tex = GetMenuTexture(AllEpisodes[i].mPicName); if (AllEpisodes[i].mEpisodeName.IsEmpty() || OkForLocalization(tex, AllEpisodes[i].mEpisodeName)) - it = CreateListMenuItemPatch(posx, posy, ld->mLinespacing, AllEpisodes[i].mShortcut, tex, NAME_Skillmenu, i); + it = CreateListMenuItemPatch(posx, posy, spacing, AllEpisodes[i].mShortcut, tex, NAME_Skillmenu, i); } if (it == nullptr) { - it = CreateListMenuItemText(posx, posy, ld->mLinespacing, AllEpisodes[i].mShortcut, + it = CreateListMenuItemText(posx, posy, spacing, AllEpisodes[i].mShortcut, AllEpisodes[i].mEpisodeName, ld->mFont, ld->mFontColor, ld->mFontColor2, NAME_Skillmenu, i); } ld->mItems.Push(it); - posy += ld->mLinespacing; + posy += spacing; } if (AllEpisodes.Size() == 1) { @@ -1073,9 +1086,10 @@ void M_StartupSkillMenu(FNewGameStartup *gs) } } - if (done != restart) + int spacing = ld->mLinespacing; + //if (done != restart) { - done = restart; + //done = restart; ld->mSelectedItem = ld->mItems.Size() + defindex; int posy = y; @@ -1088,8 +1102,20 @@ void M_StartupSkillMenu(FNewGameStartup *gs) if (y < topy) topy = y; } + for (unsigned i = 0; i < MenuSkills.Size(); i++) + { + if (MenuSkills[i]->PicName.IsNotEmpty()) + { + FTextureID tex = GetMenuTexture(MenuSkills[i]->PicName); + if (MenuSkills[i]->MenuName.IsEmpty() || OkForLocalization(tex, MenuSkills[i]->MenuName)) + continue; + } + if ((gameinfo.gametype & GAME_DoomStrifeChex) && spacing == 16) spacing = 18; + break; + } + // center the menu on the screen if the top space is larger than the bottom space - int totalheight = posy + MenuSkills.Size() * ld->mLinespacing - topy; + int totalheight = posy + MenuSkills.Size() * spacing - topy; if (totalheight < 190 || MenuSkills.Size() == 1) { @@ -1157,16 +1183,16 @@ void M_StartupSkillMenu(FNewGameStartup *gs) { FTextureID tex = GetMenuTexture(skill.PicName); if (skill.MenuName.IsEmpty() || OkForLocalization(tex, skill.MenuName)) - li = CreateListMenuItemPatch(posx, y, ld->mLinespacing, skill.Shortcut, tex, action, SkillIndices[i]); + li = CreateListMenuItemPatch(posx, y, spacing, skill.Shortcut, tex, action, SkillIndices[i]); } if (li == nullptr) { - li = CreateListMenuItemText(posx, y, ld->mLinespacing, skill.Shortcut, + li = CreateListMenuItemText(posx, y, spacing, skill.Shortcut, pItemText? *pItemText : skill.MenuName, ld->mFont, color,ld->mFontColor2, action, SkillIndices[i]); } ld->mItems.Push(li); GC::WriteBarrier(*desc, li); - y += ld->mLinespacing; + y += spacing; } if (AllEpisodes[gs->Episode].mNoSkill || MenuSkills.Size() == 1) { diff --git a/wadsrc/static/menudef.txt b/wadsrc/static/menudef.txt index b3d8bd4c5..1725da9dd 100644 --- a/wadsrc/static/menudef.txt +++ b/wadsrc/static/menudef.txt @@ -209,6 +209,7 @@ ListMenu "EpisodeMenu" { Position 48, 63 StaticPatch 54, 38, "M_EPISOD", 0 , "$MNU_EPISODE" + linespacing 16 } IfGame(Strife) { @@ -234,6 +235,7 @@ ListMenu "SkillMenu" IfGame(Doom, Chex) { StaticPatch 96, 14, "M_NEWG", 0, "$MNU_NEWGAME" + linespacing 16 } IfGame(Strife) { diff --git a/wadsrc/static/zscript/engine/ui/menu/listmenu.zs b/wadsrc/static/zscript/engine/ui/menu/listmenu.zs index c8a8a0f2e..dc12f4129 100644 --- a/wadsrc/static/zscript/engine/ui/menu/listmenu.zs +++ b/wadsrc/static/zscript/engine/ui/menu/listmenu.zs @@ -328,6 +328,36 @@ class ListMenu : Menu { mFocusControl = NULL; } + + //============================================================================= + // + // + // + //============================================================================= + + void ChangeLineSpacing(int newspace) + { + double top = -32767; + + for (int i = 0; i < mDesc.mItems.Size(); i++) + { + let selitem = ListMenuItemSelectable(mDesc.mItems[i]); + if (selitem) + { + let y = mDesc.mItems[i].GetY(); + if (top == -32767) + { + top = y; + } + else + { + let newy = top + (y - top) / mDesc.mLineSpacing * newspace; + mDesc.mItems[i].SetY(newy); + } + } + } + mDesc.mLineSpacing = newspace; + } } diff --git a/wadsrc/static/zscript/engine/ui/menu/menuitembase.zs b/wadsrc/static/zscript/engine/ui/menu/menuitembase.zs index 53a32e47f..2169e9fac 100644 --- a/wadsrc/static/zscript/engine/ui/menu/menuitembase.zs +++ b/wadsrc/static/zscript/engine/ui/menu/menuitembase.zs @@ -40,6 +40,7 @@ class MenuItemBase : Object native ui version("2.4") double GetY() { return mYpos; } double GetX() { return mXpos; } void SetX(double x) { mXpos = x; } + void SetY(double x) { mYpos = x; } virtual void OnMenuCreated() {} } From 9cd1e8cf7a2a20bc2afebc0602ad258e0b5b855f Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 10 Aug 2021 21:18:27 +0200 Subject: [PATCH 17/39] - use proper XMove for sheet fonts. --- src/common/fonts/font.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/fonts/font.cpp b/src/common/fonts/font.cpp index 3324a14e4..b0193c4ff 100644 --- a/src/common/fonts/font.cpp +++ b/src/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)Chars[i].OriginalPic->GetDisplayWidth(); } if (map1252) From b6156ac4908534c69ff7c02e780d43807ac7b202 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 10 Aug 2021 22:04:32 +0200 Subject: [PATCH 18/39] - re-fixed the font spacing. --- src/common/fonts/font.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/fonts/font.cpp b/src/common/fonts/font.cpp index b0193c4ff..9663f4e1c 100644 --- a/src/common/fonts/font.cpp +++ b/src/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 = (int)Chars[i].OriginalPic->GetDisplayWidth(); + Chars[i].XMove = int(width / Scale.X); } if (map1252) From 4505bfa4b82bd108c3da8cfa51e5cc623aa8983a Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 10 Aug 2021 22:09:32 +0200 Subject: [PATCH 19/39] - delay the restart action from the error pane until after everything has been shut down. This cannot be done from a place where the old instance still can write to the config file, which happens only in the shutdown process. --- src/common/platform/win32/i_main.cpp | 20 +++++++++++++++----- src/d_main.cpp | 4 ++++ 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/common/platform/win32/i_main.cpp b/src/common/platform/win32/i_main.cpp index 7207717ea..bbada0fb2 100644 --- a/src/common/platform/win32/i_main.cpp +++ b/src/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; diff --git a/src/d_main.cpp b/src/d_main.cpp index 245922beb..e29cca2db 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -3716,6 +3716,10 @@ int GameMain() DeleteStartupScreen(); delete Args; Args = nullptr; +#ifdef _WIN32 + void CheckForRestart(); + CheckForRestart(); +#endif return ret; } From 6a63d9e70e309d6360987570247f48a0c5135ee7 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 10 Aug 2021 22:17:00 +0200 Subject: [PATCH 20/39] - moved the CheckForRestart call one level up so that it is within the Windows code and does not need #ifdefs. --- src/common/platform/win32/i_main.cpp | 2 ++ src/d_main.cpp | 4 ---- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/common/platform/win32/i_main.cpp b/src/common/platform/win32/i_main.cpp index bbada0fb2..acdfd2eb5 100644 --- a/src/common/platform/win32/i_main.cpp +++ b/src/common/platform/win32/i_main.cpp @@ -979,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/src/d_main.cpp b/src/d_main.cpp index e29cca2db..245922beb 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -3716,10 +3716,6 @@ int GameMain() DeleteStartupScreen(); delete Args; Args = nullptr; -#ifdef _WIN32 - void CheckForRestart(); - CheckForRestart(); -#endif return ret; } From c24f644a61c9042987dc2614eea4e9dd55159428 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 11 Aug 2021 08:08:29 +0200 Subject: [PATCH 21/39] - do not perform shadowmap updates when dynamic lights are disabled. --- src/common/rendering/hwrenderer/data/hw_shadowmap.cpp | 3 ++- src/rendering/hwrenderer/hw_entrypoint.cpp | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/common/rendering/hwrenderer/data/hw_shadowmap.cpp b/src/common/rendering/hwrenderer/data/hw_shadowmap.cpp index cb5630594..bca545b3b 100644 --- a/src/common/rendering/hwrenderer/data/hw_shadowmap.cpp +++ b/src/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/src/rendering/hwrenderer/hw_entrypoint.cpp b/src/rendering/hwrenderer/hw_entrypoint.cpp index 1845f051c..76baf862a 100644 --- a/src/rendering/hwrenderer/hw_entrypoint.cpp +++ b/src/rendering/hwrenderer/hw_entrypoint.cpp @@ -40,6 +40,7 @@ #include "flatvertices.h" #include "v_palette.h" #include "d_main.h" +#include "g_cvars.h" #include "hw_lightbuffer.h" #include "hw_cvars.h" @@ -107,7 +108,7 @@ sector_t* RenderViewpoint(FRenderViewpoint& mainvp, AActor* camera, IntRect* bou R_SetupFrame(mainvp, r_viewwindow, camera); - if (mainview && toscreen && !(camera->Level->flags3 & LEVEL3_NOSHADOWMAP) && gl_light_shadowmap && (screen->hwcaps & RFL_SHADER_STORAGE_BUFFER)) + if (mainview && toscreen && !(camera->Level->flags3 & LEVEL3_NOSHADOWMAP) && gl_lights && gl_light_shadowmap && (screen->hwcaps & RFL_SHADER_STORAGE_BUFFER)) { screen->SetAABBTree(camera->Level->aabbTree); screen->mShadowMap.SetCollectLights([=] { From 436ec28e945b9a911c7df5d54cd0a9eab4c2ed2d Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 11 Aug 2021 10:01:11 +0200 Subject: [PATCH 22/39] - fixed file system's zip loader to not strip away a 'filter/' prefix. --- src/common/filesystem/file_zip.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/common/filesystem/file_zip.cpp b/src/common/filesystem/file_zip.cpp index 0096507bf..b3acb8d13 100644 --- a/src/common/filesystem/file_zip.cpp +++ b/src/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) From f662c629e31f29d38b1817722e623bbd648a57d3 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 11 Aug 2021 10:06:22 +0200 Subject: [PATCH 23/39] - ensure that shadowmap indices only get set when shadowmaps are enabled. Having valid indices set when shadowmaps are off would cause the shader to run the full checks for all lights. --- src/common/rendering/hwrenderer/data/hw_shadowmap.h | 5 +++++ src/rendering/hwrenderer/hw_dynlightdata.cpp | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/common/rendering/hwrenderer/data/hw_shadowmap.h b/src/common/rendering/hwrenderer/data/hw_shadowmap.h index f82e368b2..e755c0f59 100644 --- a/src/common/rendering/hwrenderer/data/hw_shadowmap.h +++ b/src/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/src/rendering/hwrenderer/hw_dynlightdata.cpp b/src/rendering/hwrenderer/hw_dynlightdata.cpp index f65b03172..044d34d3d 100644 --- a/src/rendering/hwrenderer/hw_dynlightdata.cpp +++ b/src/rendering/hwrenderer/hw_dynlightdata.cpp @@ -29,6 +29,7 @@ #include "a_dynlight.h" #include "hw_dynlightdata.h" #include"hw_cvars.h" +#include "v_video.h" #include "hwrenderer/scene/hw_drawstructs.h" // If we want to share the array to avoid constant allocations it needs to be thread local unless it'd be littered with expensive synchronization. @@ -107,7 +108,7 @@ void AddLightToList(FDynLightData &dld, int group, FDynamicLight * light, bool f } float shadowIndex; - if (gl_light_shadowmap) // note: with gl_light_shadowmap switched off, we cannot rely on properly set indices anymore. + if (screen->mShadowMap.Enabled()) // note: with shadowmaps switched off, we cannot rely on properly set indices anymore. { shadowIndex = light->mShadowmapIndex + 1.0f; } From 3adadfe4d3b58c599820facf29a4789099199ba7 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 11 Aug 2021 12:39:17 +0200 Subject: [PATCH 24/39] - do not run the dynamic light ticker when lights are switched off. --- .../rendering/hwrenderer/data/hw_shadowmap.cpp | 1 - src/common/rendering/v_video.h | 1 + src/playsim/dthinker.cpp | 14 +++++++++----- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/common/rendering/hwrenderer/data/hw_shadowmap.cpp b/src/common/rendering/hwrenderer/data/hw_shadowmap.cpp index bca545b3b..9b0de864f 100644 --- a/src/common/rendering/hwrenderer/data/hw_shadowmap.cpp +++ b/src/common/rendering/hwrenderer/data/hw_shadowmap.cpp @@ -25,7 +25,6 @@ #include "hw_dynlightdata.h" #include "buffers.h" #include "shaderuniforms.h" -#include "g_cvars.h" #include "hwrenderer/postprocessing/hw_postprocess.h" /* diff --git a/src/common/rendering/v_video.h b/src/common/rendering/v_video.h index c9124e05f..255cfa70c 100644 --- a/src/common/rendering/v_video.h +++ b/src/common/rendering/v_video.h @@ -279,6 +279,7 @@ extern DFrameBuffer *screen; #define SCREENPITCH (screen->GetPitch ()) EXTERN_CVAR (Float, vid_gamma) +EXTERN_CVAR(Bool, gl_lights) // Allocates buffer screens, call before R_Init. diff --git a/src/playsim/dthinker.cpp b/src/playsim/dthinker.cpp index 64099981f..4758d7994 100644 --- a/src/playsim/dthinker.cpp +++ b/src/playsim/dthinker.cpp @@ -42,6 +42,7 @@ #include "v_text.h" #include "g_levellocals.h" #include "a_dynlight.h" +#include "v_video.h" static int ThinkCount; @@ -124,11 +125,14 @@ void FThinkerCollection::RunThinkers(FLevelLocals *Level) } } while (count != 0); - for (auto light = Level->lights; light;) + if (gl_lights) { - auto next = light->next; - light->Tick(); - light = next; + for (auto light = Level->lights; light;) + { + auto next = light->next; + light->Tick(); + light = next; + } } } else @@ -150,7 +154,7 @@ void FThinkerCollection::RunThinkers(FLevelLocals *Level) } } while (count != 0); - if (Level->lights) + if (Level->lights && gl_lights) { // Also profile the internal dynamic lights, even though they are not implemented as thinkers. auto &prof = Profiles[NAME_InternalDynamicLight]; From 26d00e14c7370683ff6413b58230330f2ce65a64 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 11 Aug 2021 12:39:32 +0200 Subject: [PATCH 25/39] - file system update from Raze. --- src/common/filesystem/filesystem.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/common/filesystem/filesystem.cpp b/src/common/filesystem/filesystem.cpp index 4c5a5b910..8b14b1312 100644 --- a/src/common/filesystem/filesystem.cpp +++ b/src/common/filesystem/filesystem.cpp @@ -113,7 +113,20 @@ struct FileSystem::LumpRecord if (Namespace == ns_hidden) shortName.qword = 0; else { - long slash = longName.LastIndexOf('/'); + ptrdiff_t encodedResID = longName.LastIndexOf(".{"); + if (resourceId == -1 && encodedResID >= 0) + { + const char* p = longName.GetChars() + encodedResID; + char* q; + int id = (int)strtoull(p+2, &q, 10); // only decimal numbers allowed here. + if (q[0] == '}' && (q[1] == '.' || q[1] == 0)) + { + FString toDelete(p, q - p + 1); + longName.Substitute(toDelete, ""); + resourceId = id; + } + } + ptrdiff_t slash = longName.LastIndexOf('/'); FString base = (slash >= 0) ? longName.Mid(slash + 1) : longName; auto dot = base.LastIndexOf('.'); if (dot >= 0) base.Truncate(dot); From 1097bd6c7317dbabe373c2795276b66d369751c8 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 11 Aug 2021 14:09:00 +0200 Subject: [PATCH 26/39] - fixed: instead of checking gl_lights, better check Level->HasDynamicLights. Especially in the thinker code this is needed for software rendering. Strictly speaking, the software renderer should do the same, but it checks r_dynlight in so many places deep in the logic where the level is not available. --- src/common/rendering/hwrenderer/data/hw_shadowmap.cpp | 3 ++- src/common/rendering/v_video.h | 1 - src/playsim/dthinker.cpp | 4 ++-- src/rendering/hwrenderer/hw_entrypoint.cpp | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/common/rendering/hwrenderer/data/hw_shadowmap.cpp b/src/common/rendering/hwrenderer/data/hw_shadowmap.cpp index 9b0de864f..c5e5fb09b 100644 --- a/src/common/rendering/hwrenderer/data/hw_shadowmap.cpp +++ b/src/common/rendering/hwrenderer/data/hw_shadowmap.cpp @@ -98,7 +98,8 @@ bool IShadowMap::PerformUpdate() LightsProcessed = 0; LightsShadowmapped = 0; - if (gl_lights && gl_light_shadowmap && (screen->hwcaps & RFL_SHADER_STORAGE_BUFFER) && CollectLights != nullptr) + // CollectLights will be null if the calling code decides that shadowmaps are not needed. + if (CollectLights != nullptr) { UpdateCycles.Clock(); UploadAABBTree(); diff --git a/src/common/rendering/v_video.h b/src/common/rendering/v_video.h index 255cfa70c..c9124e05f 100644 --- a/src/common/rendering/v_video.h +++ b/src/common/rendering/v_video.h @@ -279,7 +279,6 @@ extern DFrameBuffer *screen; #define SCREENPITCH (screen->GetPitch ()) EXTERN_CVAR (Float, vid_gamma) -EXTERN_CVAR(Bool, gl_lights) // Allocates buffer screens, call before R_Init. diff --git a/src/playsim/dthinker.cpp b/src/playsim/dthinker.cpp index 4758d7994..0c8e687f1 100644 --- a/src/playsim/dthinker.cpp +++ b/src/playsim/dthinker.cpp @@ -125,7 +125,7 @@ void FThinkerCollection::RunThinkers(FLevelLocals *Level) } } while (count != 0); - if (gl_lights) + if (Level->HasDynamicLights) { for (auto light = Level->lights; light;) { @@ -154,7 +154,7 @@ void FThinkerCollection::RunThinkers(FLevelLocals *Level) } } while (count != 0); - if (Level->lights && gl_lights) + if (Level->lights && Level->HasDynamicLights) { // Also profile the internal dynamic lights, even though they are not implemented as thinkers. auto &prof = Profiles[NAME_InternalDynamicLight]; diff --git a/src/rendering/hwrenderer/hw_entrypoint.cpp b/src/rendering/hwrenderer/hw_entrypoint.cpp index 76baf862a..475c52272 100644 --- a/src/rendering/hwrenderer/hw_entrypoint.cpp +++ b/src/rendering/hwrenderer/hw_entrypoint.cpp @@ -108,7 +108,7 @@ sector_t* RenderViewpoint(FRenderViewpoint& mainvp, AActor* camera, IntRect* bou R_SetupFrame(mainvp, r_viewwindow, camera); - if (mainview && toscreen && !(camera->Level->flags3 & LEVEL3_NOSHADOWMAP) && gl_lights && gl_light_shadowmap && (screen->hwcaps & RFL_SHADER_STORAGE_BUFFER)) + if (mainview && toscreen && !(camera->Level->flags3 & LEVEL3_NOSHADOWMAP) && camera->Level->HasDynamicLights && gl_light_shadowmap && (screen->hwcaps & RFL_SHADER_STORAGE_BUFFER)) { screen->SetAABBTree(camera->Level->aabbTree); screen->mShadowMap.SetCollectLights([=] { From 139f501ec5ca0cd05fc0301519471fe53bcafbbe Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 11 Aug 2021 15:41:42 +0200 Subject: [PATCH 27/39] - run the dynamic light recreation loop before calling the light ticker. This was done afterward which performed some needed cleanup too late. --- src/p_tick.cpp | 16 ---------------- src/playsim/dthinker.cpp | 21 +++++++++++++++++++++ 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/src/p_tick.cpp b/src/p_tick.cpp index 7253eafbe..2889a06a5 100644 --- a/src/p_tick.cpp +++ b/src/p_tick.cpp @@ -175,22 +175,6 @@ void P_Ticker (void) { P_UpdateSpecials(Level); } - it = Level->GetThinkerIterator(); - - // Set dynamic lights at the end of the tick, so that this catches all changes being made through the last frame. - while ((ac = it.Next())) - { - if (ac->flags8 & MF8_RECREATELIGHTS) - { - ac->flags8 &= ~MF8_RECREATELIGHTS; - ac->SetDynamicLights(); - } - // This was merged from P_RunEffects to eliminate the costly duplicate ThinkerIterator loop. - if ((ac->effects || ac->fountaincolor) && !Level->isFrozen()) - { - P_RunEffect(ac, ac->effects); - } - } // for par times Level->time++; diff --git a/src/playsim/dthinker.cpp b/src/playsim/dthinker.cpp index 0c8e687f1..75c75e789 100644 --- a/src/playsim/dthinker.cpp +++ b/src/playsim/dthinker.cpp @@ -107,6 +107,25 @@ void FThinkerCollection::RunThinkers(FLevelLocals *Level) ThinkCycles.Clock(); + auto recreateLights = [=]() { + auto it = Level->GetThinkerIterator(); + + // Set dynamic lights at the end of the tick, so that this catches all changes being made through the last frame. + while (auto ac = it.Next()) + { + if (ac->flags8 & MF8_RECREATELIGHTS) + { + ac->flags8 &= ~MF8_RECREATELIGHTS; + ac->SetDynamicLights(); + } + // This was merged from P_RunEffects to eliminate the costly duplicate ThinkerIterator loop. + if ((ac->effects || ac->fountaincolor) && !Level->isFrozen()) + { + P_RunEffect(ac, ac->effects); + } + } + }; + if (!profilethinkers) { // Tick every thinker left from last time @@ -127,6 +146,7 @@ void FThinkerCollection::RunThinkers(FLevelLocals *Level) if (Level->HasDynamicLights) { + recreateLights(); for (auto light = Level->lights; light;) { auto next = light->next; @@ -156,6 +176,7 @@ void FThinkerCollection::RunThinkers(FLevelLocals *Level) if (Level->lights && Level->HasDynamicLights) { + recreateLights(); // Also profile the internal dynamic lights, even though they are not implemented as thinkers. auto &prof = Profiles[NAME_InternalDynamicLight]; prof.timer.Clock(); From ccf46281df46d9b350efefd893d4844cac71bfe0 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 11 Aug 2021 16:01:40 +0200 Subject: [PATCH 28/39] - fixed line color handling in V_BreakLines. This cannot use the last color found while reading ahead - it must pick the last color of the string part that just got broken out into its own line when starting the next one. --- src/common/fonts/v_text.cpp | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/src/common/fonts/v_text.cpp b/src/common/fonts/v_text.cpp index 59d843496..bfd6eac92 100644 --- a/src/common/fonts/v_text.cpp +++ b/src/common/fonts/v_text.cpp @@ -88,7 +88,7 @@ TArray V_BreakLines (FFont *font, int maxwidth, const uint8_t *str { if (*string == '[') { - const uint8_t *start = string; + const uint8_t* start = string; while (*string != ']' && *string != '\0') { string++; @@ -97,11 +97,6 @@ TArray V_BreakLines (FFont *font, int maxwidth, const uint8_t *str { string++; } - lastcolor = FString((const char *)start, string - start); - } - else - { - lastcolor = *string++; } } continue; @@ -130,6 +125,33 @@ TArray V_BreakLines (FFont *font, int maxwidth, const uint8_t *str } auto index = Lines.Reserve(1); + for (const uint8_t* pos = start; pos < space; pos++) + { + if (*pos == TEXTCOLOR_ESCAPE) + { + pos++; + if (*pos) + { + if (*pos == '[') + { + const uint8_t* cstart = pos; + while (*pos != ']' && *pos != '\0') + { + pos++; + } + if (*pos != '\0') + { + pos++; + } + lastcolor = FString((const char*)cstart, pos - start); + } + else + { + lastcolor = *pos++; + } + } + } + } breakit (&Lines[index], font, start, space, linecolor); if (c == '\n' && !preservecolor) { From 67e7d1a6f5fd8bdcb152e2dc53b3d5ccadaa6bb9 Mon Sep 17 00:00:00 2001 From: Gutawer Date: Thu, 29 Jul 2021 18:58:29 +0100 Subject: [PATCH 29/39] - make RenderCommands able to use Shape2D vertex buffers past the Shape2D's lifetime without crashing --- src/common/2d/v_2ddrawer.cpp | 42 +++++++++---------- src/common/2d/v_2ddrawer.h | 24 +++++++---- src/common/rendering/hwrenderer/hw_draw2d.cpp | 18 ++++---- 3 files changed, 47 insertions(+), 37 deletions(-) diff --git a/src/common/2d/v_2ddrawer.cpp b/src/common/2d/v_2ddrawer.cpp index 44865797b..d9b6ef0de 100644 --- a/src/common/2d/v_2ddrawer.cpp +++ b/src/common/2d/v_2ddrawer.cpp @@ -124,7 +124,7 @@ static void Shape2D_Clear(DShape2D* self, int which) if (which & C_Verts) self->mVertices.Clear(); if (which & C_Coords) self->mCoords.Clear(); if (which & C_Indices) self->mIndices.Clear(); - self->needsVertexUpload = true; + self->bufferInfo->needsVertexUpload = true; } DEFINE_ACTION_FUNCTION_NATIVE(DShape2D, Clear, Shape2D_Clear) @@ -138,7 +138,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(DShape2D, Clear, Shape2D_Clear) static void Shape2D_PushVertex(DShape2D* self, double x, double y) { self->mVertices.Push(DVector2(x, y)); - self->needsVertexUpload = true; + self->bufferInfo->needsVertexUpload = true; } DEFINE_ACTION_FUNCTION_NATIVE(DShape2D, PushVertex, Shape2D_PushVertex) @@ -153,7 +153,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(DShape2D, PushVertex, Shape2D_PushVertex) static void Shape2D_PushCoord(DShape2D* self, double u, double v) { self->mCoords.Push(DVector2(u, v)); - self->needsVertexUpload = true; + self->bufferInfo->needsVertexUpload = true; } DEFINE_ACTION_FUNCTION_NATIVE(DShape2D, PushCoord, Shape2D_PushCoord) @@ -170,7 +170,7 @@ static void Shape2D_PushTriangle(DShape2D* self, int a, int b, int c) self->mIndices.Push(a); self->mIndices.Push(b); self->mIndices.Push(c); - self->needsVertexUpload = true; + self->bufferInfo->needsVertexUpload = true; } DEFINE_ACTION_FUNCTION_NATIVE(DShape2D, PushTriangle, Shape2D_PushTriangle) @@ -534,7 +534,7 @@ void DShape2D::OnDestroy() { mIndices.Reset(); mVertices.Reset(); mCoords.Reset(); - buffers.Reset(); + bufferInfo.reset(); } //========================================================================== @@ -567,11 +567,11 @@ void F2DDrawer::AddShape(FGameTexture* img, DShape2D* shape, DrawParms& parms) shape->lastParms = new DrawParms(parms); } else if (shape->lastParms->vertexColorChange(parms)) { - shape->needsVertexUpload = true; - if (!shape->uploadedOnce) { - shape->bufIndex = -1; - shape->buffers.Clear(); - shape->lastCommand = -1; + shape->bufferInfo->needsVertexUpload = true; + if (!shape->bufferInfo->uploadedOnce) { + shape->bufferInfo->bufIndex = -1; + shape->bufferInfo->buffers.Clear(); + shape->bufferInfo->lastCommand = -1; } delete shape->lastParms; shape->lastParms = new DrawParms(parms); @@ -583,7 +583,7 @@ void F2DDrawer::AddShape(FGameTexture* img, DShape2D* shape, DrawParms& parms) auto osave = offset; if (parms.nooffset) offset = { 0,0 }; - if (shape->needsVertexUpload) + if (shape->bufferInfo->needsVertexUpload) { shape->minx = 16383; shape->miny = 16383; @@ -622,15 +622,15 @@ void F2DDrawer::AddShape(FGameTexture* img, DShape2D* shape, DrawParms& parms) dg.transform = shape->transform; dg.transform.Cells[0][2] += offset.X; dg.transform.Cells[1][2] += offset.Y; - dg.shape2D = shape; + dg.shape2DBufInfo = shape->bufferInfo; dg.shape2DIndexCount = shape->mIndices.Size(); - if (shape->needsVertexUpload) + if (shape->bufferInfo->needsVertexUpload) { - shape->bufIndex += 1; + shape->bufferInfo->bufIndex += 1; - shape->buffers.Reserve(1); + shape->bufferInfo->buffers.Reserve(1); - auto buf = &shape->buffers[shape->bufIndex]; + auto buf = &shape->bufferInfo->buffers[shape->bufferInfo->bufIndex]; auto verts = TArray(dg.mVertCount, true); for ( int i=0; iUploadData(&verts[0], dg.mVertCount, &shape->mIndices[0], shape->mIndices.Size()); - shape->needsVertexUpload = false; - shape->uploadedOnce = true; + shape->bufferInfo->needsVertexUpload = false; + shape->bufferInfo->uploadedOnce = true; } - dg.shape2DBufIndex = shape->bufIndex; - shape->lastCommand += 1; - dg.shape2DCommandCounter = shape->lastCommand; + dg.shape2DBufIndex = shape->bufferInfo->bufIndex; + shape->bufferInfo->lastCommand += 1; + dg.shape2DCommandCounter = shape->bufferInfo->lastCommand; AddCommand(&dg); offset = osave; } diff --git a/src/common/2d/v_2ddrawer.h b/src/common/2d/v_2ddrawer.h index 8bb113905..8e6a88a8e 100644 --- a/src/common/2d/v_2ddrawer.h +++ b/src/common/2d/v_2ddrawer.h @@ -7,6 +7,7 @@ #include "textures.h" #include "renderstyle.h" #include "dobject.h" +#include struct DrawParms; struct FColormap; @@ -49,6 +50,7 @@ struct F2DPolygons }; class DShape2D; +class DShape2DBufferInfo; class F2DDrawer { @@ -123,7 +125,7 @@ public: bool useTransform; DMatrix3x3 transform; - DShape2D* shape2D; + std::shared_ptr shape2DBufInfo; int shape2DBufIndex; int shape2DIndexCount; int shape2DCommandCounter; @@ -131,12 +133,13 @@ public: RenderCommand() { memset(this, 0, sizeof(*this)); + shape2DBufInfo.reset(); } // If these fields match, two draw commands can be batched. bool isCompatible(const RenderCommand &other) const { - if (shape2D != nullptr || other.shape2D != nullptr) return false; + if (shape2DBufInfo != nullptr || other.shape2DBufInfo != nullptr) return false; return mTexture == other.mTexture && mType == other.mType && mTranslationId == other.mTranslationId && @@ -240,6 +243,16 @@ public: bool mIsFirstPass = true; }; +class DShape2DBufferInfo +{ +public: + TArray buffers; + bool needsVertexUpload = true; + int bufIndex = -1; + int lastCommand = -1; + bool uploadedOnce = false; +}; + class DShape2D : public DObject { @@ -247,6 +260,7 @@ class DShape2D : public DObject public: DShape2D() { + bufferInfo = std::make_shared(); transform.Identity(); } @@ -261,12 +275,8 @@ public: DMatrix3x3 transform; - TArray buffers; - bool needsVertexUpload = true; - int bufIndex = -1; - int lastCommand = -1; + std::shared_ptr bufferInfo; - bool uploadedOnce = false; DrawParms* lastParms; void OnDestroy() override; diff --git a/src/common/rendering/hwrenderer/hw_draw2d.cpp b/src/common/rendering/hwrenderer/hw_draw2d.cpp index cf3399432..af10a7bf2 100644 --- a/src/common/rendering/hwrenderer/hw_draw2d.cpp +++ b/src/common/rendering/hwrenderer/hw_draw2d.cpp @@ -178,22 +178,22 @@ void Draw2D(F2DDrawer *drawer, FRenderState &state) state.EnableTexture(false); } - if (cmd.shape2D != nullptr) + if (cmd.shape2DBufInfo != nullptr) { - state.SetVertexBuffer(&cmd.shape2D->buffers[cmd.shape2DBufIndex]); + state.SetVertexBuffer(&cmd.shape2DBufInfo->buffers[cmd.shape2DBufIndex]); state.DrawIndexed(DT_Triangles, 0, cmd.shape2DIndexCount); state.SetVertexBuffer(&vb); - if (cmd.shape2DCommandCounter == cmd.shape2D->lastCommand) + if (cmd.shape2DCommandCounter == cmd.shape2DBufInfo->lastCommand) { - cmd.shape2D->lastCommand = -1; - if (cmd.shape2D->bufIndex > 0) + cmd.shape2DBufInfo->lastCommand = -1; + if (cmd.shape2DBufInfo->bufIndex > 0) { - cmd.shape2D->needsVertexUpload = true; - cmd.shape2D->buffers.Clear(); - cmd.shape2D->bufIndex = -1; + cmd.shape2DBufInfo->needsVertexUpload = true; + cmd.shape2DBufInfo->buffers.Clear(); + cmd.shape2DBufInfo->bufIndex = -1; } } - cmd.shape2D->uploadedOnce = false; + cmd.shape2DBufInfo->uploadedOnce = false; } else { From bbcd522052e59e2539e411919833a16fc125f3f9 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Tue, 3 Aug 2021 09:52:30 +0300 Subject: [PATCH 30/39] - made RefCountedPtr follow rule of five --- src/common/utility/refcounted.h | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/src/common/utility/refcounted.h b/src/common/utility/refcounted.h index b0c87d934..cff177029 100644 --- a/src/common/utility/refcounted.h +++ b/src/common/utility/refcounted.h @@ -31,10 +31,20 @@ public: { if (ptr) ptr->IncRef(); } - + + RefCountedPtr(const RefCountedPtr& r) : ptr(r.ptr) + { + if (ptr) ptr->IncRef(); + } + + RefCountedPtr(RefCountedPtr&& r) : ptr(r.ptr) + { + r.ptr = nullptr; + } + RefCountedPtr & operator=(const RefCountedPtr& r) { - if (ptr != r.ptr) + if (this != &r) { if (ptr) ptr->DecRef(); ptr = r.ptr; @@ -54,11 +64,14 @@ public: return *this; } - RefCountedPtr & operator=(const RefCountedPtr&& r) + RefCountedPtr & operator=(RefCountedPtr&& r) { - if (ptr) ptr->DecRef(); - ptr = r.ptr; - r.ptr = nullptr; + if (this != &r) + { + if (ptr) ptr->DecRef(); + ptr = r.ptr; + r.ptr = nullptr; + } return *this; } From 76ecf445495a9187c345c91543547f07b0fbe6f2 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Tue, 3 Aug 2021 09:53:21 +0300 Subject: [PATCH 31/39] - added RefCountedBase without virtual destructor --- src/common/utility/refcounted.h | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/src/common/utility/refcounted.h b/src/common/utility/refcounted.h index cff177029..fd3e82aad 100644 --- a/src/common/utility/refcounted.h +++ b/src/common/utility/refcounted.h @@ -1,20 +1,29 @@ #pragma once // Simple lightweight reference counting pointer alternative for std::shared_ptr which stores the reference counter in the handled object itself. - - // Base class for handled objects + +// Base classes for handled objects +class NoVirtualRefCountedBase +{ +public: + void IncRef() { refCount++; } + void DecRef() { if (--refCount <= 0) delete this; } +private: + int refCount = 0; +}; + class RefCountedBase { public: - void IncRef() { refCount++; } - void DecRef() { if (--refCount <= 0) delete this; } + void IncRef() { refCount++; } + void DecRef() { if (--refCount <= 0) delete this; } private: - int refCount = 0; + int refCount = 0; protected: - virtual ~RefCountedBase() = default; + virtual ~RefCountedBase() = default; }; - - // The actual pointer object + +// The actual pointer object template class RefCountedPtr { From 387aef27adfbf3c986a1a764931150ad0cb37f24 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Tue, 3 Aug 2021 09:55:01 +0300 Subject: [PATCH 32/39] - use RefCountedPtr to manage 2D shape buffer infos --- src/common/2d/v_2ddrawer.cpp | 2 +- src/common/2d/v_2ddrawer.h | 14 ++++++-------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/common/2d/v_2ddrawer.cpp b/src/common/2d/v_2ddrawer.cpp index d9b6ef0de..ed57dae4a 100644 --- a/src/common/2d/v_2ddrawer.cpp +++ b/src/common/2d/v_2ddrawer.cpp @@ -534,7 +534,7 @@ void DShape2D::OnDestroy() { mIndices.Reset(); mVertices.Reset(); mCoords.Reset(); - bufferInfo.reset(); + bufferInfo = nullptr; } //========================================================================== diff --git a/src/common/2d/v_2ddrawer.h b/src/common/2d/v_2ddrawer.h index 8e6a88a8e..0e91d3b2c 100644 --- a/src/common/2d/v_2ddrawer.h +++ b/src/common/2d/v_2ddrawer.h @@ -7,7 +7,7 @@ #include "textures.h" #include "renderstyle.h" #include "dobject.h" -#include +#include "refcounted.h" struct DrawParms; struct FColormap; @@ -50,7 +50,7 @@ struct F2DPolygons }; class DShape2D; -class DShape2DBufferInfo; +struct DShape2DBufferInfo; class F2DDrawer { @@ -125,7 +125,7 @@ public: bool useTransform; DMatrix3x3 transform; - std::shared_ptr shape2DBufInfo; + RefCountedPtr shape2DBufInfo; int shape2DBufIndex; int shape2DIndexCount; int shape2DCommandCounter; @@ -133,7 +133,6 @@ public: RenderCommand() { memset(this, 0, sizeof(*this)); - shape2DBufInfo.reset(); } // If these fields match, two draw commands can be batched. @@ -243,9 +242,8 @@ public: bool mIsFirstPass = true; }; -class DShape2DBufferInfo +struct DShape2DBufferInfo : NoVirtualRefCountedBase { -public: TArray buffers; bool needsVertexUpload = true; int bufIndex = -1; @@ -259,8 +257,8 @@ class DShape2D : public DObject DECLARE_CLASS(DShape2D,DObject) public: DShape2D() + : bufferInfo(new DShape2DBufferInfo) { - bufferInfo = std::make_shared(); transform.Identity(); } @@ -275,7 +273,7 @@ public: DMatrix3x3 transform; - std::shared_ptr bufferInfo; + RefCountedPtr bufferInfo; DrawParms* lastParms; From ed606b8ed3e2aa00397492aeadb2aa3299b37ed5 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Wed, 11 Aug 2021 11:11:01 +0300 Subject: [PATCH 33/39] - extended 2D buffer lifetime to the end of the frame --- src/common/2d/v_2ddrawer.cpp | 15 ++++++++++++++- src/common/2d/v_2ddrawer.h | 1 + src/d_main.cpp | 1 + 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/common/2d/v_2ddrawer.cpp b/src/common/2d/v_2ddrawer.cpp index ed57dae4a..612eef005 100644 --- a/src/common/2d/v_2ddrawer.cpp +++ b/src/common/2d/v_2ddrawer.cpp @@ -528,13 +528,15 @@ void F2DDrawer::AddTexture(FGameTexture* img, DrawParms& parms) offset = osave; } +static TArray> buffersToDestroy; + void DShape2D::OnDestroy() { if (lastParms) delete lastParms; lastParms = nullptr; mIndices.Reset(); mVertices.Reset(); mCoords.Reset(); - bufferInfo = nullptr; + buffersToDestroy.Push(std::move(bufferInfo)); } //========================================================================== @@ -1082,6 +1084,17 @@ void F2DDrawer::Clear() screenFade = 1.f; } +//========================================================================== +// +// +// +//========================================================================== + +void F2DDrawer::OnFrameDone() +{ + buffersToDestroy.Clear(); +} + F2DVertexBuffer::F2DVertexBuffer() { mVertexBuffer = screen->CreateVertexBuffer(); diff --git a/src/common/2d/v_2ddrawer.h b/src/common/2d/v_2ddrawer.h index 0e91d3b2c..ebcef6142 100644 --- a/src/common/2d/v_2ddrawer.h +++ b/src/common/2d/v_2ddrawer.h @@ -216,6 +216,7 @@ public: void Begin(int w, int h) { isIn2D = true; Width = w; Height = h; } void End() { isIn2D = false; } bool HasBegun2D() { return isIn2D; } + void OnFrameDone(); void ClearClipRect() { clipleft = cliptop = 0; clipwidth = clipheight = -1; } void SetClipRect(int x, int y, int w, int h); diff --git a/src/d_main.cpp b/src/d_main.cpp index 245922beb..51f7fb5aa 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -903,6 +903,7 @@ static void End2DAndUpdate() twod->End(); CheckBench(); screen->Update(); + twod->OnFrameDone(); } //========================================================================== From f34258281f19d5c0fb4f5e6311e9fc8a7662c5e5 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 11 Aug 2021 19:58:57 +0200 Subject: [PATCH 34/39] - fixed: crushing stairs must use HexenCrush mode. This was the default for floors even in Doom, so it must also apply to the stairs. --- src/playsim/mapthinkers/a_floor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/playsim/mapthinkers/a_floor.cpp b/src/playsim/mapthinkers/a_floor.cpp index a94c98012..27dc1cf0e 100644 --- a/src/playsim/mapthinkers/a_floor.cpp +++ b/src/playsim/mapthinkers/a_floor.cpp @@ -648,7 +648,7 @@ bool FLevelLocals::EV_BuildStairs (int tag, DFloor::EStair type, line_t *line, d floor->m_Instant = false; floor->m_Crush = (usespecials & DFloor::stairCrush) ? 10 : -1; //jff 2/27/98 fix uninitialized crush field - floor->m_Hexencrush = false; + floor->m_Hexencrush = true; floor->m_Speed = speed; height = sec->CenterFloor() + stairstep; From 888eab306392d47e6d5c622cb5b1bccd78f3446d Mon Sep 17 00:00:00 2001 From: Marisa Kirisame Date: Thu, 24 Dec 2020 16:39:17 +0100 Subject: [PATCH 35/39] HUD model tweaks: - Look up HUD models by referencing the psprite's caller, rather than player's ReadyWeapon. - Allow Strife hands psprite to be a model. --- src/r_data/models.cpp | 13 +++++++++---- src/rendering/hwrenderer/scene/hw_weapon.cpp | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/r_data/models.cpp b/src/r_data/models.cpp index d970d5239..72b2c0f1b 100644 --- a/src/r_data/models.cpp +++ b/src/r_data/models.cpp @@ -183,7 +183,7 @@ void RenderModel(FModelRenderer *renderer, float x, float y, float z, FSpriteMod void RenderHUDModel(FModelRenderer *renderer, DPSprite *psp, float ofsX, float ofsY) { AActor * playermo = players[consoleplayer].camera; - FSpriteModelFrame *smf = FindModelFrame(playermo->player->ReadyWeapon->GetClass(), psp->GetSprite(), psp->GetFrame(), false); + FSpriteModelFrame *smf = FindModelFrame(psp->Caller->GetClass(), psp->GetSprite(), psp->GetFrame(), false); // [BB] No model found for this sprite, so we can't render anything. if (smf == nullptr) @@ -216,7 +216,7 @@ void RenderHUDModel(FModelRenderer *renderer, DPSprite *psp, float ofsX, float o renderer->BeginDrawHUDModel(playermo->RenderStyle, objectToWorldMatrix, orientation < 0); uint32_t trans = psp->GetTranslation() != 0 ? psp->GetTranslation() : 0; if ((psp->Flags & PSPF_PLAYERTRANSLATED)) trans = psp->Owner->mo->Translation; - RenderFrameModels(renderer, playermo->Level, smf, psp->GetState(), psp->GetTics(), playermo->player->ReadyWeapon->GetClass(), trans); + RenderFrameModels(renderer, playermo->Level, smf, psp->GetState(), psp->GetTics(), psp->Caller->GetClass(), trans); renderer->EndDrawHUDModel(playermo->RenderStyle); } @@ -780,12 +780,17 @@ bool IsHUDModelForPlayerAvailable (player_t * player) if (player == nullptr || player->ReadyWeapon == nullptr) return false; - DPSprite *psp = player->FindPSprite(PSP_WEAPON); + // [MK] allow the Strife burning hands to be a model... + DPSprite *psp = player->FindPSprite(PSP_STRIFEHANDS); + + // [MK] ...otherwise, check for the weapon psprite as per usual + if (psp == nullptr) + psp = player->FindPSprite(PSP_WEAPON); if (psp == nullptr) return false; - FSpriteModelFrame *smf = FindModelFrame(player->ReadyWeapon->GetClass(), psp->GetSprite(), psp->GetFrame(), false); + FSpriteModelFrame *smf = FindModelFrame(psp->Caller->GetClass(), psp->GetSprite(), psp->GetFrame(), false); return ( smf != nullptr ); } diff --git a/src/rendering/hwrenderer/scene/hw_weapon.cpp b/src/rendering/hwrenderer/scene/hw_weapon.cpp index fd2f9cc2e..c763ab15f 100644 --- a/src/rendering/hwrenderer/scene/hw_weapon.cpp +++ b/src/rendering/hwrenderer/scene/hw_weapon.cpp @@ -614,7 +614,7 @@ void HWDrawInfo::PreparePlayerSprites(sector_t * viewsector, area_t in_area) for (DPSprite *psp = player->psprites; psp != nullptr && psp->GetID() < PSP_TARGETCENTER; psp = psp->GetNext()) { if (!psp->GetState()) continue; - FSpriteModelFrame *smf = playermo->player->ReadyWeapon ? FindModelFrame(playermo->player->ReadyWeapon->GetClass(), psp->GetSprite(), psp->GetFrame(), false) : nullptr; + FSpriteModelFrame *smf = FindModelFrame(psp->Caller->GetClass(), psp->GetSprite(), psp->GetFrame(), false); // This is an 'either-or' proposition. This maybe needs some work to allow overlays with weapon models but as originally implemented this just won't work. if (smf && !hudModelStep) continue; if (!smf && hudModelStep) continue; From 1d96b68e1a3ef3b16789741bffbde535e1005993 Mon Sep 17 00:00:00 2001 From: Marisa Kirisame Date: Sat, 20 Feb 2021 11:35:14 +0100 Subject: [PATCH 36/39] Fixed IsHUDModelForPlayerAvailable limitation. --- src/r_data/models.cpp | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/src/r_data/models.cpp b/src/r_data/models.cpp index 72b2c0f1b..2d7c0eb2e 100644 --- a/src/r_data/models.cpp +++ b/src/r_data/models.cpp @@ -777,20 +777,14 @@ FSpriteModelFrame * FindModelFrame(const PClass * ti, int sprite, int frame, boo bool IsHUDModelForPlayerAvailable (player_t * player) { - if (player == nullptr || player->ReadyWeapon == nullptr) + if (player == nullptr || player->psprites == nullptr) return false; - // [MK] allow the Strife burning hands to be a model... - DPSprite *psp = player->FindPSprite(PSP_STRIFEHANDS); - - // [MK] ...otherwise, check for the weapon psprite as per usual - if (psp == nullptr) - psp = player->FindPSprite(PSP_WEAPON); - - if (psp == nullptr) - return false; - - FSpriteModelFrame *smf = FindModelFrame(psp->Caller->GetClass(), psp->GetSprite(), psp->GetFrame(), false); - return ( smf != nullptr ); + // [MK] check that at least one psprite uses models + for (DPSprite *psp = player->psprites; psp != nullptr && psp->GetID() < PSP_TARGETCENTER; psp = psp->GetNext()) + { + FSpriteModelFrame *smf = FindModelFrame(psp->Caller->GetClass(), psp->GetSprite(), psp->GetFrame(), false); + if ( smf != nullptr ) return true; + } + return false; } - From c3772fe2036a8778d2e7198570a3ab0658e2e88e Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 12 Aug 2021 00:45:59 +0200 Subject: [PATCH 37/39] - changed FString API to use ptrdiff_t instead of long for signed size arguments. --- src/common/console/c_commandbuffer.cpp | 2 +- src/common/console/c_dispatch.cpp | 2 +- src/common/engine/stringtable.cpp | 2 +- src/common/filesystem/filesystem.cpp | 2 +- src/common/filesystem/resourcefile.cpp | 4 +- src/common/models/model.cpp | 4 +- src/common/models/models_obj.cpp | 8 +-- .../hwrenderer/data/hw_shaderpatcher.cpp | 42 ++++++------ .../scripting/interface/stringformat.cpp | 12 ++-- src/common/utility/s_playlist.cpp | 2 +- src/common/utility/zstring.cpp | 68 +++++++++---------- src/common/utility/zstring.h | 34 +++++----- src/d_iwad.cpp | 2 +- src/d_main.cpp | 4 +- src/gameconfigfile.cpp | 2 +- src/m_misc.cpp | 2 +- src/maploader/glnodes.cpp | 4 +- src/scripting/backend/codegen_doom.cpp | 4 +- 18 files changed, 100 insertions(+), 100 deletions(-) diff --git a/src/common/console/c_commandbuffer.cpp b/src/common/console/c_commandbuffer.cpp index 0ca96ade3..bf459350f 100644 --- a/src/common/console/c_commandbuffer.cpp +++ b/src/common/console/c_commandbuffer.cpp @@ -291,7 +291,7 @@ void FCommandBuffer::AddString(FString clip) if (clip.IsNotEmpty()) { // Only paste the first line. - long brk = clip.IndexOfAny("\r\n\b"); + auto brk = clip.IndexOfAny("\r\n\b"); std::u32string build; if (brk >= 0) { diff --git a/src/common/console/c_dispatch.cpp b/src/common/console/c_dispatch.cpp index bcb52ba7e..ce9f2cef7 100644 --- a/src/common/console/c_dispatch.cpp +++ b/src/common/console/c_dispatch.cpp @@ -533,7 +533,7 @@ FString BuildString (int argc, FString *argv) else if (strchr(argv[arg], '"')) { // If it contains one or more quotes, we need to escape them. buf << '"'; - long substr_start = 0, quotepos; + ptrdiff_t substr_start = 0, quotepos; while ((quotepos = argv[arg].IndexOf('"', substr_start)) >= 0) { if (substr_start < quotepos) diff --git a/src/common/engine/stringtable.cpp b/src/common/engine/stringtable.cpp index a666a4d9c..b36e6e409 100644 --- a/src/common/engine/stringtable.cpp +++ b/src/common/engine/stringtable.cpp @@ -435,7 +435,7 @@ void FStringTable::InsertString(int lumpnum, int langid, FName label, const FStr { const char *strlangid = (const char *)&langid; TableElement te = { fileSystem.GetFileContainer(lumpnum), { string, string, string, string } }; - long index; + ptrdiff_t index; while ((index = te.strings[0].IndexOf("@[")) >= 0) { auto endindex = te.strings[0].IndexOf(']', index); diff --git a/src/common/filesystem/filesystem.cpp b/src/common/filesystem/filesystem.cpp index 8b14b1312..5a709726f 100644 --- a/src/common/filesystem/filesystem.cpp +++ b/src/common/filesystem/filesystem.cpp @@ -1546,7 +1546,7 @@ bool FileSystem::CreatePathlessCopy(const char *name, int id, int /*flags*/) if (lump < 0) return false; // Does not exist. auto oldlump = FileInfo[lump]; - int slash = oldlump.longName.LastIndexOf('/'); + ptrdiff_t slash = oldlump.longName.LastIndexOf('/'); if (slash == -1) { diff --git a/src/common/filesystem/resourcefile.cpp b/src/common/filesystem/resourcefile.cpp index 5fc484b23..cc2a27345 100644 --- a/src/common/filesystem/resourcefile.cpp +++ b/src/common/filesystem/resourcefile.cpp @@ -348,8 +348,8 @@ void FResourceFile::PostProcessArchive(void *lumps, size_t lumpsize, LumpFilterI uint32_t max = NumLumps; max -= FilterLumpsByGameType(filter, lumps, lumpsize, max); - long len; - int lastpos = -1; + ptrdiff_t len; + ptrdiff_t lastpos = -1; FString file; FString LumpFilter = filter->dotFilter; while ((len = LumpFilter.IndexOf('.', lastpos+1)) > 0) diff --git a/src/common/models/model.cpp b/src/common/models/model.cpp index 90dedc272..eea099045 100644 --- a/src/common/models/model.cpp +++ b/src/common/models/model.cpp @@ -90,8 +90,8 @@ static int FindGFXFile(FString & fn) if (lump != -1) return lump; int best = -1; - int dot = fn.LastIndexOf('.'); - int slash = fn.LastIndexOf('/'); + auto dot = fn.LastIndexOf('.'); + auto slash = fn.LastIndexOf('/'); if (dot > slash) fn.Truncate(dot); static const char * extensions[] = { ".png", ".jpg", ".tga", ".pcx", nullptr }; diff --git a/src/common/models/models_obj.cpp b/src/common/models/models_obj.cpp index 1af4fab7e..05d10b5cf 100644 --- a/src/common/models/models_obj.cpp +++ b/src/common/models/models_obj.cpp @@ -44,8 +44,8 @@ bool FOBJModel::Load(const char* fn, int lumpnum, const char* buffer, int length { // Ensure usemtl statements remain intact TArray mtlUsages; - TArray mtlUsageIdxs; - long bpos = 0, nlpos = 0, slashpos = 0; + TArray mtlUsageIdxs; + ptrdiff_t bpos = 0, nlpos = 0, slashpos = 0; while (1) { bpos = objBuf.IndexOf("\nusemtl", bpos); @@ -58,7 +58,7 @@ bool FOBJModel::Load(const char* fn, int lumpnum, const char* buffer, int length } if (nlpos == -1) { - nlpos = (long)objBuf.Len(); + nlpos = objBuf.Len(); } FString lineStr(objBuf.GetChars() + bpos, nlpos - bpos); mtlUsages.Push(lineStr); @@ -76,7 +76,7 @@ bool FOBJModel::Load(const char* fn, int lumpnum, const char* buffer, int length nlpos = objBuf.IndexOf('\n', bpos); if (nlpos == -1) { - nlpos = (long)objBuf.Len(); + nlpos = objBuf.Len(); } memcpy(wObjBuf + bpos, mtlUsages[i].GetChars(), nlpos - bpos); } diff --git a/src/common/rendering/hwrenderer/data/hw_shaderpatcher.cpp b/src/common/rendering/hwrenderer/data/hw_shaderpatcher.cpp index fb3b8a535..97420e0c2 100644 --- a/src/common/rendering/hwrenderer/data/hw_shaderpatcher.cpp +++ b/src/common/rendering/hwrenderer/data/hw_shaderpatcher.cpp @@ -52,15 +52,15 @@ static bool IsGlslWhitespace(char c) } } -static FString NextGlslToken(const char *chars, long len, long &pos) +static FString NextGlslToken(const char *chars, ptrdiff_t len, ptrdiff_t &pos) { // Eat whitespace - long tokenStart = pos; + ptrdiff_t tokenStart = pos; while (tokenStart != len && IsGlslWhitespace(chars[tokenStart])) tokenStart++; // Find token end - long tokenEnd = tokenStart; + ptrdiff_t tokenEnd = tokenStart; while (tokenEnd != len && !IsGlslWhitespace(chars[tokenEnd]) && chars[tokenEnd] != ';') tokenEnd++; @@ -82,13 +82,13 @@ FString RemoveLegacyUserUniforms(FString code) // The following code searches for legacy uniform declarations in the shader itself and replaces them with whitespace. - long len = (long)code.Len(); + ptrdiff_t len = code.Len(); char *chars = code.LockBuffer(); - long startIndex = 0; + ptrdiff_t startIndex = 0; while (true) { - long matchIndex = code.IndexOf("uniform", startIndex); + ptrdiff_t matchIndex = code.IndexOf("uniform", startIndex); if (matchIndex == -1) break; @@ -98,7 +98,7 @@ FString RemoveLegacyUserUniforms(FString code) bool isKeywordEnd = matchIndex + 7 == len || IsGlslWhitespace(chars[matchIndex + 7]); if (isKeywordStart && isKeywordEnd) { - long pos = matchIndex + 7; + ptrdiff_t pos = matchIndex + 7; FString type = NextGlslToken(chars, len, pos); FString identifier = NextGlslToken(chars, len, pos); @@ -107,10 +107,10 @@ FString RemoveLegacyUserUniforms(FString code) if (isLegacyUniformName) { - long statementEndIndex = code.IndexOf(';', matchIndex + 7); + ptrdiff_t statementEndIndex = code.IndexOf(';', matchIndex + 7); if (statementEndIndex == -1) statementEndIndex = len; - for (long i = matchIndex; i <= statementEndIndex; i++) + for (ptrdiff_t i = matchIndex; i <= statementEndIndex; i++) { if (!IsGlslWhitespace(chars[i])) chars[i] = ' '; @@ -127,7 +127,7 @@ FString RemoveLegacyUserUniforms(FString code) // Modern GLSL only allows use of 'texture'. while (true) { - long matchIndex = code.IndexOf("texture2d", startIndex); + ptrdiff_t matchIndex = code.IndexOf("texture2d", startIndex); if (matchIndex == -1) break; @@ -148,14 +148,14 @@ FString RemoveLegacyUserUniforms(FString code) FString RemoveSamplerBindings(FString code, TArray> &samplerstobind) { - long len = (long)code.Len(); + ptrdiff_t len = code.Len(); char *chars = code.LockBuffer(); - long startIndex = 0; - long startpos, endpos; + ptrdiff_t startIndex = 0; + ptrdiff_t startpos, endpos; while (true) { - long matchIndex = code.IndexOf("layout(binding", startIndex); + ptrdiff_t matchIndex = code.IndexOf("layout(binding", startIndex); if (matchIndex == -1) break; @@ -165,7 +165,7 @@ FString RemoveSamplerBindings(FString code, TArray> &sam bool isKeywordEnd = matchIndex + 14 == len || IsGlslWhitespace(chars[matchIndex + 14]) || chars[matchIndex + 14] == '='; if (isKeywordStart && isKeywordEnd) { - long pos = matchIndex + 14; + ptrdiff_t pos = matchIndex + 14; startpos = matchIndex; while (IsGlslWhitespace(chars[pos])) pos++; if (chars[pos] == '=') @@ -175,7 +175,7 @@ FString RemoveSamplerBindings(FString code, TArray> &sam auto val = strtol(&chars[pos], &p, 0); if (p != &chars[pos]) { - pos = long(p - chars); + pos = (p - chars); while (IsGlslWhitespace(chars[pos])) pos++; if (chars[pos] == ')') { @@ -216,17 +216,17 @@ FString RemoveSamplerBindings(FString code, TArray> &sam FString RemoveLayoutLocationDecl(FString code, const char *inoutkeyword) { - long len = (long)code.Len(); + ptrdiff_t len = code.Len(); char *chars = code.LockBuffer(); - long startIndex = 0; + ptrdiff_t startIndex = 0; while (true) { - long matchIndex = code.IndexOf("layout(location", startIndex); + ptrdiff_t matchIndex = code.IndexOf("layout(location", startIndex); if (matchIndex == -1) break; - long endIndex = matchIndex; + ptrdiff_t endIndex = matchIndex; // Find end of layout declaration while (chars[endIndex] != ')' && chars[endIndex] != 0) @@ -255,7 +255,7 @@ FString RemoveLayoutLocationDecl(FString code, const char *inoutkeyword) if (keywordFound && IsGlslWhitespace(chars[endIndex + i])) { // yes - replace declaration with spaces - for (long i = matchIndex; i < endIndex; i++) + for (auto i = matchIndex; i < endIndex; i++) chars[i] = ' '; } diff --git a/src/common/scripting/interface/stringformat.cpp b/src/common/scripting/interface/stringformat.cpp index 87bfbb415..4bfe34ff6 100644 --- a/src/common/scripting/interface/stringformat.cpp +++ b/src/common/scripting/interface/stringformat.cpp @@ -419,7 +419,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(FStringStruct, Filter, StringFilter) static int StringIndexOf(FString *self, const FString &substr, int startIndex) { - return self->IndexOf(substr, startIndex); + return (int)self->IndexOf(substr, startIndex); } DEFINE_ACTION_FUNCTION_NATIVE(FStringStruct, IndexOf, StringIndexOf) @@ -427,12 +427,12 @@ DEFINE_ACTION_FUNCTION_NATIVE(FStringStruct, IndexOf, StringIndexOf) PARAM_SELF_STRUCT_PROLOGUE(FString); PARAM_STRING(substr); PARAM_INT(startIndex); - ACTION_RETURN_INT(self->IndexOf(substr, startIndex)); + ACTION_RETURN_INT(StringIndexOf(self, substr, startIndex)); } static int StringLastIndexOf(FString *self, const FString &substr, int endIndex) { - return self->LastIndexOfBroken(substr, endIndex); + return (int)self->LastIndexOfBroken(substr, endIndex); } DEFINE_ACTION_FUNCTION_NATIVE(FStringStruct, LastIndexOf, StringLastIndexOf) @@ -440,12 +440,12 @@ DEFINE_ACTION_FUNCTION_NATIVE(FStringStruct, LastIndexOf, StringLastIndexOf) PARAM_SELF_STRUCT_PROLOGUE(FString); PARAM_STRING(substr); PARAM_INT(endIndex); - ACTION_RETURN_INT(self->LastIndexOfBroken(substr, endIndex)); + ACTION_RETURN_INT(StringLastIndexOf(self, substr, endIndex)); } static int StringRightIndexOf(FString *self, const FString &substr, int endIndex) { - return self->LastIndexOf(substr, endIndex); + return (int)self->LastIndexOf(substr, endIndex); } DEFINE_ACTION_FUNCTION_NATIVE(FStringStruct, RightIndexOf, StringRightIndexOf) @@ -453,7 +453,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(FStringStruct, RightIndexOf, StringRightIndexOf) PARAM_SELF_STRUCT_PROLOGUE(FString); PARAM_STRING(substr); PARAM_INT(endIndex); - ACTION_RETURN_INT(self->LastIndexOf(substr, endIndex)); + ACTION_RETURN_INT(StringRightIndexOf(self, substr, endIndex)); } static void StringToUpper(FString *self) diff --git a/src/common/utility/s_playlist.cpp b/src/common/utility/s_playlist.cpp index 49e6f2d81..d284a3e90 100644 --- a/src/common/utility/s_playlist.cpp +++ b/src/common/utility/s_playlist.cpp @@ -95,7 +95,7 @@ bool FPlayList::ChangeList (const char *path) } // Check for relative paths. - long slashpos = song.IndexOf('/'); + auto slashpos = song.IndexOf('/'); if (slashpos == 0) { diff --git a/src/common/utility/zstring.cpp b/src/common/utility/zstring.cpp index 2cd308596..8d4d4d119 100644 --- a/src/common/utility/zstring.cpp +++ b/src/common/utility/zstring.cpp @@ -422,7 +422,7 @@ void FString::Remove(size_t index, size_t remlen) { if (index + remlen >= Len()) { - Truncate((long)index); + Truncate(index); } else { @@ -500,12 +500,12 @@ void FString::DeleteLastCharacter() } -long FString::IndexOf (const FString &substr, long startIndex) const +ptrdiff_t FString::IndexOf (const FString &substr, ptrdiff_t startIndex) const { return IndexOf (substr.Chars, startIndex); } -long FString::IndexOf (const char *substr, long startIndex) const +ptrdiff_t FString::IndexOf (const char *substr, ptrdiff_t startIndex) const { if (startIndex > 0 && Len() <= (size_t)startIndex) { @@ -516,10 +516,10 @@ long FString::IndexOf (const char *substr, long startIndex) const { return -1; } - return long(str - Chars); + return str - Chars; } -long FString::IndexOf (char subchar, long startIndex) const +ptrdiff_t FString::IndexOf (char subchar, ptrdiff_t startIndex) const { if (startIndex > 0 && Len() <= (size_t)startIndex) { @@ -530,15 +530,15 @@ long FString::IndexOf (char subchar, long startIndex) const { return -1; } - return long(str - Chars); + return str - Chars; } -long FString::IndexOfAny (const FString &charset, long startIndex) const +ptrdiff_t FString::IndexOfAny (const FString &charset, ptrdiff_t startIndex) const { return IndexOfAny (charset.Chars, startIndex); } -long FString::IndexOfAny (const char *charset, long startIndex) const +ptrdiff_t FString::IndexOfAny (const char *charset, ptrdiff_t startIndex) const { if (startIndex > 0 && Len() <= (size_t)startIndex) { @@ -549,19 +549,19 @@ long FString::IndexOfAny (const char *charset, long startIndex) const { return -1; } - return long(brk - Chars); + return brk - Chars; } -long FString::LastIndexOf (char subchar) const +ptrdiff_t FString::LastIndexOf (char subchar) const { - return LastIndexOf (subchar, long(Len())); + return LastIndexOf (subchar, Len()); } -long FString::LastIndexOf (char subchar, long endIndex) const +ptrdiff_t FString::LastIndexOf (char subchar, ptrdiff_t endIndex) const { if ((size_t)endIndex > Len()) { - endIndex = long(Len()); + endIndex = Len(); } while (--endIndex >= 0) { @@ -573,16 +573,16 @@ long FString::LastIndexOf (char subchar, long endIndex) const return -1; } -long FString::LastIndexOfBroken (const FString &_substr, long endIndex) const +ptrdiff_t FString::LastIndexOfBroken (const FString &_substr, ptrdiff_t endIndex) const { const char *substr = _substr.GetChars(); size_t substrlen = _substr.Len(); if ((size_t)endIndex > Len()) { - endIndex = long(Len()); + endIndex = Len(); } substrlen--; - while (--endIndex >= long(substrlen)) + while (--endIndex >= ptrdiff_t(substrlen)) { if (strncmp (substr, Chars + endIndex - substrlen, substrlen + 1) == 0) { @@ -592,26 +592,26 @@ long FString::LastIndexOfBroken (const FString &_substr, long endIndex) const return -1; } -long FString::LastIndexOfAny (const FString &charset) const +ptrdiff_t FString::LastIndexOfAny (const FString &charset) const { - return LastIndexOfAny (charset.Chars, long(Len())); + return LastIndexOfAny (charset.Chars, Len()); } -long FString::LastIndexOfAny (const char *charset) const +ptrdiff_t FString::LastIndexOfAny (const char *charset) const { return LastIndexOfAny (charset, long(Len())); } -long FString::LastIndexOfAny (const FString &charset, long endIndex) const +ptrdiff_t FString::LastIndexOfAny (const FString &charset, ptrdiff_t endIndex) const { return LastIndexOfAny (charset.Chars, endIndex); } -long FString::LastIndexOfAny (const char *charset, long endIndex) const +ptrdiff_t FString::LastIndexOfAny (const char *charset, ptrdiff_t endIndex) const { if ((size_t)endIndex > Len()) { - endIndex = long(Len()); + endIndex = Len(); } while (--endIndex >= 0) { @@ -623,31 +623,31 @@ long FString::LastIndexOfAny (const char *charset, long endIndex) const return -1; } -long FString::LastIndexOf (const FString &substr) const +ptrdiff_t FString::LastIndexOf (const FString &substr) const { - return LastIndexOf(substr.Chars, long(Len() - substr.Len()), substr.Len()); + return LastIndexOf(substr.Chars, Len() - substr.Len(), substr.Len()); } -long FString::LastIndexOf (const FString &substr, long endIndex) const +ptrdiff_t FString::LastIndexOf (const FString &substr, ptrdiff_t endIndex) const { return LastIndexOf(substr.Chars, endIndex, substr.Len()); } -long FString::LastIndexOf (const char *substr) const +ptrdiff_t FString::LastIndexOf (const char *substr) const { - return LastIndexOf(substr, long(Len() - strlen(substr)), strlen(substr)); + return LastIndexOf(substr, Len() - strlen(substr), strlen(substr)); } -long FString::LastIndexOf (const char *substr, long endIndex) const +ptrdiff_t FString::LastIndexOf (const char *substr, ptrdiff_t endIndex) const { return LastIndexOf(substr, endIndex, strlen(substr)); } -long FString::LastIndexOf (const char *substr, long endIndex, size_t substrlen) const +ptrdiff_t FString::LastIndexOf (const char *substr, ptrdiff_t endIndex, size_t substrlen) const { if ((size_t)endIndex + substrlen > Len()) { - endIndex = long(Len() - substrlen); + endIndex = Len() - substrlen; } while (endIndex >= 0) { @@ -1256,15 +1256,15 @@ void FString::Split(TArray& tokens, const char *delimiter, EmptyTokenTy { assert(nullptr != delimiter); - const long selfLen = static_cast(Len()); - const long delimLen = static_cast(strlen(delimiter)); - long lastPos = 0; + const auto selfLen = static_cast(Len()); + const auto delimLen = static_cast(strlen(delimiter)); + ptrdiff_t lastPos = 0; if (selfLen == 0) return; // Empty strings do not contain tokens, even with TOK_KEEPEMPTY. while (lastPos <= selfLen) { - long pos = IndexOf(delimiter, lastPos); + auto pos = IndexOf(delimiter, lastPos); if (-1 == pos) { diff --git a/src/common/utility/zstring.h b/src/common/utility/zstring.h index a30458c3c..4640d5c28 100644 --- a/src/common/utility/zstring.h +++ b/src/common/utility/zstring.h @@ -215,28 +215,28 @@ public: void AppendCharacter(int codepoint); void DeleteLastCharacter(); - long IndexOf (const FString &substr, long startIndex=0) const; - long IndexOf (const char *substr, long startIndex=0) const; - long IndexOf (char subchar, long startIndex=0) const; + ptrdiff_t IndexOf (const FString &substr, ptrdiff_t startIndex=0) const; + ptrdiff_t IndexOf (const char *substr, ptrdiff_t startIndex=0) const; + ptrdiff_t IndexOf (char subchar, ptrdiff_t startIndex=0) const; - long IndexOfAny (const FString &charset, long startIndex=0) const; - long IndexOfAny (const char *charset, long startIndex=0) const; + ptrdiff_t IndexOfAny (const FString &charset, ptrdiff_t startIndex=0) const; + ptrdiff_t IndexOfAny (const char *charset, ptrdiff_t startIndex=0) const; // This is only kept for backwards compatibility with old ZScript versions that used this function and depend on its bug. - long LastIndexOf (char subchar) const; - long LastIndexOfBroken (const FString &substr, long endIndex) const; - long LastIndexOf (char subchar, long endIndex) const; + ptrdiff_t LastIndexOf (char subchar) const; + ptrdiff_t LastIndexOfBroken (const FString &substr, ptrdiff_t endIndex) const; + ptrdiff_t LastIndexOf (char subchar, ptrdiff_t endIndex) const; - long LastIndexOfAny (const FString &charset) const; - long LastIndexOfAny (const char *charset) const; - long LastIndexOfAny (const FString &charset, long endIndex) const; - long LastIndexOfAny (const char *charset, long endIndex) const; + ptrdiff_t LastIndexOfAny (const FString &charset) const; + ptrdiff_t LastIndexOfAny (const char *charset) const; + ptrdiff_t LastIndexOfAny (const FString &charset, ptrdiff_t endIndex) const; + ptrdiff_t LastIndexOfAny (const char *charset, ptrdiff_t endIndex) const; - long LastIndexOf (const FString &substr) const; - long LastIndexOf (const FString &substr, long endIndex) const; - long LastIndexOf (const char *substr) const; - long LastIndexOf (const char *substr, long endIndex) const; - long LastIndexOf (const char *substr, long endIndex, size_t substrlen) const; + ptrdiff_t LastIndexOf (const FString &substr) const; + ptrdiff_t LastIndexOf (const FString &substr, ptrdiff_t endIndex) const; + ptrdiff_t LastIndexOf (const char *substr) const; + ptrdiff_t LastIndexOf (const char *substr, ptrdiff_t endIndex) const; + ptrdiff_t LastIndexOf (const char *substr, ptrdiff_t endIndex, size_t substrlen) const; void ToUpper (); void ToLower (); diff --git a/src/d_iwad.cpp b/src/d_iwad.cpp index d147c8e7e..ca0f50f87 100644 --- a/src/d_iwad.cpp +++ b/src/d_iwad.cpp @@ -762,7 +762,7 @@ int FIWadManager::IdentifyVersion (TArray &wadfiles, const char *iwad, FString path; if (info.Load[i][0] != ':') { - long lastslash = picks[pick].mFullPath.LastIndexOf('/'); + auto lastslash = picks[pick].mFullPath.LastIndexOf('/'); if (lastslash == -1) { diff --git a/src/d_main.cpp b/src/d_main.cpp index 51f7fb5aa..1b77b57d8 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -2122,8 +2122,8 @@ static void AddAutoloadFiles(const char *autoname) // Add common (global) wads D_AddConfigFiles(allwads, "Global.Autoload", "*.wad", GameConfig); - long len; - int lastpos = -1; + ptrdiff_t len; + ptrdiff_t lastpos = -1; while ((len = LumpFilterIWAD.IndexOf('.', lastpos+1)) > 0) { diff --git a/src/gameconfigfile.cpp b/src/gameconfigfile.cpp index 830cef232..17898f3ae 100644 --- a/src/gameconfigfile.cpp +++ b/src/gameconfigfile.cpp @@ -255,7 +255,7 @@ void FGameConfigFile::DoAutoloadSetup (FIWadManager *iwad_man) { FString section = workname + ".Autoload"; CreateSectionAtStart(section.GetChars()); - long dotpos = workname.LastIndexOf('.'); + auto dotpos = workname.LastIndexOf('.'); if (dotpos < 0) break; workname.Truncate(dotpos); } diff --git a/src/m_misc.cpp b/src/m_misc.cpp index 40474c69e..6680911ac 100644 --- a/src/m_misc.cpp +++ b/src/m_misc.cpp @@ -635,7 +635,7 @@ void M_ScreenShot (const char *filename) if (!screenshot_quiet) { - int slash = -1; + ptrdiff_t slash = -1; if (!longsavemessages) slash = autoname.LastIndexOfAny(":/\\"); Printf ("Captured %s\n", autoname.GetChars()+slash+1); } diff --git a/src/maploader/glnodes.cpp b/src/maploader/glnodes.cpp index 216fb5784..843afeaa5 100644 --- a/src/maploader/glnodes.cpp +++ b/src/maploader/glnodes.cpp @@ -1001,13 +1001,13 @@ static FString CreateCacheName(MapData *map, bool create) { FString path = M_GetCachePath(create); FString lumpname = fileSystem.GetFileFullPath(map->lumpnum); - int separator = lumpname.IndexOf(':'); + auto separator = lumpname.IndexOf(':'); path << '/' << lumpname.Left(separator); if (create) CreatePath(path); lumpname.ReplaceChars('/', '%'); lumpname.ReplaceChars(':', '$'); - path << '/' << lumpname.Right(lumpname.Len() - separator - 1) << ".gzc"; + path << '/' << lumpname.Right((ptrdiff_t)lumpname.Len() - separator - 1) << ".gzc"; return path; } diff --git a/src/scripting/backend/codegen_doom.cpp b/src/scripting/backend/codegen_doom.cpp index 111147c2c..e10756354 100644 --- a/src/scripting/backend/codegen_doom.cpp +++ b/src/scripting/backend/codegen_doom.cpp @@ -808,12 +808,12 @@ FxMultiNameState::FxMultiNameState(const char *_statestring, const FScriptPositi { FName scopename = NAME_None; FString statestring = _statestring; - int scopeindex = statestring.IndexOf("::"); + auto scopeindex = statestring.IndexOf("::"); if (scopeindex >= 0) { scopename = FName(statestring, scopeindex, false); - statestring = statestring.Right(statestring.Len() - scopeindex - 2); + statestring = statestring.Right((ptrdiff_t)statestring.Len() - scopeindex - 2); } names = MakeStateNameList(statestring); names.Insert(0, scopename); From f9f48c4a95725966c20fda648eaf841a9d32888d Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 12 Aug 2021 20:07:04 +0200 Subject: [PATCH 38/39] - replaced the alt HUD's index font with a sheet based variant. Mainly to correct an error in the '1' glyph. --- wadsrc/static/fonts/indexfont/0030.png | Bin 0 -> 230 bytes wadsrc/static/fonts/indexfont/font.inf | 2 ++ wadsrc/static/indexfont | Bin 309 -> 0 bytes 3 files changed, 2 insertions(+) create mode 100644 wadsrc/static/fonts/indexfont/0030.png create mode 100644 wadsrc/static/fonts/indexfont/font.inf delete mode 100644 wadsrc/static/indexfont diff --git a/wadsrc/static/fonts/indexfont/0030.png b/wadsrc/static/fonts/indexfont/0030.png new file mode 100644 index 0000000000000000000000000000000000000000..1e4547d5b98eb9ea696381e368f2f55837b4d7a1 GIT binary patch literal 230 zcmeAS@N?(olHy`uVBq!ia0y~yV9;P-U|{25W?*1wYtxZrU|?V@4sv&5Sa(k5B?AKk zOS+@4BLl<6e(pbstPBhcJOMr-uFe1dGk`z{0|Ud{#bIYb>PmwAg8%>j&)}f7@(Tk4 z180FpWHAE+-w_aIoT|+y&A`AA?CIhdA`u?i*C=#Afy2r6$Nze{{##j+S}k#tlZ%77 zAHA&)NJ?4WB&x;dKcS~^PFFz5=}SrLxAkUJzMPgXyzj}UYG&JKYYl_e7W^+#{M>$c a#U2T3=qulkNH2tKSmJA#mLOaz|6qN%)p2t%FM{Xz|06WgPoay8Ep1HW)4OMkS>rM z0|Q8&ff-^L6C+&tKajB?Q5L8sutPvL@__V0ZDeNr$H2tMzyNbM*d>h23{X4&F~fAT JfUSfI0|00DEi(WB From 73f73cdf7cfe24083063b218b3e325fdaeedd950 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 12 Aug 2021 20:28:04 +0200 Subject: [PATCH 39/39] - added a null check to CheckWeaponChange. --- wadsrc/static/zscript/actors/player/player.zs | 1 + 1 file changed, 1 insertion(+) diff --git a/wadsrc/static/zscript/actors/player/player.zs b/wadsrc/static/zscript/actors/player/player.zs index 67b07b282..e63a5d773 100644 --- a/wadsrc/static/zscript/actors/player/player.zs +++ b/wadsrc/static/zscript/actors/player/player.zs @@ -456,6 +456,7 @@ class PlayerPawn : Actor virtual void CheckWeaponChange () { let player = self.player; + if (!player) return; if ((player.WeaponState & WF_DISABLESWITCH) || // Weapon changing has been disabled. player.morphTics != 0) // Morphed classes cannot change weapons. { // ...so throw away any pending weapon requests.