From 98feeade02a1d0c0547d3520751f48543899070e Mon Sep 17 00:00:00 2001 From: Misa Date: Tue, 28 Mar 2023 20:56:03 -0700 Subject: [PATCH] Fix gray entities applying in main game As reported by Lilithtreasure on the VVVVVV Discord server, it is possible to get gray moving platforms and enemies in the main game. This happens if you play the main game after loading a custom level with a room that is gray at the same coordinates. E.g. if you play a custom level with a gray room at (12, 4), then exit and go to Gantry and Dolly in the main game which is also at (12, 4), then the platforms there would be gray too. This is because there is a missing map.custommode check. --- desktop_version/src/Entity.cpp | 14 ++++++++++---- desktop_version/src/Graphics.cpp | 14 ++++++++++---- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/desktop_version/src/Entity.cpp b/desktop_version/src/Entity.cpp index a50d9722..5c5b6a0d 100644 --- a/desktop_version/src/Entity.cpp +++ b/desktop_version/src/Entity.cpp @@ -1286,13 +1286,19 @@ void entityclass::createentity(int xp, int yp, int t, int meta1, int meta2, int //Rule 4 is a horizontal line, 5 is vertical //Rule 6 is a crew member + bool custom_gray; #if !defined(NO_CUSTOM_LEVELS) // Special case for gray Warp Zone tileset! - const RoomProperty* const room = cl.getroomprop(game.roomx - 100, game.roomy - 100); - bool custom_gray = room->tileset == 3 && room->tilecol == 6; -#else - bool custom_gray = false; + if (map.custommode) + { + const RoomProperty* const room = cl.getroomprop(game.roomx - 100, game.roomy - 100); + custom_gray = room->tileset == 3 && room->tilecol == 6; + } + else #endif + { + custom_gray = false; + } entclass& entity = *entptr; entity.xp = xp; diff --git a/desktop_version/src/Graphics.cpp b/desktop_version/src/Graphics.cpp index da68ba43..9e310795 100644 --- a/desktop_version/src/Graphics.cpp +++ b/desktop_version/src/Graphics.cpp @@ -1913,13 +1913,19 @@ void Graphics::drawentity(const int i, const int yoff) SDL_Rect drawRect; + bool custom_gray; #if !defined(NO_CUSTOM_LEVELS) // Special case for gray Warp Zone tileset! - const RoomProperty* const room = cl.getroomprop(game.roomx - 100, game.roomy - 100); - const bool custom_gray = room->tileset == 3 && room->tilecol == 6; -#else - const bool custom_gray = false; + if (map.custommode) + { + const RoomProperty* const room = cl.getroomprop(game.roomx - 100, game.roomy - 100); + custom_gray = room->tileset == 3 && room->tilecol == 6; + } + else #endif + { + custom_gray = false; + } SDL_Texture* sprites = flipmode ? grphx.im_flipsprites : grphx.im_sprites; SDL_Texture* tiles = (map.custommode && !map.finalmode) ? grphx.im_entcolours : grphx.im_tiles;