# HG changeset patch # User sam # Date 1730824105 -25200 # Node ID 8f774d9c25186f38985937370abbb3f06053ebe5 # Parent ce92db0b8f50ffdcf238eff13c577f467625a15d fix: change implementation to allow for easier reload of whole engine diff -r ce92db0b8f50 -r 8f774d9c2518 semicongine/audio/mixer_module.nim --- a/semicongine/audio/mixer_module.nim Tue Nov 05 23:02:32 2024 +0700 +++ b/semicongine/audio/mixer_module.nim Tue Nov 05 23:28:25 2024 +0700 @@ -5,6 +5,7 @@ import std/monotimes import std/strformat import std/tables +import std/logging import std/times import ../core/globals @@ -77,15 +78,13 @@ # mixer.sounds[name] = LoadAudio(resource) proc addSound*(mixer: var Mixer, name: string, sound: SoundData) = - assert not (name in mixer.sounds) - mixer.sounds[name] = sound - -proc replaceSound*(mixer: var Mixer, name: string, sound: SoundData) = - assert (name in mixer.sounds) + if name in mixer.sounds: + warn "sound with name '", name, "' was already loaded, overwriting" mixer.sounds[name] = sound proc addTrack*(mixer: var Mixer, name: string, level: Level = 1'f) = - assert not (name in mixer.tracks) + if name in mixer.tracks: + warn "track with name '", name, "' was already loaded, overwriting" mixer.lock.withLock: mixer.tracks[name] = Track(level: level) diff -r ce92db0b8f50 -r 8f774d9c2518 semicongine/rendering.nim --- a/semicongine/rendering.nim Tue Nov 05 23:02:32 2024 +0700 +++ b/semicongine/rendering.nim Tue Nov 05 23:28:25 2024 +0700 @@ -382,8 +382,7 @@ vulkan.swapchain = initSwapchain(renderPass, vSync = vSync) proc destroyVulkan*() = - if vulkan.swapchain != nil: - destroySwapchain(vulkan.swapchain) + clearSwapchain() vkDestroyDevice(vulkan.device, nil) vkDestroySurfaceKHR(vulkan.instance, vulkan.surface, nil) if vulkan.debugMessenger.Valid: