mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2024-11-30 07:31:36 +00:00
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)
This commit is contained in:
parent
65f1b6c209
commit
db8babf811
1 changed files with 5 additions and 4 deletions
|
@ -5,12 +5,13 @@ using System.Collections.Generic;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using CodeImp.DoomBuilder.Editing;
|
using CodeImp.DoomBuilder.Editing;
|
||||||
using CodeImp.DoomBuilder.Geometry;
|
using CodeImp.DoomBuilder.Geometry;
|
||||||
|
using CodeImp.DoomBuilder.Map;
|
||||||
using CodeImp.DoomBuilder.Rendering;
|
using CodeImp.DoomBuilder.Rendering;
|
||||||
using CodeImp.DoomBuilder.Windows;
|
using CodeImp.DoomBuilder.Windows;
|
||||||
using CodeImp.DoomBuilder.Map;
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
@ -93,7 +94,7 @@ namespace CodeImp.DoomBuilder.Plugins.NodesViewer
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private bool LoadClassicStructures()
|
private bool LoadClassicStructures()
|
||||||
{
|
{
|
||||||
List<char[]> unsupportedheaders = new List<char[]>() { "ZNOD".ToCharArray(), "XNOD".ToCharArray() };
|
List<byte[]> unsupportedheaders = new List<byte[]>() { Encoding.ASCII.GetBytes("ZNOD"), Encoding.ASCII.GetBytes("XNOD") };
|
||||||
|
|
||||||
// Load the nodes structure
|
// Load the nodes structure
|
||||||
MemoryStream nodesstream = General.Map.GetLumpData("NODES");
|
MemoryStream nodesstream = General.Map.GetLumpData("NODES");
|
||||||
|
@ -107,9 +108,9 @@ namespace CodeImp.DoomBuilder.Plugins.NodesViewer
|
||||||
|
|
||||||
BinaryReader nodesreader = new BinaryReader(nodesstream);
|
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
|
// 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())
|
if(unsupportedheaders.Where(e => Enumerable.SequenceEqual(e, header)).Any())
|
||||||
{
|
{
|
||||||
MessageBox.Show("ZDBSP compressed nodes are currently not supported.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBox.Show("ZDBSP compressed nodes are currently not supported.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
|
Loading…
Reference in a new issue