public void Assign(PowerEntry iPe)
 {
     this.Level         = iPe.Level;
     this.NIDPowerset   = iPe.NIDPowerset;
     this.IDXPower      = iPe.IDXPower;
     this.NIDPower      = iPe.NIDPower;
     this.Tag           = iPe.Tag;
     this.StatInclude   = iPe.StatInclude;
     this.VariableValue = iPe.VariableValue;
     if (iPe.Slots != null)
     {
         this.Slots = new SlotEntry[iPe.Slots.Length];
         for (int index = 0; index <= this.Slots.Length - 1; index++)
         {
             this.Slots[index].Assign(iPe.Slots[index]);
         }
     }
     else
     {
         this.Slots = new SlotEntry[0];
     }
     if (iPe.SubPowers != null)
     {
         this.SubPowers = new PowerSubEntry[iPe.SubPowers.Length];
         for (int index2 = 0; index2 <= this.SubPowers.Length - 1; index2++)
         {
             this.SubPowers[index2].Assign(iPe.SubPowers[index2]);
         }
     }
     else
     {
         this.SubPowers = new PowerSubEntry[0];
     }
 }
Esempio n. 2
0
 public void Assign(PowerEntry iPe)
 {
     Level         = iPe.Level;
     NIDPowerset   = iPe.NIDPowerset;
     IDXPower      = iPe.IDXPower;
     NIDPower      = iPe.NIDPower;
     Tag           = iPe.Tag;
     StatInclude   = iPe.StatInclude;
     VariableValue = iPe.VariableValue;
     if (iPe.Slots != null)
     {
         Slots = new SlotEntry[iPe.Slots.Length];
         for (int index = 0; index <= Slots.Length - 1; ++index)
         {
             Slots[index].Assign(iPe.Slots[index]);
         }
     }
     else
     {
         Slots = new SlotEntry[0];
     }
     if (iPe.SubPowers != null)
     {
         SubPowers = new PowerSubEntry[iPe.SubPowers.Length];
         for (int index = 0; index <= SubPowers.Length - 1; ++index)
         {
             SubPowers[index].Assign(iPe.SubPowers[index]);
         }
     }
     else
     {
         SubPowers = new PowerSubEntry[0];
     }
 }
Esempio n. 3
0
        public void UpdateNonMutationAbilityDescription(string category, ActivatedAbilityEntry ability, bool bAddCooldownOnly = false)
        {
            if (!this.Categories.ContainsKey(category))
            {
                Debug.Log("QudUX Mod: Couldn't find any data for activated ability category '" + category + "'. Activated ability description for " + this.SimplifiedAbilityName(ability.DisplayName) + " won't be updated.");
                return;
            }
            List <Egcb_AbilityDataEntry> abilityData = this.Categories[category];
            string deleteLines   = null;
            string deletePhrases = null;

            foreach (Egcb_AbilityDataEntry abilityDataEntry in abilityData)
            {
                if (abilityDataEntry.Name == this.SimplifiedAbilityName(ability.DisplayName))
                {
                    string description = string.Empty;
                    deleteLines   = abilityDataEntry.DeleteLines;
                    deletePhrases = abilityDataEntry.DeletePhrases;
                    if (!string.IsNullOrEmpty(abilityDataEntry.CustomDescription))
                    {
                        description = abilityDataEntry.CustomDescription;
                    }
                    else if (bAddCooldownOnly)
                    {
                        description = this.VanillaDescriptionText.ContainsKey(ability.ID) ? this.VanillaDescriptionText[ability.ID] : ability.Description;
                    }
                    else if (!string.IsNullOrEmpty(abilityDataEntry.SkillName))
                    {
                        if (SkillFactory.Factory.PowersByClass.ContainsKey(abilityDataEntry.SkillName))
                        {
                            PowerEntry skill = SkillFactory.Factory.PowersByClass[abilityDataEntry.SkillName];
                            description = skill.Description;
                        }
                    }
                    description = description.TrimEnd('\r', '\n', ' ');
                    if (!string.IsNullOrEmpty(description))
                    {
                        if (!string.IsNullOrEmpty(abilityDataEntry.BaseCooldown))
                        {
                            string adjustedCooldownString = this.GetCooldownString(abilityDataEntry.BaseCooldown);
                            if (!string.IsNullOrEmpty(adjustedCooldownString))
                            {
                                description += "\n\n" + adjustedCooldownString;
                            }
                        }
                        if (!this.VanillaDescriptionText.ContainsKey(ability.ID))
                        {
                            this.VanillaDescriptionText.Add(ability.ID, ability.Description);
                        }
                        ability.Description = description;
                    }
                    break;
                }
            }
            if (!this.VanillaDescriptionText.ContainsKey(ability.ID))
            {
                this.VanillaDescriptionText.Add(ability.ID, ability.Description);
            }
            ability.Description = Egcb_AbilityData.SpecialFormatDescription(ability.Description, deleteLines, deletePhrases);
        }
Esempio n. 4
0
            /// <summary>
            /// Creates an ability description for a non-mutation ability. Generally these are loaded
            /// from a combination of AbilityExtenderData.xml, SkillFactory skill/power descriptions,
            /// or the hard-coded activated ability description when one exists. Cooldown information
            /// is also appended to the description.
            /// </summary>
            public List <string> MakeNonMutationAbilityDescription(string category, ActivatedAbilityEntry ability, bool bAddCooldownOnly = false)
            {
                if (!this.Categories.ContainsKey(category))
                {
                    LogUnique($"(Warning) Activated ability description for '{SimplifiedAbilityName(ability?.DisplayName)}'"
                              + $" won't be updated. (Couldn't find any data for activated ability category '{category}')");
                    return(SpecialFormatDescription(ability?.Description, SourceAbility: ability));
                }
                List <AbilityXmlInfo> abilityData = this.Categories[category];

                foreach (AbilityXmlInfo abilityDataEntry in abilityData)
                {
                    if (abilityDataEntry.Name == SimplifiedAbilityName(ability.DisplayName))
                    {
                        string description   = string.Empty;
                        string deleteLines   = abilityDataEntry.DeleteLines;
                        string deletePhrases = abilityDataEntry.DeletePhrases;
                        if (!string.IsNullOrEmpty(abilityDataEntry.CustomDescription))
                        {
                            description = abilityDataEntry.CustomDescription;
                        }
                        else if (bAddCooldownOnly)
                        {
                            description = ability.Description;
                        }
                        else if (!string.IsNullOrEmpty(abilityDataEntry.SkillName))
                        {
                            if (SkillFactory.Factory.PowersByClass.ContainsKey(abilityDataEntry.SkillName))
                            {
                                PowerEntry skill = SkillFactory.Factory.PowersByClass[abilityDataEntry.SkillName];
                                description = skill.Description;
                            }
                        }
                        description = description.TrimEnd('\r', '\n', ' ');
                        if (string.IsNullOrEmpty(description) && !string.IsNullOrEmpty(ability.Description)) //just in case
                        {
                            description = ability.Description;
                            description = description.TrimEnd('\r', '\n', ' ');
                        }
                        if (!string.IsNullOrEmpty(description))
                        {
                            if (!string.IsNullOrEmpty(abilityDataEntry.BaseCooldown))
                            {
                                if (string.IsNullOrEmpty(abilityDataEntry.NoCooldownReduction) || abilityDataEntry.NoCooldownReduction != "true")
                                {
                                    string baseCooldown   = GetAdjustedBaseCooldown(abilityDataEntry);
                                    string cooldownString = this.GetCooldownString(baseCooldown);
                                    if (!string.IsNullOrEmpty(cooldownString))
                                    {
                                        description += "\n\n" + cooldownString;
                                    }
                                }
                            }
                        }
                        return(SpecialFormatDescription(description, deleteLines, deletePhrases, ability));
                    }
                }
                return(SpecialFormatDescription(ability?.Description, SourceAbility: ability));
            }
    public object Clone()
    {
        PowerEntry powerEntry = new PowerEntry(this.Level, this.Power, this.Chosen)
        {
            StatInclude   = this.StatInclude,
            Tag           = this.Tag,
            VariableValue = this.VariableValue,
            SubPowers     = (PowerSubEntry[])this.SubPowers.Clone(),
            Slots         = new SlotEntry[this.Slots.Length]
        };

        for (int index = 0; index < this.SlotCount; index++)
        {
            powerEntry.Slots[index].Level              = this.Slots[index].Level;
            powerEntry.Slots[index].Enhancement        = (this.Slots[index].Enhancement.Clone() as I9Slot);
            powerEntry.Slots[index].FlippedEnhancement = (this.Slots[index].FlippedEnhancement.Clone() as I9Slot);
        }
        return(powerEntry);
    }
Esempio n. 6
0
    public object Clone()
    {
        PowerEntry powerEntry = new PowerEntry(Level, Power, Chosen)
        {
            StatInclude   = StatInclude,
            Tag           = Tag,
            VariableValue = VariableValue,
            SubPowers     = (PowerSubEntry[])SubPowers.Clone(),
            Slots         = new SlotEntry[Slots.Length]
        };

        for (int index = 0; index < SlotCount; ++index)
        {
            powerEntry.Slots[index].Level              = Slots[index].Level;
            powerEntry.Slots[index].Enhancement        = Slots[index].Enhancement.Clone() as I9Slot;
            powerEntry.Slots[index].FlippedEnhancement = Slots[index].FlippedEnhancement.Clone() as I9Slot;
        }
        return(powerEntry);
    }
Esempio n. 7
0
 public void Reset()
 {
     PowerEntry = null;
     InternalReset();
 }
    static bool MxDReadSaveData(ref byte[] buffer, bool silent)
    {
        if (buffer.Length < 1)
        {
            MessageBox.Show("Unable to read data - Empty Buffer.", "ReadSaveData Failed");
            return(false);
        }
        else
        {
            MemoryStream memoryStream;
            BinaryReader reader;
            try
            {
                memoryStream = new MemoryStream(buffer, writable: false);
                reader       = new BinaryReader(memoryStream);
                reader.BaseStream.Seek(0L, SeekOrigin.Begin);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Unable to read data - " + ex.Message, "ReadSaveData Failed");
                return(false);
            }
            try
            {
                int  streamIndex = 0;
                bool magicFound;
                // try to find magic number, reading 4 bytes at a time, offset by 1 on each failure
                do
                {
                    reader.BaseStream.Seek(streamIndex, SeekOrigin.Begin);

                    var numArray = reader.ReadBytes(4);
                    if (numArray.Length >= 4)
                    {
                        magicFound = true;
                        for (int index = 0; index < MagicNumber.Length; ++index)
                        {
                            if (MagicNumber[index] != numArray[index])
                            {
                                magicFound = false;
                            }
                        }
                        if (!magicFound)
                        {
                            ++streamIndex;
                        }
                    }
                    else
                    {
                        if (!silent)
                        {
                            MessageBox.Show("Unable to read data - Magic Number not found.", "ReadSaveData Failed");
                        }
                        reader.Close();
                        memoryStream.Close();
                        return(false);
                    }
                }while (!magicFound);

                float fVersion = reader.ReadSingle();
                if (fVersion > 2.0)
                {
                    MessageBox.Show("File was saved by a newer version of the application. Please obtain the most recent release in order to open this file.", "Unable to Load");
                    reader.Close();
                    memoryStream.Close();
                    return(false);
                }
                else
                {
                    bool qualifiedNames = reader.ReadBoolean();
                    bool hasSubPower    = reader.ReadBoolean();
                    int  nIDClass       = DatabaseAPI.NidFromUidClass(reader.ReadString());
                    if (nIDClass < 0)
                    {
                        if (!silent)
                        {
                            MessageBox.Show("Unable to read data - Invalid Class UID.", "ReadSaveData Failed");
                        }
                        reader.Close();
                        memoryStream.Close();
                        return(false);
                    }
                    else
                    {
                        int iOrigin = DatabaseAPI.NidFromUidOrigin(reader.ReadString(), nIDClass);
                        MidsContext.Character.Reset(DatabaseAPI.Database.Classes[nIDClass], iOrigin);
                        if (fVersion > 1.0)
                        {
                            int align = reader.ReadInt32();
                            MidsContext.Character.Alignment = (Enums.Alignment)align;
                        }
                        MidsContext.Character.Name = reader.ReadString();
                        int num4 = reader.ReadInt32();
                        if (MidsContext.Character.Powersets.Length - 1 != num4)
                        {
                            MidsContext.Character.Powersets = new IPowerset[num4 + 1];
                        }
                        for (int index = 0; index < MidsContext.Character.Powersets.Length; ++index)
                        {
                            string iName = reader.ReadString();
                            MidsContext.Character.Powersets[index] = !string.IsNullOrEmpty(iName) ? DatabaseAPI.GetPowersetByName(iName) : null;
                        }
                        MidsContext.Character.CurrentBuild.LastPower = reader.ReadInt32() - 1;
                        int powerCount = reader.ReadInt32();
                        try
                        {
                            for (int powerIndex = 0; powerIndex <= powerCount; ++powerIndex)
                            {
                                int    nId       = -1;
                                string name1     = "";
                                int    sidPower1 = -1;
                                if (qualifiedNames)
                                {
                                    name1 = reader.ReadString();
                                    if (!string.IsNullOrEmpty(name1))
                                    {
                                        nId = DatabaseAPI.NidFromUidPower(name1);
                                    }
                                }
                                else
                                {
                                    sidPower1 = reader.ReadInt32();
                                    nId       = DatabaseAPI.NidFromStaticIndexPower(sidPower1);
                                }
                                bool       flag5 = false;
                                PowerEntry powerEntry1;
                                if (powerIndex < MidsContext.Character.CurrentBuild.Powers.Count)
                                {
                                    powerEntry1 = MidsContext.Character.CurrentBuild.Powers[powerIndex];
                                }
                                else
                                {
                                    powerEntry1 = new PowerEntry(-1, null, false);
                                    flag5       = true;
                                }
                                if (sidPower1 > -1 | !string.IsNullOrEmpty(name1))
                                {
                                    powerEntry1.Level         = reader.ReadSByte();
                                    powerEntry1.StatInclude   = reader.ReadBoolean();
                                    powerEntry1.VariableValue = reader.ReadInt32();
                                    if (hasSubPower)
                                    {
                                        powerEntry1.SubPowers = new PowerSubEntry[reader.ReadSByte() + 1];
                                        for (int subPowerIndex = 0; subPowerIndex < powerEntry1.SubPowers.Length; ++subPowerIndex)
                                        {
                                            var powerSub = new PowerSubEntry();
                                            powerEntry1.SubPowers[subPowerIndex] = powerSub;
                                            if (qualifiedNames)
                                            {
                                                string name2 = reader.ReadString();
                                                if (!string.IsNullOrEmpty(name2))
                                                {
                                                    powerSub.nIDPower = DatabaseAPI.NidFromUidPower(name2);
                                                }
                                            }
                                            else
                                            {
                                                int sidPower2 = reader.ReadInt32();
                                                powerSub.nIDPower = DatabaseAPI.NidFromStaticIndexPower(sidPower2);
                                            }
                                            if (powerSub.nIDPower > -1)
                                            {
                                                powerSub.Powerset = DatabaseAPI.Database.Power[powerSub.nIDPower].PowerSetID;
                                                powerSub.Power    = DatabaseAPI.Database.Power[powerSub.nIDPower].PowerSetIndex;
                                            }
                                            powerSub.StatInclude = reader.ReadBoolean();
                                            if (powerSub.nIDPower > -1 & powerSub.StatInclude)
                                            {
                                                PowerEntry powerEntry2 = new PowerEntry(DatabaseAPI.Database.Power[powerSub.nIDPower])
                                                {
                                                    StatInclude = true
                                                };
                                                MidsContext.Character.CurrentBuild.Powers.Add(powerEntry2);
                                            }
                                        }
                                    }
                                }
                                if (nId < 0 && powerIndex < DatabaseAPI.Database.Levels_MainPowers.Length)
                                {
                                    powerEntry1.Level = DatabaseAPI.Database.Levels_MainPowers[powerIndex];
                                }
                                powerEntry1.Slots = new SlotEntry[reader.ReadSByte() + 1];
                                for (var index3 = 0; index3 < powerEntry1.Slots.Length; ++index3)
                                {
                                    powerEntry1.Slots[index3] = new SlotEntry()
                                    {
                                        Level              = reader.ReadSByte(),
                                        Enhancement        = new I9Slot(),
                                        FlippedEnhancement = new I9Slot()
                                    };
                                    ReadSlotData(reader, ref powerEntry1.Slots[index3].Enhancement, qualifiedNames, fVersion);
                                    if (reader.ReadBoolean())
                                    {
                                        ReadSlotData(reader, ref powerEntry1.Slots[index3].FlippedEnhancement, qualifiedNames, fVersion);
                                    }
                                }
                                if (powerEntry1.SubPowers.Length > 0)
                                {
                                    nId = -1;
                                }
                                if (nId > -1)
                                {
                                    powerEntry1.NIDPower    = nId;
                                    powerEntry1.NIDPowerset = DatabaseAPI.Database.Power[nId].PowerSetID;
                                    powerEntry1.IDXPower    = DatabaseAPI.Database.Power[nId].PowerSetIndex;
                                    if (powerEntry1.Level == 0 && powerEntry1.Power.FullSetName == "Pool.Fitness")
                                    {
                                        if (powerEntry1.NIDPower == 2553)
                                        {
                                            powerEntry1.NIDPower = 1521;
                                        }
                                        if (powerEntry1.NIDPower == 2554)
                                        {
                                            powerEntry1.NIDPower = 1523;
                                        }
                                        if (powerEntry1.NIDPower == 2555)
                                        {
                                            powerEntry1.NIDPower = 1522;
                                        }
                                        if (powerEntry1.NIDPower == 2556)
                                        {
                                            powerEntry1.NIDPower = 1524;
                                        }
                                        powerEntry1.NIDPowerset = DatabaseAPI.Database.Power[nId].PowerSetID;
                                        powerEntry1.IDXPower    = DatabaseAPI.Database.Power[nId].PowerSetIndex;
                                    }
                                    var ps = powerEntry1.Power?.GetPowerSet();
                                    if (powerIndex < MidsContext.Character.CurrentBuild.Powers.Count)
                                    {
                                        if (!(!MidsContext.Character.CurrentBuild.Powers[powerIndex].Chosen & ((ps != null && ps.nArchetype > -1) || powerEntry1.Power.GroupName == "Pool")))
                                        {
                                            flag5 = !MidsContext.Character.CurrentBuild.Powers[powerIndex].Chosen;
                                        }
                                        else
                                        {
                                            continue;
                                        }
                                    }
                                    if (flag5)
                                    {
                                        MidsContext.Character.CurrentBuild.Powers.Add(powerEntry1);
                                    }
                                    else if ((ps != null && ps.nArchetype > -1) || powerEntry1.Power.GroupName == "Pool")
                                    {
                                        MidsContext.Character.CurrentBuild.Powers[powerIndex] = powerEntry1;
                                    }
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            if (!silent)
                            {
                                MessageBox.Show("Error reading some power data, will attempt to build character with known data - " + ex.Message, "ReadSaveData Failed");
                            }
                            return(false);
                        }
                        MidsContext.Archetype = MidsContext.Character.Archetype;
                        MidsContext.Character.Validate();
                        MidsContext.Character.Lock();
                        return(true);
                    }
                }
            }
            catch (Exception ex)
            {
                if (!silent)
                {
                    MessageBox.Show("Unable to read data - " + ex.Message, "ReadSaveData Failed");
                }
                return(false);
            }
        }
    }
Esempio n. 9
0
        protected void AddPowerToBuildSheet(RawPowerData p, ref List <PowerEntry> listPowers)
        {
            int i;
            var powerEntry = new PowerEntry
            {
                Level         = p.Level,
                StatInclude   = false,
                VariableValue = 0,
                Slots         = new SlotEntry[p.Slots.Count]
            };

            if (p.Slots.Count > 0)
            {
                for (i = 0; i < powerEntry.Slots.Length; i++)
                {
                    powerEntry.Slots[i] = new SlotEntry
                    {
                        Level              = 49,
                        Enhancement        = new I9Slot(),
                        FlippedEnhancement = new I9Slot()
                    };
                    if (p.Slots[i].InternalName == "Empty")
                    {
                        continue;
                    }

                    var i9Slot  = SelectEnhancementByIdx(p.Slots[i].eData, p.Slots[i].InternalName);
                    var enhType = DatabaseAPI.Database.Enhancements[i9Slot.Enh].TypeID;

                    if (enhType == Enums.eType.Normal || enhType == Enums.eType.SpecialO)
                    {
                        i9Slot.RelativeLevel =
                            (Enums.eEnhRelative)(p.Slots[i].Boosters + 4);  // +4 === 5 boosters ??? Damn you, maths.
                        i9Slot.Grade = Enums.eEnhGrade.SingleO;
                    }

                    if (enhType == Enums.eType.InventO || enhType == Enums.eType.SetO)
                    {
                        // Current enhancement level: //p.Slots[i].Level;
                        // Set to maximum since attuned ones will give the lowest level possible.
                        i9Slot.IOLevel       = DatabaseAPI.Database.Enhancements[i9Slot.Enh].LevelMax;
                        i9Slot.RelativeLevel = (Enums.eEnhRelative)(p.Slots[i].Boosters + 4);
                    }

                    powerEntry.Slots[i].Enhancement = i9Slot;
                }

                if (powerEntry.Slots.Length > 0)
                {
                    powerEntry.Slots[0].Level = powerEntry.Level;
                }
            }

            powerEntry.NIDPower    = p.pData.PowerIndex;
            powerEntry.NIDPowerset = p.pData.PowerSetID;
            powerEntry.IDXPower    = p.pData.PowerSetIndex;
            if (powerEntry.Level == 0 && powerEntry.Power.FullSetName == "Pool.Fitness")
            {
                powerEntry.NIDPower    = OldFitnessPoolIDs[powerEntry.NIDPower];
                powerEntry.NIDPowerset = p.pData.PowerSetID;
                powerEntry.IDXPower    = p.pData.PowerSetIndex;
            }

            try
            {
                listPowers.Add(powerEntry);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace);
            }
        }
Esempio n. 10
0
 public void Reset()
 {
     this.PowerEntry = null;
     this.InternalReset();
 }
    static bool MxDReadSaveData(ref byte[] buffer, bool silent)
    {
        bool flag;

        if (buffer.Length < 1)
        {
            MessageBox.Show("Unable to read data - Empty Buffer.", "ReadSaveData Failed");
            flag = false;
        }
        else
        {
            MemoryStream memoryStream;
            BinaryReader reader;
            bool         flag2;
            try
            {
                memoryStream = new MemoryStream(buffer, false);
                reader       = new BinaryReader(memoryStream);
                reader.BaseStream.Seek(0L, SeekOrigin.Begin);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Unable to read data - " + ex.Message, "ReadSaveData Failed");
                flag2 = false;
                return(flag2);
            }
            try
            {
                int num = 0;
                for (; ;)
                {
                    reader.BaseStream.Seek((long)num, SeekOrigin.Begin);
                    byte[] numArray = reader.ReadBytes(4);
                    if (numArray.Length < 4)
                    {
                        break;
                    }
                    bool flag3 = true;
                    for (int index = 0; index < MidsCharacterFileFormat.MagicNumber.Length; index++)
                    {
                        if (MidsCharacterFileFormat.MagicNumber[index] != numArray[index])
                        {
                            flag3 = false;
                        }
                    }
                    if (!flag3)
                    {
                        num++;
                    }
                    if (flag3)
                    {
                        goto Block_11;
                    }
                }
                if (!silent)
                {
                    MessageBox.Show("Unable to read data - Magic Number not found.", "ReadSaveData Failed");
                }
                reader.Close();
                memoryStream.Close();
                flag2 = false;
                return(flag2);

Block_11:
                float fVersion = reader.ReadSingle();
                if ((double)fVersion > 2.0)
                {
                    MessageBox.Show("File was saved by a newer version of the application. Please obtain the most recent release in order to open this file.", "Unable to Load");
                    reader.Close();
                    memoryStream.Close();
                    flag2 = false;
                }
                else
                {
                    bool qualifiedNames = reader.ReadBoolean();
                    bool flag4          = reader.ReadBoolean();
                    int  nIDClass       = DatabaseAPI.NidFromUidClass(reader.ReadString());
                    if (nIDClass < 0)
                    {
                        if (!silent)
                        {
                            MessageBox.Show("Unable to read data - Invalid Class UID.", "ReadSaveData Failed");
                        }
                        reader.Close();
                        memoryStream.Close();
                        flag2 = false;
                    }
                    else
                    {
                        int iOrigin = DatabaseAPI.NidFromUidOrigin(reader.ReadString(), nIDClass);
                        MidsContext.Character.Reset(DatabaseAPI.Database.Classes[nIDClass], iOrigin);
                        if ((double)fVersion > 1.0)
                        {
                            int num2 = reader.ReadInt32();
                            MidsContext.Character.Alignment = (Enums.Alignment)num2;
                        }
                        MidsContext.Character.Name = reader.ReadString();
                        int num3 = reader.ReadInt32();
                        if (MidsContext.Character.Powersets.Length - 1 != num3)
                        {
                            MidsContext.Character.Powersets = new IPowerset[num3 + 1];
                        }
                        for (int index2 = 0; index2 < MidsContext.Character.Powersets.Length; index2++)
                        {
                            string iName = reader.ReadString();
                            if (string.IsNullOrEmpty(iName))
                            {
                                MidsContext.Character.Powersets[index2] = null;
                            }
                            else
                            {
                                MidsContext.Character.Powersets[index2] = DatabaseAPI.GetPowersetByName(iName);
                            }
                        }
                        MidsContext.Character.CurrentBuild.LastPower = reader.ReadInt32() - 1;
                        int num4 = reader.ReadInt32();
                        try
                        {
                            for (int index3 = 0; index3 <= num4; index3++)
                            {
                                int    index4    = -1;
                                string name2     = string.Empty;
                                int    sidPower2 = -1;
                                if (qualifiedNames)
                                {
                                    name2 = reader.ReadString();
                                    if (!string.IsNullOrEmpty(name2))
                                    {
                                        index4 = DatabaseAPI.NidFromUidPower(name2);
                                    }
                                }
                                else
                                {
                                    sidPower2 = reader.ReadInt32();
                                    index4    = DatabaseAPI.NidFromStaticIndexPower(sidPower2);
                                }
                                bool       flag5 = false;
                                PowerEntry powerEntry;
                                if (index3 < MidsContext.Character.CurrentBuild.Powers.Count)
                                {
                                    powerEntry = MidsContext.Character.CurrentBuild.Powers[index3];
                                }
                                else
                                {
                                    powerEntry = new PowerEntry(-1, null, false);
                                    flag5      = true;
                                }
                                if (sidPower2 > -1 | !string.IsNullOrEmpty(name2))
                                {
                                    powerEntry.Level         = (int)reader.ReadSByte();
                                    powerEntry.StatInclude   = reader.ReadBoolean();
                                    powerEntry.VariableValue = reader.ReadInt32();
                                    if (flag4)
                                    {
                                        powerEntry.SubPowers = new PowerSubEntry[(int)(reader.ReadSByte() + 1)];
                                        for (int index5 = 0; index5 < powerEntry.SubPowers.Length; index5++)
                                        {
                                            powerEntry.SubPowers[index5] = new PowerSubEntry();
                                            if (qualifiedNames)
                                            {
                                                name2 = reader.ReadString();
                                                if (!string.IsNullOrEmpty(name2))
                                                {
                                                    powerEntry.SubPowers[index5].nIDPower = DatabaseAPI.NidFromUidPower(name2);
                                                }
                                            }
                                            else
                                            {
                                                sidPower2 = reader.ReadInt32();
                                                powerEntry.SubPowers[index5].nIDPower = DatabaseAPI.NidFromStaticIndexPower(sidPower2);
                                            }
                                            if (powerEntry.SubPowers[index5].nIDPower > -1)
                                            {
                                                powerEntry.SubPowers[index5].Powerset = DatabaseAPI.Database.Power[powerEntry.SubPowers[index5].nIDPower].PowerSetID;
                                                powerEntry.SubPowers[index5].Power    = DatabaseAPI.Database.Power[powerEntry.SubPowers[index5].nIDPower].PowerSetIndex;
                                            }
                                            powerEntry.SubPowers[index5].StatInclude = reader.ReadBoolean();
                                            if (powerEntry.SubPowers[index5].nIDPower > -1 & powerEntry.SubPowers[index5].StatInclude)
                                            {
                                                PowerEntry powerEntry2 = new PowerEntry(DatabaseAPI.Database.Power[powerEntry.SubPowers[index5].nIDPower])
                                                {
                                                    StatInclude = true
                                                };
                                                MidsContext.Character.CurrentBuild.Powers.Add(powerEntry2);
                                            }
                                        }
                                    }
                                }
                                if (index4 < 0 && index3 < DatabaseAPI.Database.Levels_MainPowers.Length)
                                {
                                    powerEntry.Level = DatabaseAPI.Database.Levels_MainPowers[index3];
                                }
                                powerEntry.Slots = new SlotEntry[(int)(reader.ReadSByte() + 1)];
                                for (int index6 = 0; index6 < powerEntry.Slots.Length; index6++)
                                {
                                    powerEntry.Slots[index6] = new SlotEntry
                                    {
                                        Level              = (int)reader.ReadSByte(),
                                        Enhancement        = new I9Slot(),
                                        FlippedEnhancement = new I9Slot()
                                    };
                                    MidsCharacterFileFormat.ReadSlotData(ref reader, ref powerEntry.Slots[index6].Enhancement, qualifiedNames, fVersion);
                                    if (reader.ReadBoolean())
                                    {
                                        MidsCharacterFileFormat.ReadSlotData(ref reader, ref powerEntry.Slots[index6].FlippedEnhancement, qualifiedNames, fVersion);
                                    }
                                }
                                if (powerEntry.SubPowers.Length > 0)
                                {
                                    index4 = -1;
                                }
                                if (index4 > -1)
                                {
                                    powerEntry.NIDPower    = index4;
                                    powerEntry.NIDPowerset = DatabaseAPI.Database.Power[index4].PowerSetID;
                                    powerEntry.IDXPower    = DatabaseAPI.Database.Power[index4].PowerSetIndex;
                                    if (powerEntry.Level == 0 && powerEntry.Power.FullSetName == "Pool.Fitness")
                                    {
                                        if (powerEntry.NIDPower == 2553)
                                        {
                                            powerEntry.NIDPower = 1521;
                                        }
                                        if (powerEntry.NIDPower == 2554)
                                        {
                                            powerEntry.NIDPower = 1523;
                                        }
                                        if (powerEntry.NIDPower == 2555)
                                        {
                                            powerEntry.NIDPower = 1522;
                                        }
                                        if (powerEntry.NIDPower == 2556)
                                        {
                                            powerEntry.NIDPower = 1524;
                                        }
                                        powerEntry.NIDPowerset = DatabaseAPI.Database.Power[index4].PowerSetID;
                                        powerEntry.IDXPower    = DatabaseAPI.Database.Power[index4].PowerSetIndex;
                                    }
                                    if (index3 < MidsContext.Character.CurrentBuild.Powers.Count)
                                    {
                                        if (!MidsContext.Character.CurrentBuild.Powers[index3].Chosen & (powerEntry.Power.PowerSet.nArchetype > -1 | powerEntry.Power.GroupName == "Pool"))
                                        {
                                            goto IL_91F;
                                        }
                                        flag5 = !MidsContext.Character.CurrentBuild.Powers[index3].Chosen;
                                    }
                                    if (flag5)
                                    {
                                        MidsContext.Character.CurrentBuild.Powers.Add(powerEntry);
                                    }
                                    else if (powerEntry.Power.PowerSet.nArchetype > -1 || powerEntry.Power.GroupName == "Pool")
                                    {
                                        MidsContext.Character.CurrentBuild.Powers[index3] = powerEntry;
                                    }
                                }
                                IL_91F :;
                            }
                        }
                        catch (Exception ex2)
                        {
                            if (!silent)
                            {
                                MessageBox.Show("Error reading some power data, will attempt to build character with known data - " + ex2.Message, "ReadSaveData Failed");
                            }
                            flag2 = false;
                            return(flag2);
                        }
                        MidsContext.Archetype = MidsContext.Character.Archetype;
                        MidsContext.Character.Validate();
                        MidsContext.Character.Lock();
                        flag2 = true;
                    }
                }
            }
            catch (Exception ex3)
            {
                if (!silent)
                {
                    MessageBox.Show("Unable to read data - " + ex3.Message, "ReadSaveData Failed");
                }
                flag2 = false;
            }
            flag = flag2;
        }
        return(flag);
    }