diff --git a/changelog.txt b/changelog.txt index d663bb8..4ed61e1 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,6 @@ +5/22/2024 2.0.3: +* Improve error handling and handle more edge cases + 5/11/2024 2.0.2: * Fix build error diff --git a/pom.xml b/pom.xml index 5e08abf..6c276df 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.lathrum.VMF2OBJ VMF2OBJ - 2.0.2 + 2.0.3 jar VMF2OBJ diff --git a/src/main/java/com/lathrum/VMF2OBJ/VMF2OBJ.java b/src/main/java/com/lathrum/VMF2OBJ/VMF2OBJ.java index 191a31e..17d3222 100644 --- a/src/main/java/com/lathrum/VMF2OBJ/VMF2OBJ.java +++ b/src/main/java/com/lathrum/VMF2OBJ/VMF2OBJ.java @@ -1010,8 +1010,14 @@ public void run() { if (crowbarSubfolderSetting) { path += File.separator + entity.modelName; } - String smdText = readFile(formatPath( + String smdText = ""; + try { + smdText = readFile(formatPath( tempDir + File.separator + "models" + path + File.separator + bodyGroup)); + } catch (IOException e) { + printProgressBar("Error: Could not find SMD file for model, skipping bodygroup: " + bodyGroup); + continue; + } SMDTriangles.addAll(Arrays.asList(SMDTriangle.parseSMD(smdText))); } diff --git a/src/main/java/com/lathrum/VMF2OBJ/dataStructure/model/QC.java b/src/main/java/com/lathrum/VMF2OBJ/dataStructure/model/QC.java index 1292aba..a3c9b1d 100644 --- a/src/main/java/com/lathrum/VMF2OBJ/dataStructure/model/QC.java +++ b/src/main/java/com/lathrum/VMF2OBJ/dataStructure/model/QC.java @@ -37,15 +37,15 @@ public static QC parseQC(String text) { text = text.replaceAll("//(.*)", ""); // Remove all commented lines text = text.replaceAll("\\$[^\" \\t]+\\n", ""); // Remove all keyless values text = text.replaceAll("[^\"](\\$[^\" \\t]+)", "\"$1\""); // fix unquoted keys - text = text.replaceAll("(\".+\"[ \\t]+)([^\" \\t\\s].*)", "$1\"$2\""); // fix unquoted values + text = text.replaceAll("(\".+\"[ \\t]+)([^\" \\t\\s\\{].*)", "$1\"$2\""); // fix unquoted values text = text.replaceAll("\\$", ""); // Remove all key prefixes text = text.replaceAll("\\{ (\".+\") +\"\\}\"", "$1"); // Fix texturegroup formatting text = text.replaceAll("[\\t\\r\\n]", ""); // Remove all whitespaces and newlines not in quotes text = text.replaceAll("\" +\"", "\"\""); // Remove all whitespaces and newlines not in quotes // text = text.replaceAll("\\s+(?=([^\"]*\"[^\"]*\")*[^\"]*$)", ""); // Remove all whitespaces and newlines not in quotes - Matcher modelNameMatcher = Pattern.compile("\"modelname\"\"([a-zA-Z0-9._/-]+)\"").matcher(text); - String modelName = ""; + Matcher modelNameMatcher = Pattern.compile("\"modelname\"\"([,a-zA-Z0-9._/-]+)\"").matcher(text); + String modelName = "model.smd"; if (modelNameMatcher.find()) { modelName = modelNameMatcher.group(1); } else { diff --git a/src/main/java/com/lathrum/VMF2OBJ/dataStructure/texture/VMT.java b/src/main/java/com/lathrum/VMF2OBJ/dataStructure/texture/VMT.java index d086189..8f44fc1 100644 --- a/src/main/java/com/lathrum/VMF2OBJ/dataStructure/texture/VMT.java +++ b/src/main/java/com/lathrum/VMF2OBJ/dataStructure/texture/VMT.java @@ -62,13 +62,13 @@ public static VMT parseVMT(String text) { text = text.replaceAll("//(.*)", ""); // Remove all commented lines text = text.replaceAll("\\x1B", ""); // Remove all illegal characters text = text.replaceAll("!?srgb\\?", ""); // Remove all weirdos - text = text.replaceAll("360\\?", ""); // Remove all weirdos + text = text.replaceAll("!*360\\?", ""); // Remove all weirdos text = text.replaceAll("-dx10", ""); // Remove all dx10 fallback textures text = text.replaceAll("GPU[<>=]{1,2}[0-3]\\?", ""); // Remove all GPU conditional textures text = text.replaceAll("[^\"](\\$[^\" \\t]+)", "\"$1\""); // fix unquoted keys - text = text.replaceAll("(\".+\"[ \\t]+)([^\" \\t\\s].*)", "$1\"$2\""); // fix unquoted values + text = text.replaceAll("(\".+\"[ \\t]+)([^\" \\t\\s\\{].*)", "$1\"$2\""); // fix unquoted values text = text.replaceAll("\\$", ""); // Remove all key prefixes - text = text.replaceAll("\"%.+", ""); // Remove all lines with keys that start with percentage signs + text = text.replaceAll("\"*%.+", ""); // Remove all lines with keys that start with percentage signs // text = text.replaceAll("(\".+)[{}](.+\")", "$1$2"); // Remove brackets in quotes text = text.replaceAll("[\\t\\r\\n]", ""); // Remove all whitespaces and newlines not in quotes text = text.replaceAll("\" +\"", "\"\""); // Remove all whitespaces and newlines not in quotes