diff --git a/MapleStoryDB2/Form1.cs b/MapleStoryDB2/Form1.cs index df45c03..ebdd798 100644 --- a/MapleStoryDB2/Form1.cs +++ b/MapleStoryDB2/Form1.cs @@ -1006,22 +1006,25 @@ void LoadNpc() var Row = -1; var Links = new List<(string, int)>(); Bitmap Icon = null; + var Name = ""; foreach (var Img in Arc.NpcWz.Nodes()) { Row += 1; var ID = Img.ImgID(); var Entry = Arc.NpcWz.GetNode(Img.Text); - if (Entry.GetNode("stand/0") != null) + if (Entry.GetNode("stand/0") != null ) Icon = Entry.GetNode("stand/0").ExtractPng2(); if (Entry.GetNode("default/0") != null) Icon = Entry.GetNode("default/0").ExtractPng2(); - var Name = Arc.StringWz.GetNode("Npc.img/" + ID.IDString()).GetValue2("name", ""); + if(Arc.StringWz.GetNode("Npc.img/"+ ID.IDString()) != null) + Name = Arc.StringWz.GetNode("Npc.img/" + ID.IDString()).GetValue2("name", ""); DumpData2(Arc.StringWz.GetNode("Npc.img/" + ID.IDString())); Grid.Rows.Add(ID, Icon, Name, ""); var Link = Arc.NpcWz.GetNode(Img.Text + "/info/link"); if (Link != null) Links.Add((Link.Value.ToString() + ".img", Row)); } + Wz_Node Child = null; for (int i = 0; i < Links.Count; i++) { diff --git a/MapleStoryDB2/WzUtils.cs b/MapleStoryDB2/WzUtils.cs index 35d3180..a1afd25 100644 --- a/MapleStoryDB2/WzUtils.cs +++ b/MapleStoryDB2/WzUtils.cs @@ -12,7 +12,7 @@ namespace Wz.Utils public class Arc { public static Wz_Structure MobWz, Mob001Wz, Mob2Wz, MapWz, Map2Wz, Map001Wz, Map002Wz, SkillWz, Skill001Wz, Skill002Wz, - CharacterWz, ItemWz, NpcWz, MorphWz, StringWz, EtcWz, ReactorWz,UIWz,SoundWz,Sound001Wz,Sound2Wz,EffectWz,BaseWz; + CharacterWz, ItemWz, NpcWz, MorphWz, StringWz, EtcWz, ReactorWz, UIWz, SoundWz, Sound001Wz, Sound2Wz, EffectWz, BaseWz; } public static class WzUtils @@ -26,15 +26,18 @@ public static string IDString(this string Str) public static string GetPathD(this Wz_Node Node) { - Stack Path = new Stack(); - Wz_Node ThisNode = Node; - do + if (Node != null) { - Path.Push(ThisNode.Text); - ThisNode = ThisNode.ParentNode; - } while (ThisNode != null); - return string.Join(".", Path.ToArray()); - + Stack Path = new Stack(); + Wz_Node ThisNode = Node; + do + { + Path.Push(ThisNode.Text); + ThisNode = ThisNode.ParentNode; + } while (ThisNode != null); + return string.Join(".", Path.ToArray()); + } + return null; } public static string GetPath(this Wz_Node Node) @@ -77,7 +80,7 @@ public static Wz_Node FindNodeByPathA(this Wz_Node Node, string FullPath, bool E public static Wz_Node GetNode(this Wz_Node Node, string Path) { - // Wz_Node Result = null; + if (Node.FindNodeByPathA(Path, true) != null) { if (Node.FindNodeByPathA(Path, true).Value is Wz_Uol) @@ -138,6 +141,7 @@ public static bool HasNode(this Wz_Node Node, string Path) public static Bitmap ExtractPng2(this Wz_Node Node) { + if (Node.HasNode("_outlink")) { var LinkData = Node.GetNode("_outlink").Value.ToString(); @@ -191,14 +195,13 @@ public static Bitmap ExtractPng2(this Wz_Node Node) { var LinkData = Node.GetNode("_inlink").Value.ToString(); return (Node.GetNodeWzImage().Node.GetNode(LinkData).Value as Wz_Png).ExtractPng(); - } else if (Node.HasNode("source")) { var LinkData = Node.GetNode("source").Value.ToString(); var DestPath = Regex.Replace(LinkData, Node.GetNodeWzFile().Type.ToString() + "/", ""); - return (Node.GetNodeWzFile().WzStructure.GetNode(DestPath).Value as Wz_Png).ExtractPng(); - + if (Node.GetNodeWzFile().WzStructure.GetNode(DestPath) != null) + return (Node.GetNodeWzFile().WzStructure.GetNode(DestPath).Value as Wz_Png).ExtractPng(); } else { @@ -206,10 +209,8 @@ public static Bitmap ExtractPng2(this Wz_Node Node) return (Node.ResolveUol().Value as Wz_Png).ExtractPng(); else return (Node.Value as Wz_Png).ExtractPng(); - } - return null; } @@ -234,7 +235,7 @@ public static string ValueToStr(this Wz_Node Node) return Node.GetValueEx(""); } - + public static string RightStr(string s, int count) { if (count > s.Length) @@ -243,7 +244,7 @@ public static string RightStr(string s, int count) } - + } @@ -262,7 +263,7 @@ public static bool HasNode(this Wz_Structure Wz, string Path) } public static WzComparerR2.WzLib.Wz_Node.WzNodeCollection Nodes(this Wz_Structure Self) - { + { return Self.WzNode.Nodes; }