From 8179d9f7930af2469b57a0d196a010666d70a9c1 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Fri, 18 Dec 2015 14:08:42 +1100 Subject: [PATCH] Add sounds for BlockDefinitions. --- ClassicalSharp/Blocks/BlockInfo.cs | 2 ++ .../Network/NetworkProcessor.CPE.cs | 23 ++++++++++++++++++- credits.txt | 1 + 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/ClassicalSharp/Blocks/BlockInfo.cs b/ClassicalSharp/Blocks/BlockInfo.cs index a5ff17b56..d5fed40a4 100644 --- a/ClassicalSharp/Blocks/BlockInfo.cs +++ b/ClassicalSharp/Blocks/BlockInfo.cs @@ -182,6 +182,8 @@ namespace ClassicalSharp { SetupCullingCache(); MinBB[id] = Vector3.Zero; MaxBB[id] = Vector3.One; + StepSounds[id] = SoundType.None; + DigSounds[id] = SoundType.None; } } diff --git a/ClassicalSharp/Network/NetworkProcessor.CPE.cs b/ClassicalSharp/Network/NetworkProcessor.CPE.cs index 845ede392..9da59e895 100644 --- a/ClassicalSharp/Network/NetworkProcessor.CPE.cs +++ b/ClassicalSharp/Network/NetworkProcessor.CPE.cs @@ -396,7 +396,11 @@ namespace ClassicalSharp { info.SetSide( reader.ReadUInt8(), (Block)block ); info.SetBottom( reader.ReadUInt8(), (Block)block ); info.BlocksLight[block] = reader.ReadUInt8() == 0; - reader.ReadUInt8(); // walk sound, but we ignore this. + byte sound = reader.ReadUInt8(); + if( sound < breakSnds.Length ) { + info.StepSounds[block] = stepSnds[sound]; + info.DigSounds[block] = breakSnds[sound]; + } info.FullBright[block] = reader.ReadUInt8() != 0; byte shape = reader.ReadUInt8(); @@ -473,6 +477,23 @@ namespace ClassicalSharp { return buffer[offset + 0] << 24 | buffer[offset + 1] << 16 | buffer[offset + 2] << 8 | buffer[offset + 3]; } + + static SoundType[] stepSnds, breakSnds; + static NetworkProcessor() { + stepSnds = new SoundType[10]; + breakSnds = new SoundType[10]; + stepSnds[0] = SoundType.None; breakSnds[0] = SoundType.None; + stepSnds[1] = SoundType.Wood; breakSnds[1] = SoundType.Wood; + stepSnds[2] = SoundType.Gravel; breakSnds[2] = SoundType.Gravel; + stepSnds[3] = SoundType.Grass; breakSnds[3] = SoundType.Grass; + stepSnds[4] = SoundType.Stone; breakSnds[4] = SoundType.Stone; + // TODO: metal sound type, just use stone for now. + stepSnds[5] = SoundType.Stone; breakSnds[5] = SoundType.Stone; + stepSnds[6] = SoundType.Stone; breakSnds[6] = SoundType.Glass; + stepSnds[7] = SoundType.Cloth; breakSnds[7] = SoundType.Cloth; + stepSnds[8] = SoundType.Sand; breakSnds[8] = SoundType.Sand; + stepSnds[9] = SoundType.Snow; breakSnds[9] = SoundType.Snow; + } } #endregion } \ No newline at end of file diff --git a/credits.txt b/credits.txt index 461fa2bb5..56c624e42 100644 --- a/credits.txt +++ b/credits.txt @@ -8,6 +8,7 @@ * Cheesse - multiple suggestions, testing ClassicalSharp on AMD graphics cards. * Hemsindor - testing ClassicalSharp on OSX. * FabTheZen - suggestions about how to improve user experience, testing. +* Jerralish - reverse engineering and documenting the original classic map generation algorithm. And a big thanks to everyone else in the ClassiCube community (who I didn't mention here), who in the past have provided many suggestions and assisted in identifying bugs. \ No newline at end of file