Пример #1
0
 static void logBSAError(String source, Exception ex) {
   String error =
       "Could not get " + source + ". Strings files or ini changes in it will not be availible.";
   SPGlobal.logError(header, error);
   StringWriter sw = new StringWriter();
   PrintWriter pw = new PrintWriter(sw, true);
   ex.printStackTrace(pw);
   pw.flush();
   sw.flush();
   SPGlobal.log(sw.toString());
 }
Пример #2
0
 /**
  * @param types Types to load in.
  * @return List of all BSA files that contain any of the filetypes.
  */
 public static ArrayList<BSA> loadInBSAs(FileType... types) {
   ArrayList<BSA> out = new ArrayList<>();
   Iterator<BSA> bsas = iterator();
   while (bsas.hasNext()) {
     BSA tmp = bsas.next();
     try {
       if (!tmp.bad && tmp.containsAny(types)) {
         tmp.loadFolders();
         out.add(tmp);
       }
     } catch (Exception e) {
       SPGlobal.logException(e);
       SPGlobal.logError("BSA", "Skipped BSA " + tmp);
     }
   }
   return out;
 }
Пример #3
0
 final void loadFolders() {
   if (loaded) {
     return;
   }
   loaded = true;
   if (SPGlobal.logging()) {
     SPGlobal.logSpecial(LogTypes.BSA, header, "|============================================");
     SPGlobal.logSpecial(LogTypes.BSA, header, "|============  Loading " + this + " ============");
     SPGlobal.logSpecial(LogTypes.BSA, header, "|============================================");
   }
   try {
     String fileName;
     int fileCounter = 0;
     in.pos(offset);
     LShrinkArray folderData = new LShrinkArray(in.extract(0, folderCount * 16));
     posAtFilenames();
     LShrinkArray fileNames = new LShrinkArray(in.extract(0, fileNameLength));
     for (int i = 0; i < folderCount; i++) {
       BSAFolder folder = new BSAFolder();
       folderData.skip(8); // Skip Hash
       folder.setFileCount(folderData.extractInt(4));
       folder.dataPos = folderData.extractInt(4);
       posAtFolder(folder);
       folder.name = in.extractString(0, in.read() - 1) + "\\";
       folder.name = folder.name.toUpperCase();
       in.skip(1);
       folders.put(folder.name, folder);
       if (SPGlobal.debugBSAimport && SPGlobal.logging()) {
         SPGlobal.logSpecial(LogTypes.BSA, header, "Loaded folder: " + folder.name);
       }
       for (int j = 0; j < folder.fileCount; j++) {
         BSAFileRef f = new BSAFileRef();
         f.size = in.extractInt(8, 3); // Skip Hash
         LFlags sizeFlag = new LFlags(in.extract(1));
         f.flippedCompression = sizeFlag.get(6);
         f.dataOffset = in.extractLong(0, 4);
         fileName = fileNames.extractString();
         folder.files.put(fileName.toUpperCase(), f);
         if (SPGlobal.logging()) {
           SPGlobal.logSpecial(
               LogTypes.BSA,
               header,
               "  "
                   + fileName
                   + ", size: "
                   + Ln.prettyPrintHex(f.size)
                   + ", offset: "
                   + Ln.prettyPrintHex(f.dataOffset));
           fileCounter++;
         }
       }
     }
     if (SPGlobal.logging()) {
       if (SPGlobal.debugBSAimport) {
         SPGlobal.logSpecial(LogTypes.BSA, header, "Loaded " + fileCounter + " files.");
       }
       SPGlobal.logSpecial(LogTypes.BSA, header, "Loaded BSA: " + getFilePath());
     }
   } catch (Exception e) {
     SPGlobal.logException(e);
     SPGlobal.logError("BSA", "Skipped BSA " + this);
     bad = true;
   }
 }