~ruther/NosSmooth.Local

3b12a07e818b863fd0a70888a290df83a41bddd1 — Rutherther 2 years ago d6b6d7c
fix(binding): skip first cancel packet receive due to crashing on OpenNos servers
1 files changed, 15 insertions(+), 1 deletions(-)

M src/Core/NosSmooth.LocalBinding/Objects/NetworkBinding.cs
M src/Core/NosSmooth.LocalBinding/Objects/NetworkBinding.cs => src/Core/NosSmooth.LocalBinding/Objects/NetworkBinding.cs +15 -1
@@ 217,6 217,8 @@ public class NetworkBinding
        }
    }

    private bool _receivedCancel = false;

    private void ReceivePacketDetour(IntPtr packetObject, IntPtr packetString)
    {
        var packet = Marshal.PtrToStringAnsi(packetString);


@@ 229,7 231,19 @@ public class NetworkBinding
            var result = PacketReceive?.Invoke(packet);
            if (result ?? true)
            {
                _originalReceive(packetObject, packetString);
                // This is a TEMPORARY fix, I don't know why,
                // but upon logging in (for OpenNos servers)
                // there is an exception when receiving packet
                // cancel.
                // TODO FIX THIS correctly
                if (_receivedCancel || !packet.StartsWith("cancel"))
                {
                    _originalReceive(packetObject, packetString);
                }
                else
                {
                    _receivedCancel = true;
                }
            }
        }
    }

Do not follow this link