Пример #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();

                var MjbO = io.ReadUInt32();

                var compressionCode = io.ReadByte();
                if (compressionCode != 1)
                {
                    throw new Exception("hey what!!");
                }

                Name = io.ReadNullTerminatedString();
                if (Name.Length % 2 == 1)
                {
                    io.ReadByte();
                }
                var iop = new IffFieldEncode(io);


                var numLevels = iop.ReadInt32();

                JobLevels = new JobLevel[numLevels];
                for (int i = 0; i < numLevels; i++)
                {
                    JobLevels[i] = new JobLevel(iop);
                }
            }
        }
Пример #2
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.ReadUInt32();

                var compressionCode = io.ReadByte();
                if (compressionCode != 1)
                {
                    throw new Exception("hey what!!");
                }

                var 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;
                }
            }
        }
Пример #3
0
        public JobLevel(IffFieldEncode iop)
        {
            for (int i = 0; i < MinRequired.Length; i++)
            {
                MinRequired[i] = iop.ReadInt32();
            }
            for (int i = 0; i < MotiveDelta.Length; i++)
            {
                MotiveDelta[i] = iop.ReadInt32();
            }
            Salary    = iop.ReadInt32();
            StartTime = iop.ReadInt32();
            EndTime   = iop.ReadInt32();
            CarType   = iop.ReadInt32();

            JobName           = iop.ReadString(false);
            MaleUniformMesh   = iop.ReadString(false);
            FemaleUniformMesh = iop.ReadString(false);
            UniformSkin       = iop.ReadString(false);
            unknown           = iop.ReadString(true);
        }
Пример #4
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;
                }
            }
        }
Пример #5
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)
             {
                 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();
                 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);
         }
     }
 }
Пример #6
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();

                //house 00: 33 00 00 00
                //house 03: 3E 00 00 00
                //house 79: 45 00 00 00
                //completec:49 00 00 00
                //corresponds to house version?

                var MjbO = io.ReadUInt32();

                var compressionCode = io.ReadByte();
                if (compressionCode != 1)
                {
                    throw new Exception("hey what!!");
                }

                var iop = new IffFieldEncode(io);

                /*
                 * var test1 = iop.ReadInt16();
                 * var testas = new ushort[test1*2];
                 * for (int i=0; i<test1*2; i++)
                 * {
                 *  testas[i] = iop.ReadUInt16();
                 * }*/

                var table = new List <ushort>();
                while (io.HasMore)
                {
                    var value = iop.ReadUInt16();
                    if (value == 0)
                    {
                        break;
                    }
                    table.Add(value);
                }
                IDToOBJT = table.ToArray();

                var list = new List <short>();
                while (io.HasMore)
                {
                    list.Add(iop.ReadInt16());
                }

                var offsets = SearchForObjectData(list);
                for (int i = 1; i < offsets.Count; i++)
                {
                    Console.WriteLine(offsets[i] - offsets[i - 1]);
                }

                ObjectData = new Dictionary <int, MappedObject>();
                int lastOff = 0;
                foreach (var off in offsets)
                {
                    var endOff = off + 72;
                    var size   = endOff - lastOff;
                    var data   = list.Skip(lastOff).Take(size).ToArray();

                    var bas           = size - 72;
                    var objID         = data[bas + 11]; //object id
                    var dir           = data[bas + 1];
                    var parent        = data[bas + 26];
                    var containerid   = data[bas + 2];
                    var containerslot = data[bas + 2];

                    ObjectData[objID] = new MappedObject()
                    {
                        ObjectID = objID, Direction = dir, Data = data, ParentID = parent, ContainerID = containerid, ContainerSlot = containerslot
                    };

                    lastOff = endOff;
                }
            }
        }