From cee021ef17f957ef7465e9482d1179f3fba4239c Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Thu, 31 Mar 2011 10:59:22 +1300 Subject: [PATCH] fix AudLoader failing to load sounds that use only half of the final byte --- OpenRA.FileFormats/FileFormats/AudLoader.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/OpenRA.FileFormats/FileFormats/AudLoader.cs b/OpenRA.FileFormats/FileFormats/AudLoader.cs index bfa0915784..607ef4bf53 100644 --- a/OpenRA.FileFormats/FileFormats/AudLoader.cs +++ b/OpenRA.FileFormats/FileFormats/AudLoader.cs @@ -1,4 +1,4 @@ -#region Copyright & License Information +\#region Copyright & License Information /* * Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * This file is part of OpenRA, which is free software. It is made @@ -141,9 +141,13 @@ namespace OpenRA.FileFormats output[offset++] = (byte)t; output[offset++] = (byte)(t >> 8); - t = DecodeSample((byte)(b >> 4), ref index, ref currentSample); - output[offset++] = (byte)t; - output[offset++] = (byte)(t >> 8); + if (offset < outputSize) + { + /* possible that only half of the final byte is used! */ + t = DecodeSample((byte)(b >> 4), ref index, ref currentSample); + output[offset++] = (byte)t; + output[offset++] = (byte)(t >> 8); + } } dataSize -= 8 + chunk.CompressedSize;