From 4e7d63cf096213c85bda7aec86169fe7dfbf6446 Mon Sep 17 00:00:00 2001 From: Misa Date: Fri, 19 Feb 2021 15:16:28 -0800 Subject: [PATCH] Remove assigning block type to -1 when disabling them This fixes a regression where moving platforms had no collision. Because their width and height would be maintained, but their type would be -1. (Also because I didn't test enough.) In #565, I decided to set blocks' types to -1 when disabling them, to be a bit safer in case there was some code that used block types but not their width and heights. However, this means that when blocks get disabled and re-created in the platform update loops, their types get set to -1, which effectively also disables their collision. In the end, I'll just have to compromise and remove setting blocks to type -1. Because in a better world, we shouldn't be destroying and creating blocks constantly just to move some platforms - however, fixing such a fundamental problem is beyond the scope of at least 2.3 (there's also the fact that this problem also results in some bugs that are a part of compatibility, whether we like it or not). So I'll just remove the -1. --- desktop_version/src/Entity.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/desktop_version/src/Entity.cpp b/desktop_version/src/Entity.cpp index 7cea39ca..ed1d44ab 100644 --- a/desktop_version/src/Entity.cpp +++ b/desktop_version/src/Entity.cpp @@ -767,8 +767,7 @@ void entityclass::createblock( int t, int xp, int yp, int w, int h, int trig /*= bool reuse = false; for (size_t i = 0; i < blocks.size(); ++i) { - if (blocks[i].type == -1 - && blocks[i].wp == 0 + if (blocks[i].wp == 0 && blocks[i].hp == 0 && blocks[i].rect.w == 0 && blocks[i].rect.h == 0) @@ -1107,8 +1106,6 @@ void entityclass::disableblock( int t ) return; } - blocks[t].type = -1; - blocks[t].wp = 0; blocks[t].hp = 0;