Skip to content

Commit 41d42e8

Browse files
committed
Allow game exe override
Supports specifying a specific file that will be run for the runmap commands, overriding other config
1 parent ca47830 commit 41d42e8

File tree

4 files changed

+12
-8
lines changed

4 files changed

+12
-8
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,11 @@ private static CompletableFuture<Object> startMap(WurstLanguageServer server, Ex
100100
JsonObject options = (JsonObject) params.getArguments().get(0);
101101
Optional<String> mapPath = getString(options, "mappath");
102102
Optional<String> wc3Path = getString(options, "wc3path");
103+
Optional<String> gameExePath = getString(options, "gameExePath");
103104

104105
Optional<File> map = mapPath.map(File::new);
105106
List<String> compileArgs = getCompileArgs(workspaceRoot, additionalArgs);
106-
return server.worker().handle(new RunMap(server, workspaceRoot, wc3Path, map, compileArgs)).thenApply(x -> x);
107+
return server.worker().handle(new RunMap(server, workspaceRoot, wc3Path, map, compileArgs, gameExePath)).thenApply(x -> x);
107108
}
108109

109110
private static Optional<String> getString(JsonObject options, String key) {

de.peeeq.wurstscript/src/main/java/de/peeeq/wurstio/languageserver/requests/BuildMap.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public class BuildMap extends MapRequest {
2727

2828
public BuildMap(WurstLanguageServer languageServer, WFile workspaceRoot, Optional<String> wc3Path, Optional<File> map,
2929
List<String> compileArgs) {
30-
super(languageServer, map, compileArgs, workspaceRoot, wc3Path);
30+
super(languageServer, map, compileArgs, workspaceRoot, wc3Path, Optional.empty());
3131
}
3232

3333
@Override

de.peeeq.wurstscript/src/main/java/de/peeeq/wurstio/languageserver/requests/MapRequest.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,15 @@
2828
import de.peeeq.wurstscript.parser.WPos;
2929
import de.peeeq.wurstscript.utils.LineOffsets;
3030
import de.peeeq.wurstscript.utils.Utils;
31-
import net.moonlightflower.wc3libs.bin.Wc3BinOutputStream;
3231
import net.moonlightflower.wc3libs.bin.app.W3I;
32+
import net.moonlightflower.wc3libs.port.GameVersion;
3333
import net.moonlightflower.wc3libs.port.Orient;
3434
import org.apache.commons.lang.StringUtils;
3535
import org.eclipse.lsp4j.MessageParams;
3636
import org.eclipse.lsp4j.MessageType;
3737
import org.eclipse.lsp4j.services.LanguageClient;
3838
import org.jetbrains.annotations.Nullable;
3939

40-
import java.io.ByteArrayOutputStream;
4140
import java.io.File;
4241
import java.io.FileNotFoundException;
4342
import java.io.IOException;
@@ -88,14 +87,18 @@ public static class CompilationResult {
8887
}
8988

9089
public MapRequest(WurstLanguageServer langServer, Optional<File> map, List<String> compileArgs, WFile workspaceRoot,
91-
Optional<String> wc3Path) {
90+
Optional<String> wc3Path, Optional<String> gameExePath) {
9291
this.langServer = langServer;
9392
this.map = map;
9493
this.compileArgs = compileArgs;
9594
this.workspaceRoot = workspaceRoot;
9695
this.runArgs = new RunArgs(compileArgs);
9796
this.wc3Path = wc3Path;
98-
this.w3data = getBestW3InstallationData();
97+
if (gameExePath.isPresent() && StringUtils.isNotBlank(gameExePath.get())) {
98+
this.w3data = new W3InstallationData(Optional.of(new File(gameExePath.get())), Optional.of(GameVersion.VERSION_1_29));
99+
} else {
100+
this.w3data = getBestW3InstallationData();
101+
}
99102
if (runArgs.isMeasureTimes()) {
100103
this.timeTaker = new TimeTaker.Recording();
101104
} else {

de.peeeq.wurstscript/src/main/java/de/peeeq/wurstio/languageserver/requests/RunMap.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ public class RunMap extends MapRequest {
4545

4646

4747
public RunMap(WurstLanguageServer langServer, WFile workspaceRoot, Optional<String> wc3Path, Optional<File> map,
48-
List<String> compileArgs) {
49-
super(langServer, map, compileArgs, workspaceRoot, wc3Path);
48+
List<String> compileArgs, Optional<String> gameExePath) {
49+
super(langServer, map, compileArgs, workspaceRoot, wc3Path, gameExePath);
5050
safeCompilation = SafetyLevel.QuickAndDirty;
5151
}
5252

0 commit comments

Comments
 (0)