Open
Conversation
AI-generated code by Codex.
AI-generated code by Codex.
AI-generated code by Codex.
AI-generated code by Codex.
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.
[中文] PR 说明
背景与目标
本 PR 主要修复新版地图(如
x6rb/x6rc_2)在加载与导出过程中的一组连锁问题,包括:ArgumentOutOfRangeException/InvalidDataException)OutOfMemoryException/ZlibException根因概述
旧逻辑在偏移计算和 source 选择上对新版数据不够稳健,导致读取到错误 dat 偏移。
Bg字段在不同地图结构下存在差异,导致拼接路径失配。对异常长度、异常尺寸、压缩流类型切换(zlib/deflate)保护不足,易触发 OOM 或异常风暴。
某些记录包含前缀噪声/不规范分隔符,触发路径解析异常或查找失败。
高分辨率/压缩纹理在解码导出时容易造成峰值内存过高或不支持格式报错。
主要改动
1) Index 与 Pack 读取链路修正
IIndexFile.Offset改为long,统一支持更大偏移。IndexFile/Index2File对 dat 标记与实际偏移的解析。Pack.TryGetFile优先尝试Index2Source(若可用),回退到IndexSource。SaintCoinach/IO/IIndexFile.csSaintCoinach/IO/IndexFile.csSaintCoinach/IO/Index2File.csSaintCoinach/IO/Pack.cs2) Territory 路径解析增强
terrain.tera/bg.lgb/planmap.lgb/planevent.lgb)。SaintCoinach/Graphics/Territory.cs3) SqPack 读取与解压健壮性增强
FileCommonHeader增加 header 长度合法性检查,阻止负值/越界长度。File.ReadBlock增加 block 大小、解压后尺寸、一致性校验。Inflate增加 zlib header 判定,按数据特征选择 zlib/deflate,减少错误解压路径。Directory/Index2Source在TryGetFile中对损坏文件做可诊断日志并安全跳过。ByteArrayExtensions增加结构读取越界保护与字符串读取边界修正。SaintCoinach/IO/FileCommonHeader.csSaintCoinach/IO/File.csSaintCoinach/IO/Directory.csSaintCoinach/IO/Index2Source.csSaintCoinach/ByteArrayExtensions.cs4) LGB 模型路径规范化
bg/,common/,chara/等),裁剪到合法扩展名。startIndex问题与模型漏加载。SaintCoinach/Graphics/Lgb/LgbModelEntry.cs5) 导出流程与纹理处理稳定性
Godbert/ViewModels/TerritoryViewModel.csSaintCoinach/Imaging/ImageConverter.cs结果与影响
x6rb类路径)。测试与验证
AI 生成与人工复核声明
本 PR 的代码由 OpenAI Codex 协助生成;提交者已进行逐项人工审查、手动调试与结果验证,并按功能相关性拆分为独立 commits。
[English] PR Description
Background and Goal
This PR fixes a chain of issues encountered when loading/exporting newer territories (e.g.
x6rb/x6rc_2), including:ArgumentOutOfRangeException/InvalidDataException)OutOfMemoryException/ZlibExceptionduring exportRoot Cause Summary
Bgstrings.Key Changes
1) Index and Pack read-path fixes
IIndexFile.Offsetis nowlong.IndexFile/Index2File.Pack.TryGetFilenow prefersIndex2Sourcewhen available, then falls back toIndexSource.SaintCoinach/IO/IIndexFile.csSaintCoinach/IO/IndexFile.csSaintCoinach/IO/Index2File.csSaintCoinach/IO/Pack.cs2) Stronger Territory base-path resolution
terrain.tera,bg.lgb,planmap.lgb,planevent.lgb).SaintCoinach/Graphics/Territory.cs3) Hardened SqPack header/block parsing
FileCommonHeader.File.ReadBlock.Inflate.Directory/Index2Sourcefor malformed files.ByteArrayExtensions.SaintCoinach/IO/FileCommonHeader.csSaintCoinach/IO/File.csSaintCoinach/IO/Directory.csSaintCoinach/IO/Index2Source.csSaintCoinach/ByteArrayExtensions.cs4) LGB model path normalization
bg/,common/,chara/, etc.).SaintCoinach/Graphics/Lgb/LgbModelEntry.cs5) Export stability + texture handling improvements
DX10header for BC7).Godbert/ViewModels/TerritoryViewModel.csSaintCoinach/Imaging/ImageConverter.csImpact
Validation
AI + Human Review Disclosure
The implementation in this PR was assisted/generated by OpenAI Codex.
The contributor performed manual review, debugging, and validation before preparing the final commits.