diff --git a/ClassicalSharp/Audio/Soundboard.cs b/ClassicalSharp/Audio/Soundboard.cs index 54991e5e0..2ec3228bd 100644 --- a/ClassicalSharp/Audio/Soundboard.cs +++ b/ClassicalSharp/Audio/Soundboard.cs @@ -55,7 +55,7 @@ namespace ClassicalSharp.Audio { } public Sound PickRandomSound(byte type) { - if (type == SoundType.None) return null; + if (type == SoundType.None || type >= SoundType.Count) return null; if (type == SoundType.Metal) type = SoundType.Stone; string name = SoundType.Names[type]; diff --git a/ClassicalSharp/Blocks/BlockInfo.cs b/ClassicalSharp/Blocks/BlockInfo.cs index 2c628c8df..9c2502cc8 100644 --- a/ClassicalSharp/Blocks/BlockInfo.cs +++ b/ClassicalSharp/Blocks/BlockInfo.cs @@ -12,9 +12,10 @@ namespace ClassicalSharp { public const byte Gravel = 2; public const byte Grass = 3; public const byte Stone = 4; public const byte Metal = 5; public const byte Glass = 6; public const byte Cloth = 7; - public const byte Sand = 8; public const byte Snow = 9; + public const byte Sand = 8; public const byte Snow = 9; - public static string[] Names = new string[10] { + public const byte Count = 10; + public static string[] Names = new string[Count] { "none", "wood", "gravel", "grass", "stone", "metal", "glass", "cloth", "sand", "snow", }; diff --git a/src/Client/Block.h b/src/Client/Block.h index 20af1b619..c0c33c49a 100644 --- a/src/Client/Block.h +++ b/src/Client/Block.h @@ -12,7 +12,7 @@ enum SOUND { SOUND_NONE, SOUND_WOOD, SOUND_GRAVEL, SOUND_GRASS, SOUND_STONE, SOUND_METAL, SOUND_GLASS, SOUND_CLOTH, - SOUND_SAND, SOUND_SNOW, + SOUND_SAND, SOUND_SNOW, SOUND_COUNT, }; /* Describes how a block is rendered in the world. */