Commit 1790e394 authored by Spencer Alves's avatar Spencer Alves

"Probably1" is the number of function parameters, listed functionLocals.

With that, CODE/VARI/FUNC is pretty much complete.
parent 935d5f11
......@@ -394,7 +394,7 @@ namespace Altar
{
public uint Name;
public uint Length;
public uint Probably1;
public uint ArgumentCount;
public int BytecodeOffset;
uint Probably0;
}
......
......@@ -814,6 +814,18 @@ namespace Altar.Repack
f.Code[i] = DeserializeCodeFromFile(Path.Combine(baseDir, (string)(code[i])), f.General.BytecodeVersion,
stringIndices, objectIndices);
f.Code[i].Name = Path.GetFileNameWithoutExtension(Path.GetFileNameWithoutExtension((string)(code[i])));
f.Code[i].ArgumentCount = 1;
if (f.FunctionLocals != null)
{
for (int j = 0; j < f.FunctionLocals.Length; j++)
{
int fastIndex = (j + i) % f.FunctionLocals.Length;
if (f.FunctionLocals[fastIndex].FunctionName == f.Code[i].Name)
{
f.Code[i].ArgumentCount = f.FunctionLocals[fastIndex].LocalNames.Length;
}
}
}
}
}
if (projFile.Has("sounds"))
......
......@@ -1063,13 +1063,13 @@ namespace Altar.Repack
private static void WriteCodeInfo(BBData data, CodeInfo ci, IDictionary<string, int> stringOffsets, uint bytecodeVersion)
{
data.Buffer.Write(stringOffsets[ci.Name]);
data.Buffer.Write(ci.Size);
data.Buffer.Write(stringOffsets[ci.Name]); // Name
data.Buffer.Write(ci.Size); // Length
if (bytecodeVersion > 0xE)
{
data.Buffer.Write(1);
data.Buffer.Write(0);
data.Buffer.Write(0);
data.Buffer.Write(ci.ArgumentCount); // ArgumentCount
data.Buffer.Write(0); // BytecodeOffset
data.Buffer.Write(0); // pad
}
else
{
......
......@@ -200,6 +200,7 @@ namespace Altar
public string Name;
public AnyInstruction*[] Instructions;
public int Size;
internal int ArgumentCount;
internal AnyInstruction[] InstructionsCopy; // I ain't dealin' with no pointers
// (TODO: don't use pointers)
internal IList<Tuple<ReferenceSignature, uint>> functionReferences;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment