From 68bf3d32b078dd4d0bdb8c917da94cdc33eb3568 Mon Sep 17 00:00:00 2001 From: Kelsi Date: Mon, 9 Mar 2026 16:24:12 -0700 Subject: [PATCH] Wire ambient sound zone detection: setZoneType/setCityType was never called Add AmbientSoundManager::setZoneId() that maps WoW zone IDs to the appropriate ZoneType (forest/grasslands/desert/jungle/marsh/beach) or CityType (Stormwind/Ironforge/Darnassus/Orgrimmar/Undercity/ThunderBluff) and delegates to setZoneType/setCityType. Call it from the renderer's zone transition handler so zone ambience (looping sounds, city bells, etc.) actually activates when the player enters a zone. --- include/audio/ambient_sound_manager.hpp | 3 + src/audio/ambient_sound_manager.cpp | 88 +++++++++++++++++++++++++ src/rendering/renderer.cpp | 4 ++ 3 files changed, 95 insertions(+) diff --git a/include/audio/ambient_sound_manager.hpp b/include/audio/ambient_sound_manager.hpp index 88f326aa..8a14d200 100644 --- a/include/audio/ambient_sound_manager.hpp +++ b/include/audio/ambient_sound_manager.hpp @@ -45,6 +45,9 @@ public: void setZoneType(ZoneType type); ZoneType getCurrentZone() const { return currentZone_; } + // Convenience: derive ZoneType and CityType from a WoW zone ID + void setZoneId(uint32_t zoneId); + // City ambience control enum class CityType { NONE, diff --git a/src/audio/ambient_sound_manager.cpp b/src/audio/ambient_sound_manager.cpp index 5e820ef7..473bf36a 100644 --- a/src/audio/ambient_sound_manager.cpp +++ b/src/audio/ambient_sound_manager.cpp @@ -554,6 +554,94 @@ void AmbientSoundManager::setZoneType(ZoneType type) { } } +void AmbientSoundManager::setZoneId(uint32_t zoneId) { + // Map WoW zone ID to ZoneType + CityType. + // City zones: set CityType and clear ZoneType. + // Outdoor zones: set ZoneType and clear CityType. + CityType city = CityType::NONE; + ZoneType zone = ZoneType::NONE; + + switch (zoneId) { + // ---- Major cities ---- + case 1519: city = CityType::STORMWIND; break; + case 1537: city = CityType::IRONFORGE; break; + case 1657: city = CityType::DARNASSUS; break; + case 1637: city = CityType::ORGRIMMAR; break; + case 1497: city = CityType::UNDERCITY; break; + case 1638: city = CityType::THUNDERBLUFF; break; + + // ---- Forest / snowy forest ---- + case 12: // Elwynn Forest + case 141: // Teldrassil + case 148: // Darkshore + case 493: // Moonglade + case 361: // Felwood + case 331: // Ashenvale + case 357: // Feralas + case 15: // Dustwallow Marsh (lush) + case 267: // Hillsbrad Foothills + case 36: // Alterac Mountains + case 45: // Arathi Highlands + zone = ZoneType::FOREST_NORMAL; break; + + case 1: // Dun Morogh + case 196: // Winterspring + case 3: // Badlands (actually dry but close enough) + case 2817: // Crystalsong Forest + case 66: // Storm Peaks + case 67: // Icecrown + case 394: // Dragonblight + case 65: // Howling Fjord + zone = ZoneType::FOREST_SNOW; break; + + // ---- Grasslands / plains ---- + case 40: // Westfall + case 215: // Mulgore + case 44: // Redridge Mountains + case 10: // Duskwood (counts as grassland night) + case 38: // Loch Modan + zone = ZoneType::GRASSLANDS; break; + + // ---- Desert ---- + case 17: // The Barrens + case 14: // Durotar + case 440: // Tanaris + case 400: // Thousand Needles + zone = ZoneType::DESERT_PLAINS; break; + + case 46: // Burning Steppes + case 51: // Searing Gorge + case 241: // Eastern Plaguelands (barren) + case 28: // Western Plaguelands + zone = ZoneType::DESERT_CANYON; break; + + // ---- Jungle ---- + case 33: // Stranglethorn Vale + case 78: // Un'Goro Crater + case 210: // Uldaman + case 1377: // Silithus (arid but closest) + zone = ZoneType::JUNGLE; break; + + // ---- Marsh / swamp ---- + case 8: // Swamp of Sorrows + case 11: // Wetlands + case 139: // Eastern Plaguelands + case 763: // Zangarmarsh + zone = ZoneType::MARSH; break; + + // ---- Beach / coast ---- + case 4: // Barrens coast (Merchant Coast) + case 3537: // Azuremyst Isle + case 3524: // Bloodmyst Isle + zone = ZoneType::BEACH; break; + + default: break; + } + + setCityType(city); + setZoneType(zone); +} + void AmbientSoundManager::setCityType(CityType type) { if (currentCity_ != type) { LOG_INFO("AmbientSoundManager: City changed from ", static_cast(currentCity_), diff --git a/src/rendering/renderer.cpp b/src/rendering/renderer.cpp index 52a33b72..5a8f23f6 100644 --- a/src/rendering/renderer.cpp +++ b/src/rendering/renderer.cpp @@ -3155,6 +3155,10 @@ void Renderer::update(float deltaTime) { } } } + // Update ambient sound manager zone type + if (ambientSoundManager) { + ambientSoundManager->setZoneId(zoneId); + } } musicManager->update(deltaTime);