diff --git a/MapleLib/WzLib/WzProperties/WzCanvasProperty.cs b/MapleLib/WzLib/WzProperties/WzCanvasProperty.cs index 4947712e..bd801793 100644 --- a/MapleLib/WzLib/WzProperties/WzCanvasProperty.cs +++ b/MapleLib/WzLib/WzProperties/WzCanvasProperty.cs @@ -19,6 +19,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the using MapleLib.WzLib.Util; using System; using System.Drawing; +using System.Text.RegularExpressions; namespace MapleLib.WzLib.WzProperties { @@ -323,9 +324,22 @@ public WzImageProperty GetLinkedWzImageProperty() { if (!(currentWzObj is WzDirectory)) // keep looping if its not a WzImage continue; - WzFile wzFileParent = ((WzDirectory)currentWzObj).wzFile; - WzObject foundProperty = wzFileParent.GetObjectFromPath(_outlink); + Match match = Regex.Match(wzFileParent.Name, @"^([A-Za-z]+)([0-9]*).wz"); + + string prefixWz = match.Groups[1].Value + "/"; // remove ended numbers and .wz from wzfile name + + WzObject foundProperty; + + if (_outlink.StartsWith(prefixWz)) + { + // fixed root path + string realpath = _outlink.Replace(prefixWz, WzFileParent.Name.Replace(".wz", "") + "/"); + foundProperty = wzFileParent.GetObjectFromPath(realpath); + } else + { + foundProperty = wzFileParent.GetObjectFromPath(_outlink); + } if (foundProperty != null && foundProperty is WzImageProperty property) { return property;