Fixed crash bug with snares and possibly in other places.
This commit is contained in:
@@ -317,6 +317,10 @@ void update_blessings() {
|
||||
update_max_health_from_equipment();
|
||||
speak_with_history("The speed blessing fades.", true);
|
||||
}
|
||||
if (blessing_resident_active && blessing_resident_timer.elapsed >= BLESSING_RESIDENT_DURATION) {
|
||||
blessing_resident_active = false;
|
||||
speak_with_history("The residents' purpose fades.", true);
|
||||
}
|
||||
}
|
||||
|
||||
void attempt_blessing() {
|
||||
@@ -328,6 +332,7 @@ void attempt_blessing() {
|
||||
if (player_health < max_health) options.insert_last(0);
|
||||
if (!blessing_speed_active) options.insert_last(1);
|
||||
if (barricade_health < BARRICADE_MAX_HEALTH) options.insert_last(2);
|
||||
if (residents_count > 0 && !blessing_resident_active) options.insert_last(3);
|
||||
if (options.length() == 0) return;
|
||||
|
||||
int choice = options[random(0, options.length() - 1)];
|
||||
@@ -358,6 +363,10 @@ void attempt_blessing() {
|
||||
? "A divine force repairs the barricade. +" + gained + " health."
|
||||
: "A divine force surrounds the barricade.";
|
||||
notify(god_name + " favor shines upon you. " + bonus);
|
||||
} else if (choice == 3) {
|
||||
blessing_resident_active = true;
|
||||
blessing_resident_timer.restart();
|
||||
notify(god_name + " radiance fills residents with purpose.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -401,7 +410,7 @@ void update_time() {
|
||||
|
||||
if (is_daytime && residents_count > 0 && barricade_health < BARRICADE_MAX_HEALTH && current_hour % 4 == 0) {
|
||||
if (has_any_storage_food()) {
|
||||
int gained = add_barricade_health(residents_count);
|
||||
int gained = add_barricade_health(residents_count * get_resident_effect_multiplier());
|
||||
if (gained > 0 && x <= BASE_END) {
|
||||
speak_with_history("Residents repaired the barricade. +" + gained + " health.", true);
|
||||
}
|
||||
@@ -527,6 +536,31 @@ void start_crossfade(bool to_night) {
|
||||
void update_crossfade() {
|
||||
if (!crossfade_active) return;
|
||||
|
||||
// If a handle went inactive mid-fade, cancel and restart ambience to avoid fading unrelated sounds.
|
||||
if (crossfade_to_night) {
|
||||
if (day_sound_handle == -1 || !p.sound_is_active(day_sound_handle)) {
|
||||
crossfade_active = false;
|
||||
update_ambience(true);
|
||||
return;
|
||||
}
|
||||
if (night_sound_handle == -1 || !p.sound_is_active(night_sound_handle)) {
|
||||
crossfade_active = false;
|
||||
update_ambience(true);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if (night_sound_handle == -1 || !p.sound_is_active(night_sound_handle)) {
|
||||
crossfade_active = false;
|
||||
update_ambience(true);
|
||||
return;
|
||||
}
|
||||
if (day_sound_handle == -1 || !p.sound_is_active(day_sound_handle)) {
|
||||
crossfade_active = false;
|
||||
update_ambience(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
float progress = float(crossfade_timer.elapsed) / float(CROSSFADE_DURATION);
|
||||
if (progress > 1.0) progress = 1.0;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user