Ejemplo n.º 1
0
        public override void Read(IffFile iff, Stream stream)
        {
            using (var io = IoBuffer.FromStream(stream, ByteOrder.LITTLE_ENDIAN))
            {
                io.ReadUInt32();               //pad
                var version = io.ReadUInt32(); //zero

                var TTAT = io.ReadCString(4);

                IOProxy iop;
                var     compressionCode = io.ReadByte();
                //HACK: for freeso we don't run the field encoding coompression
                //since fso neighbourhoods are not compatible with ts1, it does not matter too much
                if (compressionCode != 1)
                {
                    iop = new TTABNormal(io);
                }
                else
                {
                    iop = new IffFieldEncode(io);
                }

                var total = iop.ReadInt32();
                for (int i = 0; i < total; i++)
                {
                    var guid  = (uint)iop.ReadInt32();
                    var count = iop.ReadInt32();
                    var tatts = new short[count];
                    for (int j = 0; j < count; j++)
                    {
                        tatts[j] = iop.ReadInt16();
                    }
                    TypeAttributesByGUID[guid] = tatts;
                }
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Reads a TTAB chunk from a stream.
 /// </summary>
 /// <param name="iff">An Iff instance.</param>
 /// <param name="stream">A Stream object holding a TTAB chunk.</param>
 public override void Read(IffFile iff, Stream stream)
 {
     using (var io = IoBuffer.FromStream(stream, ByteOrder.LITTLE_ENDIAN))
     {
         InteractionByIndex.Clear();
         Interactions = new TTABInteraction[io.ReadUInt16()];
         if (Interactions.Length == 0)
         {
             return;                           //no interactions, don't bother reading remainder.
         }
         var     version = io.ReadUInt16();
         IOProxy iop;
         if (version != 9 && version != 10)
         {
             iop = new TTABNormal(io);
         }
         else
         {
             var compressionCode = io.ReadByte();
             if (compressionCode != 1)
             {
                 throw new Exception("hey what!!");
             }
             iop = new TTABFieldEncode(io); //haven't guaranteed that this works, since none of the objects in the test lot use it.
         }
         for (int i = 0; i < Interactions.Length; i++)
         {
             var result = new TTABInteraction();
             result.ActionFunction = iop.ReadUInt16();
             result.TestFunction   = iop.ReadUInt16();
             result.MotiveEntries  = new TTABMotiveEntry[iop.ReadUInt32()];
             result.Flags          = (TTABFlags)iop.ReadUInt32();
             result.TTAIndex       = iop.ReadUInt32();
             if (version > 6)
             {
                 result.AttenuationCode = iop.ReadUInt32();
             }
             result.AttenuationValue  = iop.ReadFloat();
             result.AutonomyThreshold = iop.ReadUInt32();
             result.JoiningIndex      = iop.ReadInt32();
             for (int j = 0; j < result.MotiveEntries.Length; j++)
             {
                 var motive = new TTABMotiveEntry();
                 if (version > 6)
                 {
                     motive.EffectRangeMinimum = iop.ReadInt16();
                 }
                 motive.EffectRangeMaximum = iop.ReadInt16();
                 if (version > 6)
                 {
                     motive.PersonalityModifier = iop.ReadUInt16();
                 }
                 result.MotiveEntries[j] = motive;
             }
             if (version > 9)
             {
                 result.Flags2 = (TSOFlags)iop.ReadUInt32();
             }
             Interactions[i] = result;
             InteractionByIndex.Add(result.TTAIndex, result);
         }
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Reads a TTAB chunk from a stream.
 /// </summary>
 /// <param name="iff">An Iff instance.</param>
 /// <param name="stream">A Stream object holding a TTAB chunk.</param>
 public override void Read(IffFile iff, Stream stream)
 {
     using (var io = IoBuffer.FromStream(stream, ByteOrder.LITTLE_ENDIAN))
     {
         InteractionByIndex.Clear();
         Interactions = new TTABInteraction[io.ReadUInt16()];
         if (Interactions.Length == 0)
         {
             return;                           //no interactions, don't bother reading remainder.
         }
         var     version = io.ReadUInt16();
         IOProxy iop;
         if (version <= 3)
         {
             // DO NOT LOAD THIS TTAB TYPE
             Interactions = new TTABInteraction[0];
             return;
         }
         if (version < 9 || (version > 10 && !iff.TSBO))
         {
             iop = new TTABNormal(io);
         }
         else
         {
             var compressionCode = io.ReadByte();
             if (compressionCode != 1)
             {
                 iop = new TTABNormal(io);
             }
             else
             {
                 iop = new IffFieldEncode(io);
             }
         }
         for (int i = 0; i < Interactions.Length; i++)
         {
             var result = new TTABInteraction();
             result.ActionFunction = iop.ReadUInt16();
             result.TestFunction   = iop.ReadUInt16();
             result.MotiveEntries  = new TTABMotiveEntry[iop.ReadUInt32()];
             result.Flags          = (TTABFlags)iop.ReadUInt32();
             result.TTAIndex       = iop.ReadUInt32();
             if (version > 6)
             {
                 result.AttenuationCode = iop.ReadUInt32();
             }
             result.AttenuationValue  = iop.ReadFloat();
             result.AutonomyThreshold = iop.ReadUInt32();
             result.JoiningIndex      = iop.ReadInt32();
             for (int j = 0; j < result.MotiveEntries.Length; j++)
             {
                 var motive = new TTABMotiveEntry();
                 motive.MotiveIndex = j;
                 if (version > 6)
                 {
                     motive.EffectRangeMinimum = iop.ReadInt16();
                 }
                 motive.EffectRangeDelta = iop.ReadInt16();
                 if (version > 6)
                 {
                     motive.PersonalityModifier = iop.ReadUInt16();
                 }
                 result.MotiveEntries[j] = motive;
             }
             if (version > 9 && !iff.TSBO)
             {
                 result.Flags2 = (TSOFlags)iop.ReadUInt32();
             }
             Interactions[i] = result;
             InteractionByIndex.Add(result.TTAIndex, result);
         }
     }
     InitAutoInteractions();
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Reads a TTAB chunk from a stream.
 /// </summary>
 /// <param name="iff">An Iff instance.</param>
 /// <param name="stream">A Stream object holding a TTAB chunk.</param>
 public override void Read(IffFile iff, Stream stream)
 {
     using (var io = IoBuffer.FromStream(stream, ByteOrder.LITTLE_ENDIAN))
     {
         InteractionByIndex.Clear();
         Interactions = new TTABInteraction[io.ReadUInt16()];
         if (Interactions.Length == 0) return; //no interactions, don't bother reading remainder.
         var version = io.ReadUInt16();
         IOProxy iop;
         if (version != 9 && version != 10) iop = new TTABNormal(io);
         else
         {
             var compressionCode = io.ReadByte();
             if (compressionCode != 1) throw new Exception("hey what!!");
             iop = new TTABFieldEncode(io); //haven't guaranteed that this works, since none of the objects in the test lot use it.
         }
         for (int i = 0; i < Interactions.Length; i++)
         {
             var result = new TTABInteraction();
             result.ActionFunction = iop.ReadUInt16();
             result.TestFunction = iop.ReadUInt16();
             result.MotiveEntries = new TTABMotiveEntry[iop.ReadUInt32()];
             result.Flags = (TTABFlags)iop.ReadUInt32();
             result.TTAIndex = iop.ReadUInt32();
             if (version > 6) result.AttenuationCode = iop.ReadUInt32();
             result.AttenuationValue = iop.ReadFloat();
             result.AutonomyThreshold = iop.ReadUInt32();
             result.JoiningIndex = iop.ReadInt32();
             for (int j = 0; j < result.MotiveEntries.Length; j++)
             {
                 var motive = new TTABMotiveEntry();
                 if (version > 6) motive.EffectRangeMinimum = iop.ReadInt16();
                 motive.EffectRangeMaximum = iop.ReadInt16();
                 if (version > 6) motive.PersonalityModifier = iop.ReadUInt16();
                 result.MotiveEntries[j] = motive;
             }
             if (version > 9)
             {
                 result.Flags2 = (TSOFlags)iop.ReadUInt32();
             }
             Interactions[i] = result;
             InteractionByIndex.Add(result.TTAIndex, result);
         }
     }
 }