feat: add write support for nGRP and LAYR#14
Draft
Calfur wants to merge 1 commit intomidstreeeam:mainfrom
Draft
Conversation
Contributor
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.