fix: 1052014 GraalJS -1*0 类型错误导致兑奖中断#804
Open
ArthurZhu1992 wants to merge 1 commit into
Open
Conversation
原版 HeavenMS 使用 Nashorn 引擎,-1*0 被引擎转为 Integer 0, 调用 gainItem(int, short) 正常。BeiDou 改为 GraalJS 后 -1*0 始终保留为 Double 类型 -0.0,Java 找不到 gainItem(int, double) 重载,抛出 ScriptException 中断 givePrize() 流程。 结果:橡皮擦已被扣除但奖励物品未发放。 修复: - 橡皮擦扣减循环:仅 tickets[i] > 0 才调用 gainItem - 硬币扣减:从 hasCoin(包里有) 改为 coins > 0(实际提交了) - 兑奖成功后弹窗显示具体获得的物品名称和数量
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.
废都橡皮擦兑换功能bug
根因
原版 HeavenMS 使用 Nashorn 引擎, 被转为 Integer
0,调用gainItem(int, short)正常。BeiDou 改用 GraalJS 后-1 * 0保留为 Double-0.0,Java 找不到gainItem(int, double)重载,抛出ScriptException中断givePrize()流程。结果:橡皮擦已扣除但奖励物品未发放。
改动
tickets[i] > 0时才调用gainItem,避免-1 * 0类型错误(英文版新增,中文版已有守卫)hasCoin(包里有羽毛)改为coins > 0(实际提交了才扣),防止coins=0时误执行