Read() public method

public Read ( BinaryReader BR, Type T ) : bool
BR System.IO.BinaryReader
T System.Type
return bool
Beispiel #1
0
 public override ThingList Load(BinaryReader BR, ProgressCallback ProgressCallback)
 {
     ThingList TL = new ThingList();
     if (ProgressCallback != null)
     {
         ProgressCallback(I18N.GetText("FTM:CheckingFile"), 0);
     }
     if ((BR.BaseStream.Length % 0xC00) != 0 || BR.BaseStream.Length < 0xc000 || BR.BaseStream.Position != 0)
     {
         return TL;
     }
     // First deduce the type of item data is in the file.
     Item.Type T;
     Item.DeduceType(BR, out T);
     // Now read the items
     if (ProgressCallback != null)
     {
         ProgressCallback(I18N.GetText("FTM:LoadingData"), 0);
     }
     long ItemCount = BR.BaseStream.Length / 0xC00;
     long CurrentItem = 0;
     while (BR.BaseStream.Position < BR.BaseStream.Length)
     {
         Item I = new Item();
         if (!I.Read(BR, T))
         {
             TL.Clear();
             break;
         }
         if (ProgressCallback != null)
         {
             ProgressCallback(null, (double)++CurrentItem / ItemCount);
         }
         TL.Add(I);
         // A currency DAT currently has 1 "real" item and 15 dummy entries (all NULs); a better thing to do would be to break if such a dummy entry
         // is seen, but since we currently detect currency from its 0xFFFF ID, this is safe enough for now.
         if (BR.BaseStream.Length == 0xc000 && T == Item.Type.Currency)
         {
             break;
         }
     }
     return TL;
 }
Beispiel #2
0
 public static string GetItemName(byte Language, ushort ID)
 {
     foreach (ushort ItemDAT in FFXIResourceManager.ItemDATs) {
       BinaryReader BR = FFXIResourceManager.OpenDATFile(ItemDAT);
     if (BR != null) {
     Item.Type T;
       Item.DeduceType(BR, out T);
     long Offset = (ID & 0xfff) * 0xc00;
       if (BR.BaseStream.Length >= Offset + 0xc00) {
       Item I = new Item();
     BR.BaseStream.Position = Offset;
     if (I.Read(BR, T) && (uint) I.GetFieldValue("id") == ID) {
       BR.Close();
       return I.GetFieldText("name");
     }
       }
       BR.Close();
     }
       }
       return null;
 }