Skip to content

Commit

Permalink
Add failsafe to SoundManager.normVolume
Browse files Browse the repository at this point in the history
Underlying issue may still need fixed.

#714
  • Loading branch information
AntumDeluge committed Jun 22, 2024
1 parent 2df0596 commit c3f81e5
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/js/stendhal/data/sound/SoundManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,10 @@ export class SoundManager {
* Normalized volume level between 0.0 and 1.0.
*/
private normVolume(vol: number): number {
if (isNaN(vol) || !isFinite(vol)) {
console.warn("Tried to set invalid volume level: " + vol, new Error());
vol = 1;
}
return vol < 0 ? 0 : vol > 1 ? 1 : vol;
}

Expand Down

0 comments on commit c3f81e5

Please sign in to comment.