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

Offen
#482 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Anfängerfreundlichkeit
74/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
cpp, typescript
Bereich
backend, game-dev

Rechercherichtung

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.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

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

Vorherrschende Sprache
TypeScript
Sterne
7
Forks
2
Ø Merge
1 T. 17 Std.
Gemergte PRs (30 T.)
17

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus NanoForge-dev/Engine

Alle Issues in NanoForge-dev/Engine

Ähnliche Issues

Weitere Issues zu TypeScript

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.