Exemplo n.º 1
0
        void DeleteItemsInPageX(string filename)
        {
            GDCryptoDataBuffer pCrypto = new GDCryptoDataBuffer(DataBuffer.ReadBytesFromDisk(filename));

            Stash stash = new Stash();

            if (stash.Read(pCrypto))
            {
                int lootFromIndex;
                if (Settings.Default.StashToLootFrom == 0)
                {
                    lootFromIndex = stash.Tabs.Count - 1;
                }
                else
                {
                    lootFromIndex = Settings.Default.StashToLootFrom - 1;
                }

                Logger.Debug($"Deleting all items in stash #{lootFromIndex}");
                if (stash.Tabs.Count >= lootFromIndex + 1)
                {
                    if (stash.Tabs[lootFromIndex].Items.Count > 0)
                    {
                        stash.Tabs[lootFromIndex].Items.Clear();
                        SafelyWriteStash(filename, stash);
                    }
                }
            }
        }
Exemplo n.º 2
0
        public void Read(GDCryptoDataBuffer reader)
        {
            reader.ReadBlockStart(BLOCK);

            int version = reader.ReadCryptoIntUnchecked();

            if (version != VERSION)
            {
                throw new FormatException("ERR_UNSUPPORTED_VERSION");
            }

            bool allGood;

            reader.ReadCryptoBool(out allGood);
            if (allGood)
            {
                int numSacks = reader.ReadCryptoIntUnchecked(true);

                int focused  = reader.ReadCryptoIntUnchecked(true);
                int selected = reader.ReadCryptoIntUnchecked(true);

                for (int i = 0; i < numSacks; i = i + 1)
                {
                    GDCharInventorySack sack = new GDCharInventorySack();
                    sack.Read(reader);

                    //sacks.add(sack);
                }

                equipment.Read(reader);
            }

            // end marker
            reader.ReadBlockEnd();
        }
Exemplo n.º 3
0
        public List <PlayerItem> EmptyStash(string filename)
        {
            Logger.InfoFormat("Looting {0}", filename);

            var pCrypto = new GDCryptoDataBuffer(DataBuffer.ReadBytesFromDisk(filename));
            var items   = new List <Item>();
            var stash   = new Stash();

            if (stash.Read(pCrypto))
            {
                var isHardcore = GlobalPaths.IsHardcore(filename);

                foreach (var tab in stash.Tabs)
                {
                    // Grab the items and clear the tab
                    items.AddRange(tab.Items);
                    tab.Items.Clear();
                }

                SafelyWriteStash(filename, stash);
                Logger.InfoFormat("Looted {0} items from stash", items.Count);

                return(items.Select(m => Map(m, stash.ModLabel, isHardcore, stash.IsExpansion1)).ToList());
            }

            Logger.Error("Could not load stash file.");
            Logger.Error("An update from the developer is most likely required.");

            return(new List <PlayerItem>());
        }
Exemplo n.º 4
0
        public StashManager(
            IPlayerItemDao playerItemDao,
            IDatabaseItemStatDao dbItemStatDao,
            Action <string, string> setFeedback,
            Action performedLootCallback
            )
        {
            _playerItemDao         = playerItemDao;
            _itemSizeService       = new ItemSizeService(dbItemStatDao);
            _setFeedback           = setFeedback;
            _performedLootCallback = performedLootCallback;

            var path = GlobalPaths.SavePath;

            if (!string.IsNullOrEmpty(path) && File.Exists(path))
            {
                UpdateUnlooted(path);

                var pCrypto = new GDCryptoDataBuffer(DataBuffer.ReadBytesFromDisk(path));
                var stash   = new Stash();

                if (stash.Read(pCrypto))
                {
                    NumStashTabs = stash.Tabs.Count;
                }
            }
        }
Exemplo n.º 5
0
        public List <PlayerItem> EmptyStash(string filename)
        {
            Logger.InfoFormat("Looting {0}", filename);

            var pCrypto = new GDCryptoDataBuffer(DataBuffer.ReadBytesFromDisk(filename));
            var items   = new List <Item>();
            var stash   = new Stash();

            if (stash.Read(pCrypto))
            {
                var isHardcore = GlobalPaths.IsHardcore(filename);

                foreach (var tab in stash.Tabs)
                {
                    // Grab the items and clear the tab
                    items.AddRange(Classify(tab).Remaining);
                    tab.Items.Clear();
                }

                _stashWriter.SafelyWriteStash(filename, stash); // TODO: Ideally we should check if it worked.
                Logger.InfoFormat("Looted {0} items from stash", items.Count);

                return(items.Select(m => TransferStashService.Map(m, stash.ModLabel, isHardcore)).ToList());
            }

            Logger.Error("Could not load stash file.");
            Logger.Error("An update from the developer is most likely required.");

            return(new List <PlayerItem>());
        }
Exemplo n.º 6
0
        public void Read(GDCryptoDataBuffer reader)
        {
            reader.ReadBlockStart(BLOCK);


            int version = reader.ReadCryptoIntUnchecked();

            if (version != VERSION)
            {
                throw new FormatException("ERR_UNSUPPORTED_VERSION");
            }

            Level          = reader.ReadCryptoIntUnchecked();
            Experience     = reader.ReadCryptoIntUnchecked();
            ModifierPoints = reader.ReadCryptoIntUnchecked();
            SkillPoints    = reader.ReadCryptoIntUnchecked();
            DevotionPoints = reader.ReadCryptoIntUnchecked();
            TotalDevotion  = reader.ReadCryptoIntUnchecked();

            TotalStrength     = reader.ReadCryptoFloatUnchecked();
            TotalAgility      = reader.ReadCryptoFloatUnchecked();
            TotalIntelligence = reader.ReadCryptoFloatUnchecked();
            Health            = reader.ReadCryptoFloatUnchecked();
            Energy            = reader.ReadCryptoFloatUnchecked();

            // end marker
            reader.ReadBlockEnd();
        }
Exemplo n.º 7
0
        public GDItem[] Weapon2 = new GDItem[2];    // Equipped items in weapon slots 2

        public void Read(GDCryptoDataBuffer reader)
        {
            byte useAlternate = reader.ReadCryptoByteUnchecked();

            for (int i = 0; i < Equipment.Length; i = i + 1)
            {
                GDItem item = new GDItem(GDItem.GDItemType.EQUIPPED);
                item.Read(reader);
                Equipment[i] = item;
            }

            byte alternate1 = reader.ReadCryptoByteUnchecked();

            for (int i = 0; i < Weapon1.Length; i = i + 1)
            {
                GDItem item = new GDItem(GDItem.GDItemType.EQUIPPED);
                item.Read(reader);
                Weapon1[i] = item;
            }

            byte alternate2 = reader.ReadCryptoByteUnchecked();

            for (int i = 0; i < Weapon2.Length; i = i + 1)
            {
                GDItem item = new GDItem(GDItem.GDItemType.EQUIPPED);
                item.Read(reader);

                Weapon2[i] = item;
            }
        }
Exemplo n.º 8
0
        public void Read(GDCryptoDataBuffer reader)
        {
            reader.ReadBlockStart(BLOCK);

            int version = reader.ReadCryptoIntUnchecked();

            if (version != VERSION)
            {
                throw new FormatException("ERR_UNSUPPORTED_VERSION");
            }

            Skills = new List <GDCharSkill>();
            int numSkills = reader.ReadCryptoIntUnchecked();

            for (int i = 0; i < numSkills; i++)
            {
                var skill = new GDCharSkill();
                skill.Read(reader);
                Skills.Add(skill);
            }

            /*
             * int numItemSkills = reader.ReadCryptoIntUnchecked();
             * for (int i = 0; i < numItemSkills; i++) {
             * }
             *
             * reader.ReadBlockEnd();
             */
        }
Exemplo n.º 9
0
        public static void DeleteItemsInPageX(string filename)
        {
            try {
                GDCryptoDataBuffer pCrypto = new GDCryptoDataBuffer(DataBuffer.ReadBytesFromDisk(filename));

                Stash stash = new Stash();
                if (stash.Read(pCrypto))
                {
                    int lootFromIndex;
                    if (Settings.Default.StashToLootFrom == 0)
                    {
                        lootFromIndex = stash.Tabs.Count - 1;
                    }
                    else
                    {
                        lootFromIndex = Settings.Default.StashToLootFrom - 1;
                    }

                    Logger.Debug($"Deleting all items in stash #{lootFromIndex}");
                    if (stash.Tabs.Count >= lootFromIndex + 1)
                    {
                        if (stash.Tabs[lootFromIndex].Items.Count > 0)
                        {
                            stash.Tabs[lootFromIndex].Items.Clear();
                            SafelyWriteStash(filename, stash);
                        }
                    }
                }
            }
            catch (IOException ex) {
                // Unfortunate, but not the end of the world.
                Logger.Warn(ex);
            }
        }
Exemplo n.º 10
0
        public void Read(GDCryptoDataBuffer reader)
        {
            reader.ReadBlockStart(BLOCK);

            int version = reader.ReadCryptoIntUnchecked();

            if (version != VERSION)
            {
                throw new FormatException("ERR_UNSUPPORTED_VERSION");
            }

            int numDifficulties = 3;

            for (int i = 0; i < numDifficulties; i++)
            {
                int length = reader.ReadCryptoIntUnchecked();
                for (int m = 0; m < length; m++)
                {
                    reader.ReadAndDiscardUID();
                }
            }

            int numSpawnPoints = 3; // Devils, Homestead, Fort Ikon

            for (int i = 0; i < numSpawnPoints; i++)
            {
                reader.ReadAndDiscardUID();
            }

            reader.ReadBlockEnd();
        }
Exemplo n.º 11
0
        public bool Read(GDCryptoDataBuffer pCrypto)
        {
            uint num  = 0;
            bool flag = !Block.ReadStart(out this._block, pCrypto) || !pCrypto.ReadCryptoUInt(out this.Width) || !pCrypto.ReadCryptoUInt(out this.Height) || !pCrypto.ReadCryptoUInt(out num);
            bool result;

            if (flag)
            {
                result = false;
            }
            else
            {
                this.Items = new List <Item>();
                for (uint num2 = 0u; num2 < num; num2 += 1u)
                {
                    Item item  = new Item();
                    bool flag2 = !item.Read(pCrypto);
                    if (flag2)
                    {
                        result = false;
                        return(result);
                    }
                    this.Items.Add(item);
                }
                bool flag3 = !this._block.ReadEnd(pCrypto);
                result = !flag3;
            }
            return(result);
        }
Exemplo n.º 12
0
        public TransferStashService(
            IPlayerItemDao playerItemDao,
            IDatabaseItemStatDao dbItemStatDao,
            Action <string, string, string> setFeedback,
            Action performedLootCallback
            )
        {
            _playerItemDao         = playerItemDao;
            _itemSizeService       = new ItemSizeService(dbItemStatDao);
            _setFeedback           = setFeedback;
            _performedLootCallback = performedLootCallback;

            // TODO: Should also check for transfer.gsh and pick whichever is newest / has the highest number
            var path = Path.Combine(GlobalPaths.SavePath, "transfer.gst");

            if (!string.IsNullOrEmpty(path) && File.Exists(path))
            {
                UpdateUnlooted(path);

                var pCrypto = new GDCryptoDataBuffer(DataBuffer.ReadBytesFromDisk(path));
                var stash   = new Stash();

                if (stash.Read(pCrypto))
                {
                    NumStashTabs = stash.Tabs.Count;
                }
            }
        }
Exemplo n.º 13
0
        public static Stash GetStash(string filename)
        {
            var pCrypto = new GDCryptoDataBuffer(DataBuffer.ReadBytesFromDisk(filename));
            var stash   = new Stash();

            return(stash.Read(pCrypto) ? stash : null);
        }
Exemplo n.º 14
0
        public static Stash GetStash(string filename)
        {
            GDCryptoDataBuffer pCrypto = new GDCryptoDataBuffer(DataBuffer.ReadBytesFromDisk(filename));

            Stash stash = new Stash();

            if (stash.Read(pCrypto))
            {
                return(stash);
            }
            return(null);
        }
Exemplo n.º 15
0
 public void Read(GDCryptoDataBuffer reader)
 {
     Name          = reader.ReadCryptoStringUnchecked();
     Level         = reader.ReadCryptoIntUnchecked();
     Enabled       = reader.ReadCryptoByteUnchecked() == 1;
     DevotionLevel = reader.ReadCryptoIntUnchecked();
     Experience    = reader.ReadCryptoIntUnchecked();
     Active        = reader.ReadCryptoIntUnchecked();
     reader.ReadCryptoByteUnchecked();
     reader.ReadCryptoByteUnchecked();
     AutoCastSkill      = reader.ReadCryptoStringUnchecked();
     AutoCastController = reader.ReadCryptoStringUnchecked();
 }
Exemplo n.º 16
0
        public bool Read(GDCryptoDataBuffer pCrypto)
        {
            bool flag = !pCrypto.ReadCryptoString(out this.BaseRecord) || !pCrypto.ReadCryptoString(out this.PrefixRecord) ||
                        !pCrypto.ReadCryptoString(out this.SuffixRecord) || !pCrypto.ReadCryptoString(out this.ModifierRecord) ||
                        !pCrypto.ReadCryptoString(out this.TransmuteRecord) || !pCrypto.ReadCryptoUInt(out this.Seed) ||
                        !pCrypto.ReadCryptoString(out this.MateriaRecord) || !pCrypto.ReadCryptoString(out this.RelicCompletionBonusRecord) ||
                        !pCrypto.ReadCryptoUInt(out this.RelicSeed) || !pCrypto.ReadCryptoString(out this.EnchantmentRecord) ||
                        !pCrypto.ReadCryptoUInt(out this.UNKNOWN) || !pCrypto.ReadCryptoUInt(out this.EnchantmentSeed) ||
                        !pCrypto.ReadCryptoUInt(out this.MateriaCombines) || !pCrypto.ReadCryptoUInt(out this.StackCount);

            flag = flag || !pCrypto.ReadCryptoUInt(out this.XOffset) || !pCrypto.ReadCryptoUInt(out this.YOffset);
            return(!flag);
        }
Exemplo n.º 17
0
        public static int GetNumStashPages(string filename)
        {
            if (File.Exists(filename))
            {
                var pCrypto = new GDCryptoDataBuffer(DataBuffer.ReadBytesFromDisk(filename));

                var stash = new Stash();
                if (stash.Read(pCrypto))
                {
                    return(stash.Tabs.Count);
                }
            }

            return(0);
        }
Exemplo n.º 18
0
        private int GetNumTabsInStash(string file)
        {
            if (!string.IsNullOrEmpty(file) && File.Exists(file))
            {
                var pCrypto = new GDCryptoDataBuffer(DataBuffer.ReadBytesFromDisk(file));
                var stash   = new Stash();

                if (stash.Read(pCrypto))
                {
                    return(stash.Tabs.Count);
                }
            }

            return(1);
        }
Exemplo n.º 19
0
        public void UpdateUnlooted(string filename)
        {
            var pCrypto = new GDCryptoDataBuffer(DataBuffer.ReadBytesFromDisk(filename));
            var stash   = new Stash();

            if (stash.Read(pCrypto))
            {
                // Update the internal listing of unlooted items (in stash tabs)
                var unlootedLocal = new List <Item>();
                foreach (var tab in stash.Tabs)
                {
                    unlootedLocal.AddRange(tab.Items);
                }
                Interlocked.Exchange(ref _unlootedItems, new ConcurrentBag <Item>(unlootedLocal));
            }
        }
Exemplo n.º 20
0
        public void ReadSummary(byte[] data)
        {
            reader = new GDCryptoDataBuffer(data);
            int val = 0;

            reader.ReadCryptoKey();

            if (!reader.ReadCryptoInt(out val))
            {
                throw new FormatException("ERR_UNSUPPORTED_VERSION");
            }

            if (val != 0x58434447)
            {
                throw new FormatException("ERR_UNSUPPORTED_VERSION");
            }

            reader.ReadCryptoInt(out val);
            if (val != 1)
            {
                throw new FormatException("ERR_UNSUPPORTED_VERSION");
            }


            ReadHeader();

            reader.ReadCryptoInt(out val, false);
            if (val != 0)
            {
                throw new FormatException("ERR_UNSUPPORTED_VERSION");
            }

            int version;

            reader.ReadCryptoInt(out version);
            if ((version != 6) && (version != 7))
            {
                throw new FormatException("ERR_UNSUPPORTED_VERSION");
            }

            reader.ReadAndDiscardUID();
            ReadCharacterInfo();
            Bio.Read(reader);

            Inventory.Read(reader);
        }
Exemplo n.º 21
0
        public void Read(GDCryptoDataBuffer reader)
        {
            reader.ReadBlockStart(BLOCK);

            reader.ReadCryptoByteUnchecked();


            int numItems = reader.ReadCryptoIntUnchecked();

            for (int i = 0; i < numItems; i = i + 1)
            {
                GDItem item = new GDItem(GDItem.GDItemType.INVENTORY);
                item.Read(reader);
            }

            reader.ReadBlockEnd();
        }
Exemplo n.º 22
0
        /// <summary>
        /// Attempt to get the name of the current mod
        /// Vanilla leaves this tag empty
        /// </summary>
        /// <param name="filename"></param>
        /// <param name="result"></param>
        /// <returns></returns>
        public static bool TryGetModLabel(string filename, out string result)
        {
            if (File.Exists(filename))
            {
                var pCrypto = new GDCryptoDataBuffer(DataBuffer.ReadBytesFromDisk(filename));
                var stash   = new Stash();

                if (stash.Read(pCrypto))
                {
                    result = stash.ModLabel;
                    return(true);
                }
            }

            result = string.Empty;
            return(false);
        }
Exemplo n.º 23
0
        private (Stash, List <UserFeedback>) Load(string transferFile)
        {
            var pCrypto = new GDCryptoDataBuffer(DataBuffer.ReadBytesFromDisk(transferFile));
            var stash   = new Stash();

            if (stash.Read(pCrypto))
            {
                var lootFromStashIdx = _transferStashService.GetStashToLootFrom(stash);
                var errors           = Validate(stash, lootFromStashIdx);
                if (errors.Count > 0)
                {
                    return(null, errors);
                }

                return(stash, new List <UserFeedback>(0));
            }

            return(null, UserFeedback.FromTagSingleton("iatag_stash_corrupted_or_unreadable"));
        }
Exemplo n.º 24
0
        private void ReadInternalV4(GDCryptoDataBuffer reader)
        {
            BaseRecord      = reader.ReadCryptoStringUnchecked();
            PrefixRecord    = reader.ReadCryptoStringUnchecked();
            SuffixRecord    = reader.ReadCryptoStringUnchecked();
            ModifierRecord  = reader.ReadCryptoStringUnchecked();
            TransmuteRecord = reader.ReadCryptoStringUnchecked();
            Seed            = reader.ReadCryptoIntUnchecked();

            ComponentRecord = reader.ReadCryptoStringUnchecked();
            CompletionBonus = reader.ReadCryptoStringUnchecked();
            ComponentSeed   = reader.ReadCryptoIntUnchecked();
            AugmentRecord   = reader.ReadCryptoStringUnchecked();
            unknown         = reader.ReadCryptoIntUnchecked();
            AugmentSeed     = reader.ReadCryptoIntUnchecked();
            unknown2        = reader.ReadCryptoIntUnchecked();

            StackCount = reader.ReadCryptoIntUnchecked();
        }
Exemplo n.º 25
0
        public StashManager(IPlayerItemDao playerItemDao, IDatabaseItemStatDao dbItemStatDao)
        {
            _playerItemDao   = playerItemDao;
            _itemSizeService = new ItemSizeService(dbItemStatDao);
            string path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "My Games",
                                       "Grim Dawn", "Save", "transfer.gst");

            if (!string.IsNullOrEmpty(path) && File.Exists(path))
            {
                UpdateUnlooted(path);

                GDCryptoDataBuffer pCrypto = new GDCryptoDataBuffer(DataBuffer.ReadBytesFromDisk(path));
                Stash stash = new Stash();
                if (stash.Read(pCrypto))
                {
                    NumStashTabs = stash.Tabs.Count;
                }
            }
        }
Exemplo n.º 26
0
        public TransferStashService(IDatabaseItemStatDao dbItemStatDao, SettingsService settings, SafeTransferStashWriter stashWriter)
        {
            _settings        = settings;
            _stashWriter     = stashWriter;
            _itemSizeService = new ItemSizeService(dbItemStatDao);

            // TODO: Should also check for transfer.gsh and pick whichever is newest / has the highest number
            var path = Path.Combine(GlobalPaths.SavePath, "transfer.gst");

            if (!string.IsNullOrEmpty(path) && File.Exists(path))
            {
                var pCrypto = new GDCryptoDataBuffer(DataBuffer.ReadBytesFromDisk(path));
                var stash   = new Stash();

                if (stash.Read(pCrypto))
                {
                    NumStashTabs = stash.Tabs.Count;
                }
            }
        }
Exemplo n.º 27
0
        /// <summary>
        /// Attempt to get the name of the current mod
        /// Vanilla leaves this tag empty
        /// </summary>
        /// <param name="filename"></param>
        /// <param name="result"></param>
        /// <returns></returns>
        public static bool TryGetModLabel(string filename, out string result)
        {
            if (File.Exists(filename))
            {
                var pCrypto = new GDCryptoDataBuffer(DataBuffer.ReadBytesFromDisk(filename));
                var stash   = new Stash();

                if (stash.Read(pCrypto))
                {
                    result = stash.ModLabel;
                    return(true);
                }
                else
                {
                    Logger.Warn($"Discarding transfer file \"{filename}\", could not read the file.");
                }
            }

            result = string.Empty;
            return(false);
        }
Exemplo n.º 28
0
        public void Read(GDCryptoDataBuffer reader)
        {
            ReadInternalV4(reader);

            if ((containerType == GDItemType.STASH_SHARED) || (containerType == GDItemType.STASH_CHAR))
            {
                float xPos = reader.ReadCryptoIntUnchecked();
                float yPos = reader.ReadCryptoIntUnchecked();
            }

            if (containerType == GDItemType.INVENTORY)
            {
                int x = reader.ReadCryptoIntUnchecked();
                int y = reader.ReadCryptoIntUnchecked();
            }

            if (containerType == GDItemType.EQUIPPED)
            {
                int attached = reader.ReadCryptoByteUnchecked();
            }
        }
Exemplo n.º 29
0
        public void Read(GDCryptoDataBuffer reader)
        {
            reader.ReadBlockStart(BLOCK);

            int version = reader.ReadCryptoIntUnchecked();

            if (version != VERSION)
            {
                throw new FormatException("ERR_UNSUPPORTED_VERSION");
            }

            int width    = reader.ReadCryptoIntUnchecked();
            int height   = reader.ReadCryptoIntUnchecked();
            int numItems = reader.ReadCryptoIntUnchecked();

            for (int i = 0; i < numItems; i++)
            {
                var item = new GDItem(GDItem.GDItemType.STASH_CHAR);
                item.Read(reader);
            }
            reader.ReadBlockEnd();
        }
Exemplo n.º 30
0
        public void Read(GDCryptoDataBuffer reader)
        {
            reader.ReadBlockStart(BLOCK);

            int version = reader.ReadCryptoIntUnchecked();

            if (version != VERSION)
            {
                throw new FormatException("ERR_UNSUPPORTED_VERSION");
            }

            int numStates = 6;// 0 = Normal, found, 1 = Normal, restored, 2 = Epic, found and so forth

            for (int i = 0; i < numStates; i++)
            {
                int length = reader.ReadCryptoIntUnchecked();
                for (int m = 0; m < length; m++)
                {
                    reader.ReadAndDiscardUID();
                }
            }

            reader.ReadBlockEnd();
        }