From 668f8f2cf6eb535c45c003c6edc3997450771bec Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 17 May 2021 12:42:22 +0200 Subject: [PATCH] - fixed some uses of postincre,ment/decrements on narrow types. THe VM has no opcode for this, all these places produced code with undefined behavior. --- src/common/rendering/vulkan/renderer/vk_renderbuffers.cpp | 7 ++++++- src/playsim/d_player.h | 4 ++-- wadsrc/static/zscript/actors/hexen/firedemon.zs | 3 ++- wadsrc/static/zscript/actors/inventory/stateprovider.zs | 2 +- wadsrc/static/zscript/actors/player/player.zs | 4 ++-- 5 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/common/rendering/vulkan/renderer/vk_renderbuffers.cpp b/src/common/rendering/vulkan/renderer/vk_renderbuffers.cpp index 34e44096d5..75288a4f2e 100644 --- a/src/common/rendering/vulkan/renderer/vk_renderbuffers.cpp +++ b/src/common/rendering/vulkan/renderer/vk_renderbuffers.cpp @@ -239,8 +239,13 @@ void VkRenderBuffers::CreateShadowmap() ImageBuilder builder; builder.setSize(gl_shadowmap_quality, 1024); - builder.setFormat(VK_FORMAT_R32_SFLOAT); + builder.setFormat(SceneNormalFormat); builder.setUsage(VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_SAMPLED_BIT); + if (!builder.isFormatSupported(fb->device, VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT | VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT)) + { + SceneNormalFormat = VK_FORMAT_R8G8B8A8_UNORM; + builder.setFormat(SceneNormalFormat); + } Shadowmap.Image = builder.create(fb->device); Shadowmap.Image->SetDebugName("VkRenderBuffers.Shadowmap"); diff --git a/src/playsim/d_player.h b/src/playsim/d_player.h index f11763386e..269ff6984c 100644 --- a/src/playsim/d_player.h +++ b/src/playsim/d_player.h @@ -318,8 +318,8 @@ public: // This avoids anomalies with such things as Boom ice and conveyors. DVector2 Vel = { 0,0 }; + int turnticks = 0; bool centering = false; - uint8_t turnticks = 0; bool attackdown = false; @@ -344,7 +344,7 @@ public: int cheats = 0; // bit flags int timefreezer = 0; // Player has an active time freezer - short refire = 0; // refired shots are less accurate + int refire = 0; // refired shots are less accurate short inconsistant = 0; bool waiting = 0; int killcount = 0, itemcount = 0, secretcount = 0; // for intermission diff --git a/wadsrc/static/zscript/actors/hexen/firedemon.zs b/wadsrc/static/zscript/actors/hexen/firedemon.zs index d585ea745f..7849455af9 100644 --- a/wadsrc/static/zscript/actors/hexen/firedemon.zs +++ b/wadsrc/static/zscript/actors/hexen/firedemon.zs @@ -218,7 +218,8 @@ class FireDemon : Actor // Normal movement if (!fdstrafecount) { - if (--movecount<0 || !MonsterMove ()) + movecount = movecount - 1; + if (movecount < 0 || !MonsterMove ()) { NewChaseDir (); } diff --git a/wadsrc/static/zscript/actors/inventory/stateprovider.zs b/wadsrc/static/zscript/actors/inventory/stateprovider.zs index c7f3c4b43d..05aa06f22b 100644 --- a/wadsrc/static/zscript/actors/inventory/stateprovider.zs +++ b/wadsrc/static/zscript/actors/inventory/stateprovider.zs @@ -406,7 +406,7 @@ class StateProvider : Inventory if ((player.cmd.buttons & BT_ATTACK) && !player.ReadyWeapon.bAltFire && !pending && player.health > 0) { - player.refire = player.refire + 1; + player.refire++; player.mo.FireWeapon(ResolveState(flash)); } else if ((player.cmd.buttons & BT_ALTATTACK) diff --git a/wadsrc/static/zscript/actors/player/player.zs b/wadsrc/static/zscript/actors/player/player.zs index 306c0ce84c..b01c93e262 100644 --- a/wadsrc/static/zscript/actors/player/player.zs +++ b/wadsrc/static/zscript/actors/player/player.zs @@ -2652,7 +2652,7 @@ struct PlayerInfo native play // self is what internally is known as player_t native double bob; native vector2 vel; native bool centering; - native uint8 turnticks; + native int turnticks; native bool attackdown; native bool usedown; native uint oldbuttons; @@ -2670,7 +2670,7 @@ struct PlayerInfo native play // self is what internally is known as player_t native PSprite psprites; native int cheats; native int timefreezer; - native int16 refire; + native int refire; native int16 inconsistent; native bool waiting; native int killcount;