From 59865b2d677d23c682757b492772db7ef4124c27 Mon Sep 17 00:00:00 2001 From: Raul Santos Date: Wed, 18 May 2022 16:24:01 +0200 Subject: [PATCH] Fix extension for 4.0 - The `.mono` folder was moved to `.godot/mono` - The `--remote-debug` argument now requires the protocol - The `-q` argument has been repurposed, now `--quit` should be used --- GodotDebugSession/GodotDebuggerSession.cs | 15 ++++++++++++++- src/assets-generator/tasks.ts | 2 +- src/godot-tools-messaging/client.ts | 6 +++++- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/GodotDebugSession/GodotDebuggerSession.cs b/GodotDebugSession/GodotDebuggerSession.cs index a8fe60c..7f36249 100644 --- a/GodotDebugSession/GodotDebuggerSession.cs +++ b/GodotDebugSession/GodotDebuggerSession.cs @@ -89,12 +89,25 @@ protected override async void OnRun(DebuggerStartInfo startInfo) string host = "127.0.0.1"; int remoteDebugPort = ((IPEndPoint)remoteDebugListener.LocalEndpoint).Port; + // Construct the --remote-debug parameter for the found version of Godot + + var versionCommand = Command.Run(godotStartInfo.GodotExecutablePath, new[] { "--version" }).Result; + string versionOutput = versionCommand.StandardOutput; + int versionFirstDot = versionOutput.IndexOf('.'); + if (versionFirstDot == -1 || !int.TryParse(versionOutput.Substring(0, versionFirstDot), out int versionMajor)) + { + Logger.Log($"Godot launch request failed: Godot version unrecognized: {versionOutput}."); + Exit(); + return; + } + string remoteDebugAddress = versionMajor >= 4 ? $"tcp://{host}:{remoteDebugPort}" : $"{host}:{remoteDebugPort}"; + // Launch Godot to run the game and connect to our remote debugger var args = new List() { "--path", workingDir, - "--remote-debug", $"{host}:{remoteDebugPort}", + "--remote-debug", remoteDebugAddress, }; args.AddRange(godotStartInfo.ExecutableArguments); diff --git a/src/assets-generator/tasks.ts b/src/assets-generator/tasks.ts index 617ad49..dc98336 100644 --- a/src/assets-generator/tasks.ts +++ b/src/assets-generator/tasks.ts @@ -19,7 +19,7 @@ export function createBuildTaskDescription(godotExecutablePath: string | undefin label: 'build', command: godotExecutablePath, type: 'process', - args: ['--build-solutions', '--path', '${workspaceRoot}', '--no-window', '-q'], + args: ['--build-solutions', '--path', '${workspaceRoot}', '--no-window', '--quit'], problemMatcher: '$msCompile', }; } diff --git a/src/godot-tools-messaging/client.ts b/src/godot-tools-messaging/client.ts index 62e6f09..28d7629 100644 --- a/src/godot-tools-messaging/client.ts +++ b/src/godot-tools-messaging/client.ts @@ -225,7 +225,11 @@ export class Client implements Disposable { this.logger = logger; this.projectDir = godotProjectDir; - this.projectMetadataDir = path.join(godotProjectDir, '.mono', 'metadata'); + this.projectMetadataDir = path.join(godotProjectDir, '.godot', 'mono', 'metadata'); + if (!fs.existsSync(this.projectMetadataDir)) { + // Fallback for 3.x projects + this.projectMetadataDir = path.join(godotProjectDir, '.mono', 'metadata'); + } this.metaFilePath = path.join(this.projectMetadataDir, GodotIdeMetadata.defaultFileName); }