cave->pushing_stone_prob = level->bd_pushing_prob * 10000;
cave->pushing_stone_prob_sweet = level->bd_pushing_prob_with_sweet * 10000;
cave->mega_stones_pushable_with_sweet = level->bd_push_mega_rock_with_sweet;
- cave->snap_element = map_element_RND_to_BD(level->bd_snap_element);
+ cave->snap_element = map_element_RND_to_BD_cave(level->bd_snap_element);
// element properties
cave->level_bonus_time[0] = level->bd_clock_extra_time;
cave->amoeba_2_growth_prob = level->bd_amoeba_2_slow_growth_rate * 10000;
cave->amoeba_2_fast_growth_prob = level->bd_amoeba_2_fast_growth_rate * 10000;
- cave->amoeba_too_big_effect = map_element_RND_to_BD(level->bd_amoeba_content_too_big);
- cave->amoeba_enclosed_effect = map_element_RND_to_BD(level->bd_amoeba_content_enclosed);
- cave->amoeba_2_too_big_effect = map_element_RND_to_BD(level->bd_amoeba_2_content_too_big);
- cave->amoeba_2_enclosed_effect = map_element_RND_to_BD(level->bd_amoeba_2_content_enclosed);
- cave->amoeba_2_explosion_effect = map_element_RND_to_BD(level->bd_amoeba_2_content_exploding);
- cave->amoeba_2_looks_like = map_element_RND_to_BD(level->bd_amoeba_2_content_looks_like);
+ cave->amoeba_too_big_effect = map_element_RND_to_BD_cave(level->bd_amoeba_content_too_big);
+ cave->amoeba_enclosed_effect = map_element_RND_to_BD_cave(level->bd_amoeba_content_enclosed);
+ cave->amoeba_2_too_big_effect = map_element_RND_to_BD_cave(level->bd_amoeba_2_content_too_big);
+ cave->amoeba_2_enclosed_effect = map_element_RND_to_BD_cave(level->bd_amoeba_2_content_enclosed);
+ cave->amoeba_2_explosion_effect = map_element_RND_to_BD_cave(level->bd_amoeba_2_content_exploding);
+ cave->amoeba_2_looks_like = map_element_RND_to_BD_cave(level->bd_amoeba_2_content_looks_like);
cave->slime_predictable = level->bd_slime_is_predictable;
cave->slime_correct_random = level->bd_slime_correct_random;
cave->level_slime_seed_c64[0] = level->bd_slime_random_seed_c64;
cave->level_rand[0] = level->bd_cave_random_seed_c64;
- cave->acid_eats_this = map_element_RND_to_BD(level->bd_acid_eats_element);
+ cave->acid_eats_this = map_element_RND_to_BD_cave(level->bd_acid_eats_element);
cave->acid_spread_ratio = level->bd_acid_spread_rate * 10000;
- cave->acid_turns_to = map_element_RND_to_BD(level->bd_acid_turns_to_element);
+ cave->acid_turns_to = map_element_RND_to_BD_cave(level->bd_acid_turns_to_element);
cave->biter_delay_frame = level->bd_biter_move_delay;
- cave->biter_eat = map_element_RND_to_BD(level->bd_biter_eats_element);
+ cave->biter_eat = map_element_RND_to_BD_cave(level->bd_biter_eats_element);
- cave->bladder_converts_by = map_element_RND_to_BD(level->bd_bladder_converts_by_element);
+ cave->bladder_converts_by = map_element_RND_to_BD_cave(level->bd_bladder_converts_by_element);
cave->expanding_wall_changed = level->bd_change_expanding_wall;
// playfield elements
for (x = 0; x < cave->w; x++)
for (y = 0; y < cave->h; y++)
- cave->map[y][x] = map_element_RND_to_BD(level->field[x][y]);
+ cave->map[y][x] = map_element_RND_to_BD_cave(level->field[x][y]);
}
static void CopyNativeLevel_BD_to_RND(struct LevelInfo *level)
level->bd_pushing_prob = cave->pushing_stone_prob / 10000;
level->bd_pushing_prob_with_sweet = cave->pushing_stone_prob_sweet / 10000;
level->bd_push_mega_rock_with_sweet = cave->mega_stones_pushable_with_sweet;
- level->bd_snap_element = map_element_BD_to_RND(cave->snap_element);
+ level->bd_snap_element = map_element_BD_to_RND_cave(cave->snap_element);
// element properties
level->bd_clock_extra_time = cave->level_bonus_time[bd_level_nr];
level->bd_amoeba_2_slow_growth_rate = cave->amoeba_2_growth_prob / 10000;
level->bd_amoeba_2_fast_growth_rate = cave->amoeba_2_fast_growth_prob / 10000;
- level->bd_amoeba_content_too_big = map_element_BD_to_RND(cave->amoeba_too_big_effect);
- level->bd_amoeba_content_enclosed = map_element_BD_to_RND(cave->amoeba_enclosed_effect);
- level->bd_amoeba_2_content_too_big = map_element_BD_to_RND(cave->amoeba_2_too_big_effect);
- level->bd_amoeba_2_content_enclosed = map_element_BD_to_RND(cave->amoeba_2_enclosed_effect);
- level->bd_amoeba_2_content_exploding = map_element_BD_to_RND(cave->amoeba_2_explosion_effect);
- level->bd_amoeba_2_content_looks_like = map_element_BD_to_RND(cave->amoeba_2_looks_like);
+ level->bd_amoeba_content_too_big = map_element_BD_to_RND_cave(cave->amoeba_too_big_effect);
+ level->bd_amoeba_content_enclosed = map_element_BD_to_RND_cave(cave->amoeba_enclosed_effect);
+ level->bd_amoeba_2_content_too_big = map_element_BD_to_RND_cave(cave->amoeba_2_too_big_effect);
+ level->bd_amoeba_2_content_enclosed = map_element_BD_to_RND_cave(cave->amoeba_2_enclosed_effect);
+ level->bd_amoeba_2_content_exploding = map_element_BD_to_RND_cave(cave->amoeba_2_explosion_effect);
+ level->bd_amoeba_2_content_looks_like = map_element_BD_to_RND_cave(cave->amoeba_2_looks_like);
level->bd_slime_is_predictable = cave->slime_predictable;
level->bd_slime_correct_random = cave->slime_correct_random;
level->bd_slime_random_seed_c64 = cave->level_slime_seed_c64[bd_level_nr];
level->bd_cave_random_seed_c64 = cave->level_rand[bd_level_nr];
- level->bd_acid_eats_element = map_element_BD_to_RND(cave->acid_eats_this);
+ level->bd_acid_eats_element = map_element_BD_to_RND_cave(cave->acid_eats_this);
level->bd_acid_spread_rate = cave->acid_spread_ratio / 10000;
- level->bd_acid_turns_to_element = map_element_BD_to_RND(cave->acid_turns_to);
+ level->bd_acid_turns_to_element = map_element_BD_to_RND_cave(cave->acid_turns_to);
level->bd_biter_move_delay = cave->biter_delay_frame;
- level->bd_biter_eats_element = map_element_BD_to_RND(cave->biter_eat);
+ level->bd_biter_eats_element = map_element_BD_to_RND_cave(cave->biter_eat);
- level->bd_bladder_converts_by_element = map_element_BD_to_RND(cave->bladder_converts_by);
+ level->bd_bladder_converts_by_element = map_element_BD_to_RND_cave(cave->bladder_converts_by);
level->bd_change_expanding_wall = cave->expanding_wall_changed;
// playfield elements
for (x = 0; x < level->fieldx; x++)
for (y = 0; y < level->fieldy; y++)
- level->field[x][y] = map_element_BD_to_RND(cave->map[y][x]);
+ level->field[x][y] = map_element_BD_to_RND_cave(cave->map[y][x]);
checked_free(cave_name);
}
void PlayLevelSound_BD(int xx, int yy, int element_bd, int sample)
{
- int element = (element_bd > -1 ? map_element_BD_to_RND(element_bd) : 0);
+ int element = (element_bd > -1 ? map_element_BD_to_RND_game(element_bd) : 0);
int sound_effect = getSoundEffect_BD(element, sample);
int sound_action = getSoundAction_BD(sample);
boolean is_loop_sound = IS_LOOP_SOUND(sound_effect);
void StopSound_BD(int element_bd, int sample)
{
- int element = (element_bd > -1 ? map_element_BD_to_RND(element_bd) : 0);
+ int element = (element_bd > -1 ? map_element_BD_to_RND_game(element_bd) : 0);
int sound_effect = getSoundEffect_BD(element, sample);
if (sound_effect != SND_UNDEFINED)
boolean isSoundPlaying_BD(int element_bd, int sample)
{
- int element = (element_bd > -1 ? map_element_BD_to_RND(element_bd) : 0);
+ int element = (element_bd > -1 ? map_element_BD_to_RND_game(element_bd) : 0);
int sound_effect = getSoundEffect_BD(element, sample);
if (sound_effect != SND_UNDEFINED)
}
};
-int map_element_RND_to_BD(int element_rnd)
+int map_element_RND_to_BD_cave(int element_rnd)
{
static unsigned short mapping_RND_to_BD[NUM_FILE_ELEMENTS];
static boolean mapping_initialized = FALSE;
return mapping_RND_to_BD[element_rnd];
}
-int map_element_BD_to_RND(int element_bd)
+int map_element_BD_to_RND_cave(int element_bd)
+{
+ static unsigned short mapping_BD_to_RND[O_MAX_ALL];
+ static boolean mapping_initialized = FALSE;
+
+ if (!mapping_initialized)
+ {
+ int i;
+
+ // return "EL_UNKNOWN" for all undefined elements in mapping array
+ for (i = 0; i < O_MAX_ALL; i++)
+ mapping_BD_to_RND[i] = EL_UNKNOWN;
+
+ for (i = 0; bd_object_mapping_list[i].element_bd != -1; i++)
+ if (bd_object_mapping_list[i].is_rnd_to_bd_mapping)
+ mapping_BD_to_RND[bd_object_mapping_list[i].element_bd] =
+ bd_object_mapping_list[i].element_rnd;
+
+ mapping_initialized = TRUE;
+ }
+
+ if (element_bd < 0 || element_bd >= O_MAX_ALL)
+ {
+ Warn("invalid BD element %d", element_bd);
+
+ return EL_UNKNOWN;
+ }
+
+ return mapping_BD_to_RND[element_bd];
+}
+
+int map_element_BD_to_RND_game(int element_bd)
{
static unsigned short mapping_BD_to_RND[O_MAX_ALL];
static boolean mapping_initialized = FALSE;