Game shouldn't crash when you set a sound id above snow sound id

This commit is contained in:
UnknownShadow200 2018-05-25 09:27:58 +10:00
parent 21d96f1de1
commit 740c6010c2
3 changed files with 5 additions and 4 deletions

View file

@ -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];

View file

@ -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",
};

View file

@ -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. */