From 071c8ead3b76d208ab7c69cca11b4656d26b4e0c Mon Sep 17 00:00:00 2001 From: Kelsi Date: Thu, 5 Feb 2026 15:47:21 -0800 Subject: [PATCH] Retry login music playback when not playing --- src/audio/music_manager.cpp | 5 +++++ src/ui/auth_screen.cpp | 21 ++++++++++++++++----- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/src/audio/music_manager.cpp b/src/audio/music_manager.cpp index 7b721662..42554087 100644 --- a/src/audio/music_manager.cpp +++ b/src/audio/music_manager.cpp @@ -3,6 +3,7 @@ #include "core/logger.hpp" #include "platform/process.hpp" #include +#include namespace wowee { namespace audio { @@ -75,6 +76,10 @@ void MusicManager::playMusic(const std::string& mpqPath, bool loop) { void MusicManager::playFilePath(const std::string& filePath, bool loop) { if (filePath.empty()) return; if (filePath == currentTrack && playing) return; + if (!std::filesystem::exists(filePath)) { + LOG_WARNING("Music: file not found: ", filePath); + return; + } stopCurrentProcess(); diff --git a/src/ui/auth_screen.cpp b/src/ui/auth_screen.cpp index bdba4be5..efa9dd9e 100644 --- a/src/ui/auth_screen.cpp +++ b/src/ui/auth_screen.cpp @@ -6,6 +6,7 @@ #include "pipeline/asset_manager.hpp" #include "audio/music_manager.hpp" #include +#include #include #include #include @@ -75,19 +76,29 @@ void AuthScreen::render(auth::AuthHandler& authHandler) { } } + auto& app = core::Application::getInstance(); + auto* renderer = app.getRenderer(); if (!musicInitAttempted) { musicInitAttempted = true; - auto& app = core::Application::getInstance(); - auto* renderer = app.getRenderer(); auto* assets = app.getAssetManager(); if (renderer) { auto* music = renderer->getMusicManager(); if (music && assets && assets->isInitialized() && !music->isInitialized()) { music->initialize(assets); } - if (music && !musicPlaying) { - music->playFilePath("assets/20-taverns.mp3", true); - musicPlaying = true; + } + } + if (renderer) { + auto* music = renderer->getMusicManager(); + if (music) { + music->update(ImGui::GetIO().DeltaTime); + if (!music->isPlaying()) { + std::string path = "assets/20-taverns.mp3"; + if (!std::filesystem::exists(path)) { + path = (std::filesystem::current_path() / "assets/20-taverns.mp3").string(); + } + music->playFilePath(path, true); + musicPlaying = music->isPlaying(); } } }