diff --git a/modules/game_analyser/analyser.lua b/modules/game_analyser/analyser.lua index f2ea2ef55..f7f888712 100644 --- a/modules/game_analyser/analyser.lua +++ b/modules/game_analyser/analyser.lua @@ -544,7 +544,13 @@ function checkNumber(self, text) end function onLevelChange(localPlayer, value, percent) - XPAnalyser:setupLevel(value, percent) + -- See game_skills/skills.lua onLevelChange: the callback passes the level percent raw + -- (centipercent with GameLevelPercentU16, protocol >= 1520). Normalize it with + -- getLevelPercent() or the analyser bar renders full. + if not localPlayer then + return + end + XPAnalyser:setupLevel(value, localPlayer:getLevelPercent()) end function managerDropTracker(itemId, checked) diff --git a/modules/game_skills/skills.lua b/modules/game_skills/skills.lua index 3b4fd5a71..52c60f945 100644 --- a/modules/game_skills/skills.lua +++ b/modules/game_skills/skills.lua @@ -1105,7 +1105,11 @@ function onLevelChange(localPlayer, value, percent) if not localPlayer then return end - percent = percent or localPlayer:getLevelPercent() + -- The C++ onLevelChange callback passes m_levelPercent raw, which is centipercent + -- (0-10000) once GameLevelPercentU16 is enabled (protocol >= 1520), not the 0-100 the + -- UI expects. getLevelPercent() normalizes it, so always use the getter: otherwise the + -- bar renders full and the tooltip reads "-5500 percent to go" at high levels. + percent = localPlayer:getLevelPercent() setSkillValue('level', comma_value(value)) local text = tr('You have %s percent to go', 100 - percent) setSkillPercent('level', percent, text)