Exemplo n.º 1
0
        public void AddEntry(int id, BSA_Entry entry)
        {
            for (int i = 0; i < BSA_Entries.Count; i++)
            {
                if (int.Parse(BSA_Entries[i].Index) == id)
                {
                    BSA_Entries[i] = entry;
                    return;
                }
            }

            BSA_Entries.Add(entry);
        }
Exemplo n.º 2
0
        //Utility
        private int BsaTypeCount(BSA_Entry bsaEntry)
        {
            int count = 0;

            if (bsaEntry.Type0 != null)
            {
                count++;
            }
            if (bsaEntry.Type1 != null)
            {
                count++;
            }
            if (bsaEntry.Type2 != null)
            {
                count++;
            }
            if (bsaEntry.Type3 != null)
            {
                count++;
            }
            if (bsaEntry.Type4 != null)
            {
                count++;
            }
            if (bsaEntry.Type6 != null)
            {
                count++;
            }
            if (bsaEntry.Type7 != null)
            {
                count++;
            }
            if (bsaEntry.Type8 != null)
            {
                count++;
            }
            return(count);
        }
Exemplo n.º 3
0
 public int AddEntry(BSA_Entry entry)
 {
     entry.SortID = GetFreeId();
     BSA_Entries.Add(entry);
     return(entry.SortID);
 }
Exemplo n.º 4
0
        private void WriteTypes(BSA_Entry types, int offsetToFill)
        {
            if (BsaTypeCount(types) > 0)
            {
                bytes = Utils.ReplaceRange(bytes, BitConverter.GetBytes(bytes.Count() - offsetToFill + 36), offsetToFill);
                List <int> hdrOffset  = new List <int>();
                List <int> dataOffset = new List <int>();
                List <int> typeList   = new List <int>();

                //Type Headers
                if (types.Type0 != null)
                {
                    var results = WriteTypeHeader(0, types.Type0.Count());
                    hdrOffset.Add(results[0]);
                    dataOffset.Add(results[1]);
                    typeList.Add(0);
                }
                if (types.Type1 != null)
                {
                    var results = WriteTypeHeader(1, types.Type1.Count());
                    hdrOffset.Add(results[0]);
                    dataOffset.Add(results[1]);
                    typeList.Add(1);
                }
                if (types.Type2 != null)
                {
                    var results = WriteTypeHeader(2, types.Type2.Count());
                    hdrOffset.Add(results[0]);
                    dataOffset.Add(results[1]);
                    typeList.Add(2);
                }
                if (types.Type3 != null)
                {
                    var results = WriteTypeHeader(3, types.Type3.Count());
                    hdrOffset.Add(results[0]);
                    dataOffset.Add(results[1]);
                    typeList.Add(3);
                }
                if (types.Type4 != null)
                {
                    var results = WriteTypeHeader(4, types.Type4.Count());
                    hdrOffset.Add(results[0]);
                    dataOffset.Add(results[1]);
                    typeList.Add(4);
                }
                if (types.Type6 != null)
                {
                    var results = WriteTypeHeader(6, types.Type6.Count());
                    hdrOffset.Add(results[0]);
                    dataOffset.Add(results[1]);
                    typeList.Add(6);
                }
                if (types.Type7 != null)
                {
                    var results = WriteTypeHeader(7, types.Type7.Count());
                    hdrOffset.Add(results[0]);
                    dataOffset.Add(results[1]);
                    typeList.Add(7);
                }
                if (types.Type8 != null)
                {
                    var results = WriteTypeHeader(8, types.Type8.Count());
                    hdrOffset.Add(results[0]);
                    dataOffset.Add(results[1]);
                    typeList.Add(8);
                }

                //Type Data
                for (int i = 0; i < typeList.Count(); i++)
                {
                    switch (typeList[i])
                    {
                    case 0:
                        WriteType0(types.Type0, hdrOffset[i], dataOffset[i]);
                        break;

                    case 1:
                        WriteType1(types.Type1, hdrOffset[i], dataOffset[i]);
                        break;

                    case 2:
                        WriteType2(types.Type2, hdrOffset[i], dataOffset[i]);
                        break;

                    case 3:
                        WriteType3(types.Type3, hdrOffset[i], dataOffset[i]);
                        break;

                    case 4:
                        WriteType4(types.Type4, hdrOffset[i], dataOffset[i]);
                        break;

                    case 6:
                        WriteType6(types.Type6, hdrOffset[i], dataOffset[i]);
                        break;

                    case 7:
                        WriteType7(types.Type7, hdrOffset[i], dataOffset[i]);
                        break;

                    case 8:
                        WriteType8(types.Type8, hdrOffset[i], dataOffset[i]);
                        break;
                    }
                }
            }
        }