Skip to content

Commit ffa9bb6

Browse files
committed
review fix
1 parent b08bff4 commit ffa9bb6

2 files changed

Lines changed: 18 additions & 3 deletions

File tree

de.peeeq.wurstscript/src/main/java/de/peeeq/wurstio/languageserver/WurstBuildConfig.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,8 @@ public boolean shouldCopyRunMapToWarcraftMapDir(Optional<GameVersion> detectedVe
136136
}
137137

138138
public boolean shouldUseInstallDirForMaps(Optional<GameVersion> detectedVersion) {
139-
return detectedVersion
140-
.map(version -> version.compareTo(new GameVersion("1.27.9")) <= 0)
141-
.orElse(wc3PatchOrReforged() == Wc3Patch.PRE_129);
139+
return detectedVersion.orElseGet(this::fallbackGameVersion)
140+
.compareTo(new GameVersion("1.27.9")) <= 0;
142141
}
143142

144143
private static String stripComment(String line) {

de.peeeq.wurstscript/src/test/java/tests/wurstscript/tests/WurstBuildConfigTests.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,22 @@ public void readsScriptModeAndPatchFromWurstBuild() throws Exception {
3535
assertEquals(config.fallbackGameVersion(), new GameVersion("1.28"));
3636
assertTrue(config.shouldUseClassicWindowArg(Optional.empty()));
3737
assertFalse(config.shouldUseReforgedLaunchArgs(Optional.empty()));
38+
assertFalse(config.shouldUseInstallDirForMaps(Optional.empty()));
39+
}
40+
41+
@Test
42+
public void installDirMapPathIsOnlyForDetected127OrLower() throws Exception {
43+
Path project = Files.createTempDirectory("wurst-build-config-map-path");
44+
Files.writeString(project.resolve("wurst.build"), """
45+
projectName: Test
46+
wc3Patch: pre1.29
47+
""");
48+
49+
WurstBuildConfig config = WurstBuildConfig.fromWorkspaceRoot(WFile.create(project.toFile()));
50+
51+
assertTrue(config.shouldUseInstallDirForMaps(Optional.of(new GameVersion("1.27"))));
52+
assertFalse(config.shouldUseInstallDirForMaps(Optional.of(new GameVersion("1.28"))));
53+
assertFalse(config.shouldUseInstallDirForMaps(Optional.empty()));
3854
}
3955

4056
@Test

0 commit comments

Comments
 (0)