wurstscript / WurstScript

Programming language and toolkit to create Warcraft III Maps

Home Page:https://wurstlang.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Needs a way to supply custom game executable

Retera opened this issue · comments

Needs a way to supply custom game executable: I am building my game executable from source
I am building my game executable that I am using from source, but the game executable can be launched from an EXE wrapper that honors "-loadfile" argument. So I was thinking I should be able to supply this to WurstScript to run from VSCode. Since there was not a clear way to specify the binary, I tried renaming the executable to "Warcraft III.exe" thinking this would fix it, but it appears that the WurstScript used some windows binary investigator to get the version of the "Warcraft III.exe" and obviously my custom binary did not have the kind of version information that WurstScript is looking for. I compiled this binary in Visual Studio with C++.

So my wurst log shows this error:

2021-10-03 21:29:42 [pool-1-thread-1] INFO  n.m.wc3libs.bin.GameExe - Querying D:\Games\Warcraft III Patch 1.22\Warsmash\Warcraft III.exe with dorkbox PE 
2021-10-03 21:29:42 [pool-1-thread-1] INFO  n.m.wc3libs.bin.GameExe - Falling back to WMIC due to {} 
java.lang.Exception: No version found:D:\Games\Warcraft III Patch 1.22\Warsmash\Warcraft III.exe
	at dorkbox.peParser.PE.getVersion(PE.java:304)
	at net.moonlightflower.wc3libs.bin.GameExe.getVersionString(GameExe.java:30)
	at net.moonlightflower.wc3libs.bin.GameExe.getVersion(GameExe.java:93)
	at de.peeeq.wurstio.utils.W3InstallationData.lambda$new$0(W3InstallationData.java:53)
	at java.util.Optional.flatMap(Unknown Source)
	at de.peeeq.wurstio.utils.W3InstallationData.<init>(W3InstallationData.java:51)
	at de.peeeq.wurstio.languageserver.requests.MapRequest.getBestW3InstallationData(MapRequest.java:388)
	at de.peeeq.wurstio.languageserver.requests.MapRequest.<init>(MapRequest.java:77)
	at de.peeeq.wurstio.languageserver.requests.RunMap.<init>(RunMap.java:51)
	at de.peeeq.wurstio.languageserver.WurstCommands.startmap(WurstCommands.java:108)
	at de.peeeq.wurstio.languageserver.WurstCommands.execute(WurstCommands.java:51)
	at de.peeeq.wurstio.languageserver.WurstWorkspaceService.executeCommand(WurstWorkspaceService.java:42)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.lambda$null$0(GenericEndpoint.java:65)
	at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.request(GenericEndpoint.java:120)
	at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.handleRequest(RemoteEndpoint.java:261)
	at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.consume(RemoteEndpoint.java:190)
	at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.handleMessage(StreamMessageProducer.java:194)
	at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.listen(StreamMessageProducer.java:94)
	at org.eclipse.lsp4j.jsonrpc.json.ConcurrentMessageProcessor.run(ConcurrentMessageProcessor.java:113)
	at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
	at java.util.concurrent.FutureTask.run(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)

Then after this, I get Command 'wurst: Run a Wurst map' resulted in an error (Running the contributed command: 'wurst.startmap' failed. and the game does not launch. However when I am using a Blizzard Entertainment Warcraft III game binary it launches fine.

Solution: Allow WurstScript to support my custom binary or binaries that I make in the future
I am not sure if this is worth the time of other Wurst developers yet because they might say that I am doing something too nonstandard. So probably after creating this issue, maybe I will open the WurstScript in IntelliJ and try to workout if I can make a pull request to add this feature on my own. I did not do that yet at the time of writing, and I have never opened WurstScript in IntelliJ, but it looks possible.
My goal with this investigation is the novelty of getting the possibility to develop maps using VSCode/Wurst to run on the custom built-from-source game binary, which is supporting limited subset of JASS natives and running Blizzard.j to spawn the MeleeStartingUnits and warn me that I am going to be revealed to the other players and stuff.

As an update on this, when I went into Visual Studio for compiling my "Warcraft III.exe" that I was using, and I did a right-click on "Resource Files" -> Add -> Resource, then I chose to add a "Version" resource, this defaulted to version 1,0,0,1

Then, I changed the name of my EXE to "war3.exe" for standardization with legacy, and this got WurstScript to see my EXE as acceptable because it supported it as it would Warcraft III: Reign of Chaos 1.00.

So, there does appear to be a functioning workaround for the time being.

This should already work if you supply the path to an executable. But I can check this in wc3libs again.
Ideally I would want to show a file selection dialog.