use unsyced rng for animation&sound stuff
This commit is contained in:
parent
07c0af34f6
commit
4e79aedb8d
7 changed files with 11 additions and 11 deletions
|
@ -351,7 +351,7 @@ void display::init_flags_for_side_internal(size_t n, const std::string& side_col
|
|||
f = temp_anim;
|
||||
auto time = f.get_end_time();
|
||||
if (time > 0) {
|
||||
f.start_animation(randomness::generator->get_random_int(0, time-1), true);
|
||||
f.start_animation(randomness::rng::default_instance().get_random_int(0, time-1), true);
|
||||
}
|
||||
else {
|
||||
// this can happen if both flag and game_config::images::flag are empty.
|
||||
|
|
|
@ -913,7 +913,7 @@ const std::string& play_controller::select_music(bool victory) const
|
|||
|
||||
if(music_list.empty())
|
||||
return empty_str;
|
||||
return music_list[randomness::generator->get_random_int(0, music_list.size()-1)];
|
||||
return music_list[randomness::rng::default_instance().get_random_int(0, music_list.size()-1)];
|
||||
}
|
||||
|
||||
void play_controller::check_victory()
|
||||
|
|
|
@ -44,7 +44,7 @@ std::string user_handler::create_salt(int length) {
|
|||
std::stringstream ss;
|
||||
|
||||
for(int i = 0; i < length; i++) {
|
||||
ss << randomness::generator->get_random_int(0, 9);
|
||||
ss << randomness::rng::default_instance().get_random_int(0, 9);
|
||||
}
|
||||
|
||||
return ss.str();
|
||||
|
|
|
@ -324,7 +324,7 @@ static std::shared_ptr<sound::music_track> choose_track()
|
|||
|
||||
if(current_track_list.size() > 1) {
|
||||
do {
|
||||
track = randomness::generator->get_random_int(0, current_track_list.size()-1);
|
||||
track = randomness::rng::default_instance().get_random_int(0, current_track_list.size()-1);
|
||||
} while(!track_ok(current_track_list[track]->file_path()));
|
||||
}
|
||||
|
||||
|
@ -353,14 +353,14 @@ static std::string pick_one(const std::string& files)
|
|||
unsigned int choice;
|
||||
|
||||
if(prev_choices.find(files) != prev_choices.end()) {
|
||||
choice = randomness::generator->get_random_int(0, ids.size()-1 - 1);
|
||||
choice = randomness::rng::default_instance().get_random_int(0, ids.size()-1 - 1);
|
||||
if(choice >= prev_choices[files]) {
|
||||
++choice;
|
||||
}
|
||||
|
||||
prev_choices[files] = choice;
|
||||
} else {
|
||||
choice = randomness::generator->get_random_int(0, ids.size()-1);
|
||||
choice = randomness::rng::default_instance().get_random_int(0, ids.size()-1);
|
||||
prev_choices.emplace(files, choice);
|
||||
}
|
||||
|
||||
|
|
|
@ -135,7 +135,7 @@ void positional_source::update(unsigned int time, const display &disp)
|
|||
if (time - last_played_ < unsigned(min_delay_) || sound::is_sound_playing(id_))
|
||||
return;
|
||||
|
||||
int i = randomness::generator->get_random_int(1, 100);
|
||||
int i = randomness::rng::default_instance().get_random_int(1, 100);
|
||||
|
||||
if(i <= chance_) {
|
||||
last_played_ = time;
|
||||
|
|
|
@ -435,7 +435,7 @@ int unit_animation::matches(const display& disp, const map_location& loc, const
|
|||
return MATCH_FAIL;
|
||||
}
|
||||
|
||||
if(frequency_ && !(randomness::generator->get_random_int(0, frequency_-1))) {
|
||||
if(frequency_ && !(randomness::rng::default_instance().get_random_int(0, frequency_-1))) {
|
||||
return MATCH_FAIL;
|
||||
}
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ const unit_animation* unit_animation_component::choose_animation(const display&
|
|||
if(max_val == unit_animation::MATCH_FAIL) {
|
||||
return nullptr;
|
||||
}
|
||||
return options[randomness::generator->get_random_int(0, options.size()-1)];
|
||||
return options[randomness::rng::default_instance().get_random_int(0, options.size()-1)];
|
||||
}
|
||||
|
||||
void unit_animation_component::set_standing(bool with_bars)
|
||||
|
@ -117,7 +117,7 @@ void unit_animation_component::start_animation (int start_time, const unit_anima
|
|||
frame_begin_time_ = anim_->get_begin_time() -1;
|
||||
if (disp->idle_anim()) {
|
||||
next_idling_ = get_current_animation_tick()
|
||||
+ static_cast<int>(randomness::generator->get_random_int(20000, 39999) * disp->idle_anim_rate());
|
||||
+ static_cast<int>(randomness::rng::default_instance().get_random_int(20000, 39999) * disp->idle_anim_rate());
|
||||
} else {
|
||||
next_idling_ = INT_MAX;
|
||||
}
|
||||
|
@ -141,7 +141,7 @@ void unit_animation_component::refresh()
|
|||
// prevent all units animating at the same time
|
||||
if (disp.idle_anim()) {
|
||||
next_idling_ = get_current_animation_tick()
|
||||
+ static_cast<int>(randomness::generator->get_random_int(20000, 39999) * disp.idle_anim_rate());
|
||||
+ static_cast<int>(randomness::rng::default_instance().get_random_int(20000, 39999) * disp.idle_anim_rate());
|
||||
} else {
|
||||
next_idling_ = INT_MAX;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue