From f024e0937838702b54e3d618e0df7a89cfba8f4a Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Tue, 31 Dec 2024 16:23:42 +0100 Subject: [PATCH] changed setting random colors for BD style levels for new levels only Without this change, levels loaded from existing level files may get wrong colors, as default colors (that are not stored in level file) have been replaced with random colors before, which is wrong. --- src/files.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/files.c b/src/files.c index f620f596..c103b940 100644 --- a/src/files.c +++ b/src/files.c @@ -2373,7 +2373,7 @@ void setElementChangeInfoToDefaults(struct ElementChangeInfo *change) change->post_change_function = NULL; } -static void setLevelInfoToDefaults_Level(struct LevelInfo *level) +static void setLevelInfoToDefaults_Level(struct LevelInfo *level, boolean prepare_loading_level) { boolean add_border = FALSE; int x1 = 0; @@ -2454,12 +2454,17 @@ static void setLevelInfoToDefaults_Level(struct LevelInfo *level) // detect custom elements when loading them level->file_has_custom_elements = FALSE; - // set random colors for BD style levels according to preferred color type - SetRandomLevelColors_BD(setup.bd_default_color_type); + // set random colors for new levels only, but never when loading existing level + // (as default colors are not stored in level file, which would result in wrong colors) + if (!prepare_loading_level) + { + // set random colors for BD style levels according to preferred color type + SetRandomLevelColors_BD(setup.bd_default_color_type); - // set default color type and colors for BD style level colors - SetDefaultLevelColorType_BD(); - SetDefaultLevelColors_BD(); + // set default color type and colors for BD style level colors + SetDefaultLevelColorType_BD(); + SetDefaultLevelColors_BD(); + } // set all bug compatibility flags to "false" => do not emulate this bug level->use_action_after_change_bug = FALSE; @@ -2615,7 +2620,7 @@ static void setLevelInfoToDefaults(struct LevelInfo *level, boolean level_info_only, boolean prepare_loading_level) { - setLevelInfoToDefaults_Level(level); + setLevelInfoToDefaults_Level(level, prepare_loading_level); if (!level_info_only) setLevelInfoToDefaults_Elements(level); -- 2.34.1