From ee189ff557404d570a1cd9b5927a67e004efa1e9 Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Sun, 28 Apr 2024 02:34:22 +0200 Subject: [PATCH] fixed scaling wrong images when using "clone_from" graphics parameter When cloning graphic definitions using the ".clone_from" parameter in custom graphics configurations, only the graphic parameters are cloned (including bitmap pointers), but the position of the image file of the cloned graphic does not change. This may lead to the wrong image being scaled if the ".scale_up_factor" parameter is used to scale the cloned graphic (which may cause further unintended side effects if the scaled image was also used by other graphics definitions which do not intend to scale this image). This bug occurred when the game was started with the original Boulder Dash graphics (used by a native Boulder Dash level set), followed by selecting a level set which uses the classic default R'n'D graphics, leading to broken (scaled up and truncated) fonts in the main menu. --- src/init.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/init.c b/src/init.c index 9fb4b482..15044548 100644 --- a/src/init.c +++ b/src/init.c @@ -244,6 +244,10 @@ static void InitElementSmallImagesScaledUp(int graphic) { struct GraphicInfo *g = &graphic_info[graphic]; + // if graphic was cloned, scale cloned graphic + if (graphic_info[graphic].clone_from != -1) + graphic = graphic_info[graphic].clone_from; + // create small and game tile sized bitmaps (and scale up, if needed) CreateImageWithSmallImages(graphic, g->scale_up_factor, g->tile_size); } @@ -307,6 +311,10 @@ static void InitScaledImagesScaledUp(int graphic) { struct GraphicInfo *g = &graphic_info[graphic]; + // if graphic was cloned, scale cloned graphic + if (graphic_info[graphic].clone_from != -1) + graphic = graphic_info[graphic].clone_from; + ScaleImage(graphic, g->scale_up_factor); } -- 2.34.1