public static List <Property> getPropList(PCCPackage pcc, PCCPackage.ExportEntry export) { Application.DoEvents(); int start = detectStart(pcc, export.Data, (uint)export.ObjectFlags); return(ReadProp(pcc, export.Data, start)); }
private void button2_Click(object sender, EventArgs e) { int n = listBox5.SelectedIndex; if (n == -1) return; PCCPackage.ExportEntry ex = importpcc.Exports[n]; PCCPackage.ExportEntry nex = new PCCPackage.ExportEntry(); byte[] idata = importpcc.GetObjectData(n); List <PropertyReader.Property> Props = PropertyReader.getPropList(importpcc, idata); int start = PropertyReader.detectStart(importpcc, idata, (uint)importpcc.Exports[n].ObjectFlags); int end = start; if (Props.Count == 0) { DialogResult dialogResult = MessageBox.Show("This object contains no properties! Still import as binary data?", "No Properties", MessageBoxButtons.YesNo); if (dialogResult == System.Windows.Forms.DialogResult.No) { RefreshAll(); return; } } else { end = Props[Props.Count - 1].offend; if (end < idata.Length) { int diff = idata.Length - end; DialogResult dialogResult = MessageBox.Show("This object contains " + diff + " bytes of binary data after the properties! Still continue to import binary data aswell?", "Binary data", MessageBoxButtons.YesNo); if (dialogResult == System.Windows.Forms.DialogResult.No) { RefreshAll(); return; } } } MemoryStream res = new MemoryStream(); if (((uint)importpcc.Exports[n].ObjectFlags & 0x02000000) != 0) { byte[] stackdummy = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, //Lets hope for the best :D 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00,}; res.Write(stackdummy, 0, stackdummy.Length); } else { res.Write(new byte[start], 0, start); } uint namecount = pcc.Header.NameCount; try { foreach (PropertyReader.Property p in Props) { ImportProperty(pcc, importpcc, p, res); } } catch (Exception exe) { List<string> temp = new List<string>(); for (int i = 0; i < namecount; i++) temp.Add(pcc.Names[i]); pcc.Names = temp; pcc.Header.NameCount = namecount; MessageBox.Show("Error occured while trying to importing : " + exe.Message); } for (int i = end; i < idata.Length; i++) res.WriteByte(idata[i]); nex.DataLoaded = true; nex.Data = res.ToArray(); nex.Datasize = nex.Data.Length; nex.Unk1 = ex.Unk1; nex.Unk2 = ex.Unk2; nex.Unk3 = new int[ex.Unk3.Length]; for (int i = 0; i < ex.Unk3.Length; i++) nex.Unk3[i] = ex.Unk3[i]; nex.Unk4 = ex.Unk4; nex.Unk5 = ex.Unk5; nex.Unk6 = ex.Unk6; nex.Unk7 = ex.Unk7; nex.Unk8 = ex.Unk8; nex.ObjectFlags = ex.ObjectFlags; nex.Index = ex.Index; nex.idxName = pcc.FindNameOrAdd(importpcc.GetName(ex.idxName)); nex.idxArchetype = nex.idxClass = nex.idxLink = nex.idxParent = 0; pcc.Exports.Add(nex); pcc.Header.ExportCount++; RefreshAll(); MessageBox.Show("Done."); }
private void button7_Click(object sender, EventArgs ea) { int n = listBox7.SelectedIndex; if (pcc == null || n == -1 || importudk == null) return; PCCPackage.ExportEntry e; bool overwrite = toolStripComboBox2.SelectedIndex == 1; int i = 0; if(overwrite) { if (Int32.TryParse(toolStripTextBox1.Text, out i)) { e = pcc.Exports[i]; } else return; } else e = new PCCPackage.ExportEntry(); UDKObject.ExportEntry im = importudk.Exports[Objects[n]]; e.idxArchetype = 0; if (!overwrite) { e.idxLink = 0; e.idxName = pcc.FindNameOrAdd(importudk.GetName(im.name)); } e.idxParent = 0; e.idxClass = pcc.FindClass("StaticMesh"); e.ObjectFlags = 0x000F0004; e.Unk2 = 1; e.Unk3 = new int[0]; MemoryStream m = new MemoryStream(); CopySTMfromUDK(m, importudk, Objects[n]); e.Data = m.ToArray(); e.DataLoaded = true; e.Datasize = e.Data.Length; if (overwrite) pcc.Exports[i] = e; else { pcc.Exports.Add(e); pcc.Header.ExportCount++; } listBox7.Items.Clear(); richTextBox1.Text = ""; importudk = null; RefreshAll(); MessageBox.Show("Done"); }
public static byte[] getDefaultClassValue(PCCPackage pcc, string className, bool fullProps = false) { if (Structs.ContainsKey(className)) { bool isImmutable = ImmutableStructs.Contains(className); ClassInfo info = Structs[className]; PCCPackage importPCC = new PCCPackage(Path.Combine(ME3Directory.gamePath, @"BIOGame\" + info.pccPath)); byte[] buff; //Plane and CoverReference inherit from other structs, meaning they don't have default values (who knows why) //thus, I have hardcoded what those default values should be if (className == "Plane") { buff = PlaneDefault; } else if (className == "CoverReference") { buff = CoverReferenceDefault; } else { buff = importPCC.Exports[info.exportIndex].Data.Skip(0x24).ToArray(); } List <PropertyReader.Property> Props = PropertyReader.ReadProp(importPCC, buff, 0); MemoryStream m = new MemoryStream(); foreach (PropertyReader.Property p in Props) { string propName = importPCC.GetName(p.Name); //check if property is transient, if so, skip (neither of the structs that inherit have transient props) if (info.properties.ContainsKey(propName) || propName == "None" || info.baseClass != "Class") { if (isImmutable && !fullProps) { PropertyReader.ImportImmutableProperty(pcc, importPCC, p, className, m, true); } else { PropertyReader.ImportProperty(pcc, importPCC, p, className, m, true); } } } importPCC.Source.Close(); return(m.ToArray()); } else if (Classes.ContainsKey(className)) { ClassInfo info = Structs[className]; PCCPackage importPCC = new PCCPackage(Path.Combine(ME3Directory.gamePath, @"BIOGame\" + info.pccPath)); PCCPackage.ExportEntry entry = pcc.Exports[info.exportIndex + 1]; List <PropertyReader.Property> Props = PropertyReader.getPropList(importPCC, entry); MemoryStream m = new MemoryStream(entry.Datasize - 4); foreach (PropertyReader.Property p in Props) { if (!info.properties.ContainsKey(importPCC.GetName(p.Name))) { //property is transient continue; } PropertyReader.ImportProperty(pcc, importPCC, p, className, m); } return(m.ToArray()); } return(null); }