fix(shader): strip leading zeros from ACTINIUM_VERSION macro value - #112
Merged
Conversation
The encoded mod version starts with '0' whenever major is 0 (e.g. alpha-0.0.5-da83c59 encoded as "000058359"). jcpp lexes macro values inside addMacro through an internal lexer source that has no listener attached, so a leading-zero value containing 8/9 is rejected as a malformed octal constant and the LexerException aborted the whole shader pack load — every pack failed and the game reported the pack as (off). - StandardMacros: strip leading zeros from the encoded ACTINIUM_VERSION; the numeric value is unchanged. - PropertiesPreprocessor: skip a macro whose value fails to lex and log a warning instead of aborting the pack load, in both overloads; the two-arg overload no longer drops the remaining macros after the first bad one. Replace printStackTrace with logger.warn. Drop the misleading listener setup and comments from e07dd15 — the preprocessor listener is never consulted by addMacro, the catch is what actually protects the load.
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.
问题
生产环境偶发:进世界后任何光影包都无法载入,切换光影包时提示「已使用光影包:(off)!」,换任何光影包均无效(触发类似重载,但始终回退到原版渲染)。
根因
生产日志堆栈:
证据链:
StandardMacros.makeActiniumVersion()把版本alpha-0.0.5-da83c59编码为ACTINIUM_VERSION=000058359:sha 段da83c59以字母开头被当作 prerelease 抽出数字8359,而 major=0 时编码值恒以 0 开头。addMacro(name, value)在内部新建无 listener 关联的 lexer 解析宏值:多字符、0 开头、含 8/9 的数字被当作非法八进制常量,直接抛LexerException。preprocessSource的 environmentDefines 循环没有容错,异常一路抛到ShaderPack.<init>。environment define 与具体包无关,因此所有光影包都加载失败,表现为「换包无效」。Tags.VERSION无数字三元组,恒返回"0"→ dev 无法复现。pp.setListener(...)对该路径无效——addMacro内部 lexer 不关联 Preprocessor 的 listener(生产代码在行 38 装了 listener、行 45 仍抛异常,行号完全吻合)。真正起保护作用的是 catch,本 PR 一并修正注释并移除无效调用。改动
StandardMacros:编码值去前导零(000058359→58359),数值语义不变,从根源消除非法八进制常量。PropertiesPreprocessor:两个 overload 中宏值解析失败时跳过该宏并logger.warn(含宏名/值),不再让整个光影包加载失败;两参 overload 的 catch 移入循环内(原来首个坏宏会导致后续宏全部丢失);printStackTrace()统一换成logger.warn。StandardMacrosVersionTest(版本编码回归 4 例);PropertiesPreprocessorTest补充三参 overload 用例(复现生产崩溃路径)。验证
RuntimeException ← LexerException链),修复后 7 个用例全绿。./gradlew build --no-daemon全绿。