/// <summary> /// Seek the stream ahead however many bytes the size of this pad is /// </summary> /// <param name="ts"></param> public override void Read(IO.ITagStream ts) { if (ts.Flags.Test(IO.ITagStreamFlags.Halo2OldFormat_UselessPadding)) ts.GetInputStream().Seek(Value, System.IO.SeekOrigin.Current); }
/// <summary> /// Stream the field from a tag stream /// </summary> /// <param name="ts"></param> /// <exception cref="Exceptions.InvalidStringId"></exception> public override void Read(IO.ITagStream ts) { if (Handle.Set == -1) // HACK used to tell Read that we already read the string data (as this is an old halo 2 tag) { Handle = new Blam.StringId(Handle.Description, Handle.Index, Handle.Length, 0); return; } if (!ts.Flags.Test(IO.ITagStreamFlags.DontStreamStringData)) // stream the string id value if we can { IO.EndianReader s = ts.GetInputStream(); relativeOffset = s.PositionUnsigned; string value = null; try { value = new string(s.ReadChars(Handle.Length)); if (Handle != Blam.StringId.Null) Program.GetTagIndex(OwnerId).StringIds.TryAndGetStringId(value, out Handle); } catch (Exception ex) { throw new Exceptions.InvalidStringId(ex, base.headerOffset, base.relativeOffset, ts, Handle.Length, value); } } }
/// <summary> /// Read the main body of this field from a tag stream /// </summary> /// <param name="ts"></param> public virtual void Read(IO.ITagStream ts) { this.Read(ts.GetInputStream()); }
/// <summary> /// Stream the field header data from a tag stream /// </summary> /// <param name="ts"></param> /// <exception cref="Exceptions.InvalidStringId"></exception> public override void ReadHeader(IO.ITagStream ts) { IO.EndianReader s = ts.GetInputStream(); headerOffset = s.PositionUnsigned; // nifty for debugging OwnerId = ts.OwnerId; string value = null; try { if (fieldType == FieldType.OldStringId && ts.Flags.Test(IO.ITagStreamFlags.Halo2OldFormat_StringId)) value = s.ReadAsciiString(28); // max of 28 characters in the string id in old builds var owner = Program.GetTagIndex(OwnerId); Handle.Read(s, owner.StringIds.Definition.Description); if (value != null /*&& Handle != Blam.StringID.Null*/) { owner.StringIds.TryAndGetStringId(value, out Handle); Handle = new Blam.StringId(Handle.Description, Handle.Index, Handle.Length, -1); // HACK used to tell Read that we already read the string data (as this is an old halo 2 tag) } } catch (Exception ex) { throw new Exceptions.InvalidStringId(ex, base.headerOffset, uint.MaxValue, ts, Handle.Length, value); } }
public void Read(IO.ITagStream ts) { IO.EndianReader s = ts.GetInputStream(); ReadHeader(s, ts); }