From 4250ea94c31ddc25912fbe7783a90f51c78a8b97 Mon Sep 17 00:00:00 2001 From: slavidodo Date: Tue, 14 Apr 2020 05:30:54 +0200 Subject: [PATCH] Fix random crashes errors when quitting the game --- .../Scripts/Core/Communication/Internal/Connection.cs | 7 +++++-- OpenTibia/Assets/Scripts/Core/GameManager.cs | 4 +--- OpenTibia/Assets/Scripts/UI/Legacy/WorldMapWidget.cs | 11 ++++++++--- OpenTibia/ProjectSettings/GraphicsSettings.asset | 5 ++++- 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/OpenTibia/Assets/Scripts/Core/Communication/Internal/Connection.cs b/OpenTibia/Assets/Scripts/Core/Communication/Internal/Connection.cs index e467827..426606e 100644 --- a/OpenTibia/Assets/Scripts/Core/Communication/Internal/Connection.cs +++ b/OpenTibia/Assets/Scripts/Core/Communication/Internal/Connection.cs @@ -295,8 +295,11 @@ private void HandleCommunicationTermination() { _receiving = false; _sending = false; - _socket.Dispose(); - _socket = null; + if (_socket != null) { + _socket.Dispose(); + _socket = null; + } + _packetQueue = null; onConnectionTerminated.Invoke(); diff --git a/OpenTibia/Assets/Scripts/Core/GameManager.cs b/OpenTibia/Assets/Scripts/Core/GameManager.cs index 286e6be..bc7adc8 100644 --- a/OpenTibia/Assets/Scripts/Core/GameManager.cs +++ b/OpenTibia/Assets/Scripts/Core/GameManager.cs @@ -184,9 +184,7 @@ public UnityUI.GraphicRaycaster ActiveRaycaster { get => ActiveCanvas ? ActiveCanvas.GetComponent() : null; } - public bool IsGameRunning { - get => !!ProtocolGame && ProtocolGame.IsGameRunning; - } + public bool IsGameRunning { get => !!ProtocolGame && ProtocolGame.IsGameRunning; } public bool IsRealTibia { get => ClientSpecification == ClientSpecification.Cipsoft; } public bool IsOpenTibia { get => ClientSpecification == ClientSpecification.OpenTibia; } diff --git a/OpenTibia/Assets/Scripts/UI/Legacy/WorldMapWidget.cs b/OpenTibia/Assets/Scripts/UI/Legacy/WorldMapWidget.cs index 57d29af..83b5026 100644 --- a/OpenTibia/Assets/Scripts/UI/Legacy/WorldMapWidget.cs +++ b/OpenTibia/Assets/Scripts/UI/Legacy/WorldMapWidget.cs @@ -99,9 +99,14 @@ public void OnPointerEnter(PointerEventData eventData) { public void OnPointerExit(PointerEventData _) { _mouseCursorOverRenderer = false; - OpenTibiaUnity.WorldMapRenderer.HighlightTile = null; - OpenTibiaUnity.WorldMapRenderer.HighlightObject = OpenTibiaUnity.CreatureStorage.Aim; - OpenTibiaUnity.GameManager.CursorController.SetCursorState(CursorState.Default, CursorPriority.Medium); + + if (OpenTibiaUnity.WorldMapRenderer != null) { + OpenTibiaUnity.WorldMapRenderer.HighlightTile = null; + OpenTibiaUnity.WorldMapRenderer.HighlightObject = OpenTibiaUnity.CreatureStorage.Aim; + } + + if (OpenTibiaUnity.GameManager != null) + OpenTibiaUnity.GameManager.CursorController.SetCursorState(CursorState.Default, CursorPriority.Medium); } protected void RenderWorldMap() { diff --git a/OpenTibia/ProjectSettings/GraphicsSettings.asset b/OpenTibia/ProjectSettings/GraphicsSettings.asset index 44814f4..abfa703 100644 --- a/OpenTibia/ProjectSettings/GraphicsSettings.asset +++ b/OpenTibia/ProjectSettings/GraphicsSettings.asset @@ -3,7 +3,7 @@ --- !u!30 &1 GraphicsSettings: m_ObjectHideFlags: 0 - serializedVersion: 12 + serializedVersion: 13 m_Deferred: m_Mode: 1 m_Shader: {fileID: 69, guid: 0000000000000000f000000000000000, type: 0} @@ -38,6 +38,7 @@ GraphicsSettings: - {fileID: 16000, guid: 0000000000000000f000000000000000, type: 0} - {fileID: 17000, guid: 0000000000000000f000000000000000, type: 0} - {fileID: 16001, guid: 0000000000000000f000000000000000, type: 0} + - {fileID: 16003, guid: 0000000000000000f000000000000000, type: 0} m_PreloadedShaders: [] m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0} @@ -62,3 +63,5 @@ GraphicsSettings: m_AlbedoSwatchInfos: [] m_LightsUseLinearIntensity: 0 m_LightsUseColorTemperature: 0 + m_LogWhenShaderIsCompiled: 0 + m_AllowEnlightenSupportForUpgradedProject: 1