mirror of
https://github.com/simtactics/mysimulation.git
synced 2025-07-16 11:06:44 -04:00
Added FSO.Files for use with the API server
Don't ask me. FreeSO is the prime example of dependency hell.
This commit is contained in:
parent
4b5e584eeb
commit
8fec258215
104 changed files with 14653 additions and 163 deletions
79
server/tso.files/Formats/IFF/Chunks/TPRP.cs
Executable file
79
server/tso.files/Formats/IFF/Chunks/TPRP.cs
Executable file
|
@ -0,0 +1,79 @@
|
|||
using FSO.Files.Utils;
|
||||
using System.IO;
|
||||
|
||||
namespace FSO.Files.Formats.IFF.Chunks
|
||||
{
|
||||
/// <summary>
|
||||
/// Labels for BHAV local variables and parameters.
|
||||
/// </summary>
|
||||
public class TPRP : IffChunk
|
||||
{
|
||||
public string[] ParamNames;
|
||||
public string[] LocalNames;
|
||||
|
||||
/// <summary>
|
||||
/// Reads a TPRP from a stream.
|
||||
/// </summary>
|
||||
/// <param name="iff">Iff instance.</param>
|
||||
/// <param name="stream">A Stream instance holding a TPRP chunk.</param>
|
||||
public override void Read(IffFile iff, System.IO.Stream stream)
|
||||
{
|
||||
using (var io = IoBuffer.FromStream(stream, ByteOrder.LITTLE_ENDIAN))
|
||||
{
|
||||
var zero = io.ReadInt32();
|
||||
var version = io.ReadInt32();
|
||||
var name = io.ReadCString(4); //"PRPT", or randomly 4 null characters for no good reason
|
||||
|
||||
var pCount = io.ReadInt32();
|
||||
var lCount = io.ReadInt32();
|
||||
ParamNames = new string[pCount];
|
||||
LocalNames = new string[lCount];
|
||||
for (int i = 0; i < pCount; i++)
|
||||
{
|
||||
ParamNames[i] = (version == 5) ? io.ReadPascalString() : io.ReadNullTerminatedString();
|
||||
}
|
||||
for (int i = 0; i < lCount; i++)
|
||||
{
|
||||
LocalNames[i] = (version == 5) ? io.ReadPascalString() : io.ReadNullTerminatedString();
|
||||
}
|
||||
|
||||
for (int i = 0; i < pCount; i++)
|
||||
{
|
||||
//flags for parameters. probably disabled, unused, etc.
|
||||
var flag = io.ReadByte();
|
||||
}
|
||||
|
||||
//what are these?
|
||||
if (version >= 3)
|
||||
io.ReadInt32();
|
||||
if (version >= 4)
|
||||
io.ReadInt32();
|
||||
}
|
||||
}
|
||||
|
||||
public override bool Write(IffFile iff, Stream stream)
|
||||
{
|
||||
using (var io = IoWriter.FromStream(stream, ByteOrder.LITTLE_ENDIAN))
|
||||
{
|
||||
io.WriteInt32(0);
|
||||
io.WriteInt32(5); //version
|
||||
io.WriteCString("PRPT", 4);
|
||||
io.WriteInt32(ParamNames.Length);
|
||||
io.WriteInt32(LocalNames.Length);
|
||||
foreach (var param in ParamNames)
|
||||
io.WritePascalString(param);
|
||||
foreach (var local in LocalNames)
|
||||
io.WritePascalString(local);
|
||||
|
||||
for (int i=0; i<ParamNames.Length; i++)
|
||||
{
|
||||
io.WriteByte(0);
|
||||
}
|
||||
|
||||
io.WriteInt32(0);
|
||||
io.WriteInt32(0);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue