mirror of
https://github.com/simtactics/mysimulation.git
synced 2025-07-14 10:11:58 -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
91
server/tso.files/HIT/TLO.cs
Executable file
91
server/tso.files/HIT/TLO.cs
Executable file
|
@ -0,0 +1,91 @@
|
|||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
//ok, why do we have support for this? it's only used by hitlab and only the hitlab test files have them...
|
||||
|
||||
namespace FSO.Files.HIT
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a TLO file.
|
||||
/// TLO (short for Track Logic according to hitlab.ini) is a format
|
||||
/// used solely for Hitlab. Integers are little-endian.
|
||||
/// </summary>
|
||||
public class TLO
|
||||
{
|
||||
private uint m_Count;
|
||||
public List<TLOSection> Sections = new List<TLOSection>();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new tracklogic instance.
|
||||
/// </summary>
|
||||
/// <param name="Filedata">The data to create the tracklogic instance from.</param>
|
||||
public TLO(byte[] Filedata)
|
||||
{
|
||||
BinaryReader Reader = new BinaryReader(new MemoryStream(Filedata));
|
||||
|
||||
Reader.ReadBytes(4); //Reserved.
|
||||
m_Count = Reader.ReadUInt32();
|
||||
|
||||
for (int i = 0; i < m_Count; i++)
|
||||
{
|
||||
TLOSection Section = new TLOSection();
|
||||
Section.Name = new string(Reader.ReadChars(Reader.ReadInt32()));
|
||||
Section.GroupID1 = Reader.ReadUInt32();
|
||||
Section.FileID1 = Reader.ReadUInt32();
|
||||
Section.GroupID2 = Reader.ReadUInt32();
|
||||
Section.FileID1 = Reader.ReadUInt32();
|
||||
Section.TypeID = Reader.ReadUInt32();
|
||||
Section.GroupID3 = Reader.ReadUInt32();
|
||||
Section.FileID3 = Reader.ReadUInt32();
|
||||
|
||||
Sections.Add(Section);
|
||||
}
|
||||
|
||||
Reader.Close();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new tracklogic instance.
|
||||
/// </summary>
|
||||
/// <param name="Filepath">The path to the tracklogic file to read.</param>
|
||||
public TLO(string Filepath)
|
||||
{
|
||||
BinaryReader Reader = new BinaryReader(File.Open(Filepath, FileMode.Open, FileAccess.Read, FileShare.Read));
|
||||
|
||||
Reader.ReadBytes(4); //Reserved.
|
||||
m_Count = Reader.ReadUInt32();
|
||||
|
||||
for (int i = 0; i < m_Count; i++)
|
||||
{
|
||||
TLOSection Section = new TLOSection();
|
||||
Section.Name = new string(Reader.ReadChars(Reader.ReadInt32()));
|
||||
Section.GroupID1 = Reader.ReadUInt32();
|
||||
Section.FileID1 = Reader.ReadUInt32();
|
||||
Section.GroupID2 = Reader.ReadUInt32();
|
||||
Section.FileID1 = Reader.ReadUInt32();
|
||||
Section.TypeID = Reader.ReadUInt32();
|
||||
Section.GroupID3 = Reader.ReadUInt32();
|
||||
Section.FileID3 = Reader.ReadUInt32();
|
||||
|
||||
Sections.Add(Section);
|
||||
}
|
||||
|
||||
Reader.Close();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents a section in a tracklogic file.
|
||||
/// </summary>
|
||||
public class TLOSection
|
||||
{
|
||||
public string Name;
|
||||
public uint GroupID1;
|
||||
public uint FileID1;
|
||||
public uint GroupID2;
|
||||
public uint FileID2;
|
||||
public uint TypeID;
|
||||
public uint GroupID3;
|
||||
public uint FileID3;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue