Handle the case that a biome has no music(empty string).

Fixes #159
This commit is contained in:
IntegratedQuantum 2023-11-03 15:38:53 +01:00
parent d7f0796abd
commit aef0740aa3

View File

@ -217,7 +217,7 @@ fn addMusic(buffer: []f32) !void {
if(try findMusic(musicId)) |musicBuffer| { if(try findMusic(musicId)) |musicBuffer| {
currentMusic.init(musicBuffer); currentMusic.init(musicBuffer);
activeMusicId = musicId; activeMusicId = musicId;
} else return; }
} else if(!currentMusic.animationDecaying) { } else if(!currentMusic.animationDecaying) {
_ = try findMusic(musicId); // Start loading the next music into the cache ahead of time. _ = try findMusic(musicId); // Start loading the next music into the cache ahead of time.
currentMusic.animationDecaying = true; currentMusic.animationDecaying = true;
@ -229,6 +229,7 @@ fn addMusic(buffer: []f32) !void {
currentMusic.animationProgress = 0; currentMusic.animationProgress = 0;
currentMusic.interpolationPolynomial = utils.unitIntervalSpline(f32, currentMusic.animationAmplitude, currentMusic.animationVelocity, 1, 0); currentMusic.interpolationPolynomial = utils.unitIntervalSpline(f32, currentMusic.animationAmplitude, currentMusic.animationVelocity, 1, 0);
} }
if(activeMusicId.len == 0) return;
// Copy the music to the buffer. // Copy the music to the buffer.
var i: usize = 0; var i: usize = 0;