From b654b65d8d4ba3ef5c1df4f4d77cd423e50eb57a Mon Sep 17 00:00:00 2001 From: ScottNZ Date: Thu, 29 Aug 2013 01:30:29 +1200 Subject: [PATCH] Close game interface before showing crash form and don't show it at all on dedicated servers. --- OpenRA.FileFormats/Graphics/IGraphicsDevice.cs | 2 ++ OpenRA.Game/Support/Program.cs | 5 ++++- OpenRA.Renderer.Cg/GraphicsDevice.cs | 6 ++++++ OpenRA.Renderer.Null/NullGraphicsDevice.cs | 2 ++ OpenRA.Renderer.SdlCommon/SdlGraphics.cs | 5 +++++ 5 files changed, 19 insertions(+), 1 deletion(-) diff --git a/OpenRA.FileFormats/Graphics/IGraphicsDevice.cs b/OpenRA.FileFormats/Graphics/IGraphicsDevice.cs index 564a143825..9be4681fc8 100755 --- a/OpenRA.FileFormats/Graphics/IGraphicsDevice.cs +++ b/OpenRA.FileFormats/Graphics/IGraphicsDevice.cs @@ -58,6 +58,8 @@ namespace OpenRA.FileFormats.Graphics void DisableDepthBuffer(); void SetBlendMode(BlendMode mode); + + void Quit(); } public interface IVertexBuffer diff --git a/OpenRA.Game/Support/Program.cs b/OpenRA.Game/Support/Program.cs index d73aa72a8e..46af602df8 100644 --- a/OpenRA.Game/Support/Program.cs +++ b/OpenRA.Game/Support/Program.cs @@ -50,8 +50,11 @@ namespace OpenRA Log.Write("exception", "{0}", rpt); Console.Error.WriteLine(rpt); - if (Game.Settings.Debug.ShowFatalErrorDialog) + if (Game.Settings.Debug.ShowFatalErrorDialog && !Game.Settings.Server.Dedicated) + { + Game.Renderer.Device.Quit(); FatalErrorDialog.Show(); + } } static StringBuilder BuildExceptionReport(Exception e) diff --git a/OpenRA.Renderer.Cg/GraphicsDevice.cs b/OpenRA.Renderer.Cg/GraphicsDevice.cs index 0ec830f7a1..a6ede53884 100755 --- a/OpenRA.Renderer.Cg/GraphicsDevice.cs +++ b/OpenRA.Renderer.Cg/GraphicsDevice.cs @@ -61,6 +61,12 @@ namespace OpenRA.Renderer.Cg FragmentProfile = CgGl.cgGLGetLatestProfile(CgGl.CG_GL_FRAGMENT); } + public override void Quit() + { + Tao.Cg.Cg.cgDestroyContext(Context); + base.Quit(); + } + public override IShader CreateShader(string name) { return new Shader(this, name); } } } diff --git a/OpenRA.Renderer.Null/NullGraphicsDevice.cs b/OpenRA.Renderer.Null/NullGraphicsDevice.cs index e58e5c10f1..b8821266e1 100644 --- a/OpenRA.Renderer.Null/NullGraphicsDevice.cs +++ b/OpenRA.Renderer.Null/NullGraphicsDevice.cs @@ -35,6 +35,8 @@ namespace OpenRA.Renderer.Null WindowSize = size; } + public void Quit() { } + public void EnableScissor(int left, int top, int width, int height) { } public void DisableScissor() { } diff --git a/OpenRA.Renderer.SdlCommon/SdlGraphics.cs b/OpenRA.Renderer.SdlCommon/SdlGraphics.cs index 4a48be0f5f..f8ab2ecde7 100644 --- a/OpenRA.Renderer.SdlCommon/SdlGraphics.cs +++ b/OpenRA.Renderer.SdlCommon/SdlGraphics.cs @@ -106,6 +106,11 @@ namespace OpenRA.Renderer.SdlCommon return surf; } + public virtual void Quit() + { + Sdl.SDL_Quit(); + } + int ModeFromPrimitiveType(PrimitiveType pt) { switch (pt)