From db8babf811cbe726799f76870372d77c2a7a8581 Mon Sep 17 00:00:00 2001 From: biwa <6475593+biwa@users.noreply.github.com> Date: Sun, 11 Dec 2022 11:02:03 +0100 Subject: [PATCH] Nodes Viewer Mode: a crash that could happen when the nodes header was interpreted as an UTF-8 value should be fixed for good now (#827) --- Source/Plugins/NodesViewer/NodesViewerMode.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Source/Plugins/NodesViewer/NodesViewerMode.cs b/Source/Plugins/NodesViewer/NodesViewerMode.cs index 8b94c8bb..b8f2c7a3 100755 --- a/Source/Plugins/NodesViewer/NodesViewerMode.cs +++ b/Source/Plugins/NodesViewer/NodesViewerMode.cs @@ -5,12 +5,13 @@ using System.Collections.Generic; using System.Drawing; using System.IO; using System.Linq; +using System.Text; using System.Windows.Forms; using CodeImp.DoomBuilder.Editing; using CodeImp.DoomBuilder.Geometry; +using CodeImp.DoomBuilder.Map; using CodeImp.DoomBuilder.Rendering; using CodeImp.DoomBuilder.Windows; -using CodeImp.DoomBuilder.Map; #endregion @@ -93,7 +94,7 @@ namespace CodeImp.DoomBuilder.Plugins.NodesViewer /// private bool LoadClassicStructures() { - List unsupportedheaders = new List() { "ZNOD".ToCharArray(), "XNOD".ToCharArray() }; + List unsupportedheaders = new List() { Encoding.ASCII.GetBytes("ZNOD"), Encoding.ASCII.GetBytes("XNOD") }; // Load the nodes structure MemoryStream nodesstream = General.Map.GetLumpData("NODES"); @@ -107,9 +108,9 @@ namespace CodeImp.DoomBuilder.Plugins.NodesViewer BinaryReader nodesreader = new BinaryReader(nodesstream); - // Compare the char arrays. We can't do it by comparing strings, since the data read from the NODES + // Compare the byte arrays. We can't do it by comparing strings, since the data read from the NODES // lump might be interpreted as some UTF value. See https://github.com/jewalky/UltimateDoomBuilder/issues/827 - char[] header = nodesreader.ReadChars(4); + byte[] header = nodesreader.ReadBytes(4); if(unsupportedheaders.Where(e => Enumerable.SequenceEqual(e, header)).Any()) { MessageBox.Show("ZDBSP compressed nodes are currently not supported.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);