From: Holger Schemel Date: Sun, 28 Apr 2024 00:34:22 +0000 (+0200) Subject: fixed scaling wrong images when using "clone_from" graphics parameter X-Git-Tag: 4.4.0.0-test-1~26 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=ee189ff557404d570a1cd9b5927a67e004efa1e9;p=rocksndiamonds.git 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. --- 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); }