Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix typed arrays of scripts not being decoded properly #731

Merged
merged 1 commit into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions src/debugger/godot4/variables/variant_decoder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ import {
Projection,
ENCODE_FLAG_64,
ENCODE_FLAG_OBJECT_AS_ID,
ENCODE_FLAG_TYPED_ARRAY,
ENCODE_FLAG_TYPED_ARRAY_MASK,
ENCODE_FLAG_TYPED_ARRAY_BUILTIN,
ENCODE_FLAG_TYPED_ARRAY_CLASS_NAME,
ENCODE_FLAG_TYPED_ARRAY_SCRIPT,
RID,
Callable,
Signal,
Expand Down Expand Up @@ -144,8 +147,10 @@ export class VariantDecoder {
case GDScriptTypes.DICTIONARY:
return this.decode_Dictionary(model);
case GDScriptTypes.ARRAY:
if (type & ENCODE_FLAG_TYPED_ARRAY) {
return this.decode_TypedArray(model);
if (type & ENCODE_FLAG_TYPED_ARRAY_MASK) {
const with_script_name = (type & ENCODE_FLAG_TYPED_ARRAY_CLASS_NAME) != 0;
const with_script_path = (type & ENCODE_FLAG_TYPED_ARRAY_SCRIPT) != 0;
return this.decode_TypedArray(model, with_script_name || with_script_path);
} else {
return this.decode_Array(model);
}
Expand Down Expand Up @@ -231,13 +236,12 @@ export class VariantDecoder {
return output;
}

private decode_TypedArray(model: BufferModel) {
private decode_TypedArray(model: BufferModel, with_scripts: boolean) {
const output: Array<any> = [];

// TODO: the type information is currently discarded
// it needs to be decoded and then packed into the output somehow

const type = this.decode_UInt32(model);
const type = with_scripts ? this.decode_String(model) : this.decode_UInt32(model);
const count = this.decode_UInt32(model);

for (let i = 0; i < count; i++) {
Expand Down
5 changes: 4 additions & 1 deletion src/debugger/godot4/variables/variants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ export enum GDScriptTypes {

export const ENCODE_FLAG_64 = 1 << 16;
export const ENCODE_FLAG_OBJECT_AS_ID = 1 << 16;
export const ENCODE_FLAG_TYPED_ARRAY = 1 << 16;
export const ENCODE_FLAG_TYPED_ARRAY_MASK = 3 << 16;
export const ENCODE_FLAG_TYPED_ARRAY_BUILTIN = 1 << 16;
export const ENCODE_FLAG_TYPED_ARRAY_CLASS_NAME = 2 << 16;
export const ENCODE_FLAG_TYPED_ARRAY_SCRIPT = 3 << 16;

export interface BufferModel {
buffer: Buffer;
Expand Down
Loading