Ejemplo n.º 1
0
        private bool ProcessObject(Table table, SaveReader reader, DatumIndex index, uint size, long offset)
        {
            if (!index.IsValid)
            {
                _objects.Add(null);
                return(true);
            }

            // Read the ObjectEntry and seek to the object's file offset
            ObjectEntry entry      = new ObjectEntry(index, reader);
            long        fileOffset = entry.ObjectAddress - table.Address + _entryTableOffset;

            reader.SeekTo(fileOffset);

            // Construct a specialized GameObject class depending on the tag group
            GameObject obj;

            switch (entry.TagGroup)
            {
            case TagGroup.Bipd:
                obj = new BipedObject(entry, reader);
                break;

            case TagGroup.Weap:
                obj = new WeaponObject(entry, reader);
                break;

            default:
                obj = new GameObject(entry, reader);
                break;
            }
            _objects.Add(obj);
            return(true);
        }
Ejemplo n.º 2
0
 private static void DumpCharacterData(SaveReader saveData)
 {
     lock (outputLock)
     {
         sw.WriteLine(GetCharacterCSVData(saveData));
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Reads data from a SaveReader. Override this in a derived class to read object-specific data.
        /// </summary>
        /// <param name="reader">The SaveReader to read from. No guarantees can be made about its ending offset.</param>
        /// <param name="baseOffset">The offset of the start of the object data.</param>
        protected virtual void ReadFrom(SaveReader reader, long baseOffset)
        {
            _tag = DatumIndex.ReadFrom(reader);

            reader.SeekTo(baseOffset + StrengthInfoOffset);
            // Using the default Master Chief values is kind of hackish,
            // but at the same time it would be overkill to have a huge DB of original health/shield values.
            _healthInfo = new HealthInfo(reader, DefaultChiefHealthModifier, DefaultChiefShieldModifier);

            reader.SeekTo(baseOffset + PositionOffset1);
            _position.X = reader.ReadFloat();
            _position.Y = reader.ReadFloat();
            _position.Z = reader.ReadFloat();

            reader.SeekTo(baseOffset + PositionOffset2);
            _unkPosition.X = reader.ReadFloat();
            _unkPosition.Y = reader.ReadFloat();
            _unkPosition.Z = reader.ReadFloat();
            _unkPosition   = Vector3.Subtract(_unkPosition, _position);

            reader.SeekTo(baseOffset + CarryInfoOffset);
            _nextCarriedIndex  = DatumIndex.ReadFrom(reader);
            _firstCarriedIndex = DatumIndex.ReadFrom(reader);
            _carrierIndex      = DatumIndex.ReadFrom(reader);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Constructs a HealthInfo object, reading strength data from a SaveReader.
        /// </summary>
        /// <param name="reader">The SaveReader to read from.</param>
        /// <param name="defaultHealthModifier">The default health modifier that this object should use</param>
        /// <param name="defaultShieldModifier">The default shield modifier that this object should use</param>
        public HealthInfo(SaveReader reader, float defaultHealthModifier, float defaultShieldModifier, float customInfinity = float.NaN)
        {
            _customInvincibility = customInfinity;
            _healthModifier      = reader.ReadFloat();
            _shieldModifier      = reader.ReadFloat();
            //System.Diagnostics.Debug.WriteLine("{0:F} {1:F}", _healthModifier, _shieldModifier);

            // Keep backups of the values so that invincibility can be disabled
            // However, if a value is already NaN (invincible), we have to resort to the default value that was passed in.
            if (float.IsNaN(_healthModifier) || float.IsPositiveInfinity(_healthModifier) || _healthModifier == customInfinity)
            {
                _oldHealthModifier = defaultHealthModifier;
            }
            else
            {
                _oldHealthModifier = _healthModifier;
            }

            if (float.IsNaN(_shieldModifier) || float.IsPositiveInfinity(_shieldModifier) || _shieldModifier == customInfinity)
            {
                _oldShieldModifier = defaultShieldModifier;
            }
            else
            {
                _oldShieldModifier = _shieldModifier;
            }
        }
Ejemplo n.º 5
0
 public ObjectEntry(DatumIndex index, SaveReader reader)
 {
     _index    = index;
     _flags    = reader.ReadByte();
     _tagGroup = (TagGroup)reader.ReadByte();
     reader.Skip(4);
     _chunkOffset = reader.ReadUInt32();
 }
Ejemplo n.º 6
0
 public BipedObject(ObjectEntry entry, SaveReader reader)
     : base(entry, reader)
 {
     if (entry.TagGroup != HCEX.TagGroup.Bipd)
     {
         throw new ArgumentException("Cannot construct a BipedObject from a non-Bipd object entry");
     }
 }
Ejemplo n.º 7
0
        protected override void ReadFrom(SaveReader reader, long baseOffset)
        {
            base.ReadFrom(reader, baseOffset);

            reader.SeekTo(baseOffset + AmmoOffset);
            _remainingAmmo = reader.ReadInt16();
            _clipAmmo      = reader.ReadInt16();
        }
Ejemplo n.º 8
0
 public WeaponObject(ObjectEntry entry, SaveReader reader)
     : base(entry, reader)
 {
     if (entry.TagGroup != Halo3ODST.TagGroup.Weap)
     {
         throw new ArgumentException("Cannot construct a WeaponObject from a non-Weap object entry");
     }
 }
Ejemplo n.º 9
0
        private void ClearPlayerData()
        {
            playerData = null;
            itemToEdit = null;

            RefreshCharacter();
            RefreshInventory();
            RefreshItemEditor();
        }
Ejemplo n.º 10
0
 /// <summary>
 /// Constructs a new ObjectEntry, reading it from a SaveReader.
 /// </summary>
 /// <param name="index">The object's datum index.</param>
 /// <param name="reader">The SaveReader to read from. It should point to the section of the table entry after the salt.</param>
 public ObjectEntry(DatumIndex index, SaveReader reader)
 {
     _index    = index;
     _flags    = reader.ReadByte();
     _tagGroup = (TagGroup)reader.ReadByte();
     reader.Skip(2); // Unknown value
     _chunkSize    = reader.ReadUInt16();
     _chunkAddress = reader.ReadUInt32();
 }
Ejemplo n.º 11
0
        public void TestHeaderDecrypt()
        {
            var h = SaveReader.GetSaveFileHeader((byte[])Header00C_3.Clone(), 3);

            h.Magic.Should().Be(0xC63E569C);
            h.EncryptedEntrySize.Should().Be(0x70840);
            h.DecryptedEntrySize.Should().Be(0x70810);
            h.SizeMaybe.Should().Be(0x30);
        }
Ejemplo n.º 12
0
 /// <summary>
 /// Constructs a new Table and reads the header.
 /// </summary>
 /// <param name="reader">
 /// The SaveReader to read from. It should be positioned at the start of the table header.
 /// When the function finishes, it will point to the first entry in the entry list (see the HeaderSize constant).
 /// </param>
 public Table(SaveReader reader)
 {
     _name = reader.ReadAscii(0x1E);
     reader.Skip(2);
     _entryCount = reader.ReadUInt32();
     _entrySize  = reader.ReadUInt32();
     reader.Skip(0x28);
     _tableSizeWHeader    = reader.ReadUInt32();
     _tmpTableStartOffset = reader.Position;
 }
Ejemplo n.º 13
0
        public void DumpSaveNames()
        {
            var arr = SaveReader.SaveFileNames;

            for (int i = 0; i < arr.Count; i++)
            {
                var index = SaveReader.GetIndex(arr[i]);
                index.Should().Be(i);
            }
        }
Ejemplo n.º 14
0
        public void TestEntryDecrypt()
        {
            var e = SaveReader.GetSaveFileEntry((byte[])Entry000_0.Clone(), 0, 0);

            e.Magic.Should().Be(0x9B7A0B7C);
            e.AdlerChecksum.Should().Be(Adler32.ComputeChecksum(e.Data));
            e.Crc32Checksum.Should().Be(Crc32.ComputeChecksum(e.Data));
            e.DataSize.Should().Be(e.Data.Length);
            e.DataSizeDuplicate.Should().Be(e.Data.Length);
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Constructs a new GameObject based off of an ObjectEntry and data read from a SaveReader.
        /// </summary>
        /// <param name="entry">The ObjectEntry that corresponds to this object.</param>
        /// <param name="reader">The SaveRead to read from. It should be positioned at the start of the object data, after the link data.</param>
        public GameObject(ObjectEntry entry, SaveReader reader)
        {
            _entry = entry;

            // Read data
            long baseOffset = reader.Position;

            _streamOffset = baseOffset;
            ReadFrom(reader, baseOffset);
        }
Ejemplo n.º 16
0
        public ActionResult <Response> Post(IFormFile file, string type)
        {
            byte[] data;
            try
            {
                using (var fs = file.OpenReadStream())
                {
                    data = new byte[fs.Length];
                    fs.Read(data, 0, (int)fs.Length);
                }
            }
            catch (Exception e)
            {
                return(new ErrorResponse(ErrorCode.INTERNAL_ERROR, e.Message, e.ToString()));
            }

            string errorMessage = "";

            try
            {
                switch (type)
                {
                case null:
                    goto default;

                case "charinfo":
                    var charinfo = new CharInfo();
                    charinfo.Read(data);
                    return(new SuccessResponse(charinfo));

                case "charsave":
                    var charsave = new SaveReader("1.13c");
                    charsave.Read(data);
                    var charsaveResponse = new CharSaveResponse(charsave);
                    return(new SuccessResponse(charsaveResponse));

                case "charitem":
                    var charitem         = Item.NewItem(data);
                    var charitemResponse = new CharItemResponse(charitem);
                    return(new SuccessResponse(charitemResponse));

                default:
                    return(new ErrorResponse(ErrorCode.MISS_PARAM, "Type parameter is empty (allowed: charinfo, charsave, charitem)"));
                }
            }
            catch (EndOfStreamException e3)
            {
                return(new ErrorResponse(ErrorCode.NOT_SUPPORTED, e3.Message, file.Name));
            }
            catch (Exception e3)
            {
                errorMessage += "\n\n" + e3.ToString();
            }
            return(new ErrorResponse(ErrorCode.BAD_DATA, "Bad file format. Only charinfo, charsave and charitem are allowed.", errorMessage));
        }
Ejemplo n.º 17
0
        private bool ProcessPlayer(Table table, SaveReader reader, DatumIndex index, uint size, long offset)
        {
            if (!index.IsValid)
            {
                return(true);
            }

            ReadPlayerInfo(reader, offset);

            return(false);
        }
Ejemplo n.º 18
0
 public Form1()
 {
     InitializeComponent();
     _dirsReader = new DirsReader();
     _saveReader = new SaveReader(_dirsReader.Find("Saves"));
     foreach (var item in _saveReader.values)
     {
         NumericUpDown nums = (NumericUpDown)Controls.Find(item.Item1, true)[0];
         nums.Value = item.Item2;
     }
 }
Ejemplo n.º 19
0
 public void UseClick(BodyState BodyData)
 {
     if (!BodyData.isLocked)
     {
         sm.saveState.bodyID  = BodyData.id;
         SaveReader.bodyIndex = BodyData.id;
         sm.Save();
         SaveReader.Load();
         mm.UpdateMarket();
     }
 }
Ejemplo n.º 20
0
 public void UseClick(GunState GunData)
 {
     if (!GunData.isLocked)
     {
         sm.saveState.gunID  = GunData.id;
         SaveReader.gunIndex = GunData.id;
         sm.Save();
         SaveReader.Load();
         mm.UpdateMarket();
     }
 }
Ejemplo n.º 21
0
        public void ErrorOnTruncatedHeader()
        {
            var reader            = new StringReader("|MxDz;");
            var buildHeaderReader = new SaveReader(reader);
            var exception         = Assert.Throws <Exception>(() =>
            {
                var buildHeader = buildHeaderReader.Read();
            });

            Assert.Equal("The header was truncated", exception.Message);
        }
Ejemplo n.º 22
0
 private void Awake()
 {
     Instance = this;
     guns     = Resources.LoadAll <GunState>("DataFiles/Guns");
     bodies   = Resources.LoadAll <BodyState>("DataFiles/Bodies");
     Load();
     SaveReader.LoadGun(guns);
     SaveReader.LoadBody(bodies);
     SaveReader.Load(saveState);
     DontDestroyOnLoad(gameObject);
 }
Ejemplo n.º 23
0
        private void ReadPlayerInfo(SaveReader reader, long baseOffset)
        {
            reader.SeekTo(baseOffset + PlayerBipedOffset);
            _bipedIndex = DatumIndex.ReadFrom(reader);

            reader.Seek(baseOffset + 0x50, System.IO.SeekOrigin.Begin);
            _gamertag = reader.ReadUTF16();

            reader.Seek(baseOffset + 0x86, System.IO.SeekOrigin.Begin);
            _serviceTag = reader.ReadUTF16();
        }
Ejemplo n.º 24
0
 public void Save()
 {
     if (PlayerPrefs.HasKey("Save"))
     {
         saveState = SaveReader.ReturnSave();
     }
     FillItem();
     PlayerPrefs.SetString("Save", SaveHelper.Serialize <SaveState>(saveState));
     PlayerPrefs.SetString("Gun", SaveHelper.Serialize <bool[]>(gun));
     PlayerPrefs.SetString("Body", SaveHelper.Serialize <bool[]>(body));
 }
 void GetReferencesFromScene()
 {
     flowchart         = GameObject.FindObjectOfType <Flowchart>();
     flowchartTransVar = flowchart.GetVariable <TransformVariable>("thisTrans");
     gameSaver         = GameObject.FindObjectOfType <GameSaver>();
     gameLoader        = GameObject.FindObjectOfType <GameLoader>();
     saveManager       = GameObject.FindObjectOfType <SaveManager>();
     saveReader        = saveManager.SaveReader;
     someInt           = flowchart.GetVariable <IntegerVariable>("someInt");
     GetRefsToGameObjects();
 }
Ejemplo n.º 26
0
        public void ErrorOnInvalidStart()
        {
            var reader            = new StringReader("MxDz;");
            var buildHeaderReader = new SaveReader(reader);
            var exception         = Assert.Throws <Exception>(() =>
            {
                var buildHeader = buildHeaderReader.Read();
            });

            Assert.Equal("The header is missing", exception.Message);
        }
Ejemplo n.º 27
0
 public void BuyClick(GunState GunData, int index)
 {
     if (SaveReader.money >= GunData.cost && GunData.isLocked)
     {
         sm.guns[index].isLocked = false;
         GunData.isLocked        = false;
         SaveReader.money       -= GunData.cost;
         sm.Save();
         SaveReader.Load();
         mm.UpdateMarket();
     }
 }
Ejemplo n.º 28
0
 public void BuyClick(BodyState BodyData, int index)
 {
     if (SaveReader.money >= BodyData.cost && BodyData.isLocked)
     {
         sm.bodies[index].isLocked = false;
         BodyData.isLocked         = false;
         SaveReader.money         -= BodyData.cost;
         sm.Save();
         SaveReader.Load();
         mm.UpdateMarket();
     }
 }
Ejemplo n.º 29
0
        private bool ProcessPlayer(Table table, SaveReader reader, DatumIndex index, uint size, long offset)
        {
            if (!index.IsValid)
            {
                return(true);
            }

            ReadPlayerInfo(reader, offset);

            // Return false, we only need the first active entry
            return(false);
        }
Ejemplo n.º 30
0
        /// <summary>
        /// Constructs a new Player object containing player information.
        /// </summary>
        /// <param name="reader">The SaveReader to read from. It must be positioned at the start of the players table.</param>
        /// <param name="objectResolver">The IDatumIndexResolver to use to resolve object indices.</param>
        public Player(SaveReader reader, IDatumIndexResolver <GameObject> objectResolver)
        {
            // Read the first entry from the players table
            Table playerTable = new Table(reader);

            if (playerTable.Name != "players")
            {
                throw new ArgumentException("Player info must be read from the \"players\" table. The save file may be corrupt.");
            }
            playerTable.ReadEntries(reader, ProcessPlayer);

            _biped = objectResolver.ResolveIndex(_bipedIndex) as BipedObject;
        }