mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-04-17 01:23:51 +00:00
Fix NPC visibility and stabilize world transport/taxi updates
This commit is contained in:
parent
5dae994830
commit
f752a4f517
16 changed files with 452 additions and 173 deletions
|
|
@ -24,6 +24,17 @@ void MusicManager::shutdown() {
|
|||
AudioEngine::instance().stopMusic();
|
||||
playing = false;
|
||||
currentTrack.clear();
|
||||
musicDataCache_.clear();
|
||||
}
|
||||
|
||||
void MusicManager::preloadMusic(const std::string& mpqPath) {
|
||||
if (!assetManager || mpqPath.empty()) return;
|
||||
if (musicDataCache_.find(mpqPath) != musicDataCache_.end()) return;
|
||||
|
||||
auto data = assetManager->readFile(mpqPath);
|
||||
if (!data.empty()) {
|
||||
musicDataCache_[mpqPath] = std::move(data);
|
||||
}
|
||||
}
|
||||
|
||||
void MusicManager::playMusic(const std::string& mpqPath, bool loop) {
|
||||
|
|
@ -36,9 +47,13 @@ void MusicManager::playMusic(const std::string& mpqPath, bool loop) {
|
|||
return;
|
||||
}
|
||||
|
||||
// Read music file from MPQ
|
||||
auto data = assetManager->readFile(mpqPath);
|
||||
if (data.empty()) {
|
||||
// Read music file from cache or MPQ
|
||||
auto cacheIt = musicDataCache_.find(mpqPath);
|
||||
if (cacheIt == musicDataCache_.end()) {
|
||||
preloadMusic(mpqPath);
|
||||
cacheIt = musicDataCache_.find(mpqPath);
|
||||
}
|
||||
if (cacheIt == musicDataCache_.end() || cacheIt->second.empty()) {
|
||||
LOG_WARNING("Music: Could not read: ", mpqPath);
|
||||
return;
|
||||
}
|
||||
|
|
@ -48,7 +63,7 @@ void MusicManager::playMusic(const std::string& mpqPath, bool loop) {
|
|||
|
||||
// Play with AudioEngine (non-blocking, streams from memory)
|
||||
float volume = volumePercent / 100.0f;
|
||||
if (AudioEngine::instance().playMusic(data, volume, loop)) {
|
||||
if (AudioEngine::instance().playMusic(cacheIt->second, volume, loop)) {
|
||||
playing = true;
|
||||
currentTrack = mpqPath;
|
||||
currentTrackIsFile = false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue