diff --git a/tools/editor/zone_manifest.cpp b/tools/editor/zone_manifest.cpp index 2a1bbcea..afa420ca 100644 --- a/tools/editor/zone_manifest.cpp +++ b/tools/editor/zone_manifest.cpp @@ -5,6 +5,8 @@ #include #include #include +#include +#include namespace wowee { namespace editor { @@ -85,6 +87,9 @@ bool ZoneManifest::load(const std::string& path) { description = j.value("description", ""); mapId = j.value("mapId", 9000u); baseHeight = j.value("baseHeight", 100.0f); + // Sanitize edited values — baseHeight propagates into terrain mesh + // generation; volume into audio mixer. + if (!std::isfinite(baseHeight)) baseHeight = 100.0f; hasCreatures = j.value("hasCreatures", false); tiles.clear(); @@ -112,6 +117,12 @@ bool ZoneManifest::load(const std::string& path) { ambienceNight = a.value("ambienceNight", ""); musicVolume = a.value("musicVolume", 0.7f); ambienceVolume = a.value("ambienceVolume", 0.5f); + // Clamp volumes to [0, 1] and reject NaN — mixer would otherwise + // produce silent or clipping output. + if (!std::isfinite(musicVolume)) musicVolume = 0.7f; + if (!std::isfinite(ambienceVolume)) ambienceVolume = 0.5f; + musicVolume = std::clamp(musicVolume, 0.0f, 1.0f); + ambienceVolume = std::clamp(ambienceVolume, 0.0f, 1.0f); } return !mapName.empty();