From: Holger Schemel Date: Sat, 23 Mar 2024 18:18:31 +0000 (+0100) Subject: added re-defining editor graphics for "effects" elements for BD engine X-Git-Tag: 4.4.0.0-test-1~158 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=be208e8ebb9fbe5a97e7ed1d63aa421ac303c0bc;p=rocksndiamonds.git added re-defining editor graphics for "effects" elements for BD engine --- diff --git a/src/init.c b/src/init.c index 28d8aae2..7c19e260 100644 --- a/src/init.c +++ b/src/init.c @@ -1271,6 +1271,19 @@ static void InitElementSpecialGraphicInfo(void) action = -1; } + // for BD effect editor graphics, replace element with effect element, if exists + if (action != -1 && special == GFX_SPECIAL_ARG_EDITOR) + { + int element_bd = map_element_RND_to_BD_effect(element, action); + int element_ef = map_element_BD_to_RND_cave(element_bd); + + if (element_ef != EL_UNKNOWN) + { + element = element_ef; + action = -1; + } + } + if (element >= MAX_NUM_ELEMENTS) continue; diff --git a/src/tools.c b/src/tools.c index 26df7535..babb4987 100644 --- a/src/tools.c +++ b/src/tools.c @@ -7491,6 +7491,50 @@ int map_element_RND_to_BD_cave(int element_rnd) return mapping_RND_to_BD[element_rnd]; } +int map_element_RND_to_BD_effect(int element_rnd, int action) +{ + static unsigned short mapping_RND_to_BD[NUM_FILE_ELEMENTS][NUM_ACTIONS]; + static boolean mapping_initialized = FALSE; + + if (!mapping_initialized) + { + int i, j; + + // return "O_UNKNOWN" for all undefined elements in mapping array + for (i = 0; i < NUM_FILE_ELEMENTS; i++) + for (j = 0; j < NUM_ACTIONS; j++) + mapping_RND_to_BD[i][j] = O_UNKNOWN; + + for (i = 0; bd_object_mapping_list[i].element_bd != -1; i++) + { + int element_rnd = bd_object_mapping_list[i].element_rnd; + int element_bd = bd_object_mapping_list[i].element_bd; + int action = bd_object_mapping_list[i].action; + + if (action != -1) + mapping_RND_to_BD[element_rnd][action] = element_bd; + } + + mapping_initialized = TRUE; + } + + if (element_rnd < 0 || element_rnd >= NUM_FILE_ELEMENTS) + { + Warn("invalid RND element %d", element_rnd); + + return O_UNKNOWN; + } + + if (action < 0 || action >= NUM_ACTIONS) + { + Warn("invalid action %d", action); + + return O_UNKNOWN; + } + + return mapping_RND_to_BD[element_rnd][action]; +} + int map_element_BD_to_RND_cave(int element_bd) { static unsigned short mapping_BD_to_RND[O_MAX_ALL]; diff --git a/src/tools.h b/src/tools.h index 97fa4c95..afad2e37 100644 --- a/src/tools.h +++ b/src/tools.h @@ -230,6 +230,7 @@ void CreateToolButtons(void); void FreeToolButtons(void); int map_element_RND_to_BD_cave(int); +int map_element_RND_to_BD_effect(int, int); int map_element_BD_to_RND_cave(int); int map_element_BD_to_RND_game(int);