mirror of
https://github.com/simtactics/mysimulation.git
synced 2025-07-19 12:34:53 -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
50
server/tso.files/Formats/IFF/Chunks/BCON.cs
Executable file
50
server/tso.files/Formats/IFF/Chunks/BCON.cs
Executable file
|
@ -0,0 +1,50 @@
|
|||
using System.IO;
|
||||
using FSO.Files.Utils;
|
||||
|
||||
namespace FSO.Files.Formats.IFF.Chunks
|
||||
{
|
||||
/// <summary>
|
||||
/// This chunk type holds a number of constants that behavior code can refer to.
|
||||
/// Labels may be provided for them in a TRCN chunk with the same ID.
|
||||
/// </summary>
|
||||
public class BCON : IffChunk
|
||||
{
|
||||
public byte Flags;
|
||||
public ushort[] Constants = new ushort[0];
|
||||
|
||||
/// <summary>
|
||||
/// Reads a BCON chunk from a stream.
|
||||
/// </summary>
|
||||
/// <param name="iff">An Iff instance.</param>
|
||||
/// <param name="stream">A Stream instance holding a BCON.</param>
|
||||
public override void Read(IffFile iff, Stream stream)
|
||||
{
|
||||
using (var io = IoBuffer.FromStream(stream, ByteOrder.LITTLE_ENDIAN))
|
||||
{
|
||||
var num = io.ReadByte();
|
||||
Flags = io.ReadByte();
|
||||
|
||||
Constants = new ushort[num];
|
||||
for (var i = 0; i < num; i++)
|
||||
{
|
||||
Constants[i] = io.ReadUInt16();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override bool Write(IffFile iff, Stream stream)
|
||||
{
|
||||
using (var io = IoWriter.FromStream(stream, ByteOrder.LITTLE_ENDIAN))
|
||||
{
|
||||
io.WriteByte((byte)Constants.Length);
|
||||
io.WriteByte(Flags);
|
||||
foreach (var c in Constants)
|
||||
{
|
||||
io.WriteUInt16(c);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue