From 571ae2670739965ed5a3cc15af3764f79ef7567f Mon Sep 17 00:00:00 2001 From: Glatzemann Date: Thu, 15 Dec 2011 12:59:20 +0000 Subject: [PATCH] - Removed three TODOs from ContentReader. - Worked on a TODO in AudioEngine - Worked on TODOs in ContentManager - fixed another bunch of TODOs which doesn't need work or are very simple and solved directly --- ANX.Framework/Audio/AudioEngine.cs | 2 +- ANX.Framework/Content/ContentManager.cs | 16 +++++++++++----- ANX.Framework/Content/ContentReader.cs | 14 +++++++++++--- ANX.Framework/TitleContainer.cs | 7 +++++++ .../ANX.InputSystem.Recording/RecordingMouse.cs | 2 +- .../ANX.Framework.Windows.DX10/Effect_DX10.cs | 1 - .../GraphicsDeviceWindowsDX10.cs | 2 +- .../ANX.Framework.Windows.GL3/IndexBufferGL3.cs | 2 ++ .../ANX.RenderSystem.Windows.DX11/Effect_DX11.cs | 1 - Samples/Kinect/Game1.cs | 6 ++---- 10 files changed, 36 insertions(+), 17 deletions(-) diff --git a/ANX.Framework/Audio/AudioEngine.cs b/ANX.Framework/Audio/AudioEngine.cs index d1cbcdc8..4c339399 100644 --- a/ANX.Framework/Audio/AudioEngine.cs +++ b/ANX.Framework/Audio/AudioEngine.cs @@ -56,7 +56,7 @@ namespace ANX.Framework.Audio { public class AudioEngine : IDisposable { - public const int ContentVersion=0;//ToDo find the original value + public const int ContentVersion = 0x27; public AudioEngine(string settingsFile) diff --git a/ANX.Framework/Content/ContentManager.cs b/ANX.Framework/Content/ContentManager.cs index 7afc95c9..6c3fdcc8 100644 --- a/ANX.Framework/Content/ContentManager.cs +++ b/ANX.Framework/Content/ContentManager.cs @@ -193,7 +193,8 @@ namespace ANX.Framework.Content throw new ArgumentNullException("assetName"); } - // TODO: make clean asset name + assetName = TitleContainer.GetCleanPath(assetName); + object result; if (this.loadedAssets.TryGetValue(assetName, out result)) { @@ -243,10 +244,15 @@ namespace ANX.Framework.Content /// protected virtual Stream OpenStream(string assetName) { - // TODO: catch exception and throw a ContentLoadException - - string path = Path.Combine(rootDirectoryAbsolute, assetName + Extension); - return new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read); + try + { + string path = Path.Combine(rootDirectoryAbsolute, assetName + Extension); + return new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read); + } + catch (Exception ex) + { + throw new ContentLoadException("failed to open stream for '" + assetName + "'", ex); + } } protected void ThrowExceptionIfDisposed() diff --git a/ANX.Framework/Content/ContentReader.cs b/ANX.Framework/Content/ContentReader.cs index 4b08b06c..0cb51727 100644 --- a/ANX.Framework/Content/ContentReader.cs +++ b/ANX.Framework/Content/ContentReader.cs @@ -175,7 +175,11 @@ namespace ANX.Framework.Content bool isCompressed = (flags & 0x80) != 0; int sizeOnDisk = reader.ReadInt32(); - // TODO: check stream length + + if (input.CanSeek && ((sizeOnDisk - 10) > (input.Length - input.Position))) + { + throw new ContentLoadException("Bad XNB file size."); + } if (isCompressed) { @@ -399,13 +403,17 @@ namespace ANX.Framework.Content public override float ReadSingle() { - // TODO: this is handeled with unsafe code in the original implementation, dont know for what reason + // This is handeled with unsafe code in the original implementation. + // The original implementation reads as UInt32 and does some pointer magic to copy the UInt bits into the float. + // The same "pointer magic" is done by the ReadSingle method of the binary reader already. return base.ReadSingle(); } public override double ReadDouble() { - // TODO: this is handeled with unsafe code in the original implementation, dont know for what reason + // This is handeled with unsafe code in the original implementation. + // The original implementation reads as UInt64 and does some pointer magic to copy the UInt bits into the float. + // The same "pointer magic" is done by the ReadDouble method of the binary reader already. return base.ReadDouble(); } diff --git a/ANX.Framework/TitleContainer.cs b/ANX.Framework/TitleContainer.cs index 91899bb5..ac7de921 100644 --- a/ANX.Framework/TitleContainer.cs +++ b/ANX.Framework/TitleContainer.cs @@ -59,5 +59,12 @@ namespace ANX.Framework { throw new NotImplementedException(); } + + internal static string GetCleanPath(string path) + { + //TODO: implement + + return path; + } } } diff --git a/InputSystems/ANX.InputSystem.Recording/RecordingMouse.cs b/InputSystems/ANX.InputSystem.Recording/RecordingMouse.cs index 1dacab7f..b27ddfdf 100644 --- a/InputSystems/ANX.InputSystem.Recording/RecordingMouse.cs +++ b/InputSystems/ANX.InputSystem.Recording/RecordingMouse.cs @@ -168,7 +168,7 @@ namespace ANX.InputSystem.Recording byte writeOffset = 0; if ((recordInfo & MouseRecordInfo.AllButtons) != 0) //Any of the Buttons is recorded { - buffer[writeOffset] |= state.LeftButton == ButtonState.Pressed ? (byte)MouseButtons.Left : (byte)0; //TODO: Is there a byte literal? (like 118L or 91.8f) + buffer[writeOffset] |= state.LeftButton == ButtonState.Pressed ? (byte)MouseButtons.Left : (byte)0; buffer[writeOffset] |= state.RightButton == ButtonState.Pressed ? (byte)MouseButtons.Right : (byte)0; buffer[writeOffset] |= state.MiddleButton == ButtonState.Pressed ? (byte)MouseButtons.Middle : (byte)0; buffer[writeOffset] |= state.XButton1 == ButtonState.Pressed ? (byte)MouseButtons.X1 : (byte)0; diff --git a/RenderSystems/ANX.Framework.Windows.DX10/Effect_DX10.cs b/RenderSystems/ANX.Framework.Windows.DX10/Effect_DX10.cs index 55819ba7..f576bdb4 100644 --- a/RenderSystems/ANX.Framework.Windows.DX10/Effect_DX10.cs +++ b/RenderSystems/ANX.Framework.Windows.DX10/Effect_DX10.cs @@ -111,7 +111,6 @@ namespace ANX.Framework.Windows.DX10 public void Apply(GraphicsDevice graphicsDevice) { - //TODO: dummy ((GraphicsDeviceWindowsDX10)graphicsDevice.NativeDevice).currentEffect = this; } diff --git a/RenderSystems/ANX.Framework.Windows.DX10/GraphicsDeviceWindowsDX10.cs b/RenderSystems/ANX.Framework.Windows.DX10/GraphicsDeviceWindowsDX10.cs index 17f43121..9bb4f0ce 100644 --- a/RenderSystems/ANX.Framework.Windows.DX10/GraphicsDeviceWindowsDX10.cs +++ b/RenderSystems/ANX.Framework.Windows.DX10/GraphicsDeviceWindowsDX10.cs @@ -210,7 +210,7 @@ namespace ANX.Framework.Windows.DX10 this.depthStencilView = new DepthStencilView(device, this.depthStencilBuffer); - Clear(ClearOptions.DepthBuffer | ClearOptions.Stencil, Vector4.Zero, 1.0f, 0); //TODO: this workaround is working but maybe not the best solution to issue #472 + Clear(ClearOptions.DepthBuffer | ClearOptions.Stencil, Vector4.Zero, 1.0f, 0); // this workaround is working but maybe not the best solution to issue #472 } #region Clear diff --git a/RenderSystems/ANX.Framework.Windows.GL3/IndexBufferGL3.cs b/RenderSystems/ANX.Framework.Windows.GL3/IndexBufferGL3.cs index 9250d714..8f7e179d 100644 --- a/RenderSystems/ANX.Framework.Windows.GL3/IndexBufferGL3.cs +++ b/RenderSystems/ANX.Framework.Windows.GL3/IndexBufferGL3.cs @@ -94,6 +94,8 @@ namespace ANX.Framework.Windows.GL3 // StaticDraw: set once, use often // DynamicDraw: set frequently, use repeatadly // StreamDraw: set every tick, use once + + // comment from glatzemann: I think static draw should be right HERE. DynamicDraw should be used for DynamicIndexbuffer. StreamDraw shouldn't be used I think. usageHint = BufferUsageHint.DynamicDraw; GL.GenBuffers(1, out bufferHandle); diff --git a/RenderSystems/ANX.RenderSystem.Windows.DX11/Effect_DX11.cs b/RenderSystems/ANX.RenderSystem.Windows.DX11/Effect_DX11.cs index d19ff850..62cb9242 100644 --- a/RenderSystems/ANX.RenderSystem.Windows.DX11/Effect_DX11.cs +++ b/RenderSystems/ANX.RenderSystem.Windows.DX11/Effect_DX11.cs @@ -111,7 +111,6 @@ namespace ANX.RenderSystem.Windows.DX11 public void Apply(GraphicsDevice graphicsDevice) { - //TODO: dummy ((GraphicsDeviceWindowsDX11)graphicsDevice.NativeDevice).currentEffect = this; } diff --git a/Samples/Kinect/Game1.cs b/Samples/Kinect/Game1.cs index 25dbf98c..d4e55b08 100644 --- a/Samples/Kinect/Game1.cs +++ b/Samples/Kinect/Game1.cs @@ -33,14 +33,12 @@ namespace Kinect { spriteBatch = new SpriteBatch(GraphicsDevice); - // TODO: Verwenden Sie this.Content, um Ihren Spiel-Inhalt hier zu laden } protected override void Update(GameTime gameTime) { - //TODO: reactivate - //if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) - // this.Exit(); + if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) + this.Exit(); kinectState = MotionSensingDevice.GetState();