diff --git a/OpenDiablo2.Core/GameEngine.cs b/OpenDiablo2.Core/GameEngine.cs index 7e997c51..3f4e9f8b 100644 --- a/OpenDiablo2.Core/GameEngine.cs +++ b/OpenDiablo2.Core/GameEngine.cs @@ -90,8 +90,8 @@ namespace OpenDiablo2.Core sw.Start(); while (getRenderWindow().IsRunning) { - while (sw.ElapsedMilliseconds < 40) - Thread.Sleep((int)Math.Min(1, 40 -sw.ElapsedMilliseconds)); // The original runs at about 25 fps. + while (sw.ElapsedMilliseconds < 33) + Thread.Sleep((int)Math.Min(1, 33 -sw.ElapsedMilliseconds)); // Lock to 30fps var ms = sw.ElapsedMilliseconds; diff --git a/OpenDiablo2.Core/Map Engine/MapEngine.cs b/OpenDiablo2.Core/Map Engine/MapEngine.cs index 5ea231ab..39b1e2f6 100644 --- a/OpenDiablo2.Core/Map Engine/MapEngine.cs +++ b/OpenDiablo2.Core/Map Engine/MapEngine.cs @@ -98,7 +98,10 @@ namespace OpenDiablo2.Core.Map_Engine continue; var floorLayer = gameState.MapData.FloorLayers[0]; - var floor = floorLayer.Props[x + (y * gameState.MapData.Width)]; + var idx = x + (y * gameState.MapData.Width); + if (idx >= floorLayer.Props.Length) + break; + var floor = floorLayer.Props[idx]; if (floor.Prop1 == 0) return; diff --git a/OpenDiablo2.SDL2/SDL2RenderWindow.cs b/OpenDiablo2.SDL2/SDL2RenderWindow.cs index da8b0219..266a6710 100644 --- a/OpenDiablo2.SDL2/SDL2RenderWindow.cs +++ b/OpenDiablo2.SDL2/SDL2RenderWindow.cs @@ -53,7 +53,7 @@ namespace OpenDiablo2.SDL2_ if (window == IntPtr.Zero) throw new ApplicationException($"Unable to create SDL Window: {SDL.SDL_GetError()}"); - renderer = SDL.SDL_CreateRenderer(window, -1, SDL.SDL_RendererFlags.SDL_RENDERER_ACCELERATED); + renderer = SDL.SDL_CreateRenderer(window, -1, SDL.SDL_RendererFlags.SDL_RENDERER_SOFTWARE); if (renderer == IntPtr.Zero) throw new ApplicationException($"Unable to create SDL Window: {SDL.SDL_GetError()}");