public object pod(wzpackage pack, string path) { if (pack == null) { return(null); } try { dynamic eo = new ExpandoObject(); var eoColl = (ICollection <KeyValuePair <string, object> >)eo; //foreach (var id in pack.identities) //{ // var i = pack[id]; foreach (var i in pack.values) { var p = this.pod(i, path + i.identity); eoColl.Add(new KeyValuePair <string, object>(i.identity, p)); } return(eo); } catch (Exception ex) { return("<Error: " + ex.Message + "\n" + ex.StackTrace + ">"); } return("<unknow error>"); }
internal components_object(XmlNode component, wzpackage package) { if (null != package) { if ("030" == component.Attributes["type"].Value) { package = package[component.Attributes["id"].Value.Substring(0, 4) + ".img"]; } else { package = package[component.Attributes["id"].Value + ".img"]; } } properties = new object[] { component.Attributes["type"].Value, component.Attributes["id"].Value, component.Attributes["name"].Value, component.Attributes["level"].Value, component.Attributes["gender"].Value, component.Attributes["cash"].Value, component.Attributes["job"].Value, new List <string>(component.Attributes["etc"].Value.Split(new char[] { ',', }, StringSplitOptions.RemoveEmptyEntries)), package, }; }
private wzpackage expand(wzpackage host) { for (int count = reader.unpack <int>(); count > 0; --count) { string identity; byte type = reader.read <byte>(); switch (type) { case 1: case 2: identity = reader.decrypt_string(header.size + 1 + reader.read <int>()); break; case 3: case 4: identity = reader.decrypt_string(); break; default: return(null); } host.append(identity, new wzpackage(identity, type, reader.unpack <int>(), reader.unpack <int>(), header.compute_offset(), host, reader)); } foreach (wzpackage package in host) { if (0 != package.type % 2) { if (null == expand(package)) { return(null); } } } return(host); }
public static bool Init(string iniFilePath) { try { DataSource.iniFile = new Ini.File(iniFilePath); readConfig(); if (DataSource.archives != null && DataSource.packages != null) { DataSource.writeLog("Already loaded"); return(false); } DataSource.archives = new wzarchives(DataSource.location + "\\" + "base.wz"); DataSource.packages = archives.root; DataSource.tag_version = DataSource.tag + "" + archives.version; Console.Write(DataSource.tag_version); Console.Write("> "); Console.Write(DataSource.archives.location); Console.Write("\n"); } catch (Exception ex) { DataSource.writeLog(ex.Message); DataSource.writeLog(ex.StackTrace); } return(true); }
public static void get_data(string link, out wzpackage outPack, out wzproperty outProp) { _get_data(link, out outPack, out outProp); if (outProp != null && outProp.type == 5) // UOL { outProp = (outProp.data as wzuol).target; } }
internal DataExtracter(string setting) { this.inspet = new Inspector_Base64(); if (setting != "no_string") { this.chara = DataSource.packages["Character"]; this.equip_names = DataSource.packages["String", "Eqp"].root[""]["Eqp"]; } }
public bool Load(string location) { string path = location + "\\" + "base.wz"; if (System.IO.File.Exists(path)) { this.archives = new wzarchives(location + "\\" + "base.wz"); this.packages = archives.root; return(true); } //System.Windows.Forms.MessageBox.Show("version: " + MInspect.archives.version, "version"); return(false); }
public static void Init(string iniFilePath) { DataSource.iniFile = new Ini.File(iniFilePath); readConfig(); if (DataSource.archives != null && DataSource.packages != null) { return; } DataSource.archives = new wzarchives(DataSource.location + "\\" + "base.wz"); DataSource.packages = archives.root; }
internal components_object(string id, components_object component, wzpackage package) { properties = new object[] { component.type, id, component.name, component.level.ToString(), component.gender.ToString(), component.cash.ToString(), component.job.ToString(), component.etc, package, }; }
public wzarchives(string location) { wzarchive archive = new wzarchive(location); wzpackage root = archive.root; input = location; packages = root; archives = new List <wzarchive> { archive, }; if (null != root) { string prefix = Path.GetDirectoryName(location) + "\\"; foreach (wzpackage element in root) { if (0 != element.type % 2 && 0 == element.count) { location = prefix + element.identity + ".wz"; if (File.Exists(location)) { archive = new wzarchive(location); root = archive.root; if (null != root) { foreach (wzpackage package in root) { package.parent = element; element.append(package.identity, package); } archives.Add(archive); } } } } } }
public wzarchives(string location) { wzarchive archive = new wzarchive(location); wzpackage root = archive.root; if (null != root) { string prefix = Path.GetDirectoryName(location) + "\\"; List <wzarchive> archives = new List <wzarchive>() { archive, }; properties = new object[] { root, archives, }; foreach (wzpackage property in root) { if (1 == property.type % 2 && 0 == property.count) { location = prefix + property.identity + ".wz"; if (File.Exists(location)) { archive = new wzarchive(location); root = archive.root; if (null != root) { foreach (wzpackage child in root) { child.host = property; property.append(child.identity, child); } archives.Add(archive); } } } } } }
//TODO: 解析包 internal components_objects(string location, XmlNode componentses, components_sources sources) { string[] entries = location.Split(new char[] { '\\', }, StringSplitOptions.RemoveEmptyEntries); for (int index = 0; index < componentses.ChildNodes.Count; ++index) { XmlNode components = componentses.ChildNodes[index]; if (entries[0] == components.Name) { wzpackage package = sources.exists(Path.GetFullPath(components.Attributes["location"].Value))[entries[0]]; for (int entry = 1; entry < entries.Length; ++entry) { components = components[entries[entry]]; if (null != package) { package = package[match_species(entries[entry])]; } } if (components != null) { foreach (XmlNode component in components) { if ("object" == component.Name) { string id = component.Attributes["id"].Value; if (!ContainsKey(id)) { Add(id, new components_object(component, package)); } } } } } } }
public static void get_data(string link, out wzpackage outPack, out wzproperty outProp) { try { DataSource._get_data(link, out outPack, out outProp); if (outPack == null && outProp == null) { throw new Exception(); } return; } catch (Exception) { try { var p = link.Split('/'); p[0] += "2"; link = String.Join("/", p); DataSource._get_data(link, out outPack, out outProp); if (outPack == null && outProp == null) { throw new Exception(); } return; //System.Windows.Forms.MessageBox.Show(link, "2"); } catch (Exception ex) { outPack = null; outProp = null; //System.Windows.Forms.MessageBox.Show(link + "\n" + ex.Message + "\n" + ex.StackTrace); Console.WriteLine("Can not get: " + link); Console.WriteLine(" ? " + ex.Message); Console.WriteLine(" ? " + ex.StackTrace); return; } } }
protected static void _get_data(string link, out wzpackage outPack, out wzproperty outProp) { int index = link.IndexOf(".img/"); if (0 <= index) { if (!link.EndsWith(".img/")) { outProp = DataSource._get_property(DataSource.packages[link.Substring(0, index + 4).Split('/')].root[""], link.Substring(index + 5).Split('/'), 0); outPack = null; return; //return MInspect.packages[link.Substring(0, index + 4).Split('/')].root[""][link.Substring(index + 5).Split('/')]; } else { try { outProp = DataSource.packages[link.Substring(0, index + 4).Split('/')].root[""]; outPack = null; return; } catch (Exception) { outProp = null; outPack = DataSource.packages[link.Substring(0, index + 4).Split('/')]; return; } } } else { outProp = null; outPack = DataSource.packages[link.Split('/')]; return; } }
private static void _get_data(string[] sections, ref wzpackage outPack, ref wzproperty outProp) { // find package int index = 1; if (sections.Length != 1) { for (; index < sections.Length; ++index) { var section = sections[index]; if (outPack.identities.Contains(section)) { outPack = outPack.values[outPack.identities.IndexOf(section)]; } else if (outPack.root != null && (outProp = outPack.root[""]) != null) { outPack = null; break; } else { outPack = null; outProp = null; return; } } } // find property if (outProp == null) { if (outPack.root != null && (outProp = outPack.root[""]) != null) { outPack = null; return; } } else { for (; index < sections.Length; ++index) { var section = sections[index]; if (outProp.identities.Contains(section)) { outProp = outProp.values[outProp.identities.IndexOf(section)]; } else { outPack = null; outProp = null; return; } } } if (index < sections.Length) { outPack = null; outProp = null; return; } }
private static void _get_data(string link, out wzpackage outPack, out wzproperty outProp) { try { string[] sections = link.Split('/'); wzpackage pack = DataSource.packages[sections[0]]; wzproperty prop = null; // find archive if (pack != null) { _get_data(sections, ref pack, ref prop); } if (pack == null && prop == null) { var name = sections[0]; for (int i = 1; i <= 2; ++i) { if ((pack = DataSource.packages[name + (i + 1)]) != null) { _get_data(sections, ref pack, ref prop); if (pack != null || prop != null) { outPack = pack; outProp = prop; return; } } if ((pack = DataSource.packages[name + i.ToString("000")]) != null) { _get_data(sections, ref pack, ref prop); if (pack != null || prop != null) { outPack = pack; outProp = prop; return; } } } } else { outPack = pack; outProp = prop; return; } outPack = null; outProp = null; throw new Exception("Not found package or property: " + link); } catch (Exception ex) { outPack = null; outProp = null; //System.Windows.Forms.MessageBox.Show(link + "\n" + ex.Message + "\n" + ex.StackTrace); DataSource.writeLog("can not get: " + link); DataSource.writeLog(" ? " + ex.Message); DataSource.writeLog(" ? " + ex.StackTrace); return; } }
//public static object get_by_path(string fullpath) //{ // var paths = fullpath.Split('/'); // // if (paths.Length > 0) // { // wzpackage pack = DataProvider.packages[paths[0]]; // // for (var i = 1; i < paths.Length; ++i) // { // var name = paths[i]; // pack[name]. // } // } // else // { // return DataProvider.packages[fullpath]; // } //} public static void get_data(string link, out wzpackage outPack) { wzproperty prop; DataSource.get_data(link, out outPack, out prop); }
public wzarchives(string location) { wzarchive archive = new wzarchive(location); wzpackage root = archive.root; input = location; packages = root; archives = new List <wzarchive> { archive, }; if (null != root) { string prefix = Path.GetDirectoryName(location) + Path.DirectorySeparatorChar; string[] fmts = new string[] { "0", "000" }; foreach (wzpackage element in root) { if (0 != element.type % 2 && 0 == element.count) { //Map += Map001 for (var i = 0; i < 2; ++i) { var num = i == 0 ? "" : i.ToString(fmts[1]); location = prefix + element.identity + num + ".wz"; if (File.Exists(location)) { archive = new wzarchive(location); root = archive.root; if (null != root) { foreach (wzpackage package in root) { package.parent = element; if (element.identities.Contains(package.identity)) { element[package.identity].merge(package); } else { element.append(package.identity, package); } } archives.Add(archive); } } } } } ////Map += Map2 //Regex rgx = new Regex(@"([A-Za-z]+)(\d+)"); //foreach (wzpackage package in this.root) //{ // Match m = rgx.Match(package.identity); // if (m.Success) // { // string identity = m.Groups[1].Value; // // this.root[identity].merge(package); // } //} } }