Esempio n. 1
0
 public void Parse(ChunkData data, ref short listOffset)
 {
     Index = EndianessSwitchableBitConverter.ToUInt32(data[listOffset++].Data, 0);
     Count = EndianessSwitchableBitConverter.ToInt32(data[listOffset++].Data, 0);
     HasBeenDiscovered = data[listOffset++].Data[0];
     Unknown4 = data[listOffset++].Data[0];
 }
 public void Parse(ChunkData data, ref int listOffset)
 {
     NameHash = EndianessSwitchableBitConverter.ToUInt32(data.DataEntries[listOffset++].Data, 0);
     Level = data.DataEntries[listOffset++].Data[0];
     Unknown1 = data.DataEntries[listOffset++].Data[0];
     IsLocked = data.DataEntries[listOffset++].Data[0];
 }
            public void Parse(ChunkData data, ref int listOffset)
            {
                ObjectReference obj = new ObjectReference();
                obj.Parse(data.DataEntries[listOffset++].Data);
                Object = obj;

                Unknown1 = data.DataEntries[listOffset++].Data[0];
                Unknown2 = EndianessSwitchableBitConverter.ToInt32(data.DataEntries[listOffset++].Data, 0);
            }
 public void Parse(ChunkData data)
 {
     short listOffset = 0;
     int count = EndianessSwitchableBitConverter.ToInt32(data[listOffset++].Data, 0);
     for (int i = 0; i < count; i++)
     {
         SavedObject1 o = new SavedObject1();
         o.Parse(data, ref listOffset);
         _objects.Add(o);
     }
     Unknown1 = data[500].Data[0];
 }
Esempio n. 5
0
 public void Parse(ChunkData data)
 {
     short listOffset = 0;
     int count = EndianessSwitchableBitConverter.ToInt32(data[listOffset++].Data, 0);
     _objects.Clear();
     for (int i = 0; i < count; i++)
     {
         SavedObject1 so = new SavedObject1();
         so.Parse(data, ref listOffset);
         _objects.Add(so);
     }
 }
            public void Parse(ChunkData data, ref short listOffset)
            {
                Hash = EndianessSwitchableBitConverter.ToUInt32(data[listOffset++].Data, 0);
                Flags = (MissionFlag)data[listOffset++].Data[0];
                int count = EndianessSwitchableBitConverter.ToInt32(data[listOffset++].Data, 0);

                if (count > 0)
                {
                    for (int i = 0; i < count; i++)
                    {
                        SavedMissionObjectiveInfo o = new SavedMissionObjectiveInfo();
                        o.Parse(data, ref listOffset);
                        _missionObjectives.Add(o);
                    }
                }
            }
        public void Parse(ChunkData data)
        {
            Capacity = EndianessSwitchableBitConverter.ToInt32(data[0].Data, 0);
            UsedCount = EndianessSwitchableBitConverter.ToInt32(data[1].Data, 0);

            _objects.Clear();
            for(int i = 0; i < Capacity * 8; i+= 8)
            {
                ObjectReference obj = new ObjectReference();
                obj.Parse(data[9].Data, i);
                _objects.Add(obj);
            }

            Bits = new BitArray(data[10].Data);
            Bits.Length = Capacity;
        }
        public static IParsedChunk TryParse(ChunkData data)
        {
            IParsedChunk o = null;

            Type type = GetType(data.Header.ObjectID);

            if (type != null)
            {
                try
                {
                    o = (IParsedChunk)System.Activator.CreateInstance(type);
                    o.Parse(data);
                }
                catch (System.Reflection.TargetInvocationException e)
                {
                    throw e.InnerException;
                }
            }

            return o;
        }
        public void Parse(ChunkData data)
        {
            if (data.DataEntries.Count < 7)
            {
                System.Diagnostics.Debugger.Break();
            }

            NumWeaponParts  = EndianessSwitchableBitConverter.ToInt32(data.DataEntries[0].Data, 0);
            NumArmorParts   = EndianessSwitchableBitConverter.ToInt32(data.DataEntries[1].Data, 0);
            NumVehicleParts = EndianessSwitchableBitConverter.ToInt32(data.DataEntries[2].Data, 0);
            Money           = EndianessSwitchableBitConverter.ToInt32(data.DataEntries[3].Data, 0);
            Chaos           = EndianessSwitchableBitConverter.ToInt32(data.DataEntries[4].Data, 0);
            short numWeapons  = EndianessSwitchableBitConverter.ToInt16(data.DataEntries[5].Data, 0);
            short numVehicles = EndianessSwitchableBitConverter.ToInt16(data.DataEntries[6].Data, 0);

            int expectedEntryCount = (numVehicles + numWeapons) * 4;

            if (expectedEntryCount != data.DataEntries.Count - 7)
            {
                System.Diagnostics.Debugger.Break();
            }

            weapons.Clear();
            int listOffset = 7;

            for (int i = 0; i < numWeapons; i++)
            {
                SavedObject1 so = new SavedObject1();
                so.Parse(data, ref listOffset);
                weapons.Add(so);
            }

            vehicles.Clear();
            for (int i = 0; i < numVehicles; i++)
            {
                SavedObject1 so = new SavedObject1();
                so.Parse(data, ref listOffset);
                vehicles.Add(so);
            }
        }
        public void Parse(ChunkData data)
        {
            int savedCount1 = EndianessSwitchableBitConverter.ToInt32(data.DataEntries[0].Data, 0);

            int expectedEntryCount = savedCount1 + 1;
            
            /*
            if (data.DataEntries.Count != expectedEntryCount)
            {
                Debugger.Break();
            }
            */

            _objects.Clear();
            int listOffset = 1;
            for (int i = 0; i < savedCount1; i++)
            {
                ObjectReference obj = new ObjectReference();
                obj.Parse(data.DataEntries[listOffset++].Data);
                _objects.Add(obj);
            }
        }
        public void Parse(ChunkData data)
        {
            if (data.DataEntries.Count < 7)
            {
                System.Diagnostics.Debugger.Break();
            }

            NumWeaponParts = EndianessSwitchableBitConverter.ToInt32(data.DataEntries[0].Data, 0);
            NumArmorParts = EndianessSwitchableBitConverter.ToInt32(data.DataEntries[1].Data, 0);
            NumVehicleParts = EndianessSwitchableBitConverter.ToInt32(data.DataEntries[2].Data, 0);
            Money = EndianessSwitchableBitConverter.ToInt32(data.DataEntries[3].Data, 0);
            Chaos = EndianessSwitchableBitConverter.ToInt32(data.DataEntries[4].Data, 0);
            short numWeapons = EndianessSwitchableBitConverter.ToInt16(data.DataEntries[5].Data, 0);
            short numVehicles = EndianessSwitchableBitConverter.ToInt16(data.DataEntries[6].Data, 0);

            int expectedEntryCount = (numVehicles + numWeapons) * 4;
            if (expectedEntryCount != data.DataEntries.Count - 7)
            {
                System.Diagnostics.Debugger.Break();
            }

            weapons.Clear();
            int listOffset = 7;
            for (int i = 0; i < numWeapons; i ++)
            {
                SavedObject1 so = new SavedObject1();
                so.Parse(data, ref listOffset);
                weapons.Add(so);
            }

            vehicles.Clear();
            for (int i = 0; i < numVehicles; i++)
            {
                SavedObject1 so = new SavedObject1();
                so.Parse(data, ref listOffset);
                vehicles.Add(so);
            }
        }
Esempio n. 12
0
        public void Parse(ChunkData data)
        {
            int savedCount1 = EndianessSwitchableBitConverter.ToInt32(data.DataEntries[0].Data, 0);

            int expectedEntryCount = savedCount1 + 1;

            /*
             * if (data.DataEntries.Count != expectedEntryCount)
             * {
             *  Debugger.Break();
             * }
             */

            _objects.Clear();
            int listOffset = 1;

            for (int i = 0; i < savedCount1; i++)
            {
                ObjectReference obj = new ObjectReference();
                obj.Parse(data.DataEntries[listOffset++].Data);
                _objects.Add(obj);
            }
        }
Esempio n. 13
0
 public void Parse(ChunkData data)
 {
     MaxLevel = EndianessSwitchableBitConverter.ToInt32(data[0].Data, 0);
 }
Esempio n. 14
0
 public void Parse(ChunkData data)
 {
     Unknown1 = EndianessSwitchableBitConverter.ToSingle(data[0].Data, 0);
     Unknown2 = EndianessSwitchableBitConverter.ToSingle(data[1].Data, 0);
 }
Esempio n. 15
0
 public void Parse(ChunkData data)
 {
     Unknown1 = data[0].Data[0];
 }
 public void Parse(ChunkData data)
 {
     Unknown1 = data[0].Data[0];
 }
Esempio n. 17
0
        public void Parse(ChunkData data)
        {
            int count = EndianessSwitchableBitConverter.ToInt32(data[0].Data, 0);
            _objects.Clear();
            for (int i = 0; i < count; i++)
            {
                SavedObject1 so = new SavedObject1();
                so.Parse(data[1].Data, i * 8);
                _objects.Add(so);
            }

            count = EndianessSwitchableBitConverter.ToInt32(data[2].Data, 0);
            _objects2.Clear();
            for (int i = 0; i < count; i++)
            {
                SavedObject1 so = new SavedObject1();
                so.Parse(data[3].Data, i * 8);
                _objects2.Add(so);
            }

            count = EndianessSwitchableBitConverter.ToInt32(data[4].Data, 0);
            _objects3.Clear();
            for (int i = 0; i < count; i++)
            {
                SavedObject1 so = new SavedObject1();
                so.Parse(data[5].Data, i * 8);
                _objects3.Add(so);
            }

            count = EndianessSwitchableBitConverter.ToInt32(data[6].Data, 0);
            _vehicles.Clear();
            for (int i = 0; i < count; i++)
            {
                PdaDbEntryVehicle so = new PdaDbEntryVehicle();
                so.Parse(data[7].Data, i * 4);
                _vehicles.Add(so);
            }

            count = EndianessSwitchableBitConverter.ToInt32(data[8].Data, 0);
            _objects5.Clear();
            for (int i = 0; i < count; i++)
            {
                SavedObject1 so = new SavedObject1();
                so.Parse(data[9].Data, i * 8);
                _objects5.Add(so);
            }
        }
Esempio n. 18
0
        public void Read(Stream input)
        {
            // lazy check... pc savegames are exactly 891904 bytes...
            bool isXBox = input.Length != 891904;
            int  _headerOffset;
            int  _chunkHeaderOffset;
            int  _chunkDataOffset;

            if (isXBox)
            {
                EndianessSwitchableBitConverter.Mode = EndianessSwitchableBitConverter.Endianess.BIG;
            }

            BinaryReader r;

            if (isXBox)
            {
                r                  = new BigEndianBinaryReader(input);
                _headerOffset      = OFFSET_XBOX360;
                _chunkHeaderOffset = CHUNK_HEADERS_OFFSET + OFFSET_XBOX360;
                _chunkDataOffset   = CHUNK_DATA_OFFSET + OFFSET_XBOX360;
            }
            else
            {
                r                  = new BinaryReader(input);
                _headerOffset      = 0;
                _chunkHeaderOffset = CHUNK_HEADERS_OFFSET;
                _chunkDataOffset   = CHUNK_DATA_OFFSET;
            }

            r.BaseStream.Seek(_headerOffset, SeekOrigin.Begin);

            Header = new SaveFileHeader();
            Header.Read(r);

            // file can contain up to 9 headers - probably history, BUT can also contain junk, so read only first header....

            r.BaseStream.Seek(_chunkHeaderOffset, SeekOrigin.Begin);
            int count = r.ReadInt32();
            List <ChunkHeader> _chunkHeaders = new List <ChunkHeader>(count);

            for (int i = 0; i < count; i++)
            {
                ChunkHeader header = new ChunkHeader(r);
                _chunkHeaders.Add(header);
            }

            _chunkData.Clear();
            _parsedChunks.Clear();
            for (int i = 0; i < count; i++)
            {
                ChunkData data = new ChunkData();
                data.Read(r, _chunkHeaders[i], _chunkDataOffset);
                _chunkData.Add(data);

                IParsedChunk p = ParsedChunkTypeHelper.TryParse(data);
                _parsedChunks.Add(p);

                /*
                 * if (p == null)
                 * {
                 *  foreach (ChunkDataEntry e in data.DataEntries)
                 *  {
                 *      if (e.Data.Length == 4)
                 *      {
                 *          uint hash = BitConverter.ToUInt32(e.Data, 0);
                 *          string name = NameLookup.GetName(hash);
                 *          if (name != null)
                 *          {
                 *              //System.Diagnostics.Debugger.Break();
                 *          }
                 *      }
                 *  }
                 * }*/
            }
            r.Close();
            input.Close();
        }
Esempio n. 19
0
 public void Parse(ChunkData data)
 {
     _entries.Clear();
     _entries.Add(new StatisticEntry(0, "Game Time", data, StatisticEntry.ValueType.TimeSpan));
     // ???
     _entries.Add(new StatisticEntry(2, "Total kills", data, StatisticEntry.ValueType.Int));
     _entries.Add(new StatisticEntry(3, "Fall kills", data, StatisticEntry.ValueType.Int));
     _entries.Add(new StatisticEntry(4, "Drag kills", data, StatisticEntry.ValueType.Int));
     _entries.Add(new StatisticEntry(5, "Pinata kills", data, StatisticEntry.ValueType.Int));
     //_entries.Add(new StatisticEntry(6, "Wrecking Ball", data, StatisticEntry.ValueType.Int)); // perfect kill combo ?
     _entries.Add(new StatisticEntry(7, "Melee kills", data, StatisticEntry.ValueType.Int));
     _entries.Add(new StatisticEntry(8, "Hang kills", data, StatisticEntry.ValueType.Int));
     _entries.Add(new StatisticEntry(9, "Road kills", data, StatisticEntry.ValueType.Int));
     _entries.Add(new StatisticEntry(10, "Stunt driver points", data, StatisticEntry.ValueType.Int));
     _entries.Add(new StatisticEntry(11, "Highest parachute climb (m)", data, StatisticEntry.ValueType.Float));
     _entries.Add(new StatisticEntry(12, "Fully upgraded Items", data, StatisticEntry.ValueType.Int));
     _entries.Add(new StatisticEntry(13, "Stunt jump combo", data, StatisticEntry.ValueType.Int));
     
     _entries.Add(new StatisticEntry(163, "Unique vehicles driven", data, StatisticEntry.ValueType.HashedStringList));
     
     _entries.Add(new StatisticEntry(313, "Hijackings", data, StatisticEntry.ValueType.Int));
     _entries.Add(new StatisticEntry(314, "Highest Base jump (m)", data, StatisticEntry.ValueType.Float));
     // ???
     _entries.Add(new StatisticEntry(316, "Locations discovered", data, StatisticEntry.ValueType.Int));
     _entries.Add(new StatisticEntry(317, "Headshots", data, StatisticEntry.ValueType.Int));
     _entries.Add(new StatisticEntry(318, "Locations completed", data, StatisticEntry.ValueType.Int));
     _entries.Add(new StatisticEntry(319, "Total chaos", data, StatisticEntry.ValueType.Int));
     _entries.Add(new StatisticEntry(320, "Game Time (h)", data, StatisticEntry.ValueType.Int));
     _entries.Add(new StatisticEntry(321, "Total earnings ($)", data, StatisticEntry.ValueType.Int));
     _entries.Add(new StatisticEntry(322, "Agency missions completed", data, StatisticEntry.ValueType.Int));
     _entries.Add(new StatisticEntry(323, "Faction missions completed", data, StatisticEntry.ValueType.Int));
     _entries.Add(new StatisticEntry(324, "Stronghold takeovers completed", data, StatisticEntry.ValueType.Int));
     _entries.Add(new StatisticEntry(325, "Black market orders", data, StatisticEntry.ValueType.Int));
     _entries.Add(new StatisticEntry(326, "Weapons parts", data, StatisticEntry.ValueType.Int));
     _entries.Add(new StatisticEntry(327, "Vehicle parts", data, StatisticEntry.ValueType.Int));
     _entries.Add(new StatisticEntry(328, "Armor parts", data, StatisticEntry.ValueType.Int));
     _entries.Add(new StatisticEntry(329, "Cash stashes", data, StatisticEntry.ValueType.Int));
     // ???
     _entries.Add(new StatisticEntry(331, "Resource Items", data, StatisticEntry.ValueType.Int));
     _entries.Add(new StatisticEntry(332, "Sabotages comleted", data, StatisticEntry.ValueType.Int));
     _entries.Add(new StatisticEntry(333, "Skulls collected", data, StatisticEntry.ValueType.Int));
     _entries.Add(new StatisticEntry(334, "Black boxed collected", data, StatisticEntry.ValueType.Int));
     _entries.Add(new StatisticEntry(335, "Drug drops collected", data, StatisticEntry.ValueType.Int));
     _entries.Add(new StatisticEntry(336, "Faction items collected", data, StatisticEntry.ValueType.Int));
     _entries.Add(new StatisticEntry(337, "Challenges completed", data, StatisticEntry.ValueType.Int));
     // ...???
     _entries.Add(new StatisticEntry(339, "Wrecking Ball", data, StatisticEntry.ValueType.Int));
     // ...???
     _entries.Add(new StatisticEntry(341, "Juggle kills", data, StatisticEntry.ValueType.Int));
     _entries.Add(new StatisticEntry(343, "Kilometers driven", data, StatisticEntry.ValueType.Float));
     _entries.Add(new StatisticEntry(344, "Bridge limbo", data, StatisticEntry.ValueType.Int));
     _entries.Add(new StatisticEntry(345, "Low flyer record (s)", data, StatisticEntry.ValueType.Float));
     // ...???
     _entries.Add(new StatisticEntry(352, "Fuel depots destroyed", data, StatisticEntry.ValueType.Int));
     // ...???
     _entries.Add(new StatisticEntry(355, "Mobile radars destroyed", data, StatisticEntry.ValueType.Int));
     // ...???
     _entries.Add(new StatisticEntry(358, "Baby panay statues destroyed", data, StatisticEntry.ValueType.Int));
     // ...???
     _entries.Add(new StatisticEntry(361, "Comm. stations destroyed", data, StatisticEntry.ValueType.Int));
     // ...???
     _entries.Add(new StatisticEntry(364, "Fuel shafts destroyed", data, StatisticEntry.ValueType.Int));
     // ...???
     _entries.Add(new StatisticEntry(367, "Propaganda trailers destroyed", data, StatisticEntry.ValueType.Int));
     // ...???
     _entries.Add(new StatisticEntry(370, "Faction items collected", data, StatisticEntry.ValueType.Int));
     // ...???
     _entries.Add(new StatisticEntry(373, "Colonels assassinated", data, StatisticEntry.ValueType.Int));
     // ...???
     _entries.Add(new StatisticEntry(376, "Pipelines destroyed", data, StatisticEntry.ValueType.Int));
     // ...???
     _entries.Add(new StatisticEntry(379, "Satellite dishes destroyed", data, StatisticEntry.ValueType.Int));
     // ...???
     _entries.Add(new StatisticEntry(382, "Gas pumps destroyed", data, StatisticEntry.ValueType.Int));
     // ...???
     _entries.Add(new StatisticEntry(385, "Gas holders destroyed", data, StatisticEntry.ValueType.Int));
     // ...???
     _entries.Add(new StatisticEntry(391, "Water towers destroyed", data, StatisticEntry.ValueType.Int));
     // ...???
     _entries.Add(new StatisticEntry(394, "Radars destroyed", data, StatisticEntry.ValueType.Int));
     // ...???
     _entries.Add(new StatisticEntry(397, "Wind turbines destroyed", data, StatisticEntry.ValueType.Int));
     // ...???
     _entries.Add(new StatisticEntry(400, "Generators destroyed", data, StatisticEntry.ValueType.Int));
     // ...???
     _entries.Add(new StatisticEntry(403, "Transformers destroyed", data, StatisticEntry.ValueType.Int));
     // ...???
     _entries.Add(new StatisticEntry(406, "Broadcast towers destroyed", data, StatisticEntry.ValueType.Int));
     // ...???
     _entries.Add(new StatisticEntry(409, "Radio masts destroyed", data, StatisticEntry.ValueType.Int));
     // ...???
     _entries.Add(new StatisticEntry(415, "Sams destroyed", data, StatisticEntry.ValueType.Int));
     // ...???
     _entries.Add(new StatisticEntry(418, "Military vehicles destroyed", data, StatisticEntry.ValueType.Int));
     // ...???
     _entries.Add(new StatisticEntry(421, "Demolition Officers killed", data, StatisticEntry.ValueType.Int));
     // ...???
     _entries.Add(new StatisticEntry(424, "Elites killed", data, StatisticEntry.ValueType.Int));
     // ...???
     _entries.Add(new StatisticEntry(427, "Ninjas killed", data, StatisticEntry.ValueType.Int));
     // ...???
     _entries.Add(new StatisticEntry(433, "Offshore rigs destroyed", data, StatisticEntry.ValueType.Int));
     // ...???
     _entries.Add(new StatisticEntry(436, "Factory chimneys destroyed", data, StatisticEntry.ValueType.Int));
     // ...???
     _entries.Add(new StatisticEntry(439, "Cranes destroyed", data, StatisticEntry.ValueType.Int));
     // ...???
     _entries.Add(new StatisticEntry(442, "Silos destroyed", data, StatisticEntry.ValueType.Int));
 }
Esempio n. 20
0
 public void Parse(ChunkData data, ref short listOffset)
 {
     ChallengeObject = new ObjectReference();
     ChallengeObject.Parse(data[listOffset++].Data);
     Time = EndianessSwitchableBitConverter.ToSingle(data[listOffset++].Data, 0); 
 }
            public void Parse(ChunkData data, ref short listOffset)
            {
                Hash = EndianessSwitchableBitConverter.ToUInt32(data.DataEntries[listOffset++].Data, 0);
                Unknown1 = data.DataEntries[listOffset++].Data[0];

            }
 public void Parse(ChunkData data)
 {
     Unknown1 = data[0].Data[0];
     Unknown2 = data[1].Data[0];
     Unknown3 = EndianessSwitchableBitConverter.ToInt32(data[2].Data, 0);
 }
            public void Parse(ChunkData data, ref int listOffset)
            {
                ObjectReference obj = new ObjectReference();
                obj.Parse(data.DataEntries[listOffset++].Data);
                Object = obj;

                Unknown1 = data.DataEntries[listOffset++].Data[0];
                Unknown2 = data.DataEntries[listOffset++].Data[0];
                Unknown3 = data.DataEntries[listOffset++].Data[0];
                Unknown4 = data.DataEntries[listOffset++].Data[0];
            }
Esempio n. 24
0
 public void Parse(ChunkData data)
 {
     MaxLevel = EndianessSwitchableBitConverter.ToInt32(data[0].Data, 0);
 }
Esempio n. 25
0
 public void Parse(ChunkData data, ref short listOffset)
 {
     Hash   = EndianessSwitchableBitConverter.ToUInt32(data[listOffset++].Data, 0);
     Status = (MissionStatus)data[listOffset++].Data[0];
 }
        public void Parse(ChunkData data)
        {
            int savedCount1 = EndianessSwitchableBitConverter.ToInt32(data.DataEntries[0].Data, 0);
            int savedCount2 = EndianessSwitchableBitConverter.ToInt32(data.DataEntries[1].Data, 0);
            int savedCount3 = EndianessSwitchableBitConverter.ToInt32(data.DataEntries[2].Data, 0);
            int savedCount4 = EndianessSwitchableBitConverter.ToInt32(data.DataEntries[3].Data, 0);

            int expectedEntryCount = 3 * savedCount1 + 5 * savedCount2 + 5 * savedCount3 + 3 * savedCount4 + 4;
            
            /*
            if (data.DataEntries.Count != expectedEntryCount)
            {
                Debugger.Break();
            }
            */

            _objects1.Clear();
            _objects2.Clear();
            _objects3.Clear();
            _objects4.Clear();

            int listOffset = 4;
            for (int i = 0; i < savedCount1; i++)
            { 
                SavedObject1 o = new SavedObject1();
                o.Parse(data, ref listOffset);
                _objects1.Add(o);
            }

            for (int i = 0; i < savedCount2; i++)
            {
                SavedObject2 o = new SavedObject2();
                o.Parse(data, ref listOffset);
                _objects2.Add(o);
            }

            for (int i = 0; i < savedCount3; i++)
            {
                SavedObject3 o = new SavedObject3();
                o.Parse(data, ref listOffset);
                _objects3.Add(o);
            }

            for (int i = 0; i < savedCount4; i++)
            {
                SavedObject4 o = new SavedObject4();
                o.Parse(data, ref listOffset);
                _objects4.Add(o);
            }
        }
Esempio n. 27
0
 public void Parse(ChunkData data, ref short listOffset)
 {
     ChallengeObject = new ObjectReference();
     ChallengeObject.Parse(data[listOffset++].Data);
     Time = EndianessSwitchableBitConverter.ToSingle(data[listOffset++].Data, 0);
 }
 public void Parse(ChunkData data)
 {
     Unknown1 = data[0].Data[0];
     Unknown2 = data[1].Data[0];
     Unknown3 = EndianessSwitchableBitConverter.ToInt32(data[2].Data, 0);
 }
Esempio n. 29
0
 public StatisticEntry(short index, string name, ChunkData data, ValueType type)
 {
     ChunkDataEntry ce = data[index];
     if (ce == null)
     {
         throw new ArgumentOutOfRangeException("index");
     }
     
     Index = index;
     Name = name;
     Type = type;
    
     switch (type)
     {
         case ValueType.Bool:
             {
                 if (ce.Length != 1 + 6)
                 {
                     throw new Exception("not a Bool");
                 }
                 Value = data[index].Data[0] != 0;
                 break;
             }
         case ValueType.Float:
             {
                 if (ce.Length != 4 + 6)
                 {
                     throw new Exception("not a Float");
                 }
                 Value = EndianessSwitchableBitConverter.ToSingle(data[index].Data, 0);
                 break;
             }
         case ValueType.Int:
             {
                 if (ce.Length != 4 + 6)
                 {
                     throw new Exception("not an Int");
                 }
                 Value = EndianessSwitchableBitConverter.ToInt32(data[index].Data, 0);
                 break;
             }
         case ValueType.TimeSpan:
             {
                 if (ce.Length != 8 + 6)
                 {
                     throw new Exception("not a TimeSpan");
                 }
                 Value = TimeSpan.FromSeconds(EndianessSwitchableBitConverter.ToInt64(data[index].Data, 0));
                 break;
             }
         case ValueType.HashedStringList:
             {
                 try
                 {
                     int count = EndianessSwitchableBitConverter.ToInt32(data[index++].Data, 0);
                     List<HashedString> val = new List<HashedString>();
                     for (int i = 0; i < count; i++)
                     {
                         val.Add(new HashedString(data[index++].Data));
                     }
                     Value = val;
                 }
                 catch {
                     throw new Exception("not a list of hashed strings");
                 }
                 break;
             }
         default:
             {
                 throw new NotSupportedException("StatisticEntry: unsupported type");
             }
     }
 }
Esempio n. 30
0
        public void Read(Stream input)
        {
            // lazy check... pc savegames are exactly 891904 bytes...
            bool isXBox = input.Length != 891904;
            int _headerOffset;
            int _chunkHeaderOffset;
            int _chunkDataOffset;

            if (isXBox) EndianessSwitchableBitConverter.Mode = EndianessSwitchableBitConverter.Endianess.BIG;

            BinaryReader r;
            if (isXBox)
            {
                r = new BigEndianBinaryReader(input);
                _headerOffset = OFFSET_XBOX360;
                _chunkHeaderOffset = CHUNK_HEADERS_OFFSET + OFFSET_XBOX360;
                _chunkDataOffset = CHUNK_DATA_OFFSET + OFFSET_XBOX360;
            }
            else
            {
                r = new BinaryReader(input);
                _headerOffset = 0;
                _chunkHeaderOffset = CHUNK_HEADERS_OFFSET;
                _chunkDataOffset = CHUNK_DATA_OFFSET;
            }

            r.BaseStream.Seek(_headerOffset, SeekOrigin.Begin);

            Header = new SaveFileHeader();
            Header.Read(r);

            // file can contain up to 9 headers - probably history, BUT can also contain junk, so read only first header....

            r.BaseStream.Seek(_chunkHeaderOffset, SeekOrigin.Begin);
            int count = r.ReadInt32();
            List<ChunkHeader> _chunkHeaders = new List<ChunkHeader>(count);
            for (int i = 0; i < count; i++)
            {
                ChunkHeader header = new ChunkHeader(r);
                _chunkHeaders.Add(header);
            }

            _chunkData.Clear();
            _parsedChunks.Clear();
            for (int i = 0; i < count; i++)
            {
                ChunkData data = new ChunkData();
                data.Read(r, _chunkHeaders[i], _chunkDataOffset);
                _chunkData.Add(data);
                
                IParsedChunk p = ParsedChunkTypeHelper.TryParse(data);
                _parsedChunks.Add(p);

                /*
                if (p == null)
                {
                    foreach (ChunkDataEntry e in data.DataEntries)
                    {
                        if (e.Data.Length == 4)
                        {
                            uint hash = BitConverter.ToUInt32(e.Data, 0);
                            string name = NameLookup.GetName(hash);
                            if (name != null)
                            {
                                //System.Diagnostics.Debugger.Break();
                            }
                        }
                    }
                }*/
            }
            r.Close();
            input.Close();
        }
Esempio n. 31
0
 public void Parse(ChunkData data, ref short listOffset)
 {
     Hash = EndianessSwitchableBitConverter.ToUInt32(data[listOffset++].Data, 0);
     Status = (MissionStatus)data[listOffset++].Data[0];
 }
Esempio n. 32
0
        public void Parse(ChunkData data)
        {
            int numObjects1 = EndianessSwitchableBitConverter.ToInt32(data[1].Data, 0);
            
            // Missions
            short listOffset = 100;
            for(int i = 0; i < numObjects1; i++)
            {
                SavedMissionInfo o = new SavedMissionInfo();
                o.Parse(data, ref listOffset);
                _objects.Add(o);
            }

            // Challenges...
            listOffset = 2402;
            int numChallenges = EndianessSwitchableBitConverter.ToInt32(data[listOffset++].Data, 0);
            for (int i = 0; i < numChallenges; i++)
            {
                SavedChallengeInfo o = new SavedChallengeInfo();
                o.Parse(data, ref listOffset);
                _challenges.Add(o);
            }
            // end
        }
Esempio n. 33
0
            public StatisticEntry(short index, string name, ChunkData data, ValueType type)
            {
                ChunkDataEntry ce = data[index];

                if (ce == null)
                {
                    throw new ArgumentOutOfRangeException("index");
                }

                Index = index;
                Name  = name;
                Type  = type;

                switch (type)
                {
                case ValueType.Bool:
                {
                    if (ce.Length != 1 + 6)
                    {
                        throw new Exception("not a Bool");
                    }
                    Value = data[index].Data[0] != 0;
                    break;
                }

                case ValueType.Float:
                {
                    if (ce.Length != 4 + 6)
                    {
                        throw new Exception("not a Float");
                    }
                    Value = EndianessSwitchableBitConverter.ToSingle(data[index].Data, 0);
                    break;
                }

                case ValueType.Int:
                {
                    if (ce.Length != 4 + 6)
                    {
                        throw new Exception("not an Int");
                    }
                    Value = EndianessSwitchableBitConverter.ToInt32(data[index].Data, 0);
                    break;
                }

                case ValueType.TimeSpan:
                {
                    if (ce.Length != 8 + 6)
                    {
                        throw new Exception("not a TimeSpan");
                    }
                    Value = TimeSpan.FromSeconds(EndianessSwitchableBitConverter.ToInt64(data[index].Data, 0));
                    break;
                }

                case ValueType.HashedStringList:
                {
                    try
                    {
                        int count = EndianessSwitchableBitConverter.ToInt32(data[index++].Data, 0);
                        List <HashedString> val = new List <HashedString>();
                        for (int i = 0; i < count; i++)
                        {
                            val.Add(new HashedString(data[index++].Data));
                        }
                        Value = val;
                    }
                    catch {
                        throw new Exception("not a list of hashed strings");
                    }
                    break;
                }

                default:
                {
                    throw new NotSupportedException("StatisticEntry: unsupported type");
                }
                }
            }
Esempio n. 34
0
 public void Parse(ChunkData data)
 {
     Unknown1 = EndianessSwitchableBitConverter.ToSingle(data[0].Data, 0);
     Unknown2 = EndianessSwitchableBitConverter.ToSingle(data[1].Data, 0);
 }
Esempio n. 35
0
 public void Parse(ChunkData data, ref short listOffset)
 {
     Unknown1 = EndianessSwitchableBitConverter.ToUInt32(data[listOffset++].Data, 0);
     Unknown2 = data[listOffset++].Data[0];
 }
Esempio n. 36
0
        public void Parse(ChunkData data)
        {
            _entries.Clear();
            _entries.Add(new StatisticEntry(0, "Game Time", data, StatisticEntry.ValueType.TimeSpan));
            // ???
            _entries.Add(new StatisticEntry(2, "Total kills", data, StatisticEntry.ValueType.Int));
            _entries.Add(new StatisticEntry(3, "Fall kills", data, StatisticEntry.ValueType.Int));
            _entries.Add(new StatisticEntry(4, "Drag kills", data, StatisticEntry.ValueType.Int));
            _entries.Add(new StatisticEntry(5, "Pinata kills", data, StatisticEntry.ValueType.Int));
            //_entries.Add(new StatisticEntry(6, "Wrecking Ball", data, StatisticEntry.ValueType.Int)); // perfect kill combo ?
            _entries.Add(new StatisticEntry(7, "Melee kills", data, StatisticEntry.ValueType.Int));
            _entries.Add(new StatisticEntry(8, "Hang kills", data, StatisticEntry.ValueType.Int));
            _entries.Add(new StatisticEntry(9, "Road kills", data, StatisticEntry.ValueType.Int));
            _entries.Add(new StatisticEntry(10, "Stunt driver points", data, StatisticEntry.ValueType.Int));
            _entries.Add(new StatisticEntry(11, "Highest parachute climb (m)", data, StatisticEntry.ValueType.Float));
            _entries.Add(new StatisticEntry(12, "Fully upgraded Items", data, StatisticEntry.ValueType.Int));
            _entries.Add(new StatisticEntry(13, "Stunt jump combo", data, StatisticEntry.ValueType.Int));

            _entries.Add(new StatisticEntry(163, "Unique vehicles driven", data, StatisticEntry.ValueType.HashedStringList));

            _entries.Add(new StatisticEntry(313, "Hijackings", data, StatisticEntry.ValueType.Int));
            _entries.Add(new StatisticEntry(314, "Highest Base jump (m)", data, StatisticEntry.ValueType.Float));
            // ???
            _entries.Add(new StatisticEntry(316, "Locations discovered", data, StatisticEntry.ValueType.Int));
            _entries.Add(new StatisticEntry(317, "Headshots", data, StatisticEntry.ValueType.Int));
            _entries.Add(new StatisticEntry(318, "Locations completed", data, StatisticEntry.ValueType.Int));
            _entries.Add(new StatisticEntry(319, "Total chaos", data, StatisticEntry.ValueType.Int));
            _entries.Add(new StatisticEntry(320, "Game Time (h)", data, StatisticEntry.ValueType.Int));
            _entries.Add(new StatisticEntry(321, "Total earnings ($)", data, StatisticEntry.ValueType.Int));
            _entries.Add(new StatisticEntry(322, "Agency missions completed", data, StatisticEntry.ValueType.Int));
            _entries.Add(new StatisticEntry(323, "Faction missions completed", data, StatisticEntry.ValueType.Int));
            _entries.Add(new StatisticEntry(324, "Stronghold takeovers completed", data, StatisticEntry.ValueType.Int));
            _entries.Add(new StatisticEntry(325, "Black market orders", data, StatisticEntry.ValueType.Int));
            _entries.Add(new StatisticEntry(326, "Weapons parts", data, StatisticEntry.ValueType.Int));
            _entries.Add(new StatisticEntry(327, "Vehicle parts", data, StatisticEntry.ValueType.Int));
            _entries.Add(new StatisticEntry(328, "Armor parts", data, StatisticEntry.ValueType.Int));
            _entries.Add(new StatisticEntry(329, "Cash stashes", data, StatisticEntry.ValueType.Int));
            // ???
            _entries.Add(new StatisticEntry(331, "Resource Items", data, StatisticEntry.ValueType.Int));
            _entries.Add(new StatisticEntry(332, "Sabotages comleted", data, StatisticEntry.ValueType.Int));
            _entries.Add(new StatisticEntry(333, "Skulls collected", data, StatisticEntry.ValueType.Int));
            _entries.Add(new StatisticEntry(334, "Black boxed collected", data, StatisticEntry.ValueType.Int));
            _entries.Add(new StatisticEntry(335, "Drug drops collected", data, StatisticEntry.ValueType.Int));
            _entries.Add(new StatisticEntry(336, "Faction items collected", data, StatisticEntry.ValueType.Int));
            _entries.Add(new StatisticEntry(337, "Challenges completed", data, StatisticEntry.ValueType.Int));
            // ...???
            _entries.Add(new StatisticEntry(339, "Wrecking Ball", data, StatisticEntry.ValueType.Int));
            // ...???
            _entries.Add(new StatisticEntry(341, "Juggle kills", data, StatisticEntry.ValueType.Int));
            _entries.Add(new StatisticEntry(343, "Kilometers driven", data, StatisticEntry.ValueType.Float));
            _entries.Add(new StatisticEntry(344, "Bridge limbo", data, StatisticEntry.ValueType.Int));
            _entries.Add(new StatisticEntry(345, "Low flyer record (s)", data, StatisticEntry.ValueType.Float));
            // ...???
            _entries.Add(new StatisticEntry(352, "Fuel depots destroyed", data, StatisticEntry.ValueType.Int));
            // ...???
            _entries.Add(new StatisticEntry(355, "Mobile radars destroyed", data, StatisticEntry.ValueType.Int));
            // ...???
            _entries.Add(new StatisticEntry(358, "Baby panay statues destroyed", data, StatisticEntry.ValueType.Int));
            // ...???
            _entries.Add(new StatisticEntry(361, "Comm. stations destroyed", data, StatisticEntry.ValueType.Int));
            // ...???
            _entries.Add(new StatisticEntry(364, "Fuel shafts destroyed", data, StatisticEntry.ValueType.Int));
            // ...???
            _entries.Add(new StatisticEntry(367, "Propaganda trailers destroyed", data, StatisticEntry.ValueType.Int));
            // ...???
            _entries.Add(new StatisticEntry(370, "Faction items collected", data, StatisticEntry.ValueType.Int));
            // ...???
            _entries.Add(new StatisticEntry(373, "Colonels assassinated", data, StatisticEntry.ValueType.Int));
            // ...???
            _entries.Add(new StatisticEntry(376, "Pipelines destroyed", data, StatisticEntry.ValueType.Int));
            // ...???
            _entries.Add(new StatisticEntry(379, "Satellite dishes destroyed", data, StatisticEntry.ValueType.Int));
            // ...???
            _entries.Add(new StatisticEntry(382, "Gas pumps destroyed", data, StatisticEntry.ValueType.Int));
            // ...???
            _entries.Add(new StatisticEntry(385, "Gas holders destroyed", data, StatisticEntry.ValueType.Int));
            // ...???
            _entries.Add(new StatisticEntry(391, "Water towers destroyed", data, StatisticEntry.ValueType.Int));
            // ...???
            _entries.Add(new StatisticEntry(394, "Radars destroyed", data, StatisticEntry.ValueType.Int));
            // ...???
            _entries.Add(new StatisticEntry(397, "Wind turbines destroyed", data, StatisticEntry.ValueType.Int));
            // ...???
            _entries.Add(new StatisticEntry(400, "Generators destroyed", data, StatisticEntry.ValueType.Int));
            // ...???
            _entries.Add(new StatisticEntry(403, "Transformers destroyed", data, StatisticEntry.ValueType.Int));
            // ...???
            _entries.Add(new StatisticEntry(406, "Broadcast towers destroyed", data, StatisticEntry.ValueType.Int));
            // ...???
            _entries.Add(new StatisticEntry(409, "Radio masts destroyed", data, StatisticEntry.ValueType.Int));
            // ...???
            _entries.Add(new StatisticEntry(415, "Sams destroyed", data, StatisticEntry.ValueType.Int));
            // ...???
            _entries.Add(new StatisticEntry(418, "Military vehicles destroyed", data, StatisticEntry.ValueType.Int));
            // ...???
            _entries.Add(new StatisticEntry(421, "Demolition Officers killed", data, StatisticEntry.ValueType.Int));
            // ...???
            _entries.Add(new StatisticEntry(424, "Elites killed", data, StatisticEntry.ValueType.Int));
            // ...???
            _entries.Add(new StatisticEntry(427, "Ninjas killed", data, StatisticEntry.ValueType.Int));
            // ...???
            _entries.Add(new StatisticEntry(433, "Offshore rigs destroyed", data, StatisticEntry.ValueType.Int));
            // ...???
            _entries.Add(new StatisticEntry(436, "Factory chimneys destroyed", data, StatisticEntry.ValueType.Int));
            // ...???
            _entries.Add(new StatisticEntry(439, "Cranes destroyed", data, StatisticEntry.ValueType.Int));
            // ...???
            _entries.Add(new StatisticEntry(442, "Silos destroyed", data, StatisticEntry.ValueType.Int));
        }