aboutsummaryrefslogtreecommitdiff
path: root/crates/rsli/src/compress/lzh.rs
diff options
context:
space:
mode:
authorValentin Popov <valentin@popov.link>2026-02-19 12:46:23 +0300
committerValentin Popov <valentin@popov.link>2026-02-19 12:46:23 +0300
commitefab61a45c8837d3c2aaec464d8f6243fecb7a38 (patch)
treeb511f1cab917f5f2931d6bc2ae2676b553bb8ef9 /crates/rsli/src/compress/lzh.rs
parent0d7ae6a017b8b2bf26c5c14c39cb62b599e8262d (diff)
downloadfparkan-efab61a45c8837d3c2aaec464d8f6243fecb7a38.tar.xz
fparkan-efab61a45c8837d3c2aaec464d8f6243fecb7a38.zip
feat(render-core): add default UV scale and refactor UV mapping logic
- Introduced a constant `DEFAULT_UV_SCALE` for UV scaling. - Refactored UV mapping in `build_render_mesh` to use the new constant. - Simplified `compute_bounds` functions by extracting common logic into `compute_bounds_impl`. test(render-core): add tests for rendering with empty and multi-node models - Added tests to verify behavior when building render meshes from models with no slots and multiple nodes. - Ensured UV scaling is correctly applied in tests. feat(render-demo): add FOV argument and improve error handling - Added a `--fov` command-line argument to set the field of view. - Enhanced error messages for texture resolution failures. - Updated MVP computation to use the new FOV parameter. fix(rsli): improve error handling in LZH decompression - Added checks to prevent out-of-bounds access in LZH decoding logic. refactor(texm): streamline texture parsing and decoding tests - Created a helper function `build_texm_payload` for constructing test payloads. - Added tests for various texture formats including RGB565, RGB556, ARGB4444, and Luminance Alpha. - Improved error handling for invalid TEXM headers and mip bounds.
Diffstat (limited to 'crates/rsli/src/compress/lzh.rs')
-rw-r--r--crates/rsli/src/compress/lzh.rs7
1 files changed, 6 insertions, 1 deletions
diff --git a/crates/rsli/src/compress/lzh.rs b/crates/rsli/src/compress/lzh.rs
index 07dc0c5..9486c50 100644
--- a/crates/rsli/src/compress/lzh.rs
+++ b/crates/rsli/src/compress/lzh.rs
@@ -135,7 +135,12 @@ impl<'a> LzhDecoder<'a> {
let mut node = self.son[LZH_R];
while node < LZH_T {
let bit = usize::from(self.bit_reader.read_bit()?);
- node = self.son[node + bit];
+ let branch = node
+ .checked_add(bit)
+ .ok_or(Error::DecompressionFailed("lzss-huffman tree overflow"))?;
+ node = *self.son.get(branch).ok_or(Error::DecompressionFailed(
+ "lzss-huffman tree out of bounds",
+ ))?;
}
let c = node - LZH_T;