From b23983c0b854d7594ed5d0ea625393dc125616a7 Mon Sep 17 00:00:00 2001 From: AllyTally Date: Thu, 30 Nov 2023 22:24:10 -0400 Subject: [PATCH] Fix BG tile bug from switching from pink SS If you had a pink space station background, and switched to a different tileset, some solid tiles would be placed instead. This commit fixes that by transforming the room into the basic autotiling tiles before changing the tileset itself. The reason why I chose this solution is because it will help with a future change, being unhardcoding warp zone backgrounds (which'll help with custom autotiling, if that becomes a thing.) --- desktop_version/src/Editor.cpp | 42 ++++++++++++++++++++++++++++++++++ desktop_version/src/Editor.h | 2 ++ 2 files changed, 44 insertions(+) diff --git a/desktop_version/src/Editor.cpp b/desktop_version/src/Editor.cpp index d6ded494..55c70583 100644 --- a/desktop_version/src/Editor.cpp +++ b/desktop_version/src/Editor.cpp @@ -4017,8 +4017,48 @@ bool editorclass::lines_can_pass(int x, int y) return false; } +void editorclass::make_autotiling_base(void) +{ + if (cl.getroomprop(levx, levy)->directmode == 1) + { + return; + } + + for (int i = 0; i < SCREEN_WIDTH_TILES * SCREEN_HEIGHT_TILES; i++) + { + int tile_x = i % SCREEN_WIDTH_TILES; + int tile_y = i / SCREEN_WIDTH_TILES; + int tile = get_tile(tile_x, tile_y); + + if (tile == 0) + { + continue; + } + + TileTypes type = get_tile_type(tile_x, tile_y, false); + + switch (type) + { + case TileType_NONSOLID: + if (type == TileType_NONSOLID || is_warp_zone_background(tile)) + { + set_tile(tile_x, tile_y, 2); + } + break; + case TileType_SOLID: + set_tile(tile_x, tile_y, 1); + break; + case TileType_SPIKE: + set_tile(tile_x, tile_y, 6); + break; + } + } +} + void editorclass::switch_tileset(const bool reversed) { + make_autotiling_base(); + int tiles = cl.getroomprop(levx, levy)->tileset; if (reversed) @@ -4052,6 +4092,8 @@ void editorclass::switch_tileset(const bool reversed) void editorclass::switch_tilecol(const bool reversed) { + make_autotiling_base(); + int tilecol = cl.getroomprop(levx, levy)->tilecol; if (reversed) diff --git a/desktop_version/src/Editor.h b/desktop_version/src/Editor.h index 149cb005..f0f879db 100644 --- a/desktop_version/src/Editor.h +++ b/desktop_version/src/Editor.h @@ -177,6 +177,8 @@ public: bool lines_can_pass(int x, int y); + void make_autotiling_base(void); + int get_enemy_tile(int t); void switch_tileset(const bool reversed);