Exemple #1
0
        public void Add(ref I9Slot iEnh)
        {
            if (iEnh.Enh < 0 || DatabaseAPI.Database.Enhancements[iEnh.Enh].TypeID != Enums.eType.SetO)
            {
                return;
            }
            var nIdSet = DatabaseAPI.Database.Enhancements[iEnh.Enh].nIDSet;
            var index  = Lookup(nIdSet);

            if (index >= 0)
            {
                ++SetInfo[index].SlottedCount;
                Array.Resize(ref SetInfo[index].EnhIndexes, SetInfo[index].SlottedCount);
                SetInfo[index].EnhIndexes[SetInfo[index].EnhIndexes.Length - 1] = iEnh.Enh;
            }
            else
            {
                Array.Resize(ref SetInfo, SetInfo.Length + 1);
                SetInfo[SetInfo.Length - 1].SetIDX       = nIdSet;
                SetInfo[SetInfo.Length - 1].SlottedCount = 1;
                SetInfo[SetInfo.Length - 1].Powers       = new int[0];
                Array.Resize(ref SetInfo[SetInfo.Length - 1].EnhIndexes, SetInfo[SetInfo.Length - 1].SlottedCount);
                SetInfo[SetInfo.Length - 1].EnhIndexes[SetInfo[SetInfo.Length - 1].EnhIndexes.Length - 1] = iEnh.Enh;
            }
        }
 private static void WriteSlotData(ref BinaryWriter writer, ref I9Slot slot)
 {
     if (slot.Enh < 0)
     {
         writer.Write(-1);
     }
     else
     {
         if (slot.Enh <= -1)
         {
             return;
         }
         writer.Write(DatabaseAPI.Database.Enhancements[slot.Enh].StaticIndex);
         if (DatabaseAPI.Database.Enhancements[slot.Enh].StaticIndex < 0)
         {
             return;
         }
         if ((DatabaseAPI.Database.Enhancements[slot.Enh].TypeID == Enums.eType.Normal) |
             (DatabaseAPI.Database.Enhancements[slot.Enh].TypeID == Enums.eType.SpecialO))
         {
             writer.Write(Convert.ToSByte(slot.RelativeLevel));
             writer.Write(Convert.ToSByte(slot.Grade));
         }
         else if ((DatabaseAPI.Database.Enhancements[slot.Enh].TypeID == Enums.eType.InventO) |
                  (DatabaseAPI.Database.Enhancements[slot.Enh].TypeID == Enums.eType.SetO))
         {
             writer.Write(Convert.ToSByte(slot.IOLevel));
             writer.Write(Convert.ToSByte(slot.RelativeLevel));
         }
     }
 }
        private static void ReadSlotData(
            BinaryReader reader,
            ref I9Slot slot,
            bool qualifiedNames,
            float fVersion)
        {
            var num = -1;

            if (qualifiedNames)
            {
                var uidEnh = reader.ReadString();
                if (!string.IsNullOrEmpty(uidEnh))
                {
                    num = DatabaseAPI.NidFromUidEnh(uidEnh);
                }
            }
            else
            {
                num = DatabaseAPI.NidFromStaticIndexEnh(reader.ReadInt32());
            }

            if (num <= -1)
            {
                return;
            }
            slot.Enh = num;
            switch (DatabaseAPI.Database.Enhancements[slot.Enh].TypeID)
            {
            case Enums.eType.Normal:
            case Enums.eType.SpecialO:
                slot.RelativeLevel = (Enums.eEnhRelative)reader.ReadSByte();
                slot.Grade         = (Enums.eEnhGrade)reader.ReadSByte();
                break;

            case Enums.eType.InventO:
            case Enums.eType.SetO:
            {
                slot.IOLevel = reader.ReadSByte();
                if (slot.IOLevel > 49)
                {
                    slot.IOLevel = 49;
                }
                if (fVersion > 1.0)
                {
                    slot.RelativeLevel = (Enums.eEnhRelative)reader.ReadSByte();
                }
                break;
            }

            case Enums.eType.None:
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }