From 449526bb4f54cd6d14df0d0cae0b728fabd8bf0c Mon Sep 17 00:00:00 2001 From: Misa Date: Wed, 6 Oct 2021 23:18:58 -0700 Subject: [PATCH] Fix regression with per-pixel collision colors In previous versions, the game mistakenly checked the wrong color channel of sprites, checking the red channel instead of the alpha channel. I abuse this in some of my levels. Then I broke it when refactoring masks so the game now no longer checks the red channel but seems to check the blue channel instead. So re-fix this to the previous bug, and preserve the previous bug with a comment explaining why. --- desktop_version/src/Graphics.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/desktop_version/src/Graphics.cpp b/desktop_version/src/Graphics.cpp index 995780a9..3c7574ea 100644 --- a/desktop_version/src/Graphics.cpp +++ b/desktop_version/src/Graphics.cpp @@ -1656,7 +1656,11 @@ bool Graphics::Hitest(SDL_Surface* surface1, point p1, SDL_Surface* surface2, po { Uint32 pixel1 = ReadPixel(surface1 , x - p1.x, y - p1.y); Uint32 pixel2 = ReadPixel(surface2 , x - p2.x, y - p2.y); - if ((pixel1 & 0x000000FF) && (pixel2 & 0x000000FF)) + /* INTENTIONAL BUG! In previous versions, the game mistakenly + * checked the red channel, not the alpha channel. + * We preserve it here because some people abuse this. */ + if ((pixel1 & surface1->format->Rmask) + && (pixel2 & surface2->format->Rmask)) { return true; }