Package lev

Examples of lev.LInChannel


                File ini = SPGlobal.getSkyrimINI();

                if (SPGlobal.logging()) {
                    SPGlobal.logSpecial(LogTypes.BSA, header, "Loading in BSA list from Skyrim.ini: " + ini);
                }
                LInChannel input = new LInChannel(ini);

                String line = "";
                // First line
                while (input.available() > 0 && !line.toUpperCase().contains("SRESOURCEARCHIVELIST")) {
                    line = input.extractLine();
                }
                if (line.toUpperCase().contains("SRESOURCEARCHIVELIST2")) {
                    line2 = true;
                    resources.addAll(processINIline(line));
                } else {
                    line1 = true;
                    resources.addAll(0, processINIline(line));
                }

                // Second line
                line = "";
                while (input.available() > 0 && !line.toUpperCase().contains("SRESOURCEARCHIVELIST")) {
                    line = Ln.cleanLine(input.extractLine(), "#");
                }
                if (line.toUpperCase().contains("SRESOURCEARCHIVELIST2")) {
                    line2 = true;
                    resources.addAll(processINIline(line));
                } else {
                    line1 = true;
                    resources.addAll(0, processINIline(line));
                }
            } catch (IOException e) {
                SPGlobal.logException(e);
            }

            if (!line1 || !line2) {
                //Assume standard BSA listing
                if (!resources.contains("Skyrim - Misc.bsa")) {
                    resources.add("Skyrim - Misc.bsa");
                }

                if (!resources.contains("Skyrim - Shaders.bsa")) {
                    resources.add("Skyrim - Shaders.bsa");
                }

                if (!resources.contains("Skyrim - Textures.bsa")) {
                    resources.add("Skyrim - Textures.bsa");
                }

                if (!resources.contains("Skyrim - Interface.bsa")) {
                    resources.add("Skyrim - Interface.bsa");
                }

                if (!resources.contains("Skyrim - Animations.bsa")) {
                    resources.add("Skyrim - Animations.bsa");
                }

                if (!resources.contains("Skyrim - Meshes.bsa")) {
                    resources.add("Skyrim - Meshes.bsa");
                }

                if (!resources.contains("Skyrim - Sounds.bsa")) {
                    resources.add("Skyrim - Sounds.bsa");
                }

                if (!resources.contains("Skyrim - Sounds.bsa")) {
                    resources.add("Skyrim - Voices.bsa");
                }

                if (!resources.contains("Skyrim - Sounds.bsa")) {
                    resources.add("Skyrim - VoicesExtra.bsa");
                }
            }

            if (SPGlobal.logging()) {
                SPGlobal.logSpecial(LogTypes.BSA, header, "BSA resource load order: ");
                for (String s : resources) {
                    SPGlobal.logSpecial(LogTypes.BSA, header, "  " + s);
                }
                SPGlobal.logSpecial(LogTypes.BSA, header, "Loading in their headers.");
            }

            // Get BSAs loaded from all active pluging's plugin.ini files
            ArrayList<ModListing> activeMods = SPImporter.getActiveModList();
            for (ModListing m : activeMods) {
                File pluginIni = new File(SPGlobal.pathToData + Ln.changeFileTypeTo(m.print(), "ini"));
                if (pluginIni.exists()) {
                    LInChannel input = new LInChannel(pluginIni);

                    String line = "";
                    // First line
                    while (input.available() > 0 && !line.toUpperCase().contains("SRESOURCEARCHIVELIST")) {
                        line = input.extractLine();
                    }
                    if (line.toUpperCase().contains("SRESOURCEARCHIVELIST2")) {
                        resources.addAll(processINIline(line));
                    } else {
                        resources.addAll(0, processINIline(line));
                    }

                    // Second line
                    line = "";
                    while (input.available() > 0 && !line.toUpperCase().contains("SRESOURCEARCHIVELIST")) {
                        line = Ln.cleanLine(input.extractLine(), "#");
                    }
                    if (line.toUpperCase().contains("SRESOURCEARCHIVELIST2")) {
                        resources.addAll(processINIline(line));
                    } else {
                        resources.addAll(0, processINIline(line));
View Full Code Here


     * @throws IOException
     * @throws BadParameter If the nif file is malformed (by SkyProc's
     * standards)
     */
    public NIF(File f) throws FileNotFoundException, IOException, BadParameter {
  LInChannel in = new LInChannel(f);
  fileName = f.getPath();
  parseData(new LShrinkArray(in.extractByteBuffer(0, in.available())));
    }
View Full Code Here

            if (file.isFile()) {
                SPGlobal.log("Validate", "Target file exists: " + file);
            } else {
                SPGlobal.log("Validate", "Target file does NOT exist: " + file);
            }
            LInChannel input = new LInChannel(testFilePath);

            correct = testHeaderLength(input);

            String inputStr;
            //Test GRUPs
            String majorRecordType = "NULL";
            int grupLength = 0;
            long grupPos = input.pos();
            int length;
            long start = 0;
            String EDID = "";
            Map<Integer, String> formids = new HashMap<>();
            Map<Integer, String> dupIds = new HashMap<>();
            while (input.available() >= 4 && (numErrors < numErrorsToPrint || numErrorsToPrint == 0)) {

                inputStr = input.extractString(0, 4);
                if (inputStr.equals("GRUP")) {
                    long inputPos = input.pos();
                    if (inputPos - grupPos - 4 != grupLength) {
                        SPGlobal.logError(recordLengths, "GRUP " + majorRecordType + " is wrong. (" + Ln.prettyPrintHex(grupPos) + ")");
                        numErrors++;
                        correct = false;
                    }
                    grupPos = input.pos() - 4;
                    grupLength = input.extractInt(0, 4);
                    majorRecordType = input.extractString(0, 4);
                    if (skip.contains(majorRecordType)) {
                        input.skip(grupLength - 12);
                    } else {
                        input.skip(12);
                    }
                } else if (inputStr.equals(majorRecordType)) {
                    start = input.pos() - 4;
                    length = input.extractInt(0, 4);
                    input.skip(4);
                    int formID = input.extractInt(4);
                    input.skip(8);
                    String subRecordType = input.extractString(0, 4);
                    if (subRecordType.equalsIgnoreCase("EDID")) {
                        int edidLength = input.extractInt(0, 2);
                        EDID = input.extractString(0, edidLength - 1);
                        input.skip(length - 6 - EDID.length()); // 4 from subrecord type 'EDID' + 2 from length of EDID subrecord
                        if (formids.containsKey(formID)) {
                            dupIds.put(formID, EDID);
                        } else {
                            formids.put(formID, EDID);
                        }
                    } else {
                        EDID = "No EDID subrecord";
                        input.skip(length - 4); // 4 from subrecord type
                    }
                } else {
                    SPGlobal.logError(recordLengths, "Major Record: " + majorRecordType + " | " + EDID + " is wrong. (" + Ln.prettyPrintHex(start) + ")");
                    numErrors++;
                    correct = false;
                }
            }

            if (!dupIds.isEmpty()) {
                SPGlobal.logError(recordLengths, "Duplicate FormIDs: ");
                for (int id : dupIds.keySet()) {
                    SPGlobal.logError(recordLengths, Ln.printHex(id) + ", EDIDS: " + dupIds.get(id) + ", and " + formids.get(id));
                }
                correct = false;
            }

            input.close();

        } catch (FileNotFoundException ex) {
            SPGlobal.logError(recordLengths, "File could not be found.");
            SPGlobal.logException(ex);
        } catch (IOException ex) {
View Full Code Here

TOP

Related Classes of lev.LInChannel

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.