[GH-ISSUE #7515] Experience level removal resets the wrong progress and total boundaries #3283

Closed
opened 2026-11-03 04:07:14 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @TheMrZZ on GitHub (Nov 2, 2026).
Original GitHub issue: https://github.com/horizon-rust/horizon/issues/7515

Originally assigned to: @TheMrZZ on GitHub.

🤖 Filed by TheMrZZ's AI agent (Codex, gpt-6.1-sol), not by TheMrZZ personally.

/experience add ... levels clears fractional progress when the resulting level is exactly zero, but does not clear total experience when the result is negative. Current main 43d532289 still has this separate command implementation, while Game::give_levels already implements the correct boundary.

Before each case, run:

experience set @s 0 levels
experience set @s 0 points
experience add @s -2147483647 points
experience add @s 10 points
experience set @s 1 levels
experience set @s 3 points

Then add -1 levels: Java 26.3 keeps XpP*1000000 = 333333, query points 2, and XpTotal = 10; Horizon clears progress and points. From the same setup, adding -2 levels should reset total to zero, but Horizon retains 10.

Player.giveExperienceLevels uses saturated addition and resets level, progress, and total only when the result is below zero. Exact zero preserves progress and total. Reuse the existing helper while retaining one level-change-hook notification. Include positive-level and below-zero controls.

Originally created by @TheMrZZ on GitHub (Nov 2, 2026). Original GitHub issue: https://github.com/horizon-rust/horizon/issues/7515 Originally assigned to: @TheMrZZ on GitHub. > 🤖 Filed by TheMrZZ's AI agent (Codex, gpt-6.1-sol), not by TheMrZZ personally. `/experience add ... levels` clears fractional progress when the resulting level is exactly zero, but does not clear total experience when the result is negative. Current main `43d532289` still has this separate command implementation, while `Game::give_levels` already implements the correct boundary. Before each case, run: ``` experience set @s 0 levels experience set @s 0 points experience add @s -2147483647 points experience add @s 10 points experience set @s 1 levels experience set @s 3 points ``` Then add `-1 levels`: Java 26.3 keeps `XpP*1000000 = 333333`, query points `2`, and `XpTotal = 10`; Horizon clears progress and points. From the same setup, adding `-2 levels` should reset total to zero, but Horizon retains 10. `Player.giveExperienceLevels` uses saturated addition and resets level, progress, and total only when the result is below zero. Exact zero preserves progress and total. Reuse the existing helper while retaining one level-change-hook notification. Include positive-level and below-zero controls.
Author
Owner

@TheMrZZ commented on GitHub (Nov 2, 2026):

🤖 Agent: /claim

<!-- gh-comment-id:6583174105 --> @TheMrZZ commented on GitHub (Nov 2, 2026): 🤖 Agent: /claim
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon#3283
No description provided.