Major refactor part 1.

This commit is contained in:
Storm Dragon
2026-01-23 21:09:54 -05:00
parent 9ded17873d
commit cb8f028d1b
35 changed files with 1070 additions and 1526 deletions

View File

@@ -382,7 +382,7 @@ void update_time() {
check_ambience_transition();
if (is_daytime && residents_count > 0 && barricade_health < BARRICADE_MAX_HEALTH && current_hour % 4 == 0) {
if (storage_meat > 0) {
if (get_storage_count(ITEM_MEAT) > 0) {
int gained = add_barricade_health(residents_count);
if (gained > 0 && x <= BASE_END) {
speak_with_history("Residents repaired the barricade. +" + gained + " health.", true);
@@ -545,14 +545,26 @@ void complete_crossfade() {
}
void update_ambience(bool force_restart) {
if (is_daytime) {
// Start day ambience
// When force_restart is true, clean up both handles first
if (force_restart) {
if (day_sound_handle != -1) {
p.destroy_sound(day_sound_handle);
day_sound_handle = -1;
}
if (night_sound_handle != -1) {
p.destroy_sound(night_sound_handle);
night_sound_handle = -1;
}
}
if (is_daytime) {
// Stop night ambience if playing
if (night_sound_handle != -1) {
p.destroy_sound(night_sound_handle);
night_sound_handle = -1;
}
// Start day ambience if not already playing
if (day_sound_handle == -1 || !p.sound_is_active(day_sound_handle)) {
// Clean up invalid handle if it exists
if (day_sound_handle != -1) {
p.destroy_sound(day_sound_handle);
day_sound_handle = -1;
@@ -560,13 +572,13 @@ void update_ambience(bool force_restart) {
day_sound_handle = p.play_stationary("sounds/nature/day.ogg", true);
}
} else {
// Start night ambience
// Stop day ambience if playing
if (day_sound_handle != -1) {
p.destroy_sound(day_sound_handle);
day_sound_handle = -1;
}
// Start night ambience if not already playing
if (night_sound_handle == -1 || !p.sound_is_active(night_sound_handle)) {
// Clean up invalid handle if it exists
if (night_sound_handle != -1) {
p.destroy_sound(night_sound_handle);
night_sound_handle = -1;