Added PsoTypes generated struct and enum infos, and new MetaNames

This commit is contained in:
dexy 2018-12-14 02:14:14 +11:00
parent 775bbe79a8
commit e7f5238c33
7 changed files with 15749 additions and 22 deletions

View File

@ -29,8 +29,8 @@ namespace CodeWalker.GameFiles
public CTimeCycleModifier[] CTimeCycleModifiers { get; set; }
public MetaHash[] physicsDictionaries { get; set; }
public Unk_975711773[] CBoxOccluders { get; set; }
public Unk_2741784237[] COccludeModels { get; set; }
public BoxOccluder[] CBoxOccluders { get; set; }
public OccludeModel[] COccludeModels { get; set; }
public string[] Strings { get; set; }
@ -435,7 +435,7 @@ namespace CodeWalker.GameFiles
private void EnsureBoxOccluders(Meta meta)
{
CBoxOccluders = MetaTypes.ConvertDataArray<Unk_975711773>(Meta, (MetaName)975711773, CMapData.boxOccluders);
CBoxOccluders = MetaTypes.ConvertDataArray<BoxOccluder>(Meta, MetaName.BoxOccluder, CMapData.boxOccluders);
if (CBoxOccluders != null)
{
BoxOccluders = new YmapBoxOccluder[CBoxOccluders.Length];
@ -448,7 +448,7 @@ namespace CodeWalker.GameFiles
private void EnsureOccludeModels(Meta meta)
{
COccludeModels = MetaTypes.ConvertDataArray<Unk_2741784237>(Meta, (MetaName)2741784237, CMapData.occludeModels);
COccludeModels = MetaTypes.ConvertDataArray<OccludeModel>(Meta, MetaName.OccludeModel, CMapData.occludeModels);
if (COccludeModels != null)
{
OccludeModels = new YmapOccludeModel[COccludeModels.Length];
@ -2214,13 +2214,13 @@ namespace CodeWalker.GameFiles
[TypeConverter(typeof(ExpandableObjectConverter))]
public class YmapOccludeModel
{
public Unk_2741784237 _OccludeModel;
public Unk_2741784237 OccludeModel { get { return _OccludeModel; } set { _OccludeModel = value; } }
public OccludeModel _OccludeModel;
public OccludeModel OccludeModel { get { return _OccludeModel; } set { _OccludeModel = value; } }
public YmapFile Ymap { get; set; }
public YmapOccludeModel(YmapFile ymap, Unk_2741784237 model)
public YmapOccludeModel(YmapFile ymap, OccludeModel model)
{
Ymap = ymap;
_OccludeModel = model;
@ -2230,12 +2230,12 @@ namespace CodeWalker.GameFiles
[TypeConverter(typeof(ExpandableObjectConverter))]
public class YmapBoxOccluder
{
public Unk_975711773 _Box;
public Unk_975711773 Box { get { return _Box; } set { _Box = value; } }
public BoxOccluder _Box;
public BoxOccluder Box { get { return _Box; } set { _Box = value; } }
public YmapFile Ymap { get; set; }
public YmapBoxOccluder(YmapFile ymap, Unk_975711773 box)
public YmapBoxOccluder(YmapFile ymap, BoxOccluder box)
{
Ymap = ymap;
_Box = box;

View File

@ -2,6 +2,7 @@
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
@ -166,6 +167,7 @@ namespace CodeWalker.GameFiles
//TestAudioYmts();
//TestMetas();
//TestPsos();
//TestYcds();
//TestYmaps();
//TestPlacements();
@ -2203,6 +2205,56 @@ namespace CodeWalker.GameFiles
string str = MetaTypes.GetTypesInitString();
}
public void TestPsos()
{
//find all PSO meta files and generate the PsoTypes init code
PsoTypes.Clear();
var exceptions = new List<Exception>();
var allpsos = new List<string>();
foreach (RpfFile file in AllRpfs)
{
foreach (RpfEntry entry in file.AllEntries)
{
try
{
var n = entry.NameLower;
var fentry = entry as RpfFileEntry;
var data = entry.File.ExtractFile(fentry); //kind of slow, but sure to catch all PSO files
if (data != null)
{
using (MemoryStream ms = new MemoryStream(data))
{
if (PsoFile.IsPSO(ms))
{
UpdateStatus(string.Format(entry.Path));
var pso = new PsoFile();
pso.Load(ms);
allpsos.Add(fentry.Path);
PsoTypes.EnsurePsoTypes(pso);
}
}
}
}
catch (Exception ex)
{
UpdateStatus("Error! " + ex.ToString());
exceptions.Add(ex);
}
}
}
string allpsopaths = string.Join("\r\n", allpsos);
string str = PsoTypes.GetTypesInitString();
if (!string.IsNullOrEmpty(str))
{
}
}
public void TestYcds()
{
foreach (RpfFile file in AllRpfs)

View File

@ -3293,9 +3293,9 @@ namespace CodeWalker.GameFiles
////SectionUNKNOWN2 = 1185771007, //CCompositeEntityType
//SectionUNKNOWN3 = 1980345114,
////SectionUNKNOWN4 = 2085051229,
//SectionUNKNOWN5 = 2741784237, //occludeModels
//SectionUNKNOWN5 = 2741784237, //OccludeModel
////SectionUNKNOWN6 = 3985044770,
//SectionUNKNOWN7 = 975711773, //boxOccluders
//SectionUNKNOWN7 = 975711773, //BoxOccluder
//SectionUNKNOWN8 = 3430328684,//0xCC76A96C,
VECTOR3 = 3805007828,//0xe2cbcfd4, //this hash isn't correct, but is used in CDistantLODLight
@ -3407,6 +3407,25 @@ namespace CodeWalker.GameFiles
CWanted__Tunables__WantedLevel = 4209402831,
AFF_AVERAGE = 2722191879,
AFF_RICH = 1119317219,
TS_HIGH = 956599249,
StdDoorOpenPosDir = 2885011506,
CDataFileMgr__DataFile = 4025199407,
CDataFileMgr__ContentChangeSet = 2958929574,
DataFileType = 3864419067,
DataFileContents = 655728054,
CONTENTS_DEFAULT = 507224223,
InstallPartition = 2685892631,
PARTITION_NONE = 3712881064,
ExecutionConditions = 1196731409,
ExecutionCondition = 2539760734,
CTxdRelationship = 3649202799,
child = 54445749,
LODLights = 1326371921,
BoxOccluder = 975711773,
OccludeModel = 2741784237,
@ -3535,6 +3554,13 @@ namespace CodeWalker.GameFiles
CClassNameOfItemType = 440716365, //array type for (PSO) MAP fields
zones = 2319609287,
spName = 4254542050,
CInteriorBoundsFiles = 741495440,
PortalIdx = 1061685079,
RoomIdx = 3136588885,
LinkType = 1812903871,
MaxOcclusion = 3034993422,
IsDoor = 474556907,
IsGlass = 1060358829,
//from rubidium / dav90 PSO XML / zonebind

View File

@ -629,9 +629,9 @@ namespace CodeWalker.GameFiles
new MetaStructureEntryInfo_s(MetaName.entities, 96, MetaStructureEntryDataType.Array, 0, 8, 0),
new MetaStructureEntryInfo_s(MetaName.ARRAYINFO, 0, MetaStructureEntryDataType.Structure, 0, 0, (MetaName)372253349),
new MetaStructureEntryInfo_s(MetaName.containerLods, 112, MetaStructureEntryDataType.Array, 0, 10, 0),
new MetaStructureEntryInfo_s(MetaName.ARRAYINFO, 0, MetaStructureEntryDataType.Structure, 0, 0, (MetaName)975711773),
new MetaStructureEntryInfo_s(MetaName.ARRAYINFO, 0, MetaStructureEntryDataType.Structure, 0, 0, MetaName.BoxOccluder),
new MetaStructureEntryInfo_s(MetaName.boxOccluders, 128, MetaStructureEntryDataType.Array, 4, 12, 0),
new MetaStructureEntryInfo_s(MetaName.ARRAYINFO, 0, MetaStructureEntryDataType.Structure, 0, 0, (MetaName)2741784237),
new MetaStructureEntryInfo_s(MetaName.ARRAYINFO, 0, MetaStructureEntryDataType.Structure, 0, 0, MetaName.OccludeModel),
new MetaStructureEntryInfo_s(MetaName.occludeModels, 144, MetaStructureEntryDataType.Array, 4, 14, 0),
new MetaStructureEntryInfo_s(MetaName.ARRAYINFO, 0, MetaStructureEntryDataType.Hash, 0, 0, 0),
new MetaStructureEntryInfo_s(MetaName.physicsDictionaries, 160, MetaStructureEntryDataType.Array, 0, 16, 0),
@ -776,8 +776,8 @@ namespace CodeWalker.GameFiles
new MetaStructureEntryInfo_s(MetaName.numExitPortals, 152, MetaStructureEntryDataType.UnsignedInt, 0, 0, 0),
new MetaStructureEntryInfo_s(MetaName.MLOInstflags, 156, MetaStructureEntryDataType.UnsignedInt, 0, 0, 0)
);
case (MetaName)975711773:
return new MetaStructureInfo((MetaName)975711773, 1831736438, 256, 16,
case MetaName.BoxOccluder:
return new MetaStructureInfo(MetaName.BoxOccluder, 1831736438, 256, 16,
new MetaStructureEntryInfo_s(MetaName.iCenterX, 0, MetaStructureEntryDataType.SignedShort, 0, 0, 0),
new MetaStructureEntryInfo_s(MetaName.iCenterY, 2, MetaStructureEntryDataType.SignedShort, 0, 0, 0),
new MetaStructureEntryInfo_s(MetaName.iCenterZ, 4, MetaStructureEntryDataType.SignedShort, 0, 0, 0),
@ -787,8 +787,8 @@ namespace CodeWalker.GameFiles
new MetaStructureEntryInfo_s(MetaName.iHeight, 12, MetaStructureEntryDataType.SignedShort, 0, 0, 0),
new MetaStructureEntryInfo_s(MetaName.iSinZ, 14, MetaStructureEntryDataType.SignedShort, 0, 0, 0)
);
case (MetaName)2741784237:
return new MetaStructureInfo((MetaName)2741784237, 1172796107, 1024, 64,
case MetaName.OccludeModel:
return new MetaStructureInfo(MetaName.OccludeModel, 1172796107, 1024, 64,
new MetaStructureEntryInfo_s(MetaName.bmin, 0, MetaStructureEntryDataType.Float_XYZ, 0, 0, 0),
new MetaStructureEntryInfo_s(MetaName.bmax, 16, MetaStructureEntryDataType.Float_XYZ, 0, 0, 0),
new MetaStructureEntryInfo_s(MetaName.dataSize, 32, MetaStructureEntryDataType.UnsignedInt, 0, 0, 0),
@ -2808,7 +2808,7 @@ namespace CodeWalker.GameFiles
}
}
[TC(typeof(EXP))] public struct Unk_975711773 //16 bytes, Key:1831736438 //boxOccluders
[TC(typeof(EXP))] public struct BoxOccluder //16 bytes, Key:1831736438 //boxOccluders
{
public short iCenterX { get; set; } //0 0: SignedShort: 0: 48026296
public short iCenterY { get; set; } //2 2: SignedShort: 0: 896907229
@ -2820,7 +2820,7 @@ namespace CodeWalker.GameFiles
public short iSinZ { get; set; } //14 14: SignedShort: 0: iSinZ
}
[TC(typeof(EXP))] public struct Unk_2741784237 //64 bytes, Key:1172796107 //occludeModels
[TC(typeof(EXP))] public struct OccludeModel //64 bytes, Key:1172796107 //occludeModels
{
public Vector3 bmin { get; set; } //0 0: Float_XYZ: 0: bmin
public float Unused0 { get; set; }//12

View File

@ -570,6 +570,23 @@ namespace CodeWalker.GameFiles
public uint Unk_Ch { get; set; } = 0x00000000;
public PsoStructureEntryInfo[] Entries { get; set; }
public PsoStructureInfo()
{ }
public PsoStructureInfo(MetaName nameHash, byte type, byte unk, int length, params PsoStructureEntryInfo[] entries)
{
IndexInfo = new PsoElementIndexInfo();
IndexInfo.NameHash = nameHash;
IndexInfo.Offset = 0; //todo: fix?
Type = type;
EntriesCount = (short)(entries?.Length ?? 0);
Unk = unk;
StructureLength = length;
Unk_Ch = 0;
Entries = entries;
}
public override void Read(DataReader reader)
{
uint x = reader.ReadUInt32();
@ -579,6 +596,9 @@ namespace CodeWalker.GameFiles
this.StructureLength = reader.ReadInt32();
this.Unk_Ch = reader.ReadUInt32();
if (Unk_Ch != 0)
{ }
Entries = new PsoStructureEntryInfo[EntriesCount];
for (int i = 0; i < EntriesCount; i++)
{
@ -639,6 +659,18 @@ namespace CodeWalker.GameFiles
public ushort DataOffset { get; set; }
public uint ReferenceKey { get; set; } // when array -> entry index with type
public PsoStructureEntryInfo()
{ }
public PsoStructureEntryInfo(MetaName nameHash, PsoDataType type, ushort offset, byte unk, MetaName refKey)
{
EntryNameHash = nameHash;
Type = type;
Unk_5h = unk;
DataOffset = offset;
ReferenceKey = (uint)refKey;
}
public void Read(DataReader reader)
{
this.EntryNameHash = (MetaName)reader.ReadUInt32();
@ -673,6 +705,19 @@ namespace CodeWalker.GameFiles
public int EntriesCount { get; private set; }
public PsoEnumEntryInfo[] Entries { get; set; }
public PsoEnumInfo()
{ }
public PsoEnumInfo(MetaName nameHash, byte type, params PsoEnumEntryInfo[] entries)
{
IndexInfo = new PsoElementIndexInfo();
IndexInfo.NameHash = nameHash;
IndexInfo.Offset = 0; //todo: fix?
EntriesCount = entries?.Length ?? 0;
Entries = entries;
}
public override void Read(DataReader reader)
{
uint x = reader.ReadUInt32();
@ -729,6 +774,15 @@ namespace CodeWalker.GameFiles
public MetaName EntryNameHash { get; set; }
public int EntryKey { get; set; }
public PsoEnumEntryInfo()
{ }
public PsoEnumEntryInfo(MetaName nameHash, int key)
{
EntryNameHash = nameHash;
EntryKey = key;
}
public void Read(DataReader reader)
{
this.EntryNameHash = (MetaName)reader.ReadUInt32();

File diff suppressed because it is too large Load Diff

View File

@ -547,13 +547,14 @@
//
// EntitySetsListBox
//
this.EntitySetsListBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
this.EntitySetsListBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.EntitySetsListBox.CheckOnClick = true;
this.EntitySetsListBox.FormattingEnabled = true;
this.EntitySetsListBox.Location = new System.Drawing.Point(11, 42);
this.EntitySetsListBox.Name = "EntitySetsListBox";
this.EntitySetsListBox.Size = new System.Drawing.Size(603, 214);
this.EntitySetsListBox.Size = new System.Drawing.Size(603, 319);
this.EntitySetsListBox.TabIndex = 2;
this.EntitySetsListBox.ItemCheck += new System.Windows.Forms.ItemCheckEventHandler(this.EntitySetsListBox_ItemCheck);
//