public PathNode(STFReader stf) { stf.MustMatchBlockStart(); PathFlags = (PathFlags)stf.ReadHex(0); NextMainNode = stf.ReadUInt(null); NextSidingNode = stf.ReadUInt(null); PathDataPoint = stf.ReadUInt(null); stf.SkipRestOfBlock(); }
public TrPathNode(STFReader stf) { stf.MustMatch("("); pathFlags = stf.ReadHex(0); nextMainNode = stf.ReadUInt(null); nextSidingNode = stf.ReadUInt(null); fromPDP = stf.ReadUInt(null); stf.SkipRestOfBlock(); }
///// <summary>Used with junction signals, appears to be either 1 or 0</summary> //public uint SData3 { get; private set; } internal TrackItemSignalDirection(STFReader stf) { stf.MustMatchBlockStart(); TrackNode = stf.ReadUInt(null); //SData1 = stf.ReadUInt(null); stf.ReadUInt(null); LinkLRPath = stf.ReadUInt(null); //SData3 = stf.ReadUInt(null); stf.ReadUInt(null); stf.SkipRestOfBlock(); }
/// <summary> /// Default constructor used during file parsing. /// </summary> /// <param name="stf">The STFreader containing the file stream</param> public LightTableEntry(STFReader stf) { stf.MustMatch("("); Name = stf.ReadString().ToLowerInvariant(); stf.ParseBlock(new STFReader.TokenProcessor[] { new STFReader.TokenProcessor("colour", () => { stf.MustMatch("("); a = (byte)stf.ReadUInt(null); r = (byte)stf.ReadUInt(null); g = (byte)stf.ReadUInt(null); b = (byte)stf.ReadUInt(null); stf.SkipRestOfBlock(); }), }); }
/// <summary> /// Default constructor used during file parsing. /// </summary> /// <param name="stf">The STFreader containing the file stream</param> public SignalLight(STFReader stf) { stf.MustMatch("("); Index = stf.ReadUInt(null); Name = stf.ReadString().ToLowerInvariant(); stf.ParseBlock(new STFReader.TokenProcessor[] { new STFReader.TokenProcessor("radius", () => { Radius = stf.ReadFloatBlock(STFReader.UNITS.None, null); }), new STFReader.TokenProcessor("position", () => { stf.MustMatch("("); X = stf.ReadFloat(STFReader.UNITS.None, null); Y = stf.ReadFloat(STFReader.UNITS.None, null); Z = stf.ReadFloat(STFReader.UNITS.None, null); stf.SkipRestOfBlock(); }), new STFReader.TokenProcessor("signalflags", () => { stf.MustMatch("("); while (!stf.EndOfBlock()) { switch (stf.ReadString().ToLower()) { case "semaphore_change": SemaphoreChange = true; break; default: stf.StepBackOneItem(); STFException.TraceInformation(stf, "Skipped unknown SignalLight flag " + stf.ReadString()); break; } } }), }); }
/// <summary> /// Reads the ID from filestream /// </summary> /// <param name="stf">The STFreader containing the file stream</param> /// <param name="index">The index of this TrItem in the list of TrItems</param> private protected void ParseTrackItemId(STFReader stf, int index) { stf.MustMatchBlockStart(); TrackItemId = stf.ReadUInt(null); Debug.Assert(index == TrackItemId, "Index Mismatch"); stf.SkipRestOfBlock(); }
/// <summary> /// Default constructor used during file parsing. /// </summary> /// <param name="stf">The STFreader containing the file stream</param> /// <param name="index">The index of this TrItem in the list of TrItems</param> internal CrossoverItem(STFReader stf, int index) { stf.MustMatchBlockStart(); stf.ParseBlock(new STFReader.TokenProcessor[] { new STFReader.TokenProcessor("tritemid", () => { ParseTrackItemId(stf, index); }), new STFReader.TokenProcessor("tritemrdata", () => { ParseTrackItemRData(stf); }), new STFReader.TokenProcessor("tritemsdata", () => { ParseTrackItemSData(stf); }), new STFReader.TokenProcessor("crossovertritemdata", () => { stf.MustMatchBlockStart(); TrackNode = stf.ReadUInt(null); ShapeId = stf.ReadUInt(null); stf.SkipRestOfBlock(); }), }); }
public void AddRouteTrackSections(STFReader stf) { stf.MustMatchBlockStart(); MaxSectionIndex = stf.ReadUInt(null); stf.ParseBlock(new STFReader.TokenProcessor[] { new STFReader.TokenProcessor("tracksection", () => { AddSection(stf, new TrackSection(stf, true)); }), }); }
public TrackSections(STFReader stf) { stf.MustMatch("("); MaxSectionIndex = stf.ReadUInt(null); stf.ParseBlock(new STFReader.TokenProcessor[] { new STFReader.TokenProcessor("tracksection", () => { AddSection(stf, new TrackSection(stf)); }), }); }
public void AddRouteTrackShapes(STFReader stf) { stf.MustMatchBlockStart(); MaxShapeIndex = stf.ReadUInt(null); stf.ParseBlock(new STFReader.TokenProcessor[] { new STFReader.TokenProcessor("trackshape", () => { Add(stf, new TrackShape(stf)); }), }); }
/// <summary> /// Default constructor used during file parsing. /// </summary> /// <param name="stf">The STFreader containing the file stream</param> /// <param name="index">The index of this TrItem in the list of TrItems</param> public SignalItem(STFReader stf, int index) { SignalObject = -1; stf.MustMatchBlockStart(); stf.ParseBlock(new STFReader.TokenProcessor[] { new STFReader.TokenProcessor("tritemid", () => { ParseTrackItemId(stf, index); }), new STFReader.TokenProcessor("tritemrdata", () => { ParseTrackItemRData(stf); }), new STFReader.TokenProcessor("tritemsdata", () => { ParseTrackItemSData(stf); }), new STFReader.TokenProcessor("trsignaltype", () => { stf.MustMatchBlockStart(); Flags1 = stf.ReadUInt(null); Direction = (TrackDirection)stf.ReadUInt(null); SignalData = stf.ReadFloat(STFReader.Units.None, null); SignalType = stf.ReadString(); // To do get index to Sigtypes table corresponding to this sigmal stf.SkipRestOfBlock(); }), new STFReader.TokenProcessor("trsignaldirs", () => { stf.MustMatchBlockStart(); uint signalDirs = stf.ReadUInt(null); SignalDirections = new TrackItemSignalDirection[signalDirs]; int i = 0; stf.ParseBlock(new STFReader.TokenProcessor[] { new STFReader.TokenProcessor("trsignaldir", () => { if (i >= signalDirs) { STFException.TraceWarning(stf, $"Adding extra TrSignalDirs in SignalItem {TrackItemId}"); var temp = new TrackItemSignalDirection[signalDirs + 1]; Array.Copy(SignalDirections, temp, SignalDirections.Length); SignalDirections = temp; } SignalDirections[i] = new TrackItemSignalDirection(stf); i++; }), }); if (i < signalDirs) { STFException.TraceWarning(stf, $"{(signalDirs - i)} missing TrSignalDirs(s)"); } }), }); }
public TSectionIdx(STFReader stf) { stf.MustMatch("("); NoSections = stf.ReadUInt(null); TrackPaths = new Dictionary <uint, TrackPath>((int)NoSections); stf.ParseBlock(new STFReader.TokenProcessor[] { new STFReader.TokenProcessor("trackpath", () => { AddPath(stf, new TrackPath(stf)); }), }); stf.SkipRestOfBlock(); }
public TrackPaths(STFReader stf) { stf.MustMatchBlockStart(); uint sectionNumber = stf.ReadUInt(null); //new Dictionary<uint, TrackPath>((int)sectionNumber); stf.ParseBlock(new STFReader.TokenProcessor[] { new STFReader.TokenProcessor("trackpath", () => { AddPath(stf, new TrackPath(stf)); }), }); stf.SkipRestOfBlock(); }
public TrackSection(STFReader stf) { stf.MustMatch("("); SectionIndex = stf.ReadUInt(null); stf.ParseBlock(new STFReader.TokenProcessor[] { new STFReader.TokenProcessor("sectionsize", () => { SectionSize = new SectionSize(stf); }), new STFReader.TokenProcessor("sectioncurve", () => { SectionCurve = new SectionCurve(stf); }), }); //if( SectionSize == null ) // throw( new STFError( stf, "Missing SectionSize" ) ); // note- default TSECTION.DAT does have some missing sections }
public TrackPath(STFReader stf) { stf.MustMatch("("); DynamicSectionIndex = stf.ReadUInt(null); NoSections = stf.ReadUInt(null); TrackSections = new uint[NoSections]; for (int i = 0; i < NoSections; ++i) { string token = stf.ReadString(); if (token == ")") { STFException.TraceWarning(stf, "Missing track section"); return; // there are many TSECTION.DAT's with missing sections so we will accept this error } if (!uint.TryParse(token, out TrackSections[i])) { STFException.TraceWarning(stf, "Invalid track section " + token); } } stf.SkipRestOfBlock(); }
/// <summary> /// Default constructor used during file parsing. /// </summary> /// <param name="stf">The STFreader containing the file stream</param> /// <param name="idx">The index of this TrItem in the list of TrItems</param> internal SpeedPostItem(STFReader stf, int idx) { SignalObject = -1; stf.MustMatchBlockStart(); stf.ParseBlock(new STFReader.TokenProcessor[] { new STFReader.TokenProcessor("tritemid", () => { ParseTrackItemId(stf, idx); }), new STFReader.TokenProcessor("tritemrdata", () => { ParseTrackItemRData(stf); }), new STFReader.TokenProcessor("tritemsdata", () => { ParseTrackItemSData(stf); }), new STFReader.TokenProcessor("speedposttritemdata", () => { stf.MustMatchBlockStart(); flags = stf.ReadUInt(null); if (!IsWarning && !IsLimit) { IsMilePost = true; } else { if (IsWarning && IsLimit) { flags |= 0x1; IsResume = true; } } // The number of parameters depends on the flags seeting // To do: Check flags seetings and parse accordingly. if (!IsResume) { //SpeedInd = stf.ReadFloat(STFReader.Units.None, null); if (IsMilePost && ((flags & (1 << 9)) == 0)) { Distance = (float)Math.Truncate(stf.ReadDouble(null)); } else { Distance = stf.ReadFloat(STFReader.Units.None, null); } } if (ShowNumber) { NumberShown = stf.ReadInt(null); } Angle = MathHelper.WrapAngle(stf.ReadFloat(STFReader.Units.None, null)); stf.SkipRestOfBlock(); }), }); }
} // degrees public TrackSection(STFReader stf, bool routeTrackSection) { if (routeTrackSection) { stf.MustMatchBlockStart(); stf.MustMatch("SectionCurve"); stf.SkipBlock(); SectionIndex = stf.ReadUInt(null); float a = stf.ReadFloat(STFReader.Units.Distance, null); float b = stf.ReadFloat(STFReader.Units.None, null); if (b == 0) // Its straight { Length = a; } else // its curved { Radius = b; Angle = MathHelper.ToDegrees(a); Curved = true; } stf.SkipRestOfBlock(); } else { stf.MustMatchBlockStart(); SectionIndex = stf.ReadUInt(null); stf.ParseBlock(new STFReader.TokenProcessor[] { new STFReader.TokenProcessor("sectionsize", () => { ReadSectionSize(stf); }), new STFReader.TokenProcessor("sectioncurve", () => { ReadSectionCurve(stf); }), }); //if( SectionSize == null ) // throw( new STFError( stf, "Missing SectionSize" ) ); // note- default TSECTION.DAT does have some missing sections } }
/// <summary> /// Default constructor used during file parsing. /// </summary> /// <param name="stf">The STFreader containing the file stream</param> public SignalDrawLight(STFReader stf) { stf.MustMatch("("); LightIndex = stf.ReadUInt(null); stf.ParseBlock(new STFReader.TokenProcessor[] { new STFReader.TokenProcessor("signalflags", () => { stf.MustMatch("("); while (!stf.EndOfBlock()) { switch (stf.ReadString().ToLower()) { case "flashing": Flashing = true; break; default: stf.StepBackOneItem(); STFException.TraceInformation(stf, "Skipped unknown DrawLight flag " + stf.ReadString()); break; } } }), }); }
public TrackShape(STFReader stf) { stf.MustMatchBlockStart(); ShapeIndex = stf.ReadUInt(null); int nextPath = 0; stf.ParseBlock(new STFReader.TokenProcessor[] { new STFReader.TokenProcessor("filename", () => { FileName = stf.ReadStringBlock(null); }), new STFReader.TokenProcessor("numpaths", () => { SectionIndices = new SectionIndex[PathsNumber = stf.ReadUIntBlock(null)]; }), new STFReader.TokenProcessor("mainroute", () => { MainRoute = stf.ReadUIntBlock(null); }), new STFReader.TokenProcessor("clearancedist", () => { ClearanceDistance = stf.ReadFloatBlock(STFReader.Units.Distance, null); }), new STFReader.TokenProcessor("sectionidx", () => { SectionIndices[nextPath++] = new SectionIndex(stf); }), new STFReader.TokenProcessor("tunnelshape", () => { TunnelShape = stf.ReadBoolBlock(true); }), new STFReader.TokenProcessor("roadshape", () => { RoadShape = stf.ReadBoolBlock(true); }), }); // TODO - this was removed since TrackShape( 183 ) is blank //if( FileName == null ) throw( new STFError( stf, "Missing FileName" ) ); //if( SectionIdxs == null ) throw( new STFError( stf, "Missing SectionIdxs" ) ); //if( NumPaths == 0 ) throw( new STFError( stf, "No Paths in TrackShape" ) ); }
public SectionIndex(STFReader stf) { stf.MustMatchBlockStart(); SectionsCount = stf.ReadUInt(null); offset = new Vector3(stf.ReadFloat(null), stf.ReadFloat(null), -stf.ReadFloat(null)); AngularOffset = stf.ReadFloat(null); TrackSections = new uint[SectionsCount]; for (int i = 0; i < SectionsCount; ++i) { string token = stf.ReadString(); if (token == ")") { STFException.TraceWarning(stf, "Missing track section"); return; // there are many TSECTION.DAT's with missing sections so we will accept this error } if (!uint.TryParse(token, out TrackSections[i])) { STFException.TraceWarning(stf, "Invalid track section " + token); } } stf.SkipRestOfBlock(); }
public RouteTrackSection(STFReader stf) { stf.MustMatch("("); stf.MustMatch("SectionCurve"); stf.SkipBlock(); SectionIndex = stf.ReadUInt(null); SectionSize = new SectionSize(); float a = stf.ReadFloat(STFReader.UNITS.Distance, null); float b = stf.ReadFloat(STFReader.UNITS.None, null); if (b == 0) // Its straight { SectionSize.Length = a; } else // its curved { SectionCurve = new SectionCurve(); SectionCurve.Radius = b; SectionCurve.Angle = (float)MathHelper.ToDegrees(a); } stf.SkipRestOfBlock(); }
public override uint ReadUInt() { return(stf.ReadUInt(null)); }