From 5a89c5fb163638b4a88bf962cb2e656916a5a634 Mon Sep 17 00:00:00 2001 From: karstensensensen Date: Wed, 5 Jun 2024 14:28:26 +0200 Subject: [PATCH] Fix id being decoded as an signed integer instead of an unsigned integer. (#660) --- src/debugger/godot3/server_controller.ts | 7 ++++++- src/debugger/godot4/server_controller.ts | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/debugger/godot3/server_controller.ts b/src/debugger/godot3/server_controller.ts index c57fccdd1..b19d19a59 100644 --- a/src/debugger/godot3/server_controller.ts +++ b/src/debugger/godot3/server_controller.ts @@ -375,10 +375,15 @@ export class ServerController { break; } case "message:inspect_object": { - const id = BigInt(command.parameters[0]); + let id = BigInt(command.parameters[0]); const className: string = command.parameters[1]; const properties: any[] = command.parameters[2]; + // message:inspect_object returns the id as an unsigned 64 bit integer, but it is decoded as a signed 64 bit integer, + // thus we need to convert it to its equivalent unsigned value here. + if(id < 0) + id = id + BigInt(2) ** BigInt(64); + const rawObject = new RawObject(className); properties.forEach((prop) => { rawObject.set(prop[0], prop[5]); diff --git a/src/debugger/godot4/server_controller.ts b/src/debugger/godot4/server_controller.ts index 737048da4..ee138cf83 100644 --- a/src/debugger/godot4/server_controller.ts +++ b/src/debugger/godot4/server_controller.ts @@ -374,10 +374,15 @@ export class ServerController { break; } case "scene:inspect_object": { - const id = BigInt(command.parameters[0]); + let id = BigInt(command.parameters[0]); const className: string = command.parameters[1]; const properties: any[] = command.parameters[2]; + // message:inspect_object returns the id as an unsigned 64 bit integer, but it is decoded as a signed 64 bit integer, + // thus we need to convert it to its equivalent unsigned value here. + if(id < 0) + id = id + BigInt(2) ** BigInt(64); + const rawObject = new RawObject(className); properties.forEach((prop) => { rawObject.set(prop[0], prop[5]);