From 50a770a2a6f0e48c67e36865ab7ab511f3c73594 Mon Sep 17 00:00:00 2001 From: Regalis Date: Wed, 9 Nov 2016 21:01:38 +0200 Subject: [PATCH] v0.5.3.3 + removed unnecessary EventInput code from the linux build, null check before disposing sprite texture --- Subsurface/Properties/AssemblyInfo.cs | 4 +- Subsurface/Source/EventInput/EventInput.cs | 98 +++++++++++----------- Subsurface/Source/Sprite.cs | 6 +- Subsurface/changelog.txt | 11 +++ 4 files changed, 68 insertions(+), 51 deletions(-) diff --git a/Subsurface/Properties/AssemblyInfo.cs b/Subsurface/Properties/AssemblyInfo.cs index 057d6e239..c7e4b6961 100644 --- a/Subsurface/Properties/AssemblyInfo.cs +++ b/Subsurface/Properties/AssemblyInfo.cs @@ -31,5 +31,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("0.5.3.2")] -[assembly: AssemblyFileVersion("0.5.3.2")] +[assembly: AssemblyVersion("0.5.3.3")] +[assembly: AssemblyFileVersion("0.5.3.3")] diff --git a/Subsurface/Source/EventInput/EventInput.cs b/Subsurface/Source/EventInput/EventInput.cs index 1e51273fa..7965109ad 100644 --- a/Subsurface/Source/EventInput/EventInput.cs +++ b/Subsurface/Source/EventInput/EventInput.cs @@ -6,7 +6,7 @@ using Microsoft.Xna.Framework.Input; namespace EventInput { - +#if WINDOWS public class KeyboardLayout { const uint KLF_ACTIVATE = 1; //activate the layout @@ -16,14 +16,14 @@ namespace EventInput [DllImport("user32.dll")] private static extern long LoadKeyboardLayout( - string pwszKLID, // input locale identifier - uint Flags // input locale identifier options - ); + string pwszKLID, // input locale identifier + uint Flags // input locale identifier options + ); [DllImport("user32.dll")] private static extern long GetKeyboardLayoutName( - StringBuilder pwszKLID //[out] string that receives the name of the locale identifier - ); + StringBuilder pwszKLID //[out] string that receives the name of the locale identifier + ); public static string getName() { @@ -32,6 +32,7 @@ namespace EventInput return name.ToString(); } } +#endif public class CharacterEventArgs : EventArgs { @@ -115,9 +116,12 @@ namespace EventInput /// public static event KeyEventHandler KeyUp; + static bool initialized; + +#if WINDOWS delegate IntPtr WndProc(IntPtr hWnd, uint msg, IntPtr wParam, IntPtr lParam); - static bool initialized; + static IntPtr prevWndProc; static WndProc hookProcDelegate; static IntPtr hIMC; @@ -145,7 +149,7 @@ namespace EventInput [DllImport("user32.dll", CharSet = CharSet.Unicode)] static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong); - +#endif /// /// Initialize the TextInput with the given GameWindow. @@ -157,15 +161,15 @@ namespace EventInput { return; } - //throw new InvalidOperationException("TextInput.Initialize can only be called once!"); - hookProcDelegate = HookProc; #if WINDOWS - prevWndProc = (IntPtr)SetWindowLong(window.Handle, GWL_WNDPROC, - (int)Marshal.GetFunctionPointerForDelegate(hookProcDelegate)); + hookProcDelegate = HookProc; - hIMC = ImmGetContext(window.Handle); -#elif LINUX + prevWndProc = (IntPtr)SetWindowLong(window.Handle, GWL_WNDPROC, + (int)Marshal.GetFunctionPointerForDelegate(hookProcDelegate)); + + hIMC = ImmGetContext(window.Handle); +#else window.TextInput += ReceiveInput; #endif @@ -181,50 +185,48 @@ namespace EventInput { if (CharEntered != null) CharEntered(null, new CharacterEventArgs(character, 0)); } - +#if WINDOWS static IntPtr HookProc(IntPtr hWnd, uint msg, IntPtr wParam, IntPtr lParam) { - IntPtr returnCode = CallWindowProc(prevWndProc, hWnd, msg, wParam, lParam); + IntPtr returnCode = CallWindowProc(prevWndProc, hWnd, msg, wParam, lParam); - switch (msg) - { - case WM_GETDLGCODE: - returnCode = (IntPtr)(returnCode.ToInt32() | DLGC_WANTALLKEYS); - break; + switch (msg) + { + case WM_GETDLGCODE: + returnCode = (IntPtr)(returnCode.ToInt32() | DLGC_WANTALLKEYS); + break; - case WM_KEYDOWN: - if (KeyDown != null) - KeyDown(null, new KeyEventArgs((Keys)wParam)); + case WM_KEYDOWN: + if (KeyDown != null) + KeyDown(null, new KeyEventArgs((Keys)wParam)); - break; + break; - case WM_KEYUP: - if (KeyUp != null) - KeyUp(null, new KeyEventArgs((Keys)wParam)); - break; + case WM_KEYUP: + if (KeyUp != null) + KeyUp(null, new KeyEventArgs((Keys)wParam)); + break; - case WM_CHAR: - if (CharEntered != null) - CharEntered(null, new CharacterEventArgs((char)wParam, lParam.ToInt32())); - break; + case WM_CHAR: + if (CharEntered != null) + CharEntered(null, new CharacterEventArgs((char)wParam, lParam.ToInt32())); + break; - case WM_IME_SETCONTEXT: - if (wParam.ToInt32() == 1) - ImmAssociateContext(hWnd, hIMC); - break; - - case WM_INPUTLANGCHANGE: - ImmAssociateContext(hWnd, hIMC); - returnCode = (IntPtr)1; - break; - } - - - - return returnCode; + case WM_IME_SETCONTEXT: + if (wParam.ToInt32() == 1) + ImmAssociateContext(hWnd, hIMC); + break; + case WM_INPUTLANGCHANGE: + ImmAssociateContext(hWnd, hIMC); + returnCode = (IntPtr)1; + break; } + + return returnCode; + } + +#endif } - } \ No newline at end of file diff --git a/Subsurface/Source/Sprite.cs b/Subsurface/Source/Sprite.cs index b0b41696f..2f377e951 100644 --- a/Subsurface/Source/Sprite.cs +++ b/Subsurface/Source/Sprite.cs @@ -379,7 +379,11 @@ namespace Barotrauma } //if not, free the texture - texture.Dispose(); + if (texture != null) + { + texture.Dispose(); + texture = null; + } } } diff --git a/Subsurface/changelog.txt b/Subsurface/changelog.txt index 2493dfda0..c010737b6 100644 --- a/Subsurface/changelog.txt +++ b/Subsurface/changelog.txt @@ -1,3 +1,14 @@ +--------------------------------------------------------------------------------------------------------- +v0.5.3.3 +--------------------------------------------------------------------------------------------------------- + +- fixed a bug that caused crashes after a husk-infected player died +- disabled the "zoom effect" when under pressure as a huskified human +- only a limited number of messages are kept in the debug console (prevents performance issues if large +amounts of messages are added) +- some item and electricity logic optimization +- fixed "sprite tigerthresher not found" errors in the Linux version + --------------------------------------------------------------------------------------------------------- v0.5.3.2 ---------------------------------------------------------------------------------------------------------