Skip to content

Commit 1ff626b

Browse files
Fix object id decoded as wrong signedness. (#670)
* Fix id being decoded as an signed integer instead of an unsigned integer. (#660) --------- Co-authored-by: karstensensensen <[email protected]>
1 parent c07fe37 commit 1ff626b

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

src/debugger/godot3/server_controller.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,10 +377,16 @@ export class ServerController {
377377
break;
378378
}
379379
case "message:inspect_object": {
380-
const id = BigInt(command.parameters[0]);
380+
let id = BigInt(command.parameters[0]);
381381
const className: string = command.parameters[1];
382382
const properties: any[] = command.parameters[2];
383383

384+
// message:inspect_object returns the id as an unsigned 64 bit integer, but it is decoded as a signed 64 bit integer,
385+
// thus we need to convert it to its equivalent unsigned value here.
386+
if (id < 0) {
387+
id = id + BigInt(2) ** BigInt(64);
388+
}
389+
384390
const rawObject = new RawObject(className);
385391
properties.forEach((prop) => {
386392
rawObject.set(prop[0], prop[5]);

src/debugger/godot4/server_controller.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,10 +376,16 @@ export class ServerController {
376376
break;
377377
}
378378
case "scene:inspect_object": {
379-
const id = BigInt(command.parameters[0]);
379+
let id = BigInt(command.parameters[0]);
380380
const className: string = command.parameters[1];
381381
const properties: any[] = command.parameters[2];
382382

383+
// message:inspect_object returns the id as an unsigned 64 bit integer, but it is decoded as a signed 64 bit integer,
384+
// thus we need to convert it to its equivalent unsigned value here.
385+
if (id < 0) {
386+
id = id + BigInt(2) ** BigInt(64);
387+
}
388+
383389
const rawObject = new RawObject(className);
384390
properties.forEach((prop) => {
385391
rawObject.set(prop[0], prop[5]);

0 commit comments

Comments
 (0)