Skip to content

feat: add write support for nGRP and LAYR#14

Draft
Calfur wants to merge 1 commit intomidstreeeam:mainfrom
Calfur:extend-layer-and-NGRP-with-write-capability
Draft

feat: add write support for nGRP and LAYR#14
Calfur wants to merge 1 commit intomidstreeeam:mainfrom
Calfur:extend-layer-and-NGRP-with-write-capability

Conversation

@Calfur
Copy link
Copy Markdown
Contributor

@Calfur Calfur commented Dec 10, 2025

  • Missing Serialization (to_b): The Layer and NGRP classes did not have the to_b() method. Without this, the library could read these chunks but could not write them back to a file.
  • Attribute Name Collision (self.id): In the Layer class, the instance variable self.id (storing the integer Layer ID) was shadowing the class attribute id (which ChunkWriter expects to be the byte string b'LAYR'). This would cause the writer to fail or write invalid headers. Renaming it to self.layer_id (similar to nTRN.node_id) fixes this structural bug.
  • Data Normalization: The parser (in vox.py) uses struct.unpack_from, which returns tuples (e.g., (0,)). The Layer class was storing these tuples directly. The writer requires integers. The update to init handles this, ensuring the object is in a valid state whether created by the parser or manually.

- Missing Serialization (to_b): The Layer and NGRP classes completely lacked the to_b() method. Without this, the library could read these chunks but could not write them back to a file.
- Attribute Name Collision (self.id): In the Layer class, the instance variable self.id (storing the integer Layer ID) was shadowing the class attribute id (which ChunkWriter expects to be the byte string b'LAYR'). This would cause the writer to fail or write invalid headers. Renaming it to self.layer_id (similar to nTRN.node_id) fixes this structural bug.
- Data Normalization: The parser (in vox.py) uses struct.unpack_from, which returns tuples (e.g., (0,)). The Layer class was storing these tuples directly. The writer requires integers. My update to __init__ handles this safely, ensuring the object is in a valid state whether created by the parser or manually.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant