fix(ecs): a component instance with a string name field is stored under that value

Đang mở
#482 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
74/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
cpp, typescript
Lĩnh vực
backend, game-dev

Hướng nghiên cứu

Start with modules/ecs/wasm/Utils.cpp:34-43 and trace how get_js_class_name chooses a component key; check modules/ecs/src/shared/editor-world.ts:293, 300 for the editor tracker’s use of the same behavior. Reproduce with a component instance that has a string name field, then verify instances are stored under their class name and getZipper([Tag]) finds them.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

bug modules:ecs
Which package is this bug report for?

ecs

Issue description

get_js_class_name reads c.name before c.constructor.name. For an instance new Tag("player") whose class has a name field, the component array key is "player", not "Tag", and each distinct value creates its own array, so getZipper([Tag]) never finds it. Common Name / Tag components are silently stored in the wrong array. The editor tracker relies on the same behavior (editor-world.ts:293, 300).

Where:

Evidence:

return get_js_class_type_name(c).value_or(get_js_class_var_name(c).value_or(UNKNOWN_COMPONENT_TYPE));
...
const std::optional<emscripten::val> name = get_js_member(c, "name");

Suggested fix: Use .name only when c is a function (a class) or a plain { name } descriptor; for instances use constructor.name.

Found during a code audit of main at be72076.

Code sample

No response

Versions
  • Engine main at be72076
  • pnpm 12.0.0, Node.js 26, Bun 1.3.14
Issue priority

Medium (should be fixed soon)

I have tested this issue on a development release

be72076

Ngôn ngữ chính
TypeScript
Star
7
Fork
2
Merge trung bình
1 ngày 17 giờ
Pull request đã merge (30 ngày)
17

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của NanoForge-dev/Engine

Tất cả issue của NanoForge-dev/Engine

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.