Skip to content

Commit

Permalink
Beatles venue support, more backwards compatibility fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ihatecompvir committed Jan 10, 2025
1 parent 8c81937 commit 17aabb8
Show file tree
Hide file tree
Showing 9 changed files with 343 additions and 81 deletions.
8 changes: 6 additions & 2 deletions MiloLib/Assets/Char/Character.cs
Original file line number Diff line number Diff line change
Expand Up @@ -364,9 +364,13 @@ public Character Read(EndianReader reader, bool standalone, DirectoryMeta parent

if (revision > 0x10)
translucentGroup = Symbol.Read(reader);
}

charTest = new CharacterTesting().Read(reader, parent, entry);
charTest = new CharacterTesting().Read(reader, parent, entry);
}
else if (revision > 0xF)
{
charTest = new CharacterTesting().Read(reader, parent, entry);
}

if (standalone)
if ((reader.Endianness == Endian.BigEndian ? 0xADDEADDE : 0xDEADDEAD) != reader.ReadUInt32()) throw new Exception("Got to end of standalone asset but didn't find the expected end bytes, read likely did not succeed");
Expand Down
86 changes: 51 additions & 35 deletions MiloLib/Assets/DirectoryMeta.cs
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,12 @@ public DirectoryMeta Read(EndianReader reader)
pitchArrowDir.Read(reader, true, this, new Entry(type, name, pitchArrowDir));
directory = pitchArrowDir;
break;
case "SynthDir":
Debug.WriteLine("Reading SynthDir " + name.value);
SynthDir synthDir = new SynthDir(0);
synthDir.Read(reader, true, this, new Entry(type, name, synthDir));
directory = synthDir;
break;
case "":
Debug.WriteLine("GH1-style empty directory detected, just reading children");
break;
Expand Down Expand Up @@ -488,6 +494,9 @@ public void Write(EndianWriter writer)
case "StreakMeterDir":
((StreakMeterDir)directory).Write(writer, true, this, new Entry(type, name, directory));
break;
case "SynthDir":
((SynthDir)directory).Write(writer, true, this, new Entry(type, name, directory));
break;
//case "VocalTrackDir":
// ((VocalTrackDir)directory).Write(writer, true, this, new Entry(type, name, directory));
// break;
Expand Down Expand Up @@ -602,7 +611,7 @@ public void ReadEntry(EndianReader reader, DirectoryMeta.Entry entry)
entry.isProxy = true;
entry.obj = new RndDir(0).Read(reader, true, this, entry);

if (((ObjectDir)entry.obj).inlineProxy)
if (((ObjectDir)entry.obj).inlineProxy && ((ObjectDir)entry.obj).proxyPath.value != "")
{
dir = new DirectoryMeta();
dir.platform = platform;
Expand Down Expand Up @@ -706,6 +715,16 @@ public void ReadEntry(EndianReader reader, DirectoryMeta.Entry entry)
entry.isProxy = true;
entry.obj = new StreakMeterDir(0).Read(reader, true, this, entry);

dir = new DirectoryMeta();
dir.platform = platform;
dir.Read(reader);
entry.dir = dir;
break;
case "SynthDir":
Debug.WriteLine("Reading entry SynthDir " + entry.name.value);
entry.isProxy = true;
entry.obj = new SynthDir(0).Read(reader, true, this, entry);

dir = new DirectoryMeta();
dir.platform = platform;
dir.Read(reader);
Expand Down Expand Up @@ -795,14 +814,24 @@ public void ReadEntry(EndianReader reader, DirectoryMeta.Entry entry)
dir.Read(reader);
entry.dir = dir;

if (((WorldInstance)dir.directory).hasPersistentObjects)
// these can be followed by a Character or other dirs...wtf
// if it is another dir it seems to allows be followed by persistentobjects
if (entry.dir != null && entry.dir.type.value == "WorldInstance")
{
((WorldInstance)dir.directory).persistentObjects = new WorldInstance.PersistentObjects().Read(reader, this, entry);
if (((WorldInstance)dir.directory).hasPersistentObjects)
{
((WorldInstance)dir.directory).persistentObjects = new WorldInstance.PersistentObjects().Read(reader, this, entry, ((WorldInstance)entry.obj).revision);
}
}
else
{
// hack
((WorldInstance)entry.obj).persistentObjects = new WorldInstance.PersistentObjects().Read(reader, this, entry, ((WorldInstance)entry.obj).revision);
}
}
else
{
((WorldInstance)entry.obj).persistentObjects = new WorldInstance.PersistentObjects().Read(reader, this, entry);
((WorldInstance)entry.obj).persistentObjects = new WorldInstance.PersistentObjects().Read(reader, this, entry, ((WorldInstance)entry.obj).revision);
}
break;

Expand Down Expand Up @@ -1144,6 +1173,11 @@ public void WriteEntry(EndianWriter writer, DirectoryMeta.Entry entry)
entry.isProxy = false;
entry.dir.Write(writer);
break;
case "SynthDir":
((SynthDir)entry.obj).Write(writer, true, this, entry);
entry.isProxy = false;
entry.dir.Write(writer);
break;
case "TrackDir":
((TrackDir)entry.obj).Write(writer, true, this, entry);
entry.isProxy = false;
Expand Down Expand Up @@ -1189,45 +1223,27 @@ public void WriteEntry(EndianWriter writer, DirectoryMeta.Entry entry)
// Write the directory
entry.dir.Write(writer);

if (((WorldInstance)entry.dir.directory).hasPersistentObjects)
if (entry.dir.type.value == "WorldInstance")
{
// Write the persistent perObjs
((WorldInstance)entry.dir.directory).persistentObjects.Write(writer, this, entry);
if (((WorldInstance)entry.dir.directory).hasPersistentObjects)
{
// Write the persistent perObjs
((WorldInstance)entry.dir.directory).persistentObjects.Write(writer, this, entry, ((WorldInstance)entry.obj).revision);
}
}
else
{
// write the persistent objects we stored in the obj
// this is a dumb hack but prevents need to adapt the API to allow mixes like that
((WorldInstance)entry.obj).persistentObjects.Write(writer, this, entry, ((WorldInstance)entry.obj).revision);
}
}
else
{
// Write the persistent perObjs
((WorldInstance)entry.obj).persistentObjects.Write(writer, this, entry);
((WorldInstance)entry.obj).persistentObjects.Write(writer, this, entry, ((WorldInstance)entry.obj).revision);
}

//ase "WorldInstance":
// Debug.WriteLine("Reading entry WorldInstance " + entry.name.value);
// entry.isProxy = true;
//
// entry.obj = new WorldInstance(0).Read(reader, true, this, entry);
//
// // if the world instance has no persistent perObjs, it will have a dir as expected, otherwise it won't
// if (!((WorldInstance)entry.obj).hasPersistentObjects)
// {
// dir = new DirectoryMeta();
// dir.platform = platform;
// dir.Read(reader);
// entry.dir = dir;
//
// if (((WorldInstance)dir.directory).hasPersistentObjects)
// {
// ((WorldInstance)dir.directory).perObjs = new WorldInstance.PersistentObjects().Read(reader, this, entry);
// }
// }
// else
// {
// ((WorldInstance)entry.obj).perObjs = new WorldInstance.PersistentObjects().Read(reader, this, entry);
// }
//
//
// break;


break;

Expand Down
40 changes: 40 additions & 0 deletions MiloLib/Assets/EventTrigger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,10 @@ public void Write(EndianWriter writer)
public List<Symbol> partLaunchers = new();


private uint drawsCount;
public List<Symbol> draws = new();


public EventTrigger Read(EndianReader reader, bool standalone, DirectoryMeta parent, DirectoryMeta.Entry entry)
{
uint combinedRevision = reader.ReadUInt32();
Expand Down Expand Up @@ -212,6 +216,25 @@ public EventTrigger Read(EndianReader reader, bool standalone, DirectoryMeta par
hideDelays.Add(hideDelay);
}
}
else if (revision > 8)
{
hideDelaysCount = reader.ReadUInt32();
for (int i = 0; i < hideDelaysCount; i++)
{
HideDelay hideDelay = new();
hideDelay.hide = Symbol.Read(reader);
hideDelay.delay = reader.ReadFloat();
hideDelays.Add(hideDelay);
}
}
else if (revision > 6)
{
drawsCount = reader.ReadUInt32();
for (int i = 0; i < drawsCount; i++)
{
draws.Add(Symbol.Read(reader));
}
}

if (revision > 2)
{
Expand Down Expand Up @@ -339,6 +362,23 @@ public override void Write(EndianWriter writer, bool standalone, DirectoryMeta p
hideDelay.Write(writer);
}
}
else if (revision > 8)
{
writer.WriteUInt32((uint)hideDelays.Count);
foreach (var hideDelay in hideDelays)
{
Symbol.Write(writer, hideDelay.hide);
writer.WriteFloat(hideDelay.delay);
}
}
else if (revision > 6)
{
writer.WriteUInt32((uint)draws.Count);
foreach (var draw in draws)
{
Symbol.Write(writer, draw);
}
}

if (revision > 2)
{
Expand Down
16 changes: 12 additions & 4 deletions MiloLib/Assets/ObjectDir.cs
Original file line number Diff line number Diff line change
Expand Up @@ -254,9 +254,13 @@ public ObjectDir Read(EndianReader reader, bool standalone, DirectoryMeta parent
{
DirectoryMeta inlinedSubDir = new DirectoryMeta();
inlinedSubDir.platform = parent.platform;
if (referenceTypes[0] == ReferenceType.kInlineCached && referenceTypesAlt[0] == ReferenceType.kInlineCached)
// check if the reference types are actually there to avoid an out of bounds exception
if (referenceTypes.Count > 0 && referenceTypesAlt.Count > 0)
{
reader.ReadBoolean();
if (referenceTypes[0] == ReferenceType.kInlineCached && referenceTypesAlt[0] == ReferenceType.kInlineCached)
{
reader.ReadBoolean();
}
}
inlinedSubDir.Read(reader);
inlineSubDirs.Add(inlinedSubDir);
Expand Down Expand Up @@ -412,9 +416,13 @@ public override void Write(EndianWriter writer, bool standalone, DirectoryMeta p

foreach (var inlineSubDir in inlineSubDirs)
{
if (referenceTypes[0] == ReferenceType.kInlineCached && referenceTypesAlt[0] == ReferenceType.kInlineCached)
// bounds check
if (referenceTypes.Count > 0 && referenceTypesAlt.Count > 0)
{
writer.WriteBoolean(false);
if (referenceTypes[0] == ReferenceType.kInlineCached && referenceTypesAlt[0] == ReferenceType.kInlineCached)
{
writer.WriteBoolean(false);
}
}
inlineSubDir.Write(writer);
}
Expand Down
67 changes: 65 additions & 2 deletions MiloLib/Assets/Rnd/RndParticleSys.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,45 @@ namespace MiloLib.Assets.Rnd
[Name("RndParticleSys"), Description("A particle system")]
public class RndParticleSys : Object
{
public class PreservedParticle
{
public float unk1;
public float unk2;
public float unk3;
public float unk4;
public float unk5;
public float unk6;
public float unk7;
public float unk8;
public float unk9;

public PreservedParticle Read(EndianReader reader)
{
unk1 = reader.ReadFloat();
unk2 = reader.ReadFloat();
unk3 = reader.ReadFloat();
unk4 = reader.ReadFloat();
unk5 = reader.ReadFloat();
unk6 = reader.ReadFloat();
unk7 = reader.ReadFloat();
unk8 = reader.ReadFloat();
unk9 = reader.ReadFloat();
return this;
}

public void Write(EndianWriter writer)
{
writer.WriteFloat(unk1);
writer.WriteFloat(unk2);
writer.WriteFloat(unk3);
writer.WriteFloat(unk4);
writer.WriteFloat(unk5);
writer.WriteFloat(unk6);
writer.WriteFloat(unk7);
writer.WriteFloat(unk8);
writer.WriteFloat(unk9);
}
}
private ushort altRevision;
private ushort revision;

Expand Down Expand Up @@ -161,6 +200,9 @@ public class RndParticleSys : Object
[Name("Preserve Particles"), Description("Enable/disable particle perservation"), MinVersion(11)]
public bool preserveParticles;

private uint preservedParticlesCount;
private List<PreservedParticle> preservedParticles = new();

public RndParticleSys Read(EndianReader reader, bool standalone, DirectoryMeta parent, DirectoryMeta.Entry entry)
{
uint combinedRevision = reader.ReadUInt32();
Expand Down Expand Up @@ -306,8 +348,18 @@ public RndParticleSys Read(EndianReader reader, bool standalone, DirectoryMeta p
if (!(revision < 29))
fastForward = reader.ReadBoolean();

if (!(revision < 11))
if (10 < revision)
{
preserveParticles = reader.ReadBoolean();
if (preserveParticles)
{
preservedParticlesCount = reader.ReadUInt32();
for (int i = 0; i < preservedParticlesCount; i++)
{
preservedParticles.Add(new PreservedParticle().Read(reader));
}
}
}

if (standalone)
if ((reader.Endianness == Endian.BigEndian ? 0xADDEADDE : 0xDEADDEAD) != reader.ReadUInt32()) throw new Exception("Got to end of standalone asset but didn't find the expected end bytes, read likely did not succeed");
Expand Down Expand Up @@ -453,8 +505,19 @@ public override void Write(EndianWriter writer, bool standalone, DirectoryMeta p
if (!(revision < 29))
writer.WriteBoolean(fastForward);

if (!(revision < 11))
if (10 < revision)
{
writer.WriteBoolean(preserveParticles);
if (preserveParticles)
{
writer.WriteUInt32(preservedParticlesCount);
foreach (var particle in preservedParticles)
{
particle.Write(writer);
}
}
}


if (standalone)
writer.WriteBlock(new byte[4] { 0xAD, 0xDE, 0xAD, 0xDE });
Expand Down
Loading

0 comments on commit 17aabb8

Please sign in to comment.