public boolean modsCoal() {
return modCoal;
}
private void readDesc() throws InvalidFileFormatException, IOException {
Wini wini = new Wini(modDescFile);
modDesc = wini.get("ModInfo", "moddesc");
modName = wini.get("ModInfo", "modname");
if (ModManager.logging){
ModManager.debugLogger.writeMessage("------------------------"+modName+"------------------------");
ModManager.debugLogger.writeMessage("Validating that this is a valid mod");
}
// Check if this mod has been made for Mod Manager 2.0 or legacy mode
float modcmmver = 0;
try {
modcmmver = Float.parseFloat(wini.get("ModManager", "cmmver"));
} catch (NumberFormatException e) {
if (ModManager.logging){
ModManager.debugLogger.writeMessage("Didn't read a ModManager version of the mod. Setting modtype to legacy");
}
modcmmver = 0.0f;
}
// Backwards compatibility for mods that are built to target older versions of mod manager (NO DLC)
if (modcmmver < 2.0f) {
if (ModManager.logging){
ModManager.debugLogger.writeMessage("Modcmmver is less than 2, checking for coalesced.bin (legacy)");
}
File file = new File(ModManagerWindow.appendSlash(modPath) + "Coalesced.bin");
if (!file.exists()) {
if (ModManager.logging){
ModManager.debugLogger.writeMessage(modName + " doesn't have Coalesced.bin and is marked as legacy, marking as invalid.");
}
return;
}
addTask(ModType.COAL, null);
setModDescription(true);
validMod = true;
if (ModManager.logging){
ModManager.debugLogger.writeMessage(modName + " valid, marked as legacy mod. Added coalesced swap job, marked valid, finish reading mod.");
ModManager.debugLogger.writeMessage("--------------------------END OF "+modName+"--------------------------");
}
return;
}
if (ModManager.logging){
ModManager.debugLogger.writeMessage("Mod Manager version read was >= 2.0, marked as modern style mod.");
ModManager.debugLogger.writeMessage("Checking for DLC headers in the ini file.");
}
// It's a 2.0 or above mod. Check for mod tags in the desc file
String[] modIniHeaders = ModType.getHeaderNameArray();
for (String modHeader : modIniHeaders) {
if (ModManager.logging){
ModManager.debugLogger.writeMessage("Reading header: " + modHeader + " in ini of " + modName);
}
// Check for each mod. If it exists, add the task
String iniModDir = wini.get(modHeader, "moddir");
if (iniModDir != null && !iniModDir.equals("")) {
// It's a DLC header, we should check for the files to mod, and make sure they all match properly
if (ModManager.logging){
ModManager.debugLogger.writeMessage(modName + ": Found ini header " + modHeader);
}
String newFileIni = wini.get(modHeader, "newfiles");
String oldFileIni = wini.get(modHeader, "replacefiles");
// System.out.println("New files: "+newFileIni);
// System.out.println("Old Files: "+oldFileIni);
if (newFileIni == null || oldFileIni == null || newFileIni.equals("") || oldFileIni.equals("")) {
if (ModManager.logging){
ModManager.debugLogger.writeMessage("newfiles/replace files was null or empty, mod marked as invalid.");
}
return;
}
StringTokenizer newStrok = new StringTokenizer(newFileIni, ";");
StringTokenizer oldStrok = new StringTokenizer(oldFileIni, ";");
if (newStrok.countTokens() != oldStrok.countTokens()) {
// Same number of tokens aren't the same
if (ModManager.logging){
ModManager.debugLogger.writeMessage("Number of files to update/replace do not match, mod being marked as invalid.");
}
return;
}
// Check to make sure the filenames are the same, and if they are, then the mod is going to be valid.
// Start building the DLC mod job.
DLCInjectJob newJob = new DLCInjectJob(ModType.getDLCPath(modHeader));
while (newStrok.hasMoreTokens()) {
String newFile = newStrok.nextToken();
String oldFile = oldStrok.nextToken();
// System.out.println("Validating tokens: "+newFile+" vs "+oldFile);
if (!newFile.equals(getSfarFilename(oldFile))) {
if (ModManager.logging){
ModManager.debugLogger.writeMessage("Filenames failed to match, mod marked as invalid: " + newFile + " vs " + getSfarFilename(oldFile));
}
return; // The names of the files don't match
}
//Add the file swap to task job - if this method returns false it means a file doesn't exist somewhere
if (!(newJob.addFileReplace(ModManagerWindow.appendSlash(modDescFile.getParent()) + ModManagerWindow.appendSlash(iniModDir) + newFile, oldFile))){
if (ModManager.logging){
ModManager.debugLogger.writeMessage("Failed to add file to replace (File likely does not exist), marking as invalid.");
}
return;
}
}
if (ModManager.logging){
ModManager.debugLogger.writeMessage(modName + ": Successfully made a new DLC Injection Job for: " + modHeader);
}
addTask(modHeader, newJob);
}
}
// Check for coalesced in the new mod manager version (modcoal)
if (ModManager.logging){
ModManager.debugLogger.writeMessage(modName + ": Checking for coalesced flag in moddesc.ini");
}
int modCoalFlag = 0;
try {
modCoalFlag = Integer.parseInt(wini.get("ModInfo", "modcoal"));
if (ModManager.logging){
ModManager.debugLogger.writeMessage("Coalesced flag: "+modCoalFlag);
}
if (modCoalFlag != 0) {